How to put the value of the shopping cart purchase into value in the below code

dave19621
New Community Member

I am using session variable for value.

 

<script>

paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount:
{
value: '0.01'
//cartTotal = cartTotal.toString();
//value: 'cartTotal'
}
}]
});
},
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('/paypal-transaction-complete', {
method: 'post',
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
orderID: data.orderID
})
});
});
}
}).render('#paypal-button-container');
</script>

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.