React-native-iap: How to manually cancel a pending purchase?

Created on 29 Jul 2019  ·  8Comments  ·  Source: dooboolab/react-native-iap

Version of react-native-iap

3.3.7

Version of react-native

0.59.8

Platforms you faced the error (IOS or Android or both?)

Android

Expected behavior

when i request a purchase, then i validate the receipt on my server, if the validation failed i want to be able to manually cancel the purchase, instead of the function purchaseUpdatedListener triggered every time, if don't call acknowledgepurchase or consumepurchase.

Actual behavior

when not finishing the purchase, i can not cancel the pending purchase. On android i have to wait that it is cancelled automatically.

Tested environment (Emulator? Real Device?)

Real device

Steps to reproduce the behavior

Make a purchase and don't call acknowledgepurchase or consumepurchase.

1️⃣ good first issue ❓ question 🙏 help wanted 🤖 android

Most helpful comment

@hyochan, Is there a functionnality like that on iOS, in order to cancel a purchase which has not been completed by calling finishTransactionIOS and then having that purchase being removed from the purchase history. I don't know if there is another way to check if a subscription is still active, but what i do now is to check the expiration date for the last transaction in the receipt history. So if a purchase has not been completed, i don't want it to being recorded in the purchase history. Unfortunately at the moment, that's exactly what's happening. And unlike Android the incompleted purchase will not be cancelled after some time and it will never stop being triggered by the purchaseUpdateListener.

So i have the same problem on ios and android, i need to cancel a purchase which has not been completed. And specifically on ios, not having that purchase being recorded in the history unless if there is a more efficient way to check the validity of a subscription.

All 8 comments

Even the failure result, you should still call acknowledgePurchase and consumePurchase for finished transaction. You only not proceed logic such as not giving a reward on your own database. Also, you should consmePurchase so that it does not remain in your app.

@hyochan if i do that, the payment will be approved and the user account will be charged without getting rewarded.

@tmjordan Oh, I see what you meant. What if you proceed logic by giving a reward then?

@hyochan when a user purchase a product, the given receipt is sent to google servers in order to validate the receipt and to get the status of the purchase (if the payment has been approved , or is pending, or cancelled).
Let say i have an error during the validation process not coming from the google server (my backend for example), so i can't validate the receipt and i want to cancel the purchase manually instead of waiting for it to get cancelled by google (during that time i can't make another purchase) if i don't call aknowledgepurchase or consumepurchase.
Don't know if it is possible, maybe that's just how the purchasing process works on google.

It would be nice, if we can manually cancel a purchase which has not been yet acknowledged or consumed. In that scenario the user will be refunded if the payment had been approved.
Instead of having the same purchase triggered every time until it get cancelled by google.

@tmjordan Thanks for your good point of view. Sounds very reasonable but I am not quite sure that pending purchases are actually charged. I think the pending purchases should not even be charged when acknowledged and rather these should be removed. Hope we can go over more details on any other experiences.

@hyochan, Is there a functionnality like that on iOS, in order to cancel a purchase which has not been completed by calling finishTransactionIOS and then having that purchase being removed from the purchase history. I don't know if there is another way to check if a subscription is still active, but what i do now is to check the expiration date for the last transaction in the receipt history. So if a purchase has not been completed, i don't want it to being recorded in the purchase history. Unfortunately at the moment, that's exactly what's happening. And unlike Android the incompleted purchase will not be cancelled after some time and it will never stop being triggered by the purchaseUpdateListener.

So i have the same problem on ios and android, i need to cancel a purchase which has not been completed. And specifically on ios, not having that purchase being recorded in the history unless if there is a more efficient way to check the validity of a subscription.

I would like to handle similar scenario

  1. User Start the purchase of a (time sensitive) product. This product should be returned immediately
  2. Server fails to return the product. and it may be late to return the product by retrying
  3. the purchaseUpdateListener gets triggered many times until finishTransactionIOS is called however this is not the desirable results. The transaction should be cancelled at this stage.

Is there a method to cancel the transaction.

Was this page helpful?
0 / 5 - 0 ratings