IPN and PDT Work when payment mode is fast Pay (button), and when you create a payment in the rest API, PDT is invalid, it should be for the website, and IPN still works. The steps to invoke the rest Api payment are:
1. Register paypal account, upgrade to advanced or enterprise account;
2. Login to the Developer Center backstage, register the app;
3. Get the client ID, Secret;
4. Set the IPN notification address (profile inside settings);
5. Get PayPal SDK, in sandbox environment test, pay the return URL is set in the calling code;
Post/v1/payments/payment
Post/v1/payments/payment/<payment-id>/execute
This is mostly the two APIs
6. The replacement code sandbox is the official URL, on-line.
Issues to be aware of:
1. If the seller refunds, the funds will be settled immediately, and PayPal paid a certain fee, the program will receive IPN notice;
2. If the buyer disputes, the type of dispute is an unauthorized transaction, the funds will be frozen immediately, the procedure will receive the IPN notice;
3. If the buyer disputes, the type of dispute is not an unauthorized transaction, the funds will be frozen immediately, the procedure will not receive IPN notice;
4. The unique transaction number of the buyer and seller is completely inconsistent;
5. The invoice number (bill number) of buyer and seller is consistent;
6. Payment of the returned URL of the program, the data received is not credible, you can put all the local logic in the process of processing IPN. IPN messages are not real-time, almost second-level delays.
When the user pays is completed, the returned URL receives the following request data:
' Success ' = ' true ',
' Paymentid ' = ' pay-1bv5911839643144ykscua7q ',
' token ' = ' ec-8684120785130974d ',
' Payerid ' = ' jaryjk2tes6c6 ',
Call the execute interface to return:
{"id": "pay-1bv5911839643144ykscua7q", "Create_time": "2014-12-08t06:09:02z", "Update_time": "2014-12-08t06:10:5 1Z "," state ":" Approved "," intent ":" Sale "," payer ": {" Payment_method ":" PayPal "," Payer_info ": { "Email": "[email protected]", "first_name": "Test", "last_name": "Buyer", "payer_id": "Jaryjk2tes6c6", "shipping_address": {"line1": "NO 1 Nan Jin Road", "City": "Shanghai", "state": "Shanghai", "Postal_Code": "200000", "Country_c Ode ":" CN "," Recipient_name ":" Buyer Test "}}," Transactions ": [{ "Amount": {"Total": "20.00", "Currency": "USD", "details": { "Subtotal": "17.50", "tax": "1.30", "Shipping": "1.20"} }, "DEscription ":" Payment description "," Item_list ": {" items ": [{ "Name": "Ground Coffee oz", "Price": "7.50", "Currency": "USD", "Quantity": "1"}, {"name": "Granola Bars "," Price ":" 2.00 "," Currency ":" USD "," Quantity ":" 5 "}]," shipping_address ": {" Recipient_name ":" B Uyer Test "," line1 ":" NO 1 Nan Jin Road "," City ":" Shanghai "," St Ate ":" Shanghai "," Postal_Code ":" 200000 "," Country_code ":" CN "} }, "Related_resources": [{"Sale": {"id": "7 4v52932ab811673c ", "Create_time": "2014-12-08t06:09:02z", "Update_time": "2014-12-08t06:10:51z", "Amount": {"Total": "20.00", "Currency": "USD" }, "Payment_mode": "Instant_transfer", "state": "Comp Leted "," protection_eligibility ":" Eligible "," Protection_eligibility_type ": "Item_not_received_eligible,unauthorized_payment_eligible", "parent_payment": "pay-1bv591183964314 4ykscua7q "," links ": [{" href ":" https:/ /api.sandbox.paypal.com/v1/payments/sale/74v52932ab811673c "," rel ":" Self ", "Method": "GET"}, { "href": "Https://api.sanDbox.paypal.com/v1/payments/sale/74v52932ab811673c/refund "," rel ":" Refund ", "Method": "POST"}, { "href": "Https://api.sandbox.paypal.com/v1/payments/payment/PAY-1BV5911839643144YKSCUA7Q", "rel": "Parent_payment", "Method": "GET"} ]}]}], "links": [{"href": "https:/ /api.sandbox.paypal.com/v1/payments/payment/pay-1bv5911839643144ykscua7q "," rel ":" Self "," method ": "GET"}]}
At the same time the server receives the IPN message, similar to:
Array (' act ' = ' IPN ', ' mc_gross ' = ' 20.00 ', ' Invoice ' = ' 548531d624f59 ', ' protection_eligibility ' = ' Eligible ', ' address_status ' = ' unconfirmed ', ' item_number1 ' = ', ' tax ' = ' 1.30 ', ' item_number2 ' and ', ' ' payer_id ' = ' jaryjk2tes6c6 ', ' address_street ' = ' NO 1 Nan Jin Road ', ' payment_date ' = ' 21:04:35 Dec 07, 2 014 PST ', ' payment_status ' = ' completed ', ' charset ' = ' gb2312 ', ' address_zip ' = ' 200000 ', ' mc_shipping ' =& Gt ' 1.20 ', ' mc_handling ' = ' 0.00 ', ' first_name ' = ' Test ', ' mc_fee ' = ' 0.98 ', ' address_country_code ' = ' CN ' ', ' address_name ' = ' Buyer Test ', ' notify_version ' and ' 3.8 ', ' custom ' = ', ' payer_status ' = ' unverifie ' d ', ' address_country ' = ' China ', ' num_cart_items ' = ' 2 ', ' mc_handling1 ' = ' 0.00 ', ' mc_handling2 ' and ' 0. xx ', ' address_city ' = ' Shanghai ', ' verify_sign ' = ' Aomrs5l2w2xlt2an.gasrazpcl-nacivh3pz0htrsbzzfcieqdpgrxsk ' , ' payer_email ' = '[email protected] ', ' mc_shipping1 ' = ' 0.00 ', ' mc_shipping2 ' = ' 0.00 ', ' tax1 ' = ' 0.00 ', ' tax2 ' and ' = ' 0.00 ', ' txn_id ' = ' 5cs19517sj894934r ', ' payment_type ' = ' instant ', ' last_name ' = ' Buyer ', ' address_state ' = ' Shanghai ', ' item_name1 ' = ' Ground Coffee oz ', ' receiver_email ' = ' [email protected] ', ' item_name 2 ' = ' granola bars ', ' payment_fee ' and ' 0.98 ', ' quantity1 ' = ' 1 ', ' quantity2 ' = ' 5 ', ' receiver_id ' = ' 937cp9psmds2a ', ' txn_type ' = ' cart ', ' mc_gross_1 ' = ' 7.50 ', ' mc_currency ' + ' USD ', ' mc_gross_2 ' + ' 1 0.00 ', ' residence_country ' = ' CN ', ' test_ipn ' = ' 1 ', ' transaction_subject ' = ' ', ' payment_gross ' and ' 20 . xx ', ' ipn_track_id ' = ' a9059421a1dd7 ', 2014-12-08 13:04:35
Seller refunds received by IPN:
Array (' act ' = ' IPN ', ' mc_gross ' = ' -55.90 ', ' protection_eligibility ' = ' eligible ', ' payer_id ' + ' JAR Yjk2tes6c6 ', ' address_street ' = ' NO 1 Nan Jin Road ', ' payment_date ' = ' 18:17:29 Dec, ' PST ', ' Payment_sta Tus ' + ' refunded ', ' charset ' = ' gb2312 ', ' address_zip ' = ' 200000 ', ' first_name ' = ' Test ', ' Mc_fee ' =&G T ' -1.90 ', ' address_country_code ' = ' CN ', ' address_name ' = ' Buyer Test ', ' notify_version ' = ' 3.8 ', ' Reason_c Ode ' + ' refund ', ' custom ' and ' = ', ' business ' = ' [email protected] ', ' address_country ' = ' China ', ' a Ddress_city ' = ' Shanghai ', ' verify_sign ' = ' aikknbojiyuxwlohulztd3lpqcsxa1j2g80g.gf68ustx7dykhwvox4g ', ' Payer_email ' + ' [email protected] ', ' parent_txn_id ' = ' 78v79646kb938951y ', ' txn_id ' and ' = ' 03c86087bs569332h ', ' payment_type ' = ' instant ', ' btn_id ' = ' 3042078 ', ' last_name ' = ' Buyer ', ' Address_stat ' E ' = ' Shanghai ', ' receiver_email ' =' [email protected] ', ' payment_fee ' = ' -1.90 ', ' shipping_discount ' = ' 0.00 ', ' receiver_id ' and ' 2xp27kemu ' vn8a ', ' insurance_amount ' = ' 0.00 ', ' item_name ' = ' sandbox_item111 ', ' discount ' = ' 0.00 ', ' mc_currency ' =& Gt ' USD ', ' item_number ' = ', ' residence_country ' = ' CN ', ' test_ipn ' = ' 1 ', ' handling_amount ' = ' 0.00 ', ' Shipping_method ' = ' Default ', ' transaction_subject ' + ', ' payment_gross ' = ' -55.90 ', ' shipping ' and ' 10 . xx ', ' ipn_track_id ' = ' 2d16876d72c70 ', 2014-12-08 10:17:27
The IPN received when the funds were frozen:
Array ( ' act ' = ' IPN ', ' mc_gross ' = ' -19.02 ', ' invoice ' = ' 548541570184f ', ' protectio N_eligibility ' + ' eligible ', ' item_number1 ' + ', ' item_number2 ' + ' ', ' payer_id ' + ' JA Ryjk2tes6c6 ', ' address_street ' + ' NO 1 Nan Jin Road ', ' payment_date ' = ' 22:23:36 Dec, PST ', &NB Sp ' Payment_status ' = ' reversed ', ' charset ' + ' gb2312 ', ' address_zip ' + ' 200000 ', ', MC_ Shipping ' = ' = ' 1.20 ', ' mc_handling ' + ' 0.00 ', ' first_name ' = ' Test ', ' mc_fee ' = '-0.98 ', & nbsp ' Address_country_code ' + ' CN ', ' address_name ' = ' Buyer Test ', ' notify_version ' + ' 3.8 ', ' Reason_code ' + ' unauthorized_claim ', ' custom ' = ', ' address_country ' = ' China ', ' mc_ Handling1 ' + ' 0.00 ', ' mc_handling2 ' + ' 0.00 ', ' address_city ' + ' Shanghai ', ' ' verify_sign ' = > ' A.7n6acd75cb8fdbezyrgf.bovplari2BZUXGNUFBCI-QVGCHJE4LGLP ', ' payer_email ' = ' [email protected] ', ' mc_shipping1 ' = ' 0.00 ', ' mc_shipping2 ' = ' 0.00 ', ' tax1 ' + ' 0.00 ', ' tax2 ' + ' 0.00 ', ', ' parent_txn_id ' and ' 74V ' 52932ab811673c ', ' memo ' = ' 14.13 ', ' txn_id ' + ' 2y80904055783821a ', ' payment_type ' = ' Instant ', ' last_name ' + ' Buyer ', ' address_state ' + ' Shanghai ', ', item_name1 ' = ' Ground Coffee oz ', ' receiver_email ' + ' [email protected] ', ' item_name2 ' + ' granola bars ', ' Payment_fee ' + ' -0.98 ', ' quantity1 ' + ' 1 ', ' quantity2 ' = ' 5 ', ' receiver_id ' = ' 937cp9ps ' mds2a ', ' mc_gross_1 ' + ' 7.50 ', ' mc_currency ' + ' USD ', ' mc_gross_2 ' = ' 10.00 ', ', ' Residence_country ' + ' CN ', ' TEST_IPN ' + ' 1 ', ' transaction_subject ' = = ', ' payment_gross ' = > ' -19.02 ', ' ipn_track_id ' = ' 5df4cee26f6d3 ',) 2014-12-08 14:23:33
PayPal IPN and PDT 2