简体   繁体   English

Paypal 自适应/链式支付工作流程

[英]Paypal Adaptive / Chained Payments Workflow

first of all, i'm kinda new to paypal adaptive payments, until now I only used the REST api.首先,我对贝宝自适应支付有点陌生,直到现在我只使用 REST api。

I have problems understanding the complete flow of the applications when implementing adaptive payments.在实施自适应支付时,我无法理解应用程序的完整流程。

In the REST api I navigate the user to the paypal page where he pays and get's redirected to my page where I can react on the result.在 REST api 中,我将用户导航到他付款的贝宝页面,然后重定向到我的页面,我可以在那里对结果做出反应。

Using the adaptive Payments the user does not get redirected directly after the payment.使用自适应付款,用户不会在付款后直接被重定向。 Therefore I cannot guarantee he will open the given redirect page.因此我不能保证他会打开给定的重定向页面。

It seems like ipn is the solution for this, however I'm not sure on how to implement this correctly.似乎 ipn 是解决方案,但是我不确定如何正确实施。

I used an example i found and logged the result which iresults in the following log entry.我使用了一个我找到的示例并将结果记录在以下日志条目中。 I have problmens to interpret the result.我有问题来解释结果。 It is generated using the ipn simulator.它是使用 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&notify_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&notify_version=2.1&custom=xyz123&invoice=abc1234&test_ipn=1&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AIR-7FrBuOZZqJMDr8d5DxEI9rpG

Yes, the answer you are looking for is IPN.是的,您正在寻找的答案是 IPN。 There are steps to implement the flow.有一些步骤可以实现流程。

First, in your sandbox settings - you should enable the Instant Payment Notification and provide url for it.首先,在您的沙箱设置中 - 您应该启用即时付款通知并为其提供 url。 Now, you can just enter a dummy link, cause you can overwrite it with the actual call for the payment.现在,您只需输入一个虚拟链接,因为您可以使用实际的付款呼叫覆盖它。 Have in mind, that you should provide a real url, because PayPal is unable to see your localhost.请记住,您应该提供一个真实的 url,因为 PayPal 无法看到您的本地主机。

Next, you should implement an IPN listener in your code.接下来,您应该在代码中实现一个 IPN 侦听器。 I think this should help you with it.我认为这应该对您有所帮助。 I did it in C#, so cannot provide you with the exact code.我是用 C# 做的,所以不能给你提供确切的代码。 It is important for you to include some information for the payment in the payment call to paypal, so you can receive it in the IPN and detect for which payment you are receiving a notification.在向 paypal 发出的付款调用中包含一些付款信息对您来说很重要,这样您就可以在 IPN 中接收它并检测您收到的付款通知。

Btw, you can specify ReturnURL and CancelURL in the payment call to paypal, so the user is automatically redirected to where you want, after he has completed his payment.顺便说一句,您可以在对 paypal 的付款调用中指定 ReturnURL 和 CancelURL,这样用户在完成付款后会自动重定向到您想要的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM