Search code examples
androidandroid-pay

Android Pay Error in "loadMaskedWallet"


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?


Solution

  • 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.