Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paypal Express - Add Discount

I'm currently posting a regular transaction to Paypal Express and am reaching the gateway without error.

I would like to now configure my cart to send a discount to the gateway. My first thought was to modify the 'AMT' value that is sent to the gateway. However, it seems that Paypal validates the 'AMT' field by calculating the total of the ITEMAMT, TAXAMT and SHIPPINGAMT fields to ensure the total is unchanged:

[L_AMT0] => 49.99
[L_NUMBER0] => 3706{3}8
[L_QTY0] => 1
[L_TAXAMT0] => 0.00
[ITEMAMT] => 49.99
[TAXAMT] => 0
[SHIPPINGAMT] => 14.95
[AMT] => 64.94

How many I send a discount to Paypal? I have looked through what documentation I can find, with no luck; the similar questions here on SO were no help, either. Thanks.

Edit: I've noticed I can pass through the field SHIPDISCAMT. I don't know if this will let me do what I need it to though - I am still getting errors that indicate soemthing is 'mismatched'.

like image 502
pb149 Avatar asked Mar 14 '12 20:03

pb149


1 Answers

Got it.

It turns out that you can pass a negative amount through as a line item and label it as a discount yourself. I had to add the above code:

$params['L_NAME1'] = 'Discount Coupon';
$params['L_AMT1'] = -$discountCodeAmount;
$params['L_QTY1'] = 1;
$params['ITEMAMT'] -= $discountCodeAmount;
$params['AMT'] -= $discountCodeAmount;

This had the following effect:

enter image description here

I found my answer in this PDF:

https://cms.paypal.com/cms_content/CA/en_US/files/developer/PP_ExpressCheckout_IntegrationGuide.pdf

For some reason, that information was not given in several other official PayPal express articles/documents I had read.

like image 61
pb149 Avatar answered Sep 28 '22 07:09

pb149