Paypal (NVP APIs) how to discount for the order? - paypal

For example, this is my request paramaters,the order total is 270.00, if I want to use a coupon($10.00) to discount this order, than the order total must be 260.00, but now, I can't find any about discount AMT parameter in this api (https://developer.paypal.com/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/), I neglect it?
Array(
[PAYMENTREQUEST_0_CURRENCYCODE] => USD
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[PAYMENTREQUEST_0_AMT] => 270.00
**[some parameter? DISCOUNT_AMT ?] => 10.00 // have this parameter ??**
[PAYMENTREQUEST_0_ITEMAMT] => 219.00
[PAYMENTREQUEST_0_SHIPPINGAMT] => 39.00
[PAYMENTREQUEST_0_HANDLINGAMT] => 12.00
[L_PAYMENTREQUEST_0_AMT0] => 219.00
[L_PAYMENTREQUEST_0_QTY0] => 1
[L_PAYMENTREQUEST_0_NAME0] => Goods title
[L_PAYMENTREQUEST_0_DESC0] => Goods description
);
Sorry about my poor English, thanks for buddies.

You will need to add the discount as an additional line item with a negative value and then adjust the ITEMAMT and AMT accordingly.
Array(
[PAYMENTREQUEST_0_CURRENCYCODE] => USD
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[PAYMENTREQUEST_0_AMT] => 260.00
[PAYMENTREQUEST_0_ITEMAMT] => 209.00
[PAYMENTREQUEST_0_SHIPPINGAMT] => 39.00
[PAYMENTREQUEST_0_HANDLINGAMT] => 12.00
[L_PAYMENTREQUEST_0_AMT0] => 219.00
[L_PAYMENTREQUEST_0_QTY0] => 1
[L_PAYMENTREQUEST_0_NAME0] => Goods title
[L_PAYMENTREQUEST_0_DESC0] => Goods description
[L_PAYMENTREQUEST_0_AMT1] => -10.00
[L_PAYMENTREQUEST_0_QTY1] => 1
[L_PAYMENTREQUEST_0_NAME1] => Discount
[L_PAYMENTREQUEST_0_DESC1] => Coupon Code ABC123
);

Related

