PayPal SDK JavaScript Client: Set Amount - 23 #Django
The next step is to configure the price of our product, that is, to set the price of the item in this case it would be:
***
<script>
paypal.Buttons(
{
createOrder: function(data, actions){
return actions.order.create({
purchase_units:[
{
amount: {
value: '{{element.price}}'
// value: '0.01'
}
}
]
})
},
onApprove: function(data, actions){
console.log(data);
}
}
).render('#buttonPayPal');
</script>
You can put other options such as payer, item, among others.
Here it is also important that you get into context, remember that I had told you that there are two steps:
- On the one hand, the client's part is simply a kind of authorization, it is a kind of promise in which the client wants to buy that product
- In the server, in the integration that we will see later, the purchase is not approved or the purchase is not finalized, that is, the amount of the product that the client is buying is not charged from their PayPal. Here, it is simply a kind of promise, so to speak, in which there is an intention that we will then authorize.