Search code examples
androidbraintreegoogle-pay

How to show "Google Pay" option in Braintree Dropin?


When running the braintree demo app for Android from here, it seems to be possible to show the Google Pay option within the Dropin-UI in sandbox mode.

However, when trying to create the Dropin-UI by myself, I am not able to do this, the Dropin only shows the options "Paypal" and "Credit or Debit card".

When looking the docs, I cannot find something missing in my own code/configs.

I added the latest dependencies to my build.gradle:

implementation 'com.braintreepayments.api:drop-in:5.0.1'
implementation 'com.braintreepayments.api:braintree:3.14.2'
implementation 'com.braintreepayments.api:google-payment:3.3.1'
implementation 'com.google.android.gms:play-services-wallet:18.1.2'

I modified my AndroidManifest.xml to contain the following part:

<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true"/>

I crete the dropin-request using the Tokenization key like this:

DropInRequest dropInRequest = new DropInRequest()
    .clientToken("sandbox_...") //Tokenization key from the Control Panel
    .googlePaymentRequest(getGooglePaymentRequest());

startActivityForResult(dropInRequest.getIntent(MainActivity.this), 4949);

and I create the GooglePaymentRequest like this:

private GooglePaymentRequest getGooglePaymentRequest() {
    GooglePaymentRequest googlePaymentRequest = new GooglePaymentRequest()
        .transactionInfo(TransactionInfo.newBuilder()
            .setTotalPrice("1.00")
            .setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL)
            .setCurrencyCode("USD")
            .build())
        .billingAddressRequired(true);

    return googlePaymentRequest;
}

And I enabled Google Pay in the Control Panel of my Sandbox Account.

enter image description here

But unfortunately, the result is still this:

enter image description here

I scanned the documentations multiple times, but I do not see what could cause this.

Does anyone see what I am missing?

Best regards, Felix


Solution

  • After trying to find the cause of this at the wrong position for several days, I finally found it:

    Be sure to add the <meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true"/> to the application tag within the AndroidManifest.xml, NOT the activity.