Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const purchaseSubscription = async (): Promise<
"error" | "canceled" | "success"
> => {
try {
const product = await getCurrentPurchasableSubscription();
const { purchaserInfo } = await Purchases.makePurchase(product.identifier);
return isValidPurchaserInfo(purchaserInfo) ? "success" : "error";
} catch (err) {
if (err.userCanceled) {
userCanceledPayment();
return "canceled";
}
Sentry.captureException(err);
return "error";
}
};