write accessories to a product in the paypal.Buttons function in js in the "item_list":{ "items":...

Vinz1111
Contributor
Contributor

Hello, everyone,

As described, I would like to sell accessories that belong to a main article together with the main article. I add up the prices of the various accessories in js and send them to Paypal. That works too.
Under "item_list":{ "items":...I would then like to transfer the accessories to PayPal. Unfortunately I do not get back the information sent to PayPal. So I don't know how to access it or where to view it. Unfortunately, I can't find it in the Bussness portal. I can't find it under "orderData, JSON.stringify(orderData, null, 2)" either.

 

Ín short: I would like to get the information in red back from Paypal to see what was ordered.

 

Spoiler
paypal.Buttons({
// Sets up the transaction when a payment button is clicked
createOrder: (data, actions) => {
return actions.order.create({
"style": {
"layout": "vertical",
"color": "white",
"shape": "rect",
"label": "buynow",
},
"purchase_units": [{
"amount": {
"currency_code": "EUR",
"value": euroweg(document.getElementById('summe_mittel_id').innerHTML),
"breakdown": {
"item_total": { /* Required when including the `items` array */
"currency_code": "EUR",
"value": euroweg(document.getElementById('summe_mittel_id').innerHTML)
}
}
},
"item_list":{
"items": [
{
"name": "Der Stamm - Mittel", /* Shows within upper-right dropdown during payment approval */
"description": "Optional descriptive text..", /* Item details will also be in the completed paypal.com transaction view */
"unit_amount": {
"currency_code": "EUR",
"value": "100",
},
"quantity": "100"

},
{
"name": "Das Deko Packet", /* Shows within upper-right dropdown during payment approval */
"description": "Optional descriptive text..", /* Item details will also be in the completed paypal.com transaction view */
"unit_amount": {
"currency_code": "EUR",
"value": "100",
},
"quantity": "100"
},
],
}
}]
});
},



// Finalize the transaction after payer approval
onApprove: (data, actions) => {
return actions.order.capture().then(function(orderData) {
// Successful capture! For dev/demo purposes:
console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));

const transaction = orderData.purchase_units[0].payments.captures[0];
window.location.href='success.html';

alert(`Transaction ${transaction.status}: ${transaction.id}\n\nSee console for all available details`);
// When ready to go live, remove the alert and show a success message within this page. For example:
// const element = document.getElementById('paypal-button-container');
// element.innerHTML = '<h3>Thank you for your payment!</h3>';
// Or go to another URL: actions.redirect('thank_you.html');
});
},
oncancel:function(data){
window.location.href="oncancel.html";
}
}).render('#paypal-button-container');

Thank you for the help, I'm desperate.

 

Regards
Vinzent

Login to Me Too
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.