While setting up, PayPal client code to test server integration, from https://developer.paypal.com/docs/archive/checkout/how-to/server-integration/
My code is as follows:
<html>
<head>
<title>TEST PAYMENT</title>
</head>
<body>
<div id="paypal-button"></div>
<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<script>
paypal.Button.render({
env: 'sandbox', // Or 'production'
// Set up the payment:
// 1. Add a payment callback
payment: function(data, actions) {
// 2. Make a request to your server
return actions.request.post('/api/paypal/create-payment')
.then(function(res) {
console.log(res);
// 3. Return res.id from the response
return res.id;
});
},
// Execute the payment:
// 1. Add an onAuthorize callback
onAuthorize: function(data, actions) {
// 2. Make a request to your server
return actions.request.post('/api/paypal/execute-payment', {
paymentID: data.paymentID,
payerID: data.payerID
})
.then(function(res) {
// 3. Show the buyer a confirmation message.
});
}
}, '#paypal-button');
</script>
</body>
</html>
When I click the button, a modal window shows up for a second and closed with the following errors.
The checkout.js
integration you're attempting to use is deprecated.
Here is the current JS SDK to call your server with: https://developer.paypal.com/demo/checkout/#/pattern/server