2

I am trying to make a test payment with Android Pay. So far I have configured my device for testing based on this answer, I have configured a card in Android app in my device and based on this code:

Wallet.Payments.isReadyToPay(mGoogleApiClient, IsReadyToPayRequest.newBuilder()
                   .addAllowedCardNetwork(WalletConstants.CardNetwork.VISA)
                   .addAllowedCardNetwork(WalletConstants.CardNetwork.MASTERCARD)
                   .build())
                .setResultCallback(
                        booleanResult -> {
                           if (booleanResult.getStatus().isSuccess()) { // says true
...

I have build my example based on these guidelines from google code lab

private void initGoogleApi() {
    mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
            .addOnConnectionFailedListener(this)
            .enableAutoManage(getActivity(),0, this)
            .addApi(Wallet.API, new Wallet.WalletOptions.Builder()
                    .setEnvironment(WalletConstants.ENVIRONMENT_TEST)
                    .setTheme(WalletConstants.THEME_LIGHT)
                    .build())
            .build();
}

and then:

    private void initAndroidPayView() {
    mWalletFragment = (SupportWalletFragment) getActivity().getSupportFragmentManager()
            .findFragmentByTag(WALLET_FRAGMENT_ID);

    if (mWalletFragment == null) {
        // Wallet fragment style
        WalletFragmentStyle walletFragmentStyle = new WalletFragmentStyle()
                .setBuyButtonText(WalletFragmentStyle.BuyButtonText.BUY_WITH)
                .setBuyButtonWidth(WalletFragmentStyle.Dimension.MATCH_PARENT);

        // Wallet fragment options
        WalletFragmentOptions walletFragmentOptions = WalletFragmentOptions.newBuilder()
                .setEnvironment(WalletConstants.ENVIRONMENT_TEST)
                .setFragmentStyle(walletFragmentStyle)
                .setTheme(WalletConstants.THEME_DARK)
                .setMode(WalletFragmentMode.BUY_BUTTON)
                .build();

        // Initialize the WalletFragment
        WalletFragmentInitParams.Builder startParamsBuilder =
                WalletFragmentInitParams.newBuilder()
                        .setMaskedWalletRequest(generateMaskedWalletRequest())
                        .setMaskedWalletRequestCode(MASKED_WALLET_REQUEST_CODE);
        //.setAccountName("Google I/O Codelab");//https://developers.google.com/android/reference/com/google/android/gms/wallet/fragment/WalletFragmentInitParams.Builder
        mWalletFragment = SupportWalletFragment.newInstance(walletFragmentOptions);
        mWalletFragment.initialize(startParamsBuilder.build());

        // Add the WalletFragment to the UI
        getActivity().getSupportFragmentManager().beginTransaction()
                .replace(R.id.androidPayContainer, mWalletFragment, WALLET_FRAGMENT_ID)
                .commit();
    }
}

I am using the

PaymentMethodTokenizationType.NETWORK_TOKEN

and I generated the publicKey as written in github repo

Now when I make the payment I get this error code in the onActivityResult: 10

In the device I see only this error message:

Request Failed An unexpected error has occurred. Please try again later.

And when I press ok in the error dialog I get this log:

06-01 12:18:05.739 11386 11386 W WalletMerchantError: Error in loadMaskedWallet: Did you forget the set Android Pay testing environment to PROD?

I tried also changing the variables to Production but still the same error. Does anyone have any solution or I really have to try that later?

Ultimo_m
  • 4,724
  • 4
  • 38
  • 60

2 Answers2

1

If you're trying to use ENVIRONMENT_TEST, make sure you've followed the steps outlined in Setup Android Pay. Specifically, make sure your AndroidManifest.xml contains the following bit:

<application
  ...
  <!-- Enables the Android Pay API -->
  <meta-data
    android:name="com.google.android.gms.wallet.api.enabled"
    android:value="true" />
</application>

If you feel your app is ready and are trying to use ENVIRONMENT_PRODUCTION, then there a few more steps outlined here.

fstanis
  • 5,234
  • 1
  • 23
  • 42
  • Yes I have done that, also just to make sure I tried the google example and I have opened this issue: https://github.com/android-pay/androidpay-quickstart/issues/31 – Ultimo_m Jun 02 '17 at 09:56
0

According to this issue posted on Github

https://github.com/android-pay/androidpay-quickstart/issues/31

and other contacts there is an anomaly with Sandbox mode and the test card don't work at least in Europe.

The answer from the issue contains also an alternative solution.

Issue: test cards (even the one provided by Google) don't work anymore (at least not outside of US);

Solution: you need real card to make it work. You won't be charged with ENVIRONMENT_TEST.

Community
  • 1
  • 1
Ultimo_m
  • 4,724
  • 4
  • 38
  • 60
  • Hi, I'm adding Google pay in my application, after selecting card it gives me this error: Status{statusCode=DEVELOPER_ERROR, resolution=null} can you please help me? – chetan Mar 23 '18 at 10:44
  • Make sure to follow this https://github.com/google-pay/android-quickstart and if you have problems you can open an issue there – Ultimo_m Mar 26 '18 at 08:51
  • Thank you! After adding gateway version, I was able to initiate google pay. Again thanks for your time. – chetan Mar 26 '18 at 09:03