In another question I found the following has been deprecated. Specifically, actions.order.create and actions.order.capture have been deprecated and should not be used in any new integrations
So what do we use in May 2023 to avoid the backend?
My DocType at the top of the Html file is:
<!DOCTYPE html>
I have the code in the <header>:
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
In the <body>.
<script src="https://www.paypal.com/sdk/js?client-id=sb¤cy=GBP"></script>
<div id="paypal-button-10"></div>
<script>
paypal.Buttons({
style: {
layout: 'vertical', /* 'horizontal', */
color: 'gold',
shape: 'pill',
label: 'buynow'
},
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [
{
amount: {
currency_code: "GBP",
value: "10.00"
}
}
]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Congratulations! payment success');
console.log(details);
console.log(details.id); // order id
console.log(details.status); // 'COMPLETED'
// send ajax request to update the db
});
},
onCancel: function (data) {
alert('Payment cancelled');
},
onError: function (err) {
alert(err);
}
}).render('#paypal-button-10');
</script>
All such integrations were deprecated by PayPal, so there is no supported way to do so. Alternatives are:
There is no option to integrate regular "Pay Now" / "Buy Now" one-time PayPal payments without a backend. Any of the old ways you may find to do so (including actions.order.create / actions.order.capture with the JS SDK, or HTML-only redirects/buttons) are no longer supported.