Api rest change total

jmendoza91
New Community Member

Hi i create a button with a dinamic total amount but the problem is when i want change the total if the total on mi car change, do you know how can i change this?

paypal.Button.render({

env: 'production', // sandbox | production

// PayPal Client IDs - replace with your own
// Create a PayPal app: https://developer.paypal.com/developer/applications/create
client: {
sandbox: '*********************-*******',
production: '*********************-*******'
},

// Show the buyer a 'Pay Now' button in the checkout flow
commit: true,

// payment() is called when the button is clicked
payment: function(data, actions) {

// Make a call to the REST api to create the payment
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: data, currency: 'USD' }
}
]
}
});
},

// onAuthorize() is called when the buyer approves the payment
onAuthorize: function(data, actions) {

// Make a call to the REST api to execute the payment
return actions.payment.execute().then(function() {
window.alert('Payment Complete!');
});
}

}, '#buy_paypal');

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.