How to send and receive custom_id in javascript ?
whitedragon101
Contributor
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Oct-26-2020
07:26 AM
I am setting up a purchase that has a local order_id and I want to be able to link that id to the purchase. The support documents say you can send a custom_id. I am sending it using the code below but I am not sure if the format is correct or if it is getting sent.
The main issue is I don't know how to get the custom_id back from the return data. I am outputting the full contents of data and details to the console on return and neither contain the custom_id.
1) Is the code correct for sending the custom_id ?
2) How do I get the custom_id back from the returning order to make sure its the same transaction?
<script>
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '20'
},custom_id: '55',
}]
});
},
onApprove: function(data, actions) {
return actions.order.capture().then(function(details)
{
console.log("DETAILS");
console.log(details);
console.log("DATA");
console.log(data);
alert("Transaction completed by order id =" + data.orderID+ " our local id = " + custom_id????? );
payPalConfirm(data.orderID); // my ajax call to confirm the transaction via php
// Call your server to save the transaction
return fetch('/paypal-transaction-complete', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
orderID: data.orderID
})
});
});
}
}).render('#paypal-button-container');
</script>
0 REPLIES 0

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- Paypal dont send webhook PAYMENT.CAPTURE.COMPLETED in Sandbox Environment
- .. does not ship to this location. Please use a different address. in PayPal Payments Standard
- PAYER_ACTION_REQUIRED when creating order using REST API in REST APIs
- PAY ANOTHER ACCOUNT in PayPal Payments Standard
- javascript buttons payment and webhooks in REST APIs