How to use the react-native-purchases.makePurchase function in react-native-purchases

To help you get started, we’ve selected a few react-native-purchases examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Flaque / quirk / src / payments / index.ts View on Github external
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";
  }
};