Files
2024_WEBSITE_fipf/plugins/fipfcard_plugin/js/paypal/paypal.js
asus 7cfa2e6351 - added capacity in plugin tool to take urls
- test front end integration ok
2024-02-23 10:52:02 +01:00

65 lines
1.6 KiB
JavaScript

/*
paypal.Buttons({
style: {
layout: 'vertical',
color: 'blue',
shape: 'rect',
label: 'paypal',
},
// Order is created on the server and the order id is returned
createOrder() {
return fetch("/my-server/create-paypal-order", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
// Use the "body" param to optionally pass additional order information
// such as product SKUs and quantities
body: JSON.stringify({
cart: [
{
sku: "YOUR_PRODUCT_STOCK_KEEPING_UNIT",
quantity: "YOUR_PRODUCT_QUANTITY",
},
],
}),
})
.then((response) => response.json())
.then((order) => order.id);
}
}).render('#paypal-button-container');
*/
paypal.Buttons({
style: {
layout: 'vertical',
color: 'blue',
shape: 'rect',
label: 'paypal',
},
createOrder: function(data, actions) {
// This function sets up the details of the transaction, including the amount and line item details.
const my_order = actions.order.create({
purchase_units: [{
amount: {
value: '0.01'
}
}]
});
console.log("my_order: ", my_order);
return my_order;
},
onApprove: function(data, actions) {
// This function captures the funds from the transaction.
console.log("data: ", data);
console.log("actions: ", actions);
return actions.order.capture().then(function(details) {
console.log("details: ", details);
// This function shows a transaction success message to your buyer.
alert('Transaction completed by ' + details.payer.name.given_name);
});
}
}).render('#paypal-button-container');
//This function displays Smart Payment Buttons on your web page.