2013-02-05 87 views
6

我正在面對使用API​​過程和沙箱實施PayPal定期付款的麻煩。 我成功創建訂閱按鈕並將用戶重定向到PayPal Express結帳頁面。 但是,由PayPal生成的一些IPN中缺少自定義字段,我真的需要這個字段。PAYPAL IPN自定義字段丟失

這裏有我而產生的訂閱按鈕發送請求:

METHOD=SetExpressCheckout 
&VERSION=94.0 
&PWD=123456 
&[email protected] 
&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 

用戶確認交易完成後,他回來我的網站,我需要驗證信息,並建立定期PROFIL。 下面是我做的請求:

METHOD=GetExpressCheckoutDetails 
&VERSION=94.0 
&PWD=123456 
&[email protected] 
&SIGNATURE=mySignature 
&TOKEN=theToken 


METHOD=CreateRecurringPaymentsProfile 
&VERSION=94.0 
&PWD=123456 
&[email protected] 
&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 
&[email protected] 
&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] => [email protected] 
    [txn_id] => 6XC11065S3796804E 
    [quantity] => 1 
    [receiver_email] => [email protected] 
    [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] => [email protected] 
    [first_name] => buyer 
    [receiver_email] => [email protected] 
    [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中檢索自定義字段時缺少什麼?

回答

7

您的DoExpressCheckoutPayment請求包含自定義參數,這就是爲什麼您要爲該事務取回它的原因。您的CreateRecurringPaymentsProfile請求沒有包含自定義參數,因此它不會回來。

也就是說,它看起來並不像自定義參數可用於CRPP,因此您需要在本地保存數據並將您的本地記錄ID包含在CRPP請求的PROFILEREFERENCE參數中。這樣,它將以IPR形式返回,就像Matt Cole所建議的rp_invoice_id一樣,並且可以相應地使用該記錄ID將自定義數據從數據庫中拉回。

+0

看到它謝謝你的提示,這將是非常有用的。 – Shaolin

4

最好的辦法是將PROFILEREFERENCE添加到您的CreateRecurringPaymentsProfile調用中。它將作爲rp_invoice_id返回到IPN。

+0

謝謝你的回覆,但安德魯的回答更詳細。 – Shaolin

+0

這是記錄在某處嗎?我不能在https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/ – Kof