const purchasePackage = async (
parentAuthId: string,
parentServiceId: string,
pkg: PurchasesPackage,
) => {
return withInAppPurchase(parentAuthId, parentServiceId, async () => {
try {
const result = await Purchases.purchasePackage(pkg);
return result;
} catch (error) {
logError(InAppPurchaseAnalyticsEvents.PURCHASE_PACKAGE_FAILED, {
error,
parentAuthId,
parentServiceId,
});
throw error;
}
});
};
const purchase = useCallback(
(pkg: PurchasesPackage) => {
return purchasePackage(parentAuthId, parentServiceId, pkg);
},
[parentAuthId, parentServiceId],
);
const handlePurchase = useCallback(async () => {
if (!selectedPlan) {
return;
}
setStatus('inprogress');
trackEvent(getAnalyticsEvent('purchase', 'inprogress'), { plan_type: planType });
try {
await purchase(selectedPlan);
validateCustomerInfo();
} catch {
setStatus('failed');
}
}, [selectedPlan, planType, purchase, validateCustomerInfo]);
Describe the bug
On IOS, while making a payment through UPI in India, the purchase is getting cancelled in background when i go to the payment app for accepting the payment.
Error Code is PURCHASE_CANCELLED in the above case as soon as i go to payment app, Payment is successful but error code is incorrect in this case.
Additional context
Here is the code snippet