Despite trying to convert the return value into a number, I still encountered issues. The total amount works fine when manually entering a value like "1.50", but fails when using a variable.
Below is the function I utilize to calculate and return the final price:
getTotal() {
let total = 0;
for (var i = 0; i < this.list.length; i++) {
if (this.list[i].price) {
total += this.list[i].price;
}
}
return Number(total.toFixed(2));
}
Here's where I encounter an issue while setting the price for paypal payment:
payment: (data, actions) => {
return actions.payment.create({
payment: {
transactions: [{
amount: {
total: this.getTotal,
currency: 'AUD'
}
}]
}
});
}
When I assign this.getTotal
to something specific like "1.50" it works without any problem. However, in its current state, I keep receiving the following error message...
"Currency amount must be non-negative number, may optionally contain exactly 2 decimal places separated by '.'..."