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.
- Sandbox testing has beaten me !! in Sandbox Environment
- Customising Paypal Checkout Button in PayPal Payments Standard
- We're not currently set up for transactions in India. in PayPal Payments Standard
- How do I update shipping in the popup when using onShippingAddressChange() in REST APIs
- PayPal Buttons not visible in Sandbox Environment