JS SDK error with Safari 17.2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- PayPal Complete Payments Error Notification in PayPal Reporting
- Troubleshooting 'Invalid Scope' Error in Magento Social Login API in REST APIs
- Are there any restrictions to charge using only html, vanilla javascript and php with rest api? in REST APIs
- JS SDK Error: GET_MERCHANT_COUNTRY_ERROR – Assistance with Country Configuration Settings in SDKs
- help me with PayPal with google pay integration in Braintree Client-side Integration (JS, iOS, Android SDKs)