Paypal Express Checkout: Apply for a discount

The e-commerce site runs ZNode. We ship tax, shipping, total order amount, etc. Everything works fine until a discount at the order level (say, 50%) is applied. We get a response from PayPal that says the following:

The sums of the elements of the basket do not match the sum of orders.

I am browsing the API and I cannot find anything to apply an order level discount. FWIW, the user applies the discount codes on our website, and then is transferred to PayPal.

+7
source share
2 answers

I think your problem is not in the PayPal API. Have you checked that everything works fine with your parameters transferred to paypal in this case with a 50% discount?

After the PayPal documentation, you must specify a negative value to reflect the discount on the order. Thus, everything is summed up to the total amount.

Source: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECCustomizing

enter image description here

Code Update: (Nick)

I have a PayPal service that does all kinds of things, but the following code should give you an idea of ​​how the discount works. The discount is not a special type, it is a product, like any other, except that it is disguised, calling it a discount and setting the price for 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() } }); } 
+18
source

Another option to send discounts via PayPal API uses PAYMENTREQUEST_n_SHIPDISCAMT

Actually this is a discount on delivery, but it works fine, and this is one line.

But this suggests a discount on delivery at the end of PalPal.

+1
source

All Articles