2014-01-29 34 views
0

我的問題:設置將在IPN上返回的paypal變量。從cURL支付中向PayPal添加自定義變量

所以背景: 我使用CodeIgniter工作,我使用的是預製的網上圖書館,我發現對付整個貝寶的事。圖書館負責繁重工作,效果很好。 [這是我正在使用的圖書館] [1]

據我所知,圖書館發送一個使用XML格式的CURL請求到所有需要的信息的貝寶,基本上如貝寶本身[這裏] [ 2]

這個圖書館記錄不完善,我不知道如何採取下一步。

下一步是將數據添加到將顯示在IPN上的cURL請求。

確切地說;我會找到一種方法來添加數據,我更關心這應該如何看待結尾。

這是捲曲請求的經典交易部分(從我收集):

"transactions":[ 
    { 
     "amount":{ 
     "total":"7.47", 
     "currency":"USD" 
     } 
    } 
    ] 

我不知道我應該如何需要的樣子,例如,如果我想通過用戶ID信息,它會是沿線

"userID":"4", 

它應該嵌套在其他一些參數嗎?

如果需要其他代碼,我會很樂意發佈它,我廣泛搜索了該主題,並且我發現所有答案都與表單和隱藏字段相關,而不是我的情況。通過使用cURL的PHP​​函數引發)。

在此先感謝!

編輯:

您好!感謝您的回覆,並非常感謝這個真棒庫:) 我使用薪酬方法Adaptive_payments控制器。

我剛剛意識到invoiceID確實得到了返回,這很適合。 雖然我在你的回答中遺漏了一些東西,但許多字段沒有被IPN返回,包括customerID(這是我嘗試使用的,我只是假設沒有返回)。

這是我回報arguements由IPN捕獲:

cmd=_notify-validate 
    &transaction_subject= 
    &payment_date=12%3A02%3A40+Jan+29%2C+2014+PST 
    &txn_type=web_accept 
    &last_name=patrick 
    &residence_country=US 
    &item_name= 
    &payment_gross=50.00 
    &mc_currency=USD 
    &[email protected] //not the actual email 
    &payment_type=instant 
    &protection_eligibility=Ineligible 
    &verify_sign=ASsSVovq77sBsVg2xPiCnEG3N9AIAD1pW3tgoSX59hTmz9AA9lT6AH0E 
    &payer_status=verified 
    &test_ipn=1 
    &tax=0.00 
    &payer_email=patrick.buyer%40gmail.com 
    &txn_id=69J264685H5924531&quantity=0 
    &[email protected] //not the actual email 
    &first_name=patrick 
    &payer_id=5MLPF23854T8Q 
    &receiver_id=F5K3CSR99E9WA 
    &item_number= 
    &payment_status=Completed 
    &payment_fee=1.75 
    &mc_fee=1.75 
    &mc_gross=50.00 
    &custom= 
    &charset=windows-1252 
    &notify_version=3.7 
    &ipn_track_id=50879f4bb9d2 

這似乎並不是所有的控制器的控制正在由IPN返回。 發票將完美地適合我,我會標記爲已回答。 非常感謝您的時間和精力。

編輯2: $ PayPalResult ['RawResponse']由於某種原因不存在,我做了$ PayPalResult的var_dump(在adaptive_payment控制器中,就在我重定向到paypal之前)。

array(10) { 
    ["Errors"]=> 
    array(0) { 
    } 
    ["Ack"]=> 
    string(7) "Success" 
    ["Build"]=> 
    string(7) "7935900" 
    ["CorrelationID"]=> 
    string(13) "8c2afcee2d74b" 
    ["Timestamp"]=> 
    string(29) "2014-01-31T02:37:38.806-08:00" 
    ["PayKey"]=> 
    string(20) "AP-1WW538504G900525L" 
    ["PaymentExecStatus"]=> 
    string(7) "CREATED" 
    ["RedirectURL"]=> 
    string(81) "https://www.sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=AP-1WW538504G900525L" 
    ["XMLRequest"]=> 
    string(1439) "ReturnAllen_USPAYhttp://httpexample.no-ip.biz/ROOT/index.php/userControllers/regularuserActions/viewShoppingCartAPP-80W284485P519543T109.67.55.127USDBALANCECREDITCARDhttp://httpexample.no-ip.biz/root/index.php/main/[email protected]://httpexample.no-ip.biz/ROOT/index.php/userControllers/regularuserActions/paypalSuccess" 
    ["XMLResponse"]=> 
    string(373) "2014-01-31T02:37:38.806-08:00Success8c2afcee2d74b7935900AP-1WW538504G900525LCREATED" 
} 

因此,在短期,我的IPN類被調用,但它無法找到任何信息處理(我已經證實了這一點與日誌,調試顯示類被稱爲但是沒有$ _ POST數據存在)。

編輯3:

XML請求被產生的微細,這是我所測試的特定屬性是myownID - 出現在請求中。

由於某種原因,雖然沒有$ _POST信息被髮回。 這條線在IPN方法中:

$ this - > _ log('debug - IPN export for application is'。var_export($ _POST));

這樣表示對我的日誌: 調試 - IPN出口申請是

