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

Add 3DS tokens to transaction error and billing info #415

Merged
merged 1 commit into from
Jun 19, 2019

Conversation

aaron-junot
Copy link

This allows the client to use the new 3DSecure features of the API. This involves a 2 step flow with RecurlyJS, see recurly/recurly-js#527 for technical details on that side of this process.

Script 1: Attempt to update a billing info with a credit card that requires 3DS authentication:

try {
  $billing_info = new Recurly_BillingInfo();
  $billing_info->account_code       = 'x';
  $billing_info->first_name         = 'John';
  $billing_info->last_name          = 'Du Monde';
  $billing_info->address1           = '123 Paper Street';
  $billing_info->city               = 'Los Angeles';
  $billing_info->state              = 'CA';
  $billing_info->zip                = '95312';
  $billing_info->country            = 'US';
  $billing_info->phone              = '213-555-5555';
  $billing_info->number             = '4000000000003220';
  $billing_info->month              = '10';
  $billing_info->year               = '2020';
  $billing_info->create();

  print "Billing Info: $billing_info" . "\n";
} catch (Recurly_ValidationError $e) {
  // Requires 3DS authentication. Get the token id to pass into RJS:
  print $e->errors[0]->three_d_secure_action_token_id . "\n";
}

The ValidationError's TransactionError (the first element of the errors array) will contain a three_d_secure_action_token_id, which needs to be passed to RJS for authentication. Upon successful authentication, RJS will return a result token, which can then be passed with the billing info.

Script 2: Update the billing info using 3DS:

try {
  $billing_info = new Recurly_BillingInfo();
  $billing_info->account_code       = 'x';
  $billing_info->first_name         = 'John';
  $billing_info->last_name          = 'Du Monde';
  $billing_info->address1           = '123 Paper Street';
  $billing_info->city               = 'Los Angeles';
  $billing_info->state              = 'CA';
  $billing_info->zip                = '95312';
  $billing_info->country            = 'US';
  $billing_info->phone              = '213-555-5555';
  $billing_info->number             = '4000000000003220';
  $billing_info->month              = '10';
  $billing_info->year               = '2020';
  $billing_info->three_d_secure_action_result_token_id = '4jkL_3RCvKGaJ3wwphf_9A';
  $billing_info->create();

  print "Billing Info: $billing_info" . "\n";
} catch (Recurly_Error $e) {
  var_dump($e);
}

This flow still applies when passing a billing_info object to the /accounts, /subscriptions, and /purchases endpoints.

@aaron-junot aaron-junot changed the base branch from master to api_version_2_21 June 18, 2019 19:15
Copy link
Contributor

@bhelx bhelx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bhelx bhelx merged commit bba15b8 into api_version_2_21 Jun 19, 2019
@bhelx bhelx deleted the 3ds-token branch June 19, 2019 19:41
@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

Successfully merging this pull request may close these issues.

None yet

2 participants