Have an ecommerce site running ZNode. We send tax, shipping, order total, etc. Everything works fine until an order level discount is applied (say 50%). We get a response from PayPal that says the following:
The totals of the cart item amounts do not match order amounts.
I'm traversing the API, and I can't find anything to apply an order level discount. FWIW, the user is applying discount codes on our site, and then is being transferred to PayPal.
Another option for sending a discount via the PayPal API use the PAYMENTREQUEST_n_SHIPDISCAMT
Which is actually a shipping discount, but works just fine, and is a one line.
But it does say shipping discount at the PalPal end.
I think your problem is not the PayPal API. You checked that everything works perfect with your parameters passed to paypal in this 50% discount case?
After the PayPal Documentation you should provide a negative value to reflect a discount on an order. So everything adds up to the total amount.
Source: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECCustomizing
Update with code: (by Nick)
I have a paypal service that does all kinds of stuff, but the following code should give you an idea of how the discount works. The discount is not a special type, it's a product just like any other except it's disguised by naming it like a discount and setting it's price to a negative number.
List<PaymentDetailsItemType> items = paymentDetails.PaymentDetailsItem;
foreach (ShoppingCartItem item in cart.ShoppingCartItems)
{
items.Add(new PaymentDetailsItemType
{
Name = item.Book.Title,
Quantity = item.Quantity,
Number = item.BookId.ToString(),
Amount =
new BasicAmountType
{currencyID = CurrencyCodeType.USD,
value = (item.Book.Price).To2Places()}
});
}
if (cartTotals.Discount > 0)
{
items.Add(new PaymentDetailsItemType
{
Name = "Promo Code Discount",
Quantity = 1,
Number = "PromoCode",
Amount =
new BasicAmountType
{
currencyID = CurrencyCodeType.USD,
value = (cartTotals.Discount*-1).To2Places()
}
});
}
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