RevenueCat / RevenueCat/react-native-purchases
ProductAlreadyPurchasedError whereas is not the case. (Payment pending cards Android)
@aboedo is already working on this.
Since Jun 19, 2020.
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 117
- Avg merge
- 14h 40m
- Merged PRs (30d)
- 40
Description
I'm using RevenueCat on android now, in order to purchase 'non-consumable product'. I've configured my account following the doc (great doc !). However I'm facing an issue.
First of all, you know that android allow to purchase product with 4 different cards in tester account.
I've no problem with card always denied, card always accepted and card accepted after a delays.
But my problem is with card cancel after few minutes.
Here how I proceed :
1.
Add listener
// function for purchase Listener
this.purchaserInfoUpdateListener = (info) => {
checkIfPro(info, this._becomePremium);
};
// add this function to Purchases's Listener
Purchases.addPurchaserInfoUpdateListener(this.purchaserInfoUpdateListener);
//function call when listener is called
function checkIfPro(purchaserInfo, callbackFunction) {
// Check when function is called
console.log('checkIfPro is called ! ');
if (typeof purchaserInfo.entitlements.active.premium !== 'undefined') {
// Unlock premium content :
console.log('#Unlock great content#');
// Active premium
callbackFunction();
} else {
console.log('Not premium');
}
}
2.
Purchase a product (with card cancelled after few minutes)
const { purchaserInfo, productIdentifier } = await Purchases.purchaseProduct(
itemToPurchase,
null,
Purchases.PURCHASE_TYPE.INAPP
);
3.
See the logs
e.userInfo.readableErrorCode = 'PaymentPendingError'
We can see 'PaymentPendingError', ok it's normal, the transaction isn't finished yet.
4.
Wait few minutes
5.
Because nothing happened (Listener isn't call, or anything show that transaction is cancelled), I try to purchase the product again. However the logs say :
ProductAlreadyPurchasedError
whereas when I call
await Purchases.getPurchaserInfo()
the entitlement is not active.
My issues :
- I can't know if a transaction is cancelled after few minutes, so I can't try to purchase it after(when the transaction is officially cancelled)
- My product also act as a 'consumable' product and I don't know how to configure it as a 'non-consumable product'. Because if I choose the card which is always accepted, I can buy the product as many as I want.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.