JS SDK error with Safari 17.2

mbrendel
Contributor
Contributor

I have a simple web page for PayPal payments using JS SDK. It works fine in Chrome, Brave, and Firefox. But in Safari 17.2 there is 'TypeError: "" is not a constructor (evaluating 'new URL(window.document.referrer)')' that occurs in line ~11000  of an SDK module.  Hence, the PayPal  button does not appear at all.  If I paste the URL into a NEW Safari window - it works as expected.   The error occurs when coming from another page (essentially the cart).

 

Anyone have similar issue and fixed it?

Login to Me Too
2 REPLIES 2

mbrendel
Contributor
Contributor

As usually happens I found a solution before any replies. It has to do with the browser sending referring page information - and for unknown reason the PayPal SDK throws an error with Safari.  Here it is for others that may face the same problem:

 

On the page containing the link redirecting to the payment page (page with the PayPal button)

 

"<a href='https://yourdomain.com/yourpaymentpage.php'  rel='noreferrer'>Payment<\a>"

 

or using a JS redirect

 

var url = document.createElement("a");

url.referrerPolicy = "no-referrer";
url.rel = "noreferrer";

url.href = 'https://yourdomain.com/yourpaymentpage.php';
url.click();

 

There may be a better way to do the JS, but this will simply create a HTML link element on the referring page and then self click it.

 

Login to Me Too

Kavyar
Moderator
Moderator

Good day @mbrendel 

 

Thank you for posting to the PayPal community.

 

After reviewing the error message you provided, it appears that there may be an issue with the `URL()` constructor in Safari 17.2. This could potentially be caused by compatibility issues with the version of the SDK you are currently using.

 

To resolve this issue, make sure you are using the latest version of the JS SDK. Check for any updates fixes related to Safari compatibility.

 

If you are still experiencing issues, please create an MTS ticket via the following URL -  https://www.paypal-support.com/s/?language=en_US . Please ensure that you provide detailed information and error details when submitting the ticket.

 

Sincerely,

Kavya

PayPal MTS

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

 

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.