10

So I need to integrate Android Pay into an application I'm working on. This option within the app will be for US users only however I am in the UK and am having great difficulty trying to test my implementation. I'm using a sandbox Stripe account atm as the payment processor.

Once I press the "Pay with Android Pay" button I get a popup "To make purchases using Android Pay, please set up your cards in the Android Pay app". Now the Android Pay app isn't available outside the US so I've sideloaded it, however once I try to add a card it crashes. After a quick Google it seems like this crash is the apps way of saying it's not supported outside the US.. (Great UX btw)

I've also tried adding one of the cards found here, https://developers.google.com/android-pay/test-flows, to my Google Account however they don't show up in the Android Pay app.

I'm at a bit of loss trying to test this, it seems very much like Google has overlooked the fact developers outside the US would like to implement this in their apps for their US customers.

Does anyone have any ideas about how I can test this?

(Btw I'm testing on a stock, unrooted Nexus 5 running Marshmallow. I've also tried to spoof my location to no avail.)

EDIT: Spoke to Android Pay support who informed me there is no mechanism to test outside of the US. They said it checks your IP address to determine location which is why GPS spoofing doesn't work but it also seems proxies don't work either so unless anyone has hacked a way around this it looks like when they say US only they mean US only - Including development :|

crazyfool
  • 1,433
  • 4
  • 22
  • 38

2 Answers2

11

Follow these steps to convert Android pay into testable environment

  1. Install Android Pay apk from apkmirror website. Make sure you use correct apk variant. http://www.apkmirror.com/apk/google-inc/android-pay/

or

  1. You can use TunnelBear(Change VPN) App to download Android Pay App in India https://play.google.com/store/apps/details?id=com.tunnelbear.android

  2. Turn on Sandbox Mode by executing following commands from command prompt:

    adb shell
    cd /sdcard/Download;
    rm ­-f android_pay_env_override_*;
    touch android_pay_env_override_sandbox;
    
  3. Restart the phone

    • Launch the Android Pay app and add following test credit card details:

    • Card Number: 4622 9431 2999 9943 Expiry: 12/17 CVV: 125

    • Enter other details like address and proceed.

    • Card is added successfully.

enter image description here

  1. Use ENVIRONMENT_SANDBOX to integrate and test Android Pay in your app.

  2. Revert from Sandbox to Production by executing following commands from command prompt:

    adb shell
    cd /sdcard/Download;
    rm -­f android_pay_env_override_*;
    
  3. Restart phone

  4. Use ENVIRONMENT_PRODUCTION or ENVIRONMENT_TEST to integrate and test Android Pay in your app
