缺少 PAYPAL IPN 自定义字段
Posted
技术标签:
【中文标题】缺少 PAYPAL IPN 自定义字段【英文标题】:PAYPAL IPN custom field missing 【发布时间】:2013-01-20 01:52:25 【问题描述】:我在使用 API 流程和沙盒实现 paypal 定期付款时遇到了麻烦。 我成功创建了订阅按钮并将用户重定向到贝宝快速结帐页面。 但是paypal生成的一些IPN中缺少自定义字段,我真的需要这个字段。
这是我在生成订阅按钮时发送的请求:
METHOD=SetExpressCheckout
&VERSION=94.0
&PWD=123456
&USER=myEmail@biz.com
&SIGNATURE=mySignature
&PAYMENTREQUEST_0_AMT=5.00
&PAYMENTREQUEST_0_PAYMENTACTION=Sale
&PAYMENTREQUEST_0_CURRENCYCODE=EUR
&RETURNURL=http%3A%2F%2Fwww.myWebSite.com?ok
&CANCELURL=http%3A%2F%2Fwww.myWebSite.com?ko
&L_BILLINGTYPE0=RecurringPayments
&L_BILLINGAGREEMENTDESCRIPTION0=test+paypal
&REQCONFIRMSHIPPING=0
&NOSHIPPING=1
&L_PAYMENTREQUEST_0_ITEMCATEGORY0=Digital
&L_PAYMENTREQUEST_0_NAME0=test+paypal
&L_PAYMENTREQUEST_0_AMT0=5.00
&L_PAYMENTREQUEST_0_QTY0=1
&PAYMENTREQUEST_0_CUSTOM=custom_var1%3Dvalue1%7Ccustom_var2%3Dvalue2
用户确认交易后,他会回到我的网站,我必须验证信息并创建循环配置文件。 以下是我提出的要求:
METHOD=GetExpressCheckoutDetails
&VERSION=94.0
&PWD=123456
&USER=myEmail@biz.com
&SIGNATURE=mySignature
&TOKEN=theToken
METHOD=CreateRecurringPaymentsProfile
&VERSION=94.0
&PWD=123456
&USER=myEmail@biz.com
&SIGNATURE=mySignature
&TOKEN=theToken
&AMT=5.00
&CURRENCYCODE=EUR
&PROFILESTARTDATE=2013-02-04T15%3A16%3A24%2B01%3A00
&BILLINGPERIOD=Day
&BILLINGFREQUENCY=1
&DESC=test+paypal
METHOD=DoExpressCheckoutPayment
&VERSION=94.0
&PWD=123456
&USER=myEmail@biz.com
&SIGNATURE=mySignature
&TOKEN=theToken
&PAYERID=JZUVX4TAHRHRU
&PAYMENTREQUEST_0_PAYMENTACTION=Sale
&PAYMENTREQUEST_0_AMT=5.00
&PAYMENTREQUEST_0_CURRENCYCODE=EUR
&PAYMENTREQUEST_0_NOTIFYURL=http%3A%2F%2Fwww.myWebSite.com?notify
&PAYMENTREQUEST_0_CUSTOM=custom_var1%3Dvalue1%7Ccustom_var2%3Dvalue2
完成此操作后,我会收到这些 IPN:
Array
(
[transaction_subject] => test paypal
[payment_date] => 06:01:52 Feb 04, 2013 PST
[txn_type] => express_checkout
[last_name] => numerik
[residence_country] => FR
[item_name] =>
[payment_gross] =>
[mc_currency] => EUR
[payment_type] => instant
[protection_eligibility] => Ineligible
[verify_sign] => myVerifySign
[payer_status] => verified
[test_ipn] => 1
[tax] => 0.00
[payer_email] => myEmail@per.com
[txn_id] => 6XC11065S3796804E
[quantity] => 1
[receiver_email] => myEmail@biz.com
[first_name] => buyer
[payer_id] => myPayerId
[receiver_id] => myReceiverId
[item_number] =>
[handling_amount] => 0.00
[payment_status] => Completed
[payment_fee] =>
[mc_fee] => 0.42
[shipping] => 0.00
[mc_gross] => 5.00
[custom] => custom_var1=value1|custom_var2=value2
[charset] => windows-1252
[notify_version] => 3.7
[ipn_track_id] => ab76ea3421261
)
Array
(
[payment_cycle] => Daily
[txn_type] => recurring_payment_profile_created
[last_name] => numerik
[next_payment_date] => 02:00:00 Feb 04, 2013 PST
[residence_country] => FR
[initial_payment_amount] => 0.00
[currency_code] => EUR
[time_created] => 06:01:47 Feb 04, 2013 PST
[verify_sign] => myVerifySign
[period_type] => Regular
[payer_status] => verified
[test_ipn] => 1
[tax] => 0.00
[payer_email] => myEmail@per.com
[first_name] => buyer
[receiver_email] => myEmail@biz.com
[payer_id] => myPayerId
[product_type] => 1
[shipping] => 0.00
[amount_per_cycle] => 5.00
[profile_status] => Active
[charset] => windows-1252
[notify_version] => 3.7
[amount] => 5.00
[outstanding_balance] => 0.00
[recurring_payment_id] => myRecurringPaymentId
[product_name] => test paypal
[ipn_track_id] => a8adfdf8b61d3
)
正如您在第一个 IPN 中看到的,自定义字段可用,但在第二个 IPN 中不可用。 有谁知道我在第二个 IPN 中检索自定义字段时缺少什么?
【问题讨论】:
【参考方案1】:您的 DoExpressCheckoutPayment 请求包含自定义参数,这就是您为该交易取回它的原因。您的 CreateRecurringPaymentsProfile 请求没有包含自定义参数,因此不会返回。
也就是说,CRPP 似乎无法使用自定义参数,因此您需要将数据保存在本地,并将本地记录 ID 包含在 CRPP 请求的 PROFILEREFERENCE 参数中。这样,它将像 Matt Cole 建议的那样以 rp_invoice_id 的形式在 IPN 中返回,并且您可以使用相应的记录 ID 从数据库中提取自定义数据。
【讨论】:
感谢您的提示,这将非常有用。【参考方案2】:最好的办法是将PROFILEREFERENCE
添加到您的 CreateRecurringPaymentsProfile 调用中。它将以rp_invoice_id
的形式返回IPN。
【讨论】:
感谢您的回复,但安德鲁的回答更详细。 这是否记录在某处?我在developer.paypal.com/docs/classic/ipn/integration-guide/…看不到它以上是关于缺少 PAYPAL IPN 自定义字段的主要内容,如果未能解决你的问题,请参考以下文章