-
-
Notifications
You must be signed in to change notification settings - Fork 695
Closed
Labels
📱 iOSRelated to iOSRelated to iOS
Description
Version of react-native-iap
8.0.4
Version of react-native
0.67.2
Platforms you faced the error (IOS or Android or both?)
iOS
Expected behavior
calling finishTransaction marks the transaction as finished
Actual behavior
Any code after the await RNIap.finishTransaction is not executed, and the transaction is reattempted after each relaunch of the app.
Tested environment (Emulator? Real Device?)
Real device
Steps to reproduce the behavior
Purchase a product in sandbox, call finishTransaction, check if some code after the promise is executed.
Here is my listener:
purchaseUpdatedListener = RNIap.purchaseUpdatedListener(
async (purchase: RNIap.InAppPurchase | RNIap.SubscriptionPurchase) => {
const receipt = purchase.transactionReceipt;
try {
if (receipt) {
const decodedReceipt = await decodeAppleReceipt(receipt);
const isValid = await isSubValid(decodedReceipt);
if (isValid) {
const { latest_receipt_info: latestReceipts }: any = decodedReceipt;
const sortedReceiptInfo = latestReceipts.sort(
(
a: { original_purchase_date_ms: number },
b: { original_purchase_date_ms: number },
) => b.original_purchase_date_ms - a.original_purchase_date_ms,
);
let latestReceiptInfo = sortedReceiptInfo[sortedReceiptInfo.length - 1];
console.log(latestReceiptInfo);
const subPrice = await getSubPrice(latestReceiptInfo.product_id);
const subDuration = getSubDuration(latestReceiptInfo.product_id);
latestReceiptInfo = {
...latestReceiptInfo,
subscription_price: subPrice,
};
// Persist the purchase on backend API
const persistedPurchase = await persistSubscriptionIOS(latestReceiptInfo, sessionId);
const persistedPurchaseId: string = persistedPurchase.persistPurchase.id;
latestReceiptInfo = {
...latestReceiptInfo,
persisted_purchase_id: persistedPurchaseId,
source: 'ios',
subscription_duration: subDuration,
};
// Activate the subscription on backend API
const deliveryResult = await activateSubscription(latestReceiptInfo, sessionId);
if (isSuccess(deliveryResult)) {
console.log('deliveryResult is true');
await RNIap.finishTransaction(purchase, false);
console.log('finish transaction done');
onSuccess?.();
}
}
}
} catch (error) {
console.error(error);
}
},
);
The console.log of finish transaction done is never executed, neither my onSuccess callback. However the console.log before finishTransaction is logged.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
📱 iOSRelated to iOSRelated to iOS