Garima Mathur
  • 3,312
  • 3
  • 18
  • 32
  • Have tried this several times but keep getting "Your card couldn't be added". Is this working for other people? Is there particular version of Android Pay needed to get this working? – John O'Reilly Sep 24 '16 at 16:02
  • @JohnO'Reilly I have edited my answer and the change in this command: rm ­-f android_pay_env_override_*; Please include hyphen (-) before 'f'. Have you tried all commands successfully. – Garima Mathur Sep 26 '16 at 07:16
  • @JohnO'Reilly I think android pay is not converted on sandbox environment properly. We have to run all commands successfully. – Garima Mathur Sep 26 '16 at 10:58
  • Hi Garima, have tried those but no luck unfortunately. Is there particular version of apk needed? (I installed one from play store after connecting through vpn) – John O'Reilly Sep 26 '16 at 20:26
  • @JohnO'Reilly I have also installed android pay apk from play store. I have successfully converted android pay from production to sandbox to add dummy credit cards successfully not real.You wants to add dummy cards right ? Can you please explain me in brief how are you doing for it. – Garima Mathur Sep 27 '16 at 07:38
  • not sure what I did differently this time but now it's working! Thanks for the info! – John O'Reilly Sep 27 '16 at 10:25
  • next issue I'm seeing is that, within app, when I click on "Buy with Pay", it brings me to screen that says "There are no accepted cards available for user with this merchant". I'm using ENVIRONMENT_TEST (I also tried ENVIRONMENT_SANDBOX but didn't help....also looks like that's deprecated). btw where did you find info about "android_pay_env_override_sandbox"....can't find any other reference to it? – John O'Reilly Sep 27 '16 at 10:51
  • ok, turned out issue was that wallet fragment in layout file was referring to "test" and should have been "sandbox" (as java code is using). – John O'Reilly Sep 27 '16 at 19:50
  • @JohnO'Reilly Great !! Okay if you have any other issue then let me know – Garima Mathur Sep 28 '16 at 06:10
  • I'm still curious about use of ENVIRONMENT_TEST vs ENVIRONMENT_SANDBOX ....particularly given that the latter has been deprecated. – John O'Reilly Sep 28 '16 at 09:10
  • @JohnO'Reilly you can use both of them for testing. – Garima Mathur Sep 28 '16 at 10:21
  • @ Garima I had tried ENVIRONMENT_TEST but it hadn't worked for some reason. Does that work for you (using the "android_pay_env_override_sandbox" approach described above)? – John O'Reilly Sep 29 '16 at 09:38
  • @JohnO'Reilly you can use ENVIRONMENT_SANDBOX for testing. Let's try it once. – Garima Mathur Sep 29 '16 at 09:42
  • This has stopped working for me again....is anyone else having issues? I get the "Your card couldn't be added" message again. – John O'Reilly Oct 24 '16 at 10:56
  • Confirming you've got to use ENVIRONMENT_SANDBOX for this to work, even if it is deprecated. That means to use sandbox in /sdcard/Downloads override, GoogleApiClient initialisation and in WalletFragment options – mindeh Mar 10 '17 at 12:49
  • @GarimaMathur I am getting this error "Your card couldn't be added". I done everything properly but still getting this error. Please help. – Pratik B Jun 06 '17 at 09:37
  • can any one reply? – Pratik B Jun 08 '17 at 04:48
  • @pratikbhiyani Have you done wtih all steps properly? I think something would be missing in configuration. – Garima Mathur Jun 08 '17 at 05:56
  • The card mentioned in this link worked for me from India https://github.com/android-pay/androidpay-quickstart/issues/12#issuecomment-309407638 – Karthik Murugan Jun 25 '17 at 17:37
  • Hi Garima, In the step2 rm -­f command is not working when i executing: shell@gtel3g:/sdcard/Download $ rm -f android_pay_env_override_*; Getting: rm failed for -f, No such file or directory What I'm doing wrong ? I have installed Android Pay_1_2_7.apk – Deven Jul 21 '17 at 07:39
  • @Dharmendra I have added a default credit card at today. So, I think you are missing something in configuration. – Garima Mathur Aug 22 '17 at 08:58
  • @Deven I think you should be used TunnelBear(Change VPN) App to download Android Pay App in India. – Garima Mathur Aug 23 '17 at 06:00
  • @pratikbhiyani Have you changed the Android Pay's production environment to sandbox. – Garima Mathur Aug 23 '17 at 06:02
  • Use ENVIRONMENT_SANDBOX to integrate and test Android Pay in your app. - what does it mean? – Igor Kostenko Oct 19 '17 at 16:08
  • @IhorKostenko To convert Android pay into testable environment: Use ENVIRONMENT_SANDBOX in source code to integrate and test Android Pay in your app successfully. – Garima Mathur Oct 24 '17 at 07:13
  • @Garima Really Thanks to answer ! I am configure android pay app for sandbox mode in india and tested it. But Today(4 Nov 2017) i open the app and click on Get Started each time it shows "Something went wrong Please try again" Dialog. – Jeetu Nov 04 '17 at 12:58
  • @Jeetu Okay, I think we have to check Android logs in this case it can tell you the internal error about "Something went wrong Please try again" Dialog. – Garima Mathur Nov 06 '17 at 05:27
  • @Garima Thanks for reply ! This Dialog come in android pay app when i click on "Getting Started" Button in my app code it return always 1 in result code. – Jeetu Nov 06 '17 at 12:56
  • Hi @GarimaMathur I have tried the above steps. But while saving the cards I am facing an issue. The App shows a dialog with error 'Double check your card details'. I have entered the details as mentioned above and provided some fake address. But it is not working. Any comments. Also, I am currently located in UK region. So, is there any other way to test the Android Pay using any other test cards please? Thanks – udai Nov 09 '17 at 10:11
  • @udai The App shows a dialog with error 'Double check your card details'. It means that somewhere we are unable to convert app in testable environment. So, it shows you the errors for production environment. I think you have to convert app in testing environment first for further processing. – Garima Mathur Nov 13 '17 at 12:11
0

I had similar issues to what you describe, but I managed to get it working from Canada. One of the changes I had to make was to use WalletConstants.ENVIRONMENT_TEST instead of the deprecated WalletConstants.ENVIRONMENT_STAGING (the latter was mentioned in almost all tutorials and examples). I also had misconfigured the PaymentMethodTokenizationParameters on the MaskedWalletRequest.

If you are still having issues with your implementation please post the code and I can take a look.

mauricio
  • 1
  • 1