failed to load the PayPal JS SDK script TypeError: Load failed

Suezp
Contributor
Contributor

Hi,
          Our system has been use paypal sdk and paypal advance JS Sdk to load the patments for a long TIme,
   but there have a lot customer can't load that sdk recently. I need. some help to know whether the mistake in my code.
   The error message like this: 
   

 

 

[system] failed to load the PayPal JS SDK script Error: The script "https://www.paypal.com/sdk/js?client-id=AYDr8pQoXnoLb7kcUGToxbazY_ssBBsQ5EscoRHnJ2FqF1O2qnEf8fgxDsPE9uUZNNXlgEBzBkHIUGnk&components=buttons,hosted-fields&locale=en_GB&currency=GBP&enable-funding=card&disable-funding=credit" failed to load.

 

 

  The code that I have use bellow:
   

 

 

loadScript({
			  clientId: paypal_client_id,
			  dataClientToken: res.client_token,
			  components: ['buttons','hosted-fields'],
			  locale: 'en_GB',
			  currency: 'GBP',
			  'enable-funding': 'card',
			  'disable-funding': 'credit'
			})
		.then((paypal) => {
			
			let _this = this;
			// If this returns false or the card fields aren't visible, see Step #1.
			_this.payOrderId = null;
			setTimeout(()=>{
			    _this.payLoadDone = true;
			},1000)
			if (paypal.HostedFields.isEligible()) {
			    // Renders card fields  
			    paypal.HostedFields.render({
			        // Call your server to set up the transaction
			        createOrder: function() {
			            return fetch('https://myServer/payPal/createCardOrder?oId='+ _this.orderId, 
			            {
			                method: 'get',
			                headers: {
			                    'Content-Type': 'application/json',
			                    'refreshToken': uni.getStorageSync('refreshToken'),
			                    'token': uni.getStorageSync('token'),
			                }
			            }).then(function(res) {
			                return res.json();
			            }).then(function(orderData) {
			                if(orderData.code == 50033) {
			                	uni.navigateTo({
			                		url: `/pages/orders/orderSecondPage/paySuccess?orderId=${_this.orderId}&tpye=pay`
			                	})
			                	return 
			                }
			                return _this.payOrderId;
			            }).catch(error => {
			                uni.showToast({
								icon: 'none',
			                	title: error
			                })
			            });
			        },
			        styles: {
			            '.valid': {
			                'color': 'green'
			            },
			            '.invalid': {
			                'color': 'red'
			            }
			        },
			        fields: {
			            number: {
			                selector: "#card-number",
			                placeholder: "**** **** **** ****"
			            },
			            cvv: {
			                selector: "#cvv",
			                placeholder: "***"
			            },
			            expirationDate: {
			                selector: "#expiration-date",
			                placeholder: "MM/YY"
			            }
			        },
			    }).then( (cardFields)=> {
					_this.canSubmit = true;
					_this.cardFields = cardFields;
			    })
				.catch((error) => {
					this.payLoadDone = false;
					this.showErrorModal = true;
				});
			} else {
			    // Hides card fields if the merchant isn't eligible
			    document.querySelector("form").style = 'display: none';
			}
			
		   //  paypal
		   //      .render("#your-container-element")
		   //      .catch((error) => {
					// this.payLoadDone = false;
					// this.showErrorModal = true; 
		   //      });
		})
		.catch((error) => {
                    //. some customer got this error message.
		    console.error("failed to load the PayPal JS SDK script", error);
			this.payLoadDone = false;
			this.showErrorModal = true;  
		});

 

 

  

Login to Me Too
2 REPLIES 2

Philsims
Contributor
Contributor

Hi Did you ever get this fixed? I am seeing s similar issue where the SDK js fails to load it is had been happening intermittently since around 17th July.

Login to Me Too

March_Branding
New Community Member

Check out this post: https://www.paypal-community.com/t5/SDKs/Paypal-SDK-not-loading-in-Safari-16-6/m-p/3090733/highlight... It's a known issue that more than a few of us are experiencing.

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.