2011-04-08 81 views
3

更新2:哪些付款已確認PayPal?

代碼我currentlly有如下:

paypalplatform.php:

https://www.paypal-labs.com/integrationwizard/adaptive/code2.php

basic_payment.php:(中圖4b在腳本 鏈接如下)

https://www.paypal-labs.com/integrationwizard/adaptive/paymenttypes.php

ipn.php:(IPN的聽衆)

https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNImplementation

如果在第二個環節的箱子上面是空的,只需要點擊「重新開始」,直到你到點擊下一步第4步,或點擊這裏:https://www.paypal-labs.com/integrationwizard/adaptive/main.php

更新1:

,我認爲這是代碼發起ŧ他付款,我需要在這裏指定一個自定義值嗎?如果是這樣,怎麼樣?

<?php 
//------------------------------------------------- 
// When you integrate this code 
// look for TODO as an indication 
// that you may need to provide a value or take action 
// before executing this code 
//------------------------------------------------- 

require_once ("paypalplatform.php"); 


// ================================== 
// PayPal Platform Basic Payment Module 
// ================================== 

// Request specific required fields   
$actionType   = "PAY"; 
$cancelUrl   = "some url here"; // TODO - If you are not executing the Pay call for a preapproval, 
           //  then you must set a valid cancelUrl for the web approval flow 
           //  that immediately follows this Pay call 
$returnUrl   = "some url here"; // TODO - If you are not executing the Pay call for a preapproval, 
           //  then you must set a valid returnUrl for the web approval flow 
           //  that immediately follows this Pay call 
$currencyCode   = "USD"; 

// A basic payment has 1 receiver 
// TODO - specify the receiver email 
$receiverEmailArray  = array(
        'receivers email here' 
       ); 

// TODO - specify the receiver amount as the amount of money, for example, '5' or '5.55' 
$receiverAmountArray  = array(
        'receivers amount here' 
       ); 

// for basic payment, no primary indicators are needed, so set empty array 
$receiverPrimaryArray  = array(); 

// TODO - Set invoiceId to uniquely identify the transaction associated with the receiver 
//  You can set this to the same value as trackingId if you wish 
$receiverInvoiceIdArray  = array(
        '1234abc' 
       ); 

// Request specific optional or conditionally required fields 
// Provide a value for each field that you want to include in the request, if left as an empty string the field will not be passed in the request 
$senderEmail    = "";  // TODO - If you are executing the Pay call against a preapprovalKey, you should set senderEmail 
          //  It is not required if the web approval flow immediately follows this Pay call 
$feesPayer    = ""; 
$ipnNotificationUrl   = "some url here"; 
$memo     = "";  // maxlength is 1000 characters 
$pin     = "";  // TODO - If you are executing the Pay call against an existing preapproval 
          //  the requires a pin, then you must set this 
$preapprovalKey    = "";  // TODO - If you are executing the Pay call against an existing preapproval, set the preapprovalKey here 
$reverseAllParallelPaymentsOnError = "";  // Do not specify for basic payment 
$trackingId      = generateTrackingID(); // generateTrackingID function is found in paypalplatform.php 

//------------------------------------------------- 
// Make the Pay API call 
// 
// The CallPay function is defined in the paypalplatform.php file, 
// which is included at the top of this file. 
//------------------------------------------------- 
$resArray = CallPay ($actionType, $cancelUrl, $returnUrl, $currencyCode, $receiverEmailArray, 
         $receiverAmountArray, $receiverPrimaryArray, $receiverInvoiceIdArray, 
         $feesPayer, $ipnNotificationUrl, $memo, $pin, $preapprovalKey, 
         $reverseAllParallelPaymentsOnError, $senderEmail, $trackingId 
); 