See if PayPal payment came from eBay for PayPal IPN [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
How do you stop eBay PayPal payments going to the IPN listener? (preferred but probably not possible?)
Or - How do I get my listener to ask where the payment comes from?
If from eBay do nothing / just verify (or store in table in hope of extending my order management system in future, say)
If from myshop log order for invoice, sending, etc.
What IPN variable can I use? Check for length of item number, perhaps? umm
If it comes from eBay there will be a for_auction parameter included that is set to true. You will also ebay_txn_idn, where n is the number of the item(s) array. Also an auction_buyer_id will be included. Plenty of options to flag those.
Here is an example of an IPN that came from an eBay auction:
Array
(
[mc_gross] => 440.99
[protection_eligibility] => Eligible
[for_auction] => true
[address_status] => confirmed
[item_number1] => 232029148438
[tax] => 0.00
[payer_id] => 83W5CCCCCCCS6
[ebay_txn_id1] => 1370976126013
[address_street] => 123 Test Ave
[payment_date] => 23:52:09 Oct 20, 2016 PDT
[payment_status] => Completed
[charset] => windows-1252
[address_zip] => 59840-2149
[mc_shipping] => 21.00
[first_name] => David
[mc_fee] => 10.00
[auction_buyer_id] => comasdfr33
[address_country_code] => US
[address_name] => Tester Testerson
[notify_version] => 3.8
[custom] => EBAY_EMSCX0000687394734010
[payer_status] => unverified
[business] => sales#domain.com
[address_country] => United States
[num_cart_items] => 1
[address_city] => Hamilton
[verify_sign] => A0av94YibvcTZFf.ILwh4u8suh06AqfSvHzsAv3r.zSG91GuDFSbZ.Mw
[payer_email] => asdfg#gmx.com
[contact_phone] => 408-636-6400
[txn_id] => 9EX39945FA6779640
[payment_type] => instant
[last_name] => Testerson
[address_state] => MT
[item_name1] => Zebra GX420d USB/Serial/Ethernet Mono Direct Printer
[receiver_email] => sales#domain.com
[payment_fee] => 10.00
[quantity1] => 1
[receiver_id] => EMY7DGXTF8ZVE
[insurance_amount] => 0.00
[txn_type] => cart
[item_name] => Zebra GX420d USB/Serial/Ethernet Mono Direct Printer
[mc_gross_1] => 419.99
[mc_currency] => USD
[item_number] => 232029148438
[residence_country] => US
[receipt_id] => 0428-5320-1923-6500
[transaction_subject] =>
[payment_gross] => 440.99
[ipn_track_id] => 9429e4ed195db
)

Multiple recurring profiles in one go using the NVP method return invalid token error

I'm trying to create multiple recurring profiles in one go using the NVP method with PayPal API version 112.0 ... the first profile works fine, I then call it again and I get an invalid token error. The billing agreement is all same as for the other successful profile.
Though it is clearly said in documentation that multiple profiles can be created with single payment. I am using expressCheckout. Please help on this.
Here is my code:
/this create profile array works well/
Array
(
[METHOD] => CreateRecurringPaymentsProfile
[TOKEN] => EC-4AW0867838N0385684F
[INITAMT] => 180.00
[AMT] => 180.00
[CURRENCYCODE] => USD
[PROFILESTARTDATE] => 2014-10-03T13:35:04Z
[BILLINGPERIOD] => Month
[BILLINGFREQUENCY] => 3
[PAYMENTACTION] => Sale
[DESC] => 1× 3 Description
[PAYERID] => WLCZLZ2R4K7RJ
[PROFILEREFERENCE] => 29301-1396535617
[BUTTONSOURCE] => Ubercart_ShoppingCart_EC_US
[NOTIFYURL] => mysite.com/uc_paypal/ipn/77301
[ITEMAMT] => 180.00
[SHIPPINGAMT] => 0.00
[TAXAMT] => 0.00
)
in the next iteration it creates this array(which return Paypal error: Invalid Token)
Array
(
[METHOD] => CreateRecurringPaymentsProfile
[TOKEN] => EC-4AW0867838N0385684F
[INITAMT] => 180.00
[AMT] => 180.00
[CURRENCYCODE] => USD
[PROFILESTARTDATE] => 2015-10-03T13:35:04Z
[BILLINGPERIOD] => Month
[BILLINGFREQUENCY] => 13
[PAYMENTACTION] => Sale
[DESC] => 1× 3 Description
[PAYERID] => WLCZLZ2R4K7RJ
[PROFILEREFERENCE] => 29301-1396535618
[BUTTONSOURCE] => Ubercart_ShoppingCart_EC_US
[NOTIFYURL] => mysite.com/uc_paypal/ipn/77301
[ITEMAMT] => 180.00
[SHIPPINGAMT] => 0.00
[TAXAMT] => 0.00
)

PayPal Express Checkout Shipping Address should not be editable

I have already spent a lot of hours to find an answer for my problem but unfortunately i can't find a soloution.
I implement PayPal (Express Checkout) in our Shop-System. In our shop, the customer enters his shipping address. I don't want the customer to get the option to change his shipping address in PayPal. I only want the shipping address to be displayed which was entered before.
For example, here is an express checkout implementation like I want it:
Shipping Address only displayed:
How can i make this possible?
I use the PayPalSDK for ASP.NET
In your SetExpressCheckout request you can add the ADDROVERRIDE parameter and set its value to 1. Then make sure to include the shipping address parameters in your SEC request as well.
What this will do is simply display the address you pass over to PayPal without the ability for the user to change it.
The value 1 indiciates that the PayPal pages should display the
shipping address set by you in the SetExpressCheckout request, not the
shipping address on file with PayPal. This does not allow the
customer to edit the address here. Must be 1 or 0
Here's a sample of an SEC request I just sent to the PayPal sandbox:
[REQUESTDATA] => Array
(
[USER] => *****
[PWD] => *****
[VERSION] => 97.0
[BUTTONSOURCE] => AngellEYE_PHPClass
[SIGNATURE] => *****
[METHOD] => SetExpressCheckout
[MAXAMT] => 200.00
[RETURNURL] => http://paypal.angelleye.com/standard/samples/DoExpressCheckoutPayment.php
[CANCELURL] => http://paypal.angelleye.com/paypal/class/cancel.php
[REQCONFIRMSHIPPING] => 0
[NOSHIPPING] => 1
[ALLOWNOTE] => 1
[ADDROVERRIDE] => 1
[BRANDNAME] => Angell EYE
[CUSTOMERSERVICENUMBER] => 555-555-5555
[BUYEREMAILOPTIONENABLE] => 1
[SURVEYENABLE] => 1
[BUYERREGISTRATIONDATE] => 2012-07-14T00:00:00Z
[PAYMENTREQUEST_0_AMT] => 100.00
[PAYMENTREQUEST_0_CURRENCYCODE] => USD
[PAYMENTREQUEST_0_ITEMAMT] => 80.00
[PAYMENTREQUEST_0_SHIPPINGAMT] => 15.00
[PAYMENTREQUEST_0_TAXAMT] => 5.00
[PAYMENTREQUEST_0_DESC] => This is a test order.
[PAYMENTREQUEST_0_SHIPTONAME] => Tester Testerson
[PAYMENTREQUEST_0_SHIPTOSTREET] => 123 Test Ave.
[PAYMENTREQUEST_0_SHIPTOCITY] => Kansas City
[PAYMENTREQUEST_0_SHIPTOSTATE] => MO
[PAYMENTREQUEST_0_SHIPTOZIP] => 64111
[PAYMENTREQUEST_0_SHIPTOCOUNTRY] => US
[PAYMENTREQUEST_0_SHIPTOPHONENUM] => 816-555-5555
[PAYMENTREQUEST_0_NOTETEXT] => This is a test note before ever having left the web site.
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[L_PAYMENTREQUEST_0_NAME0] => Widget 123
[L_PAYMENTREQUEST_0_DESC0] => Widget 123
[L_PAYMENTREQUEST_0_AMT0] => 40.00
[L_PAYMENTREQUEST_0_NUMBER0] => 123
[L_PAYMENTREQUEST_0_QTY0] => 1
[L_PAYMENTREQUEST_0_ITEMURL0] => http://www.angelleye.com/products/123.php
[L_PAYMENTREQUEST_0_NAME1] => Widget 456
[L_PAYMENTREQUEST_0_DESC1] => Widget 456
[L_PAYMENTREQUEST_0_AMT1] => 40.00
[L_PAYMENTREQUEST_0_NUMBER1] => 456
[L_PAYMENTREQUEST_0_QTY1] => 1
[L_PAYMENTREQUEST_0_ITEMURL1] => http://www.angelleye.com/products/456.php
[L_PAYMENTREQUEST_0_ITEMCATEGORY1] => Digital
)
And here's what I see when I log in to PayPal as the buyer after this SEC call...

Can the PayPal Sandbox "charge" a transaction fee?

I am trying to test how my listener file treats PayPal transactions, but the Sandbox does not pass anything about the transaction fee. I am pretty sure that the live PayPal site does pass the transaction fee to a listener file.
Here is what is posted to the listener file:
mc_gross => 25.00
protection_eligibility => Ineligible
address_status => confirmed
item_number1 => C-1001
tax => 0.00
item_number2 => C-1002
payer_id => XXXXXXXXXXXXX
address_street => 1 Main St
payment_date => 15:10:14 May 27, 2013 PDT
payment_status => Pending
charset => windows-1252
address_zip => 95131
mc_shipping => 0.00
mc_handling => 0.00
first_name => Jon
address_country_code => US
address_name => Jon Doe
notify_version => 3.7
custom => *Member ID passed as custom variable*
payer_status => verified
address_country => United States
num_cart_items => 2
mc_handling1 => 0.00
mc_handling2 => 0.00
address_city => San Jose
verify_sign => XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-999999999999999999999999
payer_email => jon#mydomain.com
mc_shipping1 => 0.00
mc_shipping2 => 0.00
tax1 => 0.00
tax2 => 0.00
txn_id => XXXXXXXXXXXXXXXXX
payment_type => instant
last_name => Doe
address_state => CA
item_name1 => General Expenses
receiver_email => finance#ourdomain.org
item_name2 => Building Fund
quantity1 => 1
quantity2 => 1
pending_reason => unilateral
txn_type => cart
mc_gross_1 => 10.00
mc_currency => USD
mc_gross_2 => 15.00
residence_country => US
test_ipn => 1
transaction_subject => *Member ID passed as custom variable*
payment_gross => 25.00
ipn_track_id => 9999999999999
You should see variables for mc_fee and payment_fee. If you are not seeing thise variables, can you provide the transaciton id and I can take a look at it on my side. Also, you can find a list of the IPN/PDT variables listed here.

per-item details ci-merchant and PayPalExpress

I am using ci-merchant and I want to do my cart checkout with PayPal Express.
This is the code I am using:
$this->load->library('merchant');
$this->merchant->load('paypal_express');
$settings = $this->merchant->default_settings();
$settings = array(
'username' => 'bla bla bla.gmail.com',
'password' => 'bla bla bla',
'signature' => 'bla bla bla',
'test_mode' => true);
$this->merchant->initialize($settings);
$params =array(
'amount' => $this->cart->format_number($this->cart->total()),
'currency' => 'EUR',
'return_url' => 'https://www.example.com/checkout/payment_return/123',
'cancel_url' => 'https://www.example.com/checkout',
'description' => 'Esto es desc'
);
$response = $this->merchant->purchase($params);
With the above code I am being redirected to PayPal just fine, but at the items column I only see one unique item.
Now I would like to add per-item description, qty and price. But I don't know the where to include my items array, and wich format should I use. I can't find it on ci-merchant docs. Can anybody explain me?
You just need to setup your $params to include all of the fields you would need to make it work, and you need to make sure you're using version 63.0 or later.
It can be a little tricky, though, because any Express Checkout flow could include more than 1 payment, and each payment included could include more than 1 item, so you'll end up adding 0,1,2, etc. to params.
Here's a sample of SetExpressCheckout with 1 payment that has 2 items on it.
[REQUESTDATA] => Array
(
[USER] => ***
[PWD] => ***
[VERSION] => 97.0
[BUTTONSOURCE] => AngellEYE_PHPClass
[SIGNATURE] => ***
[METHOD] => SetExpressCheckout
[MAXAMT] => 200.00
[RETURNURL] => http://paypal.angelleye.com/standard/samples/DoExpressCheckoutPayment.php
[CANCELURL] => http://paypal.angelleye.com/paypal/class/cancel.php
[ALLOWNOTE] => 1
[HDRIMG] => http://paypal.angelleye.com/images/hdrimg.jpg
[SOLUTIONTYPE] => Sole
[LANDINGPAGE] => Billing
[BRANDNAME] => Angell EYE
[CUSTOMERSERVICENUMBER] => 555-555-5555
[BUYEREMAILOPTIONENABLE] => 1
[PAYMENTREQUEST_0_AMT] => 100.00
[PAYMENTREQUEST_0_CURRENCYCODE] => USD
[PAYMENTREQUEST_0_ITEMAMT] => 80.00
[PAYMENTREQUEST_0_SHIPPINGAMT] => 15.00
[PAYMENTREQUEST_0_TAXAMT] => 5.00
[PAYMENTREQUEST_0_DESC] => This is a test order.
[PAYMENTREQUEST_0_NOTETEXT] => This is a test note before ever having left the web site.
[PAYMENTREQUEST_0_PAYMENTACTION] => Sale
[L_PAYMENTREQUEST_0_NAME0] => Widget 123
[L_PAYMENTREQUEST_0_DESC0] => Widget 123
[L_PAYMENTREQUEST_0_AMT0] => 40.00
[L_PAYMENTREQUEST_0_NUMBER0] => 123
[L_PAYMENTREQUEST_0_QTY0] => 1
[L_PAYMENTREQUEST_0_ITEMURL0] => http://www.angelleye.com/products/123.php
[L_PAYMENTREQUEST_0_ITEMCATEGORY0] => Digital
[L_PAYMENTREQUEST_0_NAME1] => Widget 456
[L_PAYMENTREQUEST_0_DESC1] => Widget 456
[L_PAYMENTREQUEST_0_AMT1] => 40.00
[L_PAYMENTREQUEST_0_NUMBER1] => 456
[L_PAYMENTREQUEST_0_QTY1] => 1
[L_PAYMENTREQUEST_0_ITEMURL1] => http://www.angelleye.com/products/456.php
[L_PAYMENTREQUEST_0_ITEMCATEGORY1] => Digital
)
That results in the following when redirected to PayPal..
CI Merchant doesn't support listing order items in PayPal out of the box. There is a pull request which supports this, but it won't be merged into master until we work around some tax calculation and rounding issues.
Until it's supported officially, you may want to try using the forked version to achieve this, or simply edit the PayPal driver yourself to pass through the item data.