I am using ionic 2
i am having issue sending multiple items to PayPalPayment i have tried this below code it's working fine without items,
let payment = new PayPalPayment('3.33', 'USD', 'Description', 'sale');
PayPal.renderSinglePaymentUI(payment).then(() => {
//response ...
});
but it's not working well if i put items in it
let payment = new PayPalPayment('3.33', 'USD', 'Description', 'sale');
let items: PayPalItem[];
/**
cart = [
{
name: 'pen',
qty: 12,
price: '2.00'},
{
name: 'pencil',
qty: 2,
price: '1.00'
},
{
name: 'box',
qty: 1,
price: '20.00'
}
];
*/
cart.forEach(x => {
items.push(new PayPalItem(x.name, x.qty, x.price, "USD"));
});
payment.items = items;
PayPal.renderSinglePaymentUI(payment).then(() => {
//response ...
});
There is a problem in you code.
let payment = new PayPalPayment('3.33', 'USD', 'Description', 'sale');
Here in this code the total price i.e. '3.33'
must be equal to the price of the cart array, i.e. in the cart array the sum of (qty*price)
of all products must be equal to the price in the following part
let payment = new PayPalPayment('3.33', 'USD', 'Description', 'sale');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With