$ack = strtoupper($resArray["responseEnvelope.ack"]); 
if($ack=="SUCCESS") 
{ 
    if ("" == $preapprovalKey) 
    { 
     // redirect for web approval flow 
     $cmd = "cmd=_ap-payment&paykey=" . urldecode($resArray["payKey"]); 
     RedirectToPayPal ($cmd); 
    } 
    else 
    { 
     // payKey is the key that you can use to identify the payment resulting from the Pay call 
     $payKey = urldecode($resArray["payKey"]); 
     // paymentExecStatus is the status of the payment 
     $paymentExecStatus = urldecode($resArray["paymentExecStatus"]); 
    } 
} 
else 
{ 
    //Display a user friendly Error on the page using any of the following error information returned by PayPal 
    //TODO - There can be more than 1 error, so check for "error(1).errorId", then "error(2).errorId", and so on until you find no more errors. 
    $ErrorCode = urldecode($resArray["error(0).errorId"]); 
    $ErrorMsg = urldecode($resArray["error(0).message"]); 
    $ErrorDomain = urldecode($resArray["error(0).domain"]); 
    $ErrorSeverity = urldecode($resArray["error(0).severity"]); 
    $ErrorCategory = urldecode($resArray["error(0).category"]); 

    echo "Preapproval API call failed. "; 
    echo "Detailed Error Message: " . $ErrorMsg; 
    echo "Error Code: " . $ErrorCode; 
    echo "Error Severity: " . $ErrorSeverity; 
    echo "Error Domain: " . $ErrorDomain; 
    echo "Error Category: " . $ErrorCategory; 
} 

?> 

原題:

我來自PayPal的一些腳本,可以讓用戶實現從我的網站付款。

在第一步中,當他們通過發送基本的支付腳本支付,我得到這些值回:

Array ( 
[responseEnvelope.timestamp] => 2011-04-08T01:34:03.578-07:00 
[responseEnvelope.ack] => Success 
[responseEnvelope.correlationId] => a2de97aaf57f0 
[responseEnvelope.build] => 1822511 
[payKey] => AP-8AW04791DK417062F 
[paymentExecStatus] => CREATED) 

當付款由貝寶證實,使用他們的IPN系統,我得到這些值回:

test_ipn = 1 
payment_type = instant 
payment_date = 01:11:38 Apr 08, 2011 PDT 
payment_status = Completed 
address_status = confirmed 
payer_status = verified 
first_name = John 
last_name = Smith 
payer_email = [email protected] 
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 = [email protected] 
receiver_email = [email protected] 
receiver_id = TESTSELLERID1 
residence_country = US 
item_name = something 
item_number = AK-1234 
quantity = 1 
shipping = 3.04 
tax = 2.02 
mc_currency = USD 
mc_fee = 0.44 
mc_gross = 12.34 
mc_gross_1 = 9.34 
txn_type = web_accept 
txn_id = 3848811 
notify_version = 2.1 
custom = xyz123 
charset = windows-1252 
verify_sign = AWPjjtnKgiQkL5dH.EojlIO6uUy9AijwJCRexi2IglsAajCxoIkbVEq- 

我看不出這讓我建立連接的任何值,讓我更新了正確的數據庫記錄說,付款已成功完成。

+0

在這個調用中,Paypal返回「內部服務器錯誤,請檢查服務器日誌中的詳細信息」錯誤。我沒有得到什麼問題。我檢查了服務器日誌,但是我沒有發現任何關於這個錯誤的信息。對我有何建議? – gautamlakum 2014-01-18 11:14:29

回答

2

txn_id = 3848811是貝寶的交易ID。如果您希望paypal發回系統中某個標識符的引用(您的付款標識符),您可以使用您在請求中發送的「自定義」字段。

如果你使用NVP,它會是PAYMENTREQUEST_n_CUSTOM,不知道SOAP接口。

+0

我不明白,在paypal基本支付模塊腳本中,我如何捕獲txn_id?如果我可以捕獲它,那麼我可以看到如何使用從ipn返回的txn_id來更新正確的數據庫記錄。 – oshirowanen 2011-04-08 08:59:19

+0

您重定向客戶,對嗎?交易ID僅在客戶完成支付時生成,這意味着您只能在返回的請求(意思是成功URL)或IPN中捕獲交易ID。因此,您應該發送一個自定義字段,以確定實際付款的購物車。 – jishi 2011-04-08 12:29:58

+0

@ jishi,請參閱原始問題中的更新1。 – oshirowanen 2011-04-08 13:40:42