How to Properly Initialize Google Play Store?

I’ve been following the “Understanding IAP” article by Rob and used the sample code as a basis for my store purchasing code.

However, with Google Play, if I use the code as is (that is, store.init() followed by store.restore()), the game boots up with a “failed” event error message, but no errorString.

Removing store.restore() from boot up fixes this issue, but brings up some questions I just can’t figure out:

  1. Is this just a side effect of having a non-live app? (The IAP is registered on Google Play, it’s using my custom keystore, and the app itself is in Production draft mode)

  2. How should I be handling this in transactionCallback? (There’s no errorString…and adb just says DEVELOPER_ERROR)

As I recall from integrating IAP into my apps, when I call store.restore() at the start of the app and the user has no purchases to restore, I get a cancelled error with no errorString.  If there are purchases to restore, they restore fine.  Store purchases function as expected, regardless.

I seem to recall getting a failed error if the Google Play services were not set up with a valid Google account.  Like when I had just reset my tablet to defaults to test, but didn’t log into Google Play first and add the account.

What setting do you use on Google Play to ensure test purchases? I managed to whitelist a gmail account (and get past that failed message, though the whitelist seemed to take at least 12 hours), but when I attempt to purchase, it asks me to setup payment information.

I need to test purchasing, but as with iOS, I would like to test in a “don’t spend real money” manner…

This has been discussed to death, but you have to use “real money” in order to test. There is no sandbox or the same concept of developer accounts like there is on iOS or Amazon. However, the charges don’t go through right away. So you have time after a purchase to enter your merchant account and cancel the transaction. Then the credit card will not be charged. Though, for complete testing, it makes sense to let a purchase go through and then refund it to test your refund handling code.

Thanks thegdog; can’t really find any comprehensive threads on the subject so thanks for your patience. 

That being said, if I’m reading the SDK docs right, there’s no way to refund iAP except by emailing Google Play to ask for it?   (Which in turn means testing iAP is really using android.test.*)

So I imagine refund code in this case basically needs to do a full “sweep” when the app is loaded to check the state of each purchased iAP and whether it still has permission to be used. (secret ugh…)

Well, I think Android will always be painful.  :slight_smile:

As for refunds, no, you need to create a Google merchant account in order to do IAP.  Once that is done, you are able to go into that merchant account and see all of your transactions - both for selling apps in the Google Play store and for in-app purchases in your apps.  You can cancel transactions before the credit card is actually charged, or can refund purchases that have gone through.

To get there, log into your Google account that you are managing your apps with.  Go to the Google Play Developer Console.  Click the Settings icon and scroll to the bottom.  There should be a “Merchant Account” section at the bottom.  Click the “Go to merchant account” link and it will open your orders.  From there, you can cancel and refund purchases.

As I recall from integrating IAP into my apps, when I call store.restore() at the start of the app and the user has no purchases to restore, I get a cancelled error with no errorString.  If there are purchases to restore, they restore fine.  Store purchases function as expected, regardless.

I seem to recall getting a failed error if the Google Play services were not set up with a valid Google account.  Like when I had just reset my tablet to defaults to test, but didn’t log into Google Play first and add the account.

What setting do you use on Google Play to ensure test purchases? I managed to whitelist a gmail account (and get past that failed message, though the whitelist seemed to take at least 12 hours), but when I attempt to purchase, it asks me to setup payment information.

I need to test purchasing, but as with iOS, I would like to test in a “don’t spend real money” manner…

This has been discussed to death, but you have to use “real money” in order to test. There is no sandbox or the same concept of developer accounts like there is on iOS or Amazon. However, the charges don’t go through right away. So you have time after a purchase to enter your merchant account and cancel the transaction. Then the credit card will not be charged. Though, for complete testing, it makes sense to let a purchase go through and then refund it to test your refund handling code.

Thanks thegdog; can’t really find any comprehensive threads on the subject so thanks for your patience. 

That being said, if I’m reading the SDK docs right, there’s no way to refund iAP except by emailing Google Play to ask for it?   (Which in turn means testing iAP is really using android.test.*)

So I imagine refund code in this case basically needs to do a full “sweep” when the app is loaded to check the state of each purchased iAP and whether it still has permission to be used. (secret ugh…)

Well, I think Android will always be painful.  :slight_smile:

As for refunds, no, you need to create a Google merchant account in order to do IAP.  Once that is done, you are able to go into that merchant account and see all of your transactions - both for selling apps in the Google Play store and for in-app purchases in your apps.  You can cancel transactions before the credit card is actually charged, or can refund purchases that have gone through.

To get there, log into your Google account that you are managing your apps with.  Go to the Google Play Developer Console.  Click the Settings icon and scroll to the bottom.  There should be a “Merchant Account” section at the bottom.  Click the “Go to merchant account” link and it will open your orders.  From there, you can cancel and refund purchases.