Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix error 400 loading PayPal SDK JS

I'm trying to integrate with PayPal and can't get the sdk/js to load.

I literally pared this back to their example code, and it still gives an HTTP error 400 loading the SDK js. Following steps as given here... https://developer.paypal.com/docs/subscriptions/integrate/#4-create-a-subscription

<!DOCTYPE html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>

<body>
<script
        src="https://www.paypal.com/sdk/js?client-id=AeRCvNJjX_wuV8I8KnIxllYZhizA7I3JZBzQJk4O2q8DoC1ORE9GZM1S1wJd2ch7XZWfsG3GHAYIUWhc&vault=true">
</script>

<div id="paypal-button-container"></div>

<script>
    paypal.Buttons({
        createSubscription: function(data, actions) {
            return actions.subscription.create({
                'plan_id': 'P-3S4679857D7841235LUOV5VY'
            });
        },

        onApprove: function(data, actions) {
            alert('You have successfully created subscription ' + data.subscriptionID);
        }
    }).render('#paypal-button-container');
</script>
</body>
</html>

The SDK js doesn't load. Looking at the response I can see an HTTP error 400 on the sdk/js request, and a paypal-debug-id value.

I've checked and rechecked that I'm passing the correct client-id.

FWIW: I noticed that in some of their other button examples you can use "sb" in place of your client id. If I use just client-id=sb, it shows a payment button, but if I include "&value=true" or use my actual client-id it goes back to error 404.

like image 447
xtempore Avatar asked Oct 15 '22 13:10

xtempore


1 Answers

After beating my head against the wall on this for hours, I finally stumbled across the answer in the PayPal forums. Turns out to be some sort of issue with cookies. Clearing all the cookies related to PayPal seems to have fixed the problem.

Leaving this question here in case it helps someone else avoid the headaches it gave me!

like image 135
xtempore Avatar answered Oct 21 '22 05:10

xtempore