react-native-iap
react-native-iap copied to clipboard
Not able to clearTransaction on IOS on testflight build
Version of react-native-iap
"react-native-iap": "^8.0.5"
Version of react-native
"react-native": "0.63.4"
Platforms you faced the error (IOS or Android or both?)
IOS
Expected behavior
- Testflight build should behave same as the app installed from xcode .
- Buy consumable product.
- Finish transaction .
- And after validating the receipt should get only one item in "in_app" property which represents the current product purchase item
Actual behavior
1.When i upload a build on testflight and tries to test the IAP ( consumable product ), then i'm getting this In-App purchase has been already been bought. 5.And if i test the same app with dwai link or run app directly on my device with sandbox account then i get alert with sandbox account and every thing works fine
Tested environment (Emulator? Real Device?)
real device
Steps to reproduce the behavior
- Prepare archive with the same code and upload build on testflight.
- Tried to buy the same products multiple times to represent add credit behaviour.
purchase function
const purchase = async (item) => {
await RNIap.clearTransactionIOS();
// Reset error msg
if (connectionErrorMsg !== '') setConnectionErrorMsg('');
if (!connected) {
setConnectionErrorMsg('Please check your internet connection');
}
// If we are connected & have products, purchase the item. Gohas no inteogle will handle if user rnet here.
else if (offeredProducts?.length > 0) {
await RNIap.requestPurchase(item);
console.log('Purchasing products...');
}
// If we are connected but have no products returned, try to get products and purchase.
else {
console.log('No products. Now trying to get some...');
try {
await getProducts(consumableSkus);
await RNIap.requestPurchase(item);
console.log('Got products, now purchasing...');
} catch (error) {
setConnectionErrorMsg('Please check your internet connection');
console.log('Everything failed. Error: ', error);
}
}
};
Purchase listner
purchaseUpdate = purchaseUpdatedListener(async (purchase) => {
const receipt = purchase.transactionReceipt;
if (receipt) {
console.log('receipt', receipt);
try {
// sendReceiptToServer(receipt)
await receiptValidation(receipt);
await finishTransaction(purchase, true);
} catch (ackErr) {
console.warn('ackErr', ackErr);
}
}
});
This could also be fixed by these two: https://github.com/dooboolab/react-native-iap/pull/1665 https://github.com/dooboolab/react-native-iap/pull/1662
@andresesfm thanks , one quick question though is it possible to get multiple items in in_app array when each time i'm finishing transaction with finishTransaction().
And to get the current purchase i've to just sort this array by purchase_date_ms right ?
Those properties come directly from Apple's receipt validator, not modified by this library