Setting up the PHP code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi!
Im developing a site where users can make a simple purchase of an item. I would like to get a conformation of the order sent to my server, so i can log it.
The front-end buttons code is:
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [
{
amount: {
currency_code : 'EUR',[Removed. Phone #s not permitted]p; }
}
]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by ' + details.payer.name.given_name);
// Call your server to save the transaction
return fetch('pp_trans_comp.php', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
orderID: data.orderID
})
})
});
},
onCancel: function (data) {
// Show a cancel page, or return to cart
console.log("Cancelled");
}
}).render('#paypal-button-container1');
I already installed the SDK with the composer, but don't know how to proceed. I've been trying the examples from the documentation but it never seems to work. Any help will be appreciated.
- Labels:
-
REST SDK
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- Button in PayPal Payments Standard
- System error for my Paypal button after years of correct working in PayPal Payments Standard
- Change the button from Sandbox to Production in REST APIs
- Subscription notifications in PayPal Reporting
- Thank you page after payment with paypal buttons in PayPal Payments Standard