首先,我对paypal自适应支付有点新意,到目前为止我只使用了REST api。
在实施自适应付款时,我无法理解应用程序的完整流程。
在REST api中,我将用户导航到paypal页面,然后付费并重定向到我的页面,我可以对结果作出反应。
使用自适应付款,用户在付款后不会直接重定向。因此,我无法保证他会打开指定的重定向页面。
似乎ipn就是解决方案,但是我不确定如何正确实现这一点。
我使用了一个我找到的示例并将结果记录在以下日志条目中。我有解释结果的问题。它是使用ipn模拟器生成的。
[2016-05-02 20:17 UTC] HTTP request of validation request:POST /cgi-bin/webscr HTTP/1.1
Host: www.sandbox.paypal.com
Accept: */*
Connection: Close
Content-Length: 943
Content-Type: application/x-www-form-urlencoded
for IPN payload: cmd=_notify-validate&payment_type=instant&payment_date=Mon+May+02+2016+22%3A17%3A33+GMT%2B0200+%28Mitteleurop%C3%A4ische+Sommerzeit%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer%40paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John+Smith&address_country=United+States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San+Jose&address_street=123+any+street&business=seller%40paypalsandbox.com&receiver_email=seller%40paypalsandbox.com&receiver_id=seller%40paypalsandbox.com&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=250343399¬ify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AIR-7FrBuOZZqJMDr8d5DxEI9rpG
[2016-05-02 20:17 UTC] HTTP response of validation request: HTTP/1.1 200 OK
Date: Mon, 02 May 2016 20:17:42 GMT
Server: Apache
X-Frame-Options: SAMEORIGIN
Set-Cookie: c9MWDuvPtT9GIMyPc3jwol1VSlO=vKsQ6Wsa8-CKaGYKLQkEziH8epLey-sigvcn6CGIx_BbN7f2lkSe4OGhXkrOoD98VscO4s-IeGzIJCQSjGbkN5Zy8ggokZMUzKgmU3DXPZQ12IS1gqWwws-ZbEZwuGYp75eS0cS94sdZ7NduMDdd-wj9neb47z6x3sZOBs76MeZAu3aVS0hQFhfLWtTs5kGfVtFWpDMlA-h6xzEk1jTOteInNMwwvIKfcctwTP0lq7HdBsSpBOxgGkj5aGqanty9RiMlioT_7_3I93WK2S1pTJuN5HIIuS4Ci3HuXUkgin6ian6oEhLnCPodUjWa_VIVmAUkxmVcrb1AOxLDa0lBYfV5b7vnHTHWkxtct-r7YQKX6un7_RyfeOrlSODOK-1FPcaQl6R5W7bQEuvm98K4kECj_EkvIFeUcjZWQ7wUx5Lc-Sja3yZDfFrWSvS; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: cookie_check=yes; expires=Thu, 30-Apr-2026 20:17:42 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: navlns=0.0; expires=Wed, 02-May-2018 20:17:42 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: Apache=10.72.108.11.1462220262202022; path=/; expires=Wed, 25-Apr-46 20:17:42 GMT
Vary: Accept-Encoding,User-Agent
Connection: close
HTTP_X_PP_AZ_LOCATOR: sandbox.slc
Paypal-Debug-Id: ed99d0b22cb7d
Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.WEB.1%26silo_version%3D1880%26app%3Dappdispatcher%26TIME%3D3870631767%26HTTP_X_PP_AZ_LOCATOR%3Dsandbox.slc; Expires=Mon, 02 May 2016 20:47:42 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
Strict-Transport-Security: max-age=14400
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
INVALID
[2016-05-02 20:17 UTC] Invalid IPN: cmd=_notify-validate&payment_type=instant&payment_date=Mon+May+02+2016+22%3A17%3A33+GMT%2B0200+%28Mitteleurop%C3%A4ische+Sommerzeit%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer%40paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John+Smith&address_country=United+States&address_country_code=US&address_zip=95131&address_state=CA&address_city=San+Jose&address_street=123+any+street&business=seller%40paypalsandbox.com&receiver_email=seller%40paypalsandbox.com&receiver_id=seller%40paypalsandbox.com&residence_country=US&item_name1=something&item_number1=AK-1234&tax=2.02&mc_currency=USD&mc_fee=0.44&mc_gross=12.34&mc_gross_1=12.34&mc_handling=2.06&mc_handling1=1.67&mc_shipping=3.02&mc_shipping1=1.02&txn_type=cart&txn_id=250343399¬ify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AIR-7FrBuOZZqJMDr8d5DxEI9rpG
答案 0 :(得分:1)
是的,您正在寻找的答案是IPN。有实现流程的步骤。
首先,在您的沙箱设置中 - 您应该启用即时付款通知并为其提供网址。现在,您可以输入一个虚拟链接,因为您可以使用实际的付款请求覆盖它。请记住,您应该提供一个真实的网址,因为PayPal无法看到您的本地主机。
接下来,您应该在代码中实现IPN侦听器。我认为这应该可以帮助你。我在C#中做到了,所以无法为您提供确切的代码。在PayPal付款电话中包含一些付款信息非常重要,因此您可以在IPN中接收该信息,并检测您收到通知的付款。
顺便说一下,您可以在PayPal付款电话中指定ReturnURL和CancelURL,这样用户就可以在完成付款后自动重定向到您想要的位置。