PaddleHQ/paddle-js-wrapper

[Bug]: CORS error when accessing /pricing-preview

xgedev opened this issue · 7 comments

What happened?

I recently received reports from certain users not being able to view the prices for my subscription types.
A screenshot of their browser console shows a CORS error.
I can't reliably reproduce this, however one specific user always gets this error, no matter what they are trying.

Steps to reproduce

  1. Run Paddle.initializePaddle(...) (works fine)
  2. Run paddle.pricePreview(...) -> shows CORS error

What did you expect to happen?

No CORS error to be thrown.

How are you integrating?

SvelteKit

Logs

Access to fetch at 'https://api.paddle.com/pricing-preview' from origin 'https://mywebsite.com/subscriptions' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Hi @xgedev,
Thank you for raising this bug report.

We usually throw this error if the client-side token is missing in the request or if the request is made from an unsupported country.

Would you by any chance know the location of the user who is consistently running into this error.

Thank you.

Hi,
thank you for the fast response.
The user is from Ukraine and the client token is definitely set correctly.
Any idea what is wrong here?

Just read that there are regions of Ukraine that are unsupported. Is there any way I can check if the user is in an unsupported country to display an error message? Should I advise them to use a VPN?

Hello,
You won't be able to distinguish this error from others and it is by design to help prevent users identifying the error and using tools to circumvent them. You can use standard try/catch blocks to gracefully handle the error.

Should I advise them to use a VPN

Sorry, No. They are blocked from transacting due to regulatory reasons. We stand strongly against using any tools to bypass this restriction.

Please let us know if we can help with anything else.
Thank you.

Alright! Am I allowed to display an error message that says something like

Pricing could not be loaded. Make sure that your country is supported. Contact support@mail.com for help.

Or should I not mention the unsupported countries?
Thank you for your answers so far!

Hello,
As this is a generic error handler, it could be confusing for users from supported countries who might see this error on the rare occurrence when Paddle API fails.

maybe Pricing could not be loaded. Please try again later or Contact support@mail.com for help. might be more appropriate?

Will implement it like this, thanks!