Recommended way to validate that user has active subscription on Google Play (IAP API v3)

We are working on implementing auto-renew subscription on Google Play. The question we have been trying to figure out is, how to verify if a particular subscription is active (eg. has been renewed).

There is nothing specific in Corona’s documentation, and we have been trying to map Google’s documentation back to Corona API. There appears to be multiple options, and it’s a bit confusing. So, I would love to get some feedback.

  1. Based on this Google API v3 documentation, there is an additional call that we can do to query subscription status, but is this translated into an Corona API?

https://developer.android.com/google/play/billing/billing_integrate.html#Subs

Bundle activeSubs = mService.getPurchases(3, "com.example.myapp", "subs", continueToken);
  1. Based on API v2 documentation, there appears to be 2 more approaches. One of them uses Notification (which I am assuming Corona doesn’t support). Another that uses the Google Play Android Developer API to query for subscription status. But is this approach still supported by API v3?

https://developer.android.com/google/play/billing/v2/billing_subscriptions.html

https://developers.google.com/android-publisher/v1_1/purchases/get

  1. Lastly, at the bottom of the section “Checking Subscription Validity” on this page, it seems to imply that doing a restore will also return the subscription status. While not recommended, this actually appears to be the simplest approach.

https://developer.android.com/google/play/billing/v2/billing_subscriptions.html

What have others done? What do folks recommend? Any feedbacks appreciated!

Thanks!

Andrew

Now that I started implementing this, I believe I am running into a Corona bug that’s due to Corona not calling the correct Google Play API when doing a Subscription Purchase:

http://stackoverflow.com/questions/16377755/google-play-in-app-purchase-returns-error-code-1008-null-puchasedata-or-datasi

Basically, I went ahead and setup a subscription IAP Type on Google Play, then called Corona’s IAP API like normal. On the device, when going through the purchase flow, the Google Play UI comes back and tells me that the purchase was a success. But the transaction call back gives me the following trace:

I/Corona ( 5906): DEBUG: IAPUtil.transactionCallback: Received event storeTransaction isAmazonStore? nil I/Corona ( 5906): DEBUG: txn.state failed I/Corona ( 5906): DEBUG: txn.date nil I/Corona ( 5906): DEBUG: txn.identifier nil I/Corona ( 5906): DEBUG: txn.productIdentifier nil I/Corona ( 5906): DEBUG: txn.receipt nil I/Corona ( 5906): DEBUG: txn.originalDate: nil I/Corona ( 5906): DEBUG: txn.originalID nil I/Corona ( 5906): DEBUG: txn.originalReceipt nil I/Corona ( 5906): DEBUG: txn.errorType -1008 I/Corona ( 5906): DEBUG: txn.errorString IAB returned null purchaseData or dataSignature (response: -1008:Unknown error) I/Corona ( 5906): DEBUG: txn.userId nil

Can someone from Corona confirm if the API can work with subscription? Have I just run into a bug? 

Thx!

I want to ping again and see if anyone from Corona can chime in? Or, anyone else who had tried implementing subscription for Google Play?

Thanks!
Andrew

I don’t have a subscription based app to experiment with.  The community hasn’t responded so they may not have experience in this area either.   Engineering is going to need a test project to work with, so I would recommend going ahead and filing a bug report.  Please make sure to include your build.settings and config.lua in the zip file.

Rob

Now that I started implementing this, I believe I am running into a Corona bug that’s due to Corona not calling the correct Google Play API when doing a Subscription Purchase:

http://stackoverflow.com/questions/16377755/google-play-in-app-purchase-returns-error-code-1008-null-puchasedata-or-datasi

Basically, I went ahead and setup a subscription IAP Type on Google Play, then called Corona’s IAP API like normal. On the device, when going through the purchase flow, the Google Play UI comes back and tells me that the purchase was a success. But the transaction call back gives me the following trace:

I/Corona ( 5906): DEBUG: IAPUtil.transactionCallback: Received event storeTransaction isAmazonStore? nil I/Corona ( 5906): DEBUG: txn.state failed I/Corona ( 5906): DEBUG: txn.date nil I/Corona ( 5906): DEBUG: txn.identifier nil I/Corona ( 5906): DEBUG: txn.productIdentifier nil I/Corona ( 5906): DEBUG: txn.receipt nil I/Corona ( 5906): DEBUG: txn.originalDate: nil I/Corona ( 5906): DEBUG: txn.originalID nil I/Corona ( 5906): DEBUG: txn.originalReceipt nil I/Corona ( 5906): DEBUG: txn.errorType -1008 I/Corona ( 5906): DEBUG: txn.errorString IAB returned null purchaseData or dataSignature (response: -1008:Unknown error) I/Corona ( 5906): DEBUG: txn.userId nil

Can someone from Corona confirm if the API can work with subscription? Have I just run into a bug? 

Thx!

I want to ping again and see if anyone from Corona can chime in? Or, anyone else who had tried implementing subscription for Google Play?

Thanks!
Andrew

I don’t have a subscription based app to experiment with.  The community hasn’t responded so they may not have experience in this area either.   Engineering is going to need a test project to work with, so I would recommend going ahead and filing a bug report.  Please make sure to include your build.settings and config.lua in the zip file.

Rob

@Rob,

We did a lot of research into this, and even created a simple app to duplicate, We believe the issue is a problem with the mapping of the Corona API to the Google Play API. It looks like when calling the purchase API in Google Play, there is an item Type parameter that is either “inapp” or “subs”, where it needed to be set to “subs” for subscription. But Corona is setting it to “inapp”.

https://developer.android.com/google/play/billing/billing_integrate.html#Subs

Here is a revised trace from our sample app that points to the culprit:

D/IabHelper( 5781): Ending async operation: launchPurchaseFlow D/IabHelper( 5781): Successful resultcode from purchase activity. D/IabHelper( 5781): Purchase data: null D/IabHelper( 5781): Data signature: null D/IabHelper( 5781): Extras: Bundle[{RESPONSE\_CODE=0}] D/IabHelper( 5781): Expected item type: inapp E/IabHelper( 5781): In-app billing error: BUG: either purchaseData or dataSignature is null. D/IabHelper( 5781): Extras: Bundle[{RESPONSE\_CODE=0}] D/dchan ( 5781): IAB returned null purchaseData or dataSignature (response: -1008:Unknown error) I/Corona ( 5781): \*\*\* transactionCallback: Received event storeTransaction I/Corona ( 5781): \*\*\* state: failed I/Corona ( 5781): \*\*\* identifier: nil I/Corona ( 5781): \*\*\* productIdentifier: nil I/Corona ( 5781): \*\*\* wdate: nil I/Corona ( 5781): \*\*\* errorType: -1008 I/Corona ( 5781): \*\*\* errorString: IAB returned null purchaseData or dataSignature (response: -1008:Unknown error) D/dalvikvm( 3561): GC\_CONCURRENT freed 434K, 11% free 10699K/11948K, paused 1ms+2ms, total 24ms

We went ahead and submitted a bug along with example code and detailed info from us  (I believe it is #34697

This is a very high priority issue for us, since it directly impacts our ability to monetize our app. If you can help us bring this to engineering’s attention, we would really appreciate it. thx.

Just for the benefit of others. We were able to find a resolution to our issue. Please see here:

http://forums.coronalabs.com/topic/49043-in-app-subscriptions-need-help-on-how-best-to-maintain/#entry259648

@Rob,

We did a lot of research into this, and even created a simple app to duplicate, We believe the issue is a problem with the mapping of the Corona API to the Google Play API. It looks like when calling the purchase API in Google Play, there is an item Type parameter that is either “inapp” or “subs”, where it needed to be set to “subs” for subscription. But Corona is setting it to “inapp”.

https://developer.android.com/google/play/billing/billing_integrate.html#Subs

Here is a revised trace from our sample app that points to the culprit:

D/IabHelper( 5781): Ending async operation: launchPurchaseFlow D/IabHelper( 5781): Successful resultcode from purchase activity. D/IabHelper( 5781): Purchase data: null D/IabHelper( 5781): Data signature: null D/IabHelper( 5781): Extras: Bundle[{RESPONSE\_CODE=0}] D/IabHelper( 5781): Expected item type: inapp E/IabHelper( 5781): In-app billing error: BUG: either purchaseData or dataSignature is null. D/IabHelper( 5781): Extras: Bundle[{RESPONSE\_CODE=0}] D/dchan ( 5781): IAB returned null purchaseData or dataSignature (response: -1008:Unknown error) I/Corona ( 5781): \*\*\* transactionCallback: Received event storeTransaction I/Corona ( 5781): \*\*\* state: failed I/Corona ( 5781): \*\*\* identifier: nil I/Corona ( 5781): \*\*\* productIdentifier: nil I/Corona ( 5781): \*\*\* wdate: nil I/Corona ( 5781): \*\*\* errorType: -1008 I/Corona ( 5781): \*\*\* errorString: IAB returned null purchaseData or dataSignature (response: -1008:Unknown error) D/dalvikvm( 3561): GC\_CONCURRENT freed 434K, 11% free 10699K/11948K, paused 1ms+2ms, total 24ms

We went ahead and submitted a bug along with example code and detailed info from us  (I believe it is #34697

This is a very high priority issue for us, since it directly impacts our ability to monetize our app. If you can help us bring this to engineering’s attention, we would really appreciate it. thx.

Just for the benefit of others. We were able to find a resolution to our issue. Please see here:

http://forums.coronalabs.com/topic/49043-in-app-subscriptions-need-help-on-how-best-to-maintain/#entry259648