Problem with consumable purchase restoration on Android

Problem with consumable purchase restoration on Android
0

Sdkbox iap doesn’t restore consumable purchases after restart on Android.

On iOS restoration works fine: app starts, sdkbox.IAP.init() called, onSuccess callback with cipheredReceipt is called.

Configuration for iap validation on my server:
before init sdkbox.IAP
sdkbox.IAP.enableUserSideVerification(true)
sdkbox.IAP.setAutoFinishTransaction(false)

It works well for all other cases.

I debugged that after calling sdkbox.IAP.restore(), java listener in com.sdbox.plugin.IAPWrapper (sdkbox.jar) IAPWrapper.onPayResult method is called with data i needed, but neither onSuccess nor onRestored callback is called in my listener in typescript.

So, how can i get purchase data for verification, if sdkbox.IAP.finishTransaction not called immediately after listener’s onSuccess callback?

I’m using Cocos Creator v1.9.3 and iap plugin v2.4.1.1

so, your issue is can’t get trigger onRestore after call sdkbox.IAP.restore()?

consumable product willn’t send to native.

Step by step reproduction:

  1. Purchase consumable product
  2. Got listener’s onSuccess callback with purchase info for validation.
  3. Stop/crash app on breakpoint inside onSuccess.
  4. Restart the app
  5. After sdkbox.IAP.init() I expect to get purchase info again to resume client-server validation flow.
    In iOS i would get onSuccess callback with purchase info, in Android not. Why?

Hi

Env: Cocos2d-x plugin v2.4.1.1

We have the same issue, and users reported that they can’t purchase any more. They got “7 item already owned” error message which should be fixed in v2.4.1.1 according to change log page.

P.S. only specific items for one user cannot be purchased, other items can be purchased as normal.

the item is consumable? you need consume(sdkbox::IAP::finishTransaction) it by yourself or enable auto consume(sdkbox::IAP::setAutoFinishTransaction)

Because Apple has the concept of a transaction. When you stop/crash app on breakpoint inside onSuccess, the transaction is not done. but Google IAB not.

  1. save purchase Info first in onSuccess
  2. we provide a getPurchaseHistory(only valid on android), you can get all purchase history(include cancelled, invalid). this API is not commonly used, but can be used in special cases.

It’s consumable.
And isAutoFinishTransaction() is true.

Could you provide detail recovery flow or an example project to fix this kind of issues?
How could we identify there was one transaction not finished and to let the item become buyable again?

  1. are you fill key with your value in sdkbox_config.json?
  1. can you detail steps, so we can reproduce this issue?

Hi

We filled the key, but not in sdkbox_config.json.
We created a json string after our server sent item information to feed it into sdkbox::IAP::init(configJsonStr.c_str()).

Thanks,
Jo

Any help I could get?
Thanks

We are look into this issue. we will fix it ASAP. sorry for late!

@joappdev can you try this.

PluginIAP.jar.zip (23.1 KB)

if you have test product already bought. you can refund/revoke it in google play console. and then use this to test. if the item already bought dialog show again with the new jar.

1 Like

Hi

I don’t really get your point.
I have a device which has an item with this issue (showing item already bought).

  1. Do I have to refund/revoke the item with issue in google play console before testing your new JAR? What’s the point of refund/revoke? It’s better to have more detail steps.

  2. What’s your concept of the solution? I would like to resume the transaction to let users complete the purchase in our server (by sending the receipt and receiptCipheredPayload of the item to our sever).

Thanks,
Jo

the new jar, i fixed a consume bug, you can try.

and the refun/revoke purchase order, just test advisement.

and, i want to know, can you reproduce this issue. or just some player got this issue.

Hi

I’ll try.

My question is “Is your fix for someone who already has this issue, or just to prevent the issue in the future”?

I have a Nexus Phone which has an item not purchasable right now, should I see the issue fixed right away after I installed your new jar?

Hi

I tried the new JAR on a device which has the issue item (7 item already owned).
It still shows the same message.

can you show your sdkbox_config.json?

do you have the purchase log in logcat

I didn’t purchase again since it already shows “7 item already owned”.
I just installed new APK, try to buy item again. But shows the same message.
Here is the format of sdkbox_config string I put in IAP::init(str);

12-25 16:36:59.964  5546  5626 D IAP     : Refreshing products: ''
12-25 16:37:03.131  5546  5626 D IAP     : parsed jsonconfig from init: {
12-25 16:37:03.131  5546  5626 D IAP     :  "android":  {
12-25 16:37:03.131  5546  5626 D IAP     :      "iap":  {
12-25 16:37:03.131  5546  5626 D IAP     :          "items":    {
12-25 16:37:03.131  5546  5626 D IAP     :              "item1":    {
12-25 16:37:03.131  5546  5626 D IAP     :                  "id":   "com.****.******.item1"
12-25 16:37:03.131  5546  5626 D IAP     :              },
12-25 16:37:03.131  5546  5626 D IAP     :              "item2":    {
12-25 16:37:03.131  5546  5626 D IAP     :                  "id":   "com.****.******.item2"
12-25 16:37:03.131  5546  5626 D IAP     :              },
12-25 16:37:03.131  5546  5626 D IAP     :              "item3":    {
12-25 16:37:03.131  5546  5626 D IAP     :                  "id":   "com.****.******.item3"
12-25 16:37:03.131  5546  5626 D IAP     :              },
12-25 16:37:03.131  5546  5626 D IAP     :              "item4":    {
12-25 16:37:03.131  5546  5626 D IAP     :                  "id":   "com.****.******.item4"
12-25 16:37:03.131  5546  5626 D IAP     :              },
12-25 16:37:03.131  5546  5626 D IAP     :              "item5":    {
12-25 16:37:03.131  5546  5626 D IAP     :                  "id":   "com.****.******.item5"
12-25 16:37:03.131  5546  5626 D IAP     :              }
12-25 16:37:03.131  5546  5626 D IAP     :          },
12-25 16:37:03.131  5546  5626 D IAP     :          "key":  "******************************************************"
12-25 16:37:03.131  5546  5626 D IAP     :      }
12-25 16:37:03.131  5546  5626 D IAP     :  }
12-25 16:37:03.131  5546  5626 D IAP     : }

I replaced the confidential part.