availability

Masterpass, Amex Express Checkout, and Visa Checkout have been replaced with the latest unified checkout experience offered through Visa known as Secure Remote Commerce. If you were previously using Masterpass or Amex Express Checkout, you will need to integrate with SRC. If you were using Visa Checkout, you do not have to change your integration as SRC is an updated version of Visa Checkout. As such, you may see Visa Checkout referenced elsewhere in our documentation.

SRC is currently in a limited release to eligible merchants, and the API is subject to change. It is only available for our Android v3, Android v2, iOS v4, and JavaScript v3 SDKs.

Contact us to request access to the release.

Installation

Braintree

To set up the Braintree Android SDK, see the installation guide.

SRC integration requires the Braintree Visa Checkout module, as well as several dependencies required by the Visa Checkout SDK.

The dependencies block in your build.gradle file should look like the following:

Groovy
dependencies {
  // Braintree dependencies
  implementation 'com.braintreepayments.api:braintree:2.22.0'
  implementation 'com.braintreepayments.api:visa-checkout:2.0.1'

  // VisaCheckout aar dependency
  implementation(group: 'com.visa.checkout', name: 'visacheckout-android-sdk', version: '6.6.1', ext: 'aar')

  // Dependencies required by Visa Checkout
  implementation 'com.squareup.okio:okio:1.13.0'
  implementation 'com.squareup.okhttp3:okhttp:3.8.1'
  implementation 'com.google.code.gson:gson:2.8.1'
  implementation 'de.greenrobot:eventbus:2.4.1'
  implementation 'com.android.support:appcompat-v7:26.0.0'
  implementation 'com.android.support:design:26.0.0'
  implementation 'com.android.support:multidex:1.0.0'
}

SRC

SRC for Braintree requires the Visa Checkout SDK running in your app.

To install the Visa Checkout SDK, see Visa's documentation on adding Visa Checkout to a mobile application.

The Braintree SDK is currently designed to work with the Visa Checkout Android SDK v6.6.1.

important

You are not required to sign up with SRC. If you already have, do not initialize the SRC component with your own SRC credentials. These details will be handled internally by the Braintree SDK.

Initialization

  1. Initialize the Braintree Android SDK using the appropriate authorization
  2. Register listeners to receive callbacks for the payment method nonce once the Visa Checkout flow finishes. At minimum, you will need:

    • BraintreeResponseListener<ProfileBuilder>
    • PaymentMethodNonceCreatedListener
  3. Get a ProfileBuilder:

    Java
    VisaCheckout.createProfileBuilder(mBraintreeFragment, this);
  4. Once you receive a callback on your BraintreeResponseListener<ProfileBuilder> indicating the ProfileBuilder is ready, customize the ProfileBuilder:

    Java
    @Override
    public void onResponse(ProfileBuilder profileBuilder) {
     // Customize ProfileBuilder for your merchant.
     profileBuilder.setDisplayName("My Merchant Name");
    }

Generating a client token

If you choose to use a client token, you must generate it on the server and make it accessible to your client.

To use a merchant account ID other than your default, specify the merchant_account_id when generating the client token. This merchant account ID must match the merchant account ID used to create the transaction.

Specifying payment details

note

See Visa Checkout's user interface guidelines for more information on UI and branding requirements.

  1. Create a PurchaseInfoBuilder object, passing in an amount and currency
  2. Specify additional payment details on this object, e.g. description, subtotal, shipping

Here is an example:

Java
PurchaseInfoBuilder purchaseInfoBuilder = new PurchaseInfoBuilder(
  new BigDecimal("1.00"),
  PurchaseInfo.Currency.USD
);

purchaseInfoBuilder.setDescription("My Description");

Tokenizing

  1. Create a CheckoutButton and add it to your layout. Make sure it is accessible in the Android code:
    Java
    mVisaPaymentButton = (CheckoutButton) findViewById(R.is.visa_checkout_button);
  2. Tokenize the VisaPaymentSummary in the PAYMENT_SUCCESS case

    Java
    mVisaPaymentButton.init(VisaCheckoutActivity.this, profileBuilder.build(),
              purchaseInfo.build(), new VisaCheckoutSdk.VisaCheckoutResultListener() {
     @Override
     public void onButtonClick(LaunchReadyHandler launchReadyHandler) {
       launchReadyHandler.launch();
     }
    
     @Override
     public void onResult(VisaPaymentSummary visaPaymentSummary) {
       switch(visaPaymentSummary.getStatusName()) {
         case VisaPaymentSummary.PAYMENT_CANCEL:
           // The customer canceled the Visa Checkout flow
           break;
         case VisaPaymentSummary.PAYMENT_SUCCESS:
           VisaCheckout.tokenize(mBraintreeFragment, visaPaymentSummary);
           break;
         case VisaPaymentSummary.PAYMENT_ERROR:
         case VisaPaymentSummary.PAYMENT_FAILURE:
         default:
           // There was an issue processing Visa Checkout
           break;
       }
     }
    });

After tokenization has finished, Braintree SDK will call your PaymentMethodNonceCreatedListener, with the resulting VisaCheckoutNonce.

Java
@Override
public void onPaymentMethodCreated(PaymentMethodNonce paymentMethodNonce) {
  if (paymentMethodNonce instanceof VisaCheckoutNonce) {
    // Access VisaCheckout properties from this object, e.g.
    VisaCheckoutNonce visaCheckoutNonce = (VisaCheckoutNonce) paymentMethodNonce;
    VisaCheckoutAddress shippingAddress = visaCheckoutNonce.getShippingAddress();

    // Send this nonce to your server, and create a transaction there.
    String nonce = visaCheckoutNonce.getNonce();
  }
}

Next Page: Server-side →