Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What’s the best way of using getting a 3D secure token? #439

Closed
zoe-edwards opened this issue Nov 5, 2019 · 6 comments
Closed

What’s the best way of using getting a 3D secure token? #439

zoe-edwards opened this issue Nov 5, 2019 · 6 comments
Assignees
Labels

Comments

@zoe-edwards
Copy link

zoe-edwards commented Nov 5, 2019

Currently I’m using this:

try {
    $subscription->create();
} catch (Recurly_ValidationError $validationError) {
    foreach ($validationError->errors as $error) {
        if ($error instanceof Recurly_TransactionError) {
            if ($error->error_code === 'three_d_secure_action_required') {
                return response([
                    'status' => 'Accepted',
                    'actionTokenId' => $error->three_d_secure_action_token_id
                ], 202);
            }
        }
    }
    throw $validationError;
}

Other than refactoring it out into methods, that’s as simple as I can make it. Is there another way I’m missing?

This would be better:

try {
    $subscription->create();
} catch (Recurly_TransactionError $error) {
    if ($error->error_code === 'three_d_secure_action_required') {
        return response([
            'status' => 'OK',
            'actionTokenId' => $error->three_d_secure_action_token_id
        ], 202);
    }
    throw $error;
}
@joannasese joannasese self-assigned this Nov 6, 2019
@joannasese
Copy link
Contributor

Hi @ThomasEdwards. I see what you're saying. I'm looking into if there's a simpler way or something we can change, but initial reaction is that your approach is as straight-forward as it can be at this moment.

@zoe-edwards
Copy link
Author

I realise that anything at this level would probably break all backwards compatibility, so maybe a v3 one day? 😌Thanks!

@joannasese
Copy link
Contributor

Hi @ThomasEdwards.

After some investigating, I was alerted to this script. It's a little less verbose, but it's brittle in that it only works if you know your first error is going to be a three_d_secure_action_required error. Just something I thought to show you in case you hadn't already seen it.

@zoe-edwards
Copy link
Author

Oh that’s interesting – it presumes that the 3D secure validation will always be in errors[0] – is that always the case?

@joannasese
Copy link
Contributor

No, not always. I perceive your approach as safer, as it considers more use cases.

@zoe-edwards
Copy link
Author

Ah yeah I’d rather have one endpoint that covers all the bases than having seperate ones, thanks anyway!

@bhelx bhelx added the V2 V2 Client label Mar 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants