When I am trying to pay with the google pay option in my developed android application, I am getting the error
Request failed An unexpected error has occurred Please try again later [R_BIBED_07] For the merchant, we are using stripe as a payment gateway. Everything is set ok like the stripe key and environment. This is happening only for production. In test mode, it navigates me to the card selection. But only in production after clicking on the button it shows me the error. I don't know exactly what the reason is. I tried many ways.
I am providing the link for the snippet code I used to integrate Google Pay into my android application.
Code
// Inside OnCreate methos if (paymentmethod.equals("GooglePay")) { proceed.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PaymentDataRequest request = createPaymentDataRequest(); Log.e("onclickreq", String.valueOf(request)); if (request != null) { AutoResolveHelper.resolveTask( mPaymentsClient.loadPaymentData(request), DbsSummaryPage.this, LOAD_PAYMENT_DATA_REQUEST_CODE); // LOAD_PAYMENT_DATA_REQUEST_CODE is a constant integer of your choice, // similar to what you would use in startActivityForResult } else { Log.e("Enter in", String.valueOf(request)); Toast.makeText(DbsSummaryPage.this, "gap", Toast.LENGTH_SHORT).show(); } } }); } mPaymentsClient = Wallet.getPaymentsClient( this, new Wallet.WalletOptions.Builder() .setEnvironment(WalletConstants.ENVIRONMENT_PRODUCTION) .build()); isReadyToPay(); // End of OnCreate method private void isReadyToPay() { Log.e("isReadyToPay","isReadyToPay"); IsReadyToPayRequest request = IsReadyToPayRequest.newBuilder() .addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_CARD) .addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_TOKENIZED_CARD) .build(); Task<Boolean> task = mPaymentsClient.isReadyToPay(request); task.addOnCompleteListener( new OnCompleteListener<Boolean>() { public void onComplete(@NonNull Task<Boolean> task) { try { boolean result = task.getResult(ApiException.class); if (result) { // Show Google as payment option. System.out.println(true); System.out.println("resttrtdt" + result); } else { // Hide Google as payment option. System.out.println("hide the google button"); } } catch (ApiException exception) { System.out.println("hide the google button"); } } }); } private PaymentDataRequest createPaymentDataRequest() { Log.e("paydat", String.valueOf(totalamount)); ad = String.format("%.2f", totalamount); Log.e("adgoggole", ad); Log.e("Insidetotal", String.valueOf(totalamount)); Log.e("PSPRICE Google", "Hi " + psprice); PaymentDataRequest.Builder request = PaymentDataRequest.newBuilder() .setTransactionInfo( TransactionInfo.newBuilder() .setTotalPriceStatus(WalletConstants.TOTAL_PRICE_STATUS_FINAL) .setTotalPrice(ad) .setCurrencyCode("USD") .build()) .addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_CARD) .addAllowedPaymentMethod(WalletConstants.PAYMENT_METHOD_TOKENIZED_CARD) .setCardRequirements( CardRequirements.newBuilder() .addAllowedCardNetworks( Arrays.asList( WalletConstants.CARD_NETWORK_AMEX, WalletConstants.CARD_NETWORK_DISCOVER, WalletConstants.CARD_NETWORK_VISA, WalletConstants.CARD_NETWORK_MASTERCARD)) .build()); PaymentMethodTokenizationParameters params = PaymentMethodTokenizationParameters.newBuilder() .setPaymentMethodTokenizationType( WalletConstants.PAYMENT_METHOD_TOKENIZATION_TYPE_PAYMENT_GATEWAY) .addParameter("gateway", "stripe") .addParameter("stripe:publishableKey", key) .addParameter("stripe:version", "2018-11-08") .build(); request.setPaymentMethodTokenizationParameters(params); System.out.println("Data" + request.build()); return request.build(); } @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); System.out.println("Entered" + "into onactivity"); switch (requestCode) { case LOAD_PAYMENT_DATA_REQUEST_CODE: switch (resultCode) { case Activity.RESULT_OK: PaymentData paymentData = PaymentData.getFromIntent(data); String rawToken = paymentData.getPaymentMethodToken().getToken(); Token stripeToken = Token.fromString(rawToken); String stripegettoken = stripeToken.getId(); System.out.println(paymentData.getPaymentMethodToken().getToken()); System.out.println(rawToken); System.out.println(paymentData.getPaymentMethodToken().getToken()); System.out.println("rawToken" + rawToken); if (stripeToken != null) { // This chargeToken function is a call to your own server, which should then connect // to Stripe's API to finish the charge. pd.show(); executeFormForGooglePay(stripegettoken, totalamount, userphonenumber, proprice, producttax, pscommission, finalpsprice, stripefee, salestax, bodatysurcharge, fffee); } break; case Activity.RESULT_CANCELED: pd.dismiss(); System.out.println("status" + "Cancelled"); break; case AutoResolveHelper.RESULT_ERROR: Status status = AutoResolveHelper.getStatusFromIntent(data); System.out.println("status" + status); pd.dismiss(); Toast.makeText(DbsSummaryPage.this, "Got error " + status.getStatusMessage(), Toast.LENGTH_SHORT).show(); // Log the status for debugging. // Generally, there is no need to show an error to // the user as the Google Payment API will do that. break; default: // Do nothing. } break; default: // Do nothing. } } 52 Answers
before you use the PRODUCTION environment, your integration needs to be approved from Google Pay & Wallet Console.
In the meantime, you can test your integration using the TEST environment in your configuration.
In my case, i just forgot to add the relevant meta-data in the manifest file under application tag:
<meta-data android:name="com.google.android.gms.wallet.api.enabled" android:value="true" />