Skip to main content
Solved

Web SDK results in 500 error trying to make purchase()

  • February 25, 2025
  • 2 replies
  • 27 views

Forum|alt.badge.img+7
  • Dedicated Member
  • 31 replies

I am having issues with the RC Web SDK.  I followed the instructions to get setup, and have successfully added products to Stripe & added to my existing mobile app offerings.  I can now view my paywall with products:

Paywall successfully displays products from Stripe.  The product identified is in sync between Stripe & RevenueCat

When I click “continue” for either product it results in an error:

error code 16


The console shows a 500 error to the RevenueCat API:

POST https://api.revenuecat.com/rcbilling/v1/purchase 500 (Internal Server Error)

qr	@	Purchases.es.js:6824
postPurchase	@	Purchases.es.js:7015
startPurchase	@	Purchases.es.js:4850
ae	@	Purchases.es.js:6398
eval	@	Purchases.es.js:6383
Ei	@	Purchases.es.js:100
eval	@	Purchases.es.js:1782
cr	@	Purchases.es.js:971
eval	@	Purchases.es.js:1782
to	@	Purchases.es.js:766
lt	@	Purchases.es.js:816
ts	@	Purchases.es.js:866
rs	@	Purchases.es.js:852
ns	@	Purchases.es.js:876

When i close the modal this error shows up in the console:

Purchases.es.js:4768 Uncaught (in promise) ce: Unknown backend error.
    at ce.getForPurchasesFlowError (webpack-internal:///(app-pages-browser)/./node_modules/@revenuecat/purchases-js/dist/Purchases.es.js:4768:12)
    at onError (webpack-internal:///(app-pages-browser)/./node_modules/@revenuecat/purchases-js/dist/Purchases.es.js:9263:36)
    at HTMLButtonElement.R (webpack-internal:///(app-pages-browser)/./node_modules/@revenuecat/purchases-js/dist/Purchases.es.js:6435:8)
    at HTMLButtonElement.click (webpack-internal:///(app-pages-browser)/./node_modules/@revenuecat/purchases-js/dist/Purchases.es.js:5158:36)
    at HTMLButtonElement.fo (webpack-internal:///(app-pages-browser)/./node_modules/@revenuecat/purchases-js/dist/Purchases.es.js:1803:7)
    at HTMLButtonElement.eval (webpack-internal:///(app-pages-browser)/./node_modules/@revenuecat/purchases-js/dist/Purchases.es.js:5061:8)
    at eval (webpack-internal:///(app-pages-browser)/./node_modules/@revenuecat/purchases-js/dist/Purchases.es.js:1122:25)
    at oo (webpack-internal:///(app-pages-browser)/./node_modules/@revenuecat/purchases-js/dist/Purchases.es.js:1106:12)
    at HTMLButtonElement.a (webpack-internal:///(app-pages-browser)/./node_modules/@revenuecat/purchases-js/dist/Purchases.es.js:1122:14)

What am I doing wrong?  I am under the impression I do not need any additional setup when using this SDK.

Here is my code for making the `purchase()`:

const handleSubscription = async (pkg: Package, email: string) => {
    await Purchases.getSharedInstance().purchase({
      rcPackage: pkg,
      customerEmail: email
    });
  };


// arguments passed to RC purchase():
{
    "pkg": {
        "identifier": "$rc_monthly",
        "rcBillingProduct": {
            "identifier": "prod_RiL5rO2EYYxExK",
            "displayName": "Monthly",
            "title": "Monthly",
            "description": "Monthly Subscription",
            "productType": "subscription",
            "currentPrice": {
                "amount": 599,
                "amountMicros": 5990000,
                "currency": "USD",
                "formattedPrice": "$5.99"
            },
            "normalPeriodDuration": "P1M",
            "presentedOfferingIdentifier": "default",
            "presentedOfferingContext": {
                "offeringIdentifier": "default",
                "targetingContext": null,
                "placementIdentifier": null
            },
            "defaultPurchaseOption": {
                "id": "base_option",
                "priceId": "prc91fefcad308748de8a36",
                "base": {
                    "periodDuration": "P1M",
                    "period": {
                        "number": 1,
                        "unit": "month"
                    },
                    "cycleCount": 1,
                    "price": {
                        "amount": 599,
                        "amountMicros": 5990000,
                        "currency": "USD",
                        "formattedPrice": "$5.99"
                    }
                },
                "trial": null
            },
            "defaultSubscriptionOption": {
                "id": "base_option",
                "priceId": "prc91fefcad308748de8a36",
                "base": {
                    "periodDuration": "P1M",
                    "period": {
                        "number": 1,
                        "unit": "month"
                    },
                    "cycleCount": 1,
                    "price": {
                        "amount": 599,
                        "amountMicros": 5990000,
                        "currency": "USD",
                        "formattedPrice": "$5.99"
                    }
                },
                "trial": null
            },
            "subscriptionOptions": {
                "base_option": {
                    "id": "base_option",
                    "priceId": "prc91fefcad308748de8a36",
                    "base": {
                        "periodDuration": "P1M",
                        "period": {
                            "number": 1,
                            "unit": "month"
                        },
                        "cycleCount": 1,
                        "price": {
                            "amount": 599,
                            "amountMicros": 5990000,
                            "currency": "USD",
                            "formattedPrice": "$5.99"
                        }
                    },
                    "trial": null
                }
            },
            "defaultNonSubscriptionOption": null
        },
        "packageType": "$rc_monthly"
    },
    "email": "myemail@gmail.com"
}


Is there something different for Stripe to know Dev vs Prod environments?

Best answer by victor

Hi ​@lucksp,

It looks like the RevenueCat Stripe App was installed in test mode in your Stripe account. In this case, only sandbox purchases can be made in your Web Billing app.

Make sure you are using the sandbox API Key if you want to test sandbox purchases in your app. Alternatively, install the RevenueCat Stripe App in live mode if you want to enable production purchases.

P.S. In your message, you mentioned that you’ve added products to Stripe. Please note that this step is not necessary for setting up a RevenueCat Web app, as you can configure your products directly from the RevenueCat dashboard

View original
Did this post help you find an answer to your question?
This post has been closed for comments

2 replies

victor
RevenueCat Staff
Forum|alt.badge.img
  • RevenueCat Staff
  • 3 replies
  • Answer
  • February 25, 2025

Hi ​@lucksp,

It looks like the RevenueCat Stripe App was installed in test mode in your Stripe account. In this case, only sandbox purchases can be made in your Web Billing app.

Make sure you are using the sandbox API Key if you want to test sandbox purchases in your app. Alternatively, install the RevenueCat Stripe App in live mode if you want to enable production purchases.

P.S. In your message, you mentioned that you’ve added products to Stripe. Please note that this step is not necessary for setting up a RevenueCat Web app, as you can configure your products directly from the RevenueCat dashboard


Forum|alt.badge.img+7
  • Author
  • Dedicated Member
  • 31 replies
  • February 25, 2025

Thank you @Victor - I think I had forgotten about all the setup between test & live modes, and that the RevenueCat Dashboard posts both Live & Sandbox API keys.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings