-
Notifications
You must be signed in to change notification settings - Fork 139
Open
Description
Description
When using paypalCheckoutInstance.loadPayPalSDK(), network errors (such as 400 Bad Request) don't cause the returned Promise to reject. This makes it impossible to properly handle SDK loading failures in try/catch blocks or with Promise error handlers.
Current Behavior
When the PayPal SDK fails to load with network errors, the Promise from loadPayPalSDK():
- Never resolves or rejects (hangs indefinitely)
- Fails silently without throwing a proper error
Expected Behavior
The Promise returned by loadPayPalSDK() should reject with an appropriate error when the SDK fails to load, allowing developers to handle these errors using standard Promise error handling patterns.
Code Example
try {
// This Promise never rejects on network errors
await paypalCheckoutInstance.loadPayPalSDK({
'client-id': client_id,
currency,
intent: 'capture',
commit: false,
locale,
});
// Further code is never executed on network errors
const buttons = window.paypal.Buttons({
// Configuration...
});
} catch (error) {
// This catch block never executes on network errors
console.error('PayPal SDK loading error:', error);
}Proposed Solution
Update the internal loadScript utility to properly reject the Promise when there's a network error loading the PayPal SDK.
Environment
- braintree-web version: 3.117.1
- Browser: Chrome, Firefox, Safari (all affected)
- OS: Windows, macOS, Linux
Reactions are currently unavailable