[XMLRequest] =><?xml version="1.0" encoding="utf-8"?><PayRequest xmlns="http://svcs.paypal.com/types/ap"><requestEnvelope xmlns=""><detailLevel>ReturnAll</detailLevel><errorLanguage>en_US</errorLanguage></requestEnvelope><actionType xmlns="">PAY</actionType><cancelUrl xmlns="">http://httpexample.no-ip.biz/ROOT/index.php/userControllers/regularuserActions/viewShoppingCart</cancelUrl><clientDetails xmlns=""><applicationId xmlns="">APP-80W284485P519543T</applicationId><customerId xmlns="">myownID</customerId><geoLocation xmlns="">Israel</geoLocation><ipAddress xmlns="">109.67.55.127</ipAddress></clientDetails><currencyCode xmlns="">ILS</currencyCode><fundingConstraint xmlns=""><allowedFundingType xmlns=""><fundingTypeInfo xmlns=""><fundingType xmlns="">BALANCE</fundingType></fundingTypeInfo><fundingTypeInfo xmlns=""><fundingType xmlns="">CREDITCARD</fundingType></fundingTypeInfo></allowedFundingType></fundingConstraint><ipnNotificationUrl xmlns="">http://httpexample.no-ip.biz/root/index.php/main/IPN</ipnNotificationUrl><receiverList xmlns=""><receiver xmlns=""><amount xmlns="">25</amount><email xmlns="">[email protected]</email><invoiceId xmlns="">5</invoiceId><paymentType xmlns="">SERVICE</paymentType><primary xmlns="">false</primary></receiver></receiverList><sender><useCredentials xmlns=""></useCredentials></sender><account xmlns=""><phone xmlns=""></phone></account><returnUrl xmlns="">http://httpexample.no-ip.biz/ROOT/index.php/userControllers/regularuserActions/paypalSuccess</returnUrl></PayRequest>

編輯:最新的IPN屬性從應用IPN收到了我的IPN法。

cmd=_notify-validate& 
transaction= 
&payment_request_date=Sun+Feb+02+08%3A25%3A52+PST+2014 
&return_url=http%3A%2F%2Fhttpexample.no-ip.biz%2FROOT%2Findex.php%2FuserControllers%2FregularuserActions%2FpaypalSuccess 
&fees_payer=EACHRECEIVER 
&ipn_notification_url=http%3A%2F%2Fhttpexample.no-ip.biz%2Froot%2Findex.php%2Fpaypal%2Fpaypal_ipn%2Frunagain 
&sender_email=patrick.buyer%40gmail.com 
&verify_sign=AFcWxV21C7fd0v3bYYYRCpSSRl31AwGY-gIhQZM2WI9Ae63J.CxI7j4y 
&test_ipn=1 
&cancel_url=http%3A%2F%2Fhttpexample.no-ip.biz%2FROOT%2Findex.php%2FuserControllers%2FregularuserActions%2FviewShoppingCart 
&pay_key=AP-6RR41041VH869594S 
&action_type=PAY 
&transaction_type=Adaptive+Payment+PAY 
&status=COMPLETED 
&log_default_shipping_address_in_transaction=false 
&charset=windows-1252 
&notify_version=UNVERSIONED 
&reverse_all_parallel_payments_on_error=false 
+0

請記住,使用自適應付款有一個特定於應用程序的IPN和一個商戶特定的IPN。您的應用程序將收到您在API請求中指定的IPN URL。我相信會包含客戶ID。如果商家(賣家帳戶)在自己的Paypal帳戶中配置了IPN,則還會收到包含特定交易數據的IPN。 –

+0

感謝您的回答,那麼這是否意味着我應該獲得兩組不同的IPN?一個用於merchent帳戶,另一個用於應用程序本身? 這是有道理的我猜。 我猜我需要兩個IPN handeling不同的URL? – Patrick

+0

是的,API將具有特定於應用程序的IPN的URL,然後您的PayPal配置文件將擁有賣家帳戶IPN所在的位置。 –

回答

0

我是該圖書館的開發人員,我很樂意提供幫助。您發佈的JSON內容是指PayPal的新REST API,但這不是我的圖書館使用的。它使用了classic API's,它比今天的REST API更成熟,更少限制。

你在使用哪種API?該庫附帶已安裝的控制器,並在請求中包含所有可能的參數。包含在該請求中的任何數據也將以IPN的形式返回。

如果您有需要包含的自定義字段,則需要在可用時使用CUSTOM參數,或者另一個選項是將數據保存到數據庫中,然後在CUSTOM或INVNUM中傳遞記錄ID。這樣ID就會返回到IPN中,並且可以將所有的細節從數據庫中取出。

如果您使用Pay API,則可以將InvoiceID參數包含在$ Receiver數據中,該數據已包含在Pay()的控制器方法中。 Pay_with_options()結合了Pay和SetPaymentOptions API,它提供了更多的參數,包括可以使用的CustomID,也可以返回到IPN中。

如果您提供關於您正在使用哪個API的更多詳細信息,我可以爲您提供更多幫助。

+0

作爲迴應編輯。謝謝 – Patrick