Braintree Makes Paying In-app Easier with Android Pay™

Today Google announced availability of Android Pay for in-app purchases. A number of our merchants have already added Android Pay: JackThreads, Hotel Tonight, Houzz, Jet, ParkWhiz, Turo, and Wish.

Android Pay enables simple and secure purchases in Android apps, and eliminates the need to manually enter payment and shipping information.

Android Pay was built by Google using a recent payments innovation known as network tokenization. This means additional protection for the consumer since their card gets transformed into a network tokenized card -- a virtual account number specific to the device -- ensuring the actual card number is never shared with the merchant. Network tokenization also provides flexibility for the merchant, as they can still identify the card brand to aid in reconciliation, are never subject to any artificial limits on transaction size, and can use Android Pay to perform subscription payments.

In an effort to make the integration simple and seamless, Braintree has connected with Android Pay on our back-end to reduce the number of API calls and provide a streamlined payment flow. Now, when merchants integrate with Braintree, they will be able to add Android Pay to their checkout with just a few lines of code instead of a separate integration.

If you’re a merchant based in the US, integrate Android Pay today to reach millions of signed-in Android users. We’ll be launching additional markets with Android Pay in the future, including Australia in the first half of 2016. Visit our guide to learn more and to add Android Pay to your app.

How it works

The Android Pay integration consists of two steps. In the first step, a
MaskedWalletRequest will prompt the user to select a payment method, shipping address, and phone number if required. Once this is done, a developer can perform the second step and make a FullWalletRequest to retrieve payment credentials -- including a virtual account number -- to complete the transaction.

Built on top of this new framework, the Braintree integration for Android Pay leverages a similar two-step process using the same MaskedWalletRequest and FullWalletRequest. Instead of a virtual account number, a Braintree nonce will be directly retrieved. When charged, the nonce will automatically be funded by the underlying credit or debit card the user selected during the MaskedWalletRequest.

The benefits of using Braintree

When accepting Android Pay through Braintree, we abstract the complexity. Merchants can directly receive a Braintree payment method nonce with a few lines of code, without needing to manage encryption keys or decrypt Android Pay credentials on their servers.

Not only does this eliminate a round-trip from a mobile device to the server to process, but it avoids sensitive information from ever being present on the device. This is made possible through the direct integration between Android Pay and Braintree.

This level of integration has allowed us to greatly reduce the steps and requests required.

Easy upgrade for Google Wallet merchants

The SDK can plug into existing Google Wallet integrations to upgrade to Braintree + Android Pay with only two additional parameters to provide to the MaskedWalletRequest.Builder.

A sample integration

Below is an example of an Android Pay integration.

public void onClick(View v) {  
    AndroidPay.getTokenizationParameters(braintreeFragment, new TokenizationParametersListener() {
        public void onResult(PaymentMethodTokenizationParameters parameters, Collection<Integer> allowedCardNetworks) {
            MaskedWalletRequest maskedWalletRequest = MaskedWalletRequest.newBuilder()

            Wallet.Payments.loadMaskedWallet(mGoogleApiClient, maskedWalletRequest, MASKED_WALLET_REQUEST);

protected void onActivityResult(int requestCode, int resultCode, Intent data) {  
    if (requestCode == MASKED_WALLET_REQUEST && resultCode == Activity.RESULT_OK) {
        String googleTransactionId = ((MaskedWallet) data.getParcelableExtra(WalletConstants.EXTRA_MASKED_WALLET))

        FullWalletRequest fullWalletRequest = FullWalletRequest.newBuilder()

        Wallet.Payments.loadFullWallet(mGoogleApiClient, fullWalletRequest, FULL_WALLET_REQUEST);
    } else if (requestCode == FULL_WALLET_REQUEST && resultCode == Activity.RESULT_OK) {
        AndroidPay.tokenize(mBraintreeFragment, (FullWallet) data.getParcelableExtra(WalletConstants.EXTRA_FULL_WALLET));

public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {  
    // send paymentMethodNonce.getNonce() to your server
Luke Korth Luke is an engineer on the Developer Experience team at Braintree. Lover of all things Android and open source, Luke also spends his spare time practicing photography. More posts by this author

You Might Also Like