2015-11-02 88 views
0

我在SetExpressCheckout之後調用CreateBillingAgreement,都是成功的。 BILLINGAGREEMENTID由CreateBillingAgreement返回。調用DoReferenceTransaction方法給出錯誤

此BILLINGAGREEMENTID作爲REFERENCEID傳遞給DoReferenceTransaction。

NVP被構造爲:

$nvpstr = '&TOKEN=' . $token . '&REFERENCEID=' . $billing_agreement_id . '&PAYMENTACTION=' . $paymentType . '&AMT=' . $FinalPaymentAmt; 
    $nvpstr .= '&CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName .'&L_ITEMCATEGORY0=Digital'.'&DESC='.urlencode("Test Recurring Payment($" . $_SESSION["Payment_Amount"] . " monthly)"); 

    $nvpstr.="&L_PAYMENTREQUEST_0_ITEMCATEGORY0=Digital"; 
    $nvpstr.="&L_PAYMENTREQUEST_0_QTY0=Digital"; 
    $nvpstr.="&L_PAYMENTREQUEST_0_NAME0=Test Name"; 
    $nvpstr.="&L_PAYMENTREQUEST_0_AMT0=".$_SESSION["Payment_Amount"]; 

    $nvpstr.="&L_NAME0=Test Name"; 
    $nvpstr.="&L_DESC0=".urlencode("Test Recurring Payment($" . $_SESSION["Payment_Amount"] . " monthly)"); 
    $nvpstr.="&L_AMT0=".$_SESSION["Payment_Amount"]; 
    $nvpstr.="&L_QTY0=1"; 

調用DoReferenceTransaction方法給錯誤:

Array 
(
    [TIMESTAMP] => 2015-11-02T10:20:06Z 
    [CORRELATIONID] => 3e60a1baba3b3 
    [ACK] => Failure 
    [VERSION] => 64 
    [BUILD] => 000000 
    [L_ERRORCODE0] => 10209 
    [L_ERRORCODE1] => 10004 
    [L_SHORTMESSAGE0] => Disabled 
    [L_SHORTMESSAGE1] => Invalid Data 
    [L_LONGMESSAGE0] => Preapproved Payments not enabled. 
    [L_LONGMESSAGE1] => This transaction cannot be processed. 
    [L_SEVERITYCODE0] => Error 
    [L_SEVERITYCODE1] => Error 
    [TRANSACTIONTYPE] => None 
    [PAYMENTTYPE] => None 
    [ORDERTIME] => 1970-01-01T00:00:00Z 
    [PAYMENTSTATUS] => None 
    [PENDINGREASON] => None 
    [REASONCODE] => None 
) 

注:使用沙盒帳戶進行測試。

UPDATE:

function DoReferenceTransaction(){ 

    //Format the other parameters that were stored in the session from the previous calls 
    $token = urlencode($_SESSION['TOKEN']); 
    $paymentType = urlencode($_SESSION['PaymentType']); 
    $currencyCodeType = urlencode($_SESSION['currencyCodeType']); 
    //$payerID = urlencode($_SESSION['payer_id']); $_SESSION['billing_agreement_id'] 
    $billing_agreement_id = urlencode($_SESSION['billing_agreement_id']); 

$FinalPaymentAmt = urlencode($_SESSION["Payment_Amount"]); 
    $serverName = urlencode($_SERVER['SERVER_NAME']); 

    $nvpstr = '&TOKEN=' . $token . '&REFERENCEID=' . $billing_agreement_id . '&PAYMENTACTION=' . $paymentType . '&AMT=' . $FinalPaymentAmt; 
    $nvpstr .= '&CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName .'&L_ITEMCATEGORY0=Digital'.'&DESC='.urlencode("Test Recurring Payment($" . $_SESSION["Payment_Amount"] . " monthly)"); 

    $nvpstr.="&L_PAYMENTREQUEST_0_ITEMCATEGORY0=Digital"; 
    $nvpstr.="&L_PAYMENTREQUEST_0_QTY0=Digital"; 
    $nvpstr.="&L_PAYMENTREQUEST_0_NAME0=Test Name"; 
    $nvpstr.="&L_PAYMENTREQUEST_0_AMT0=".$_SESSION["Payment_Amount"]; 

    $nvpstr.="&L_NAME0=Test Name"; 
    $nvpstr.="&L_DESC0=".urlencode("Test Recurring Payment($" . $_SESSION["Payment_Amount"] . " monthly)"); 
    $nvpstr.="&L_AMT0=".$_SESSION["Payment_Amount"]; 
    $nvpstr.="&L_QTY0=1"; 



    /* Make the call to PayPal to finalize payment 
     If an error occured, show the resulting errors 
    */ 

     $resArray = hash_call("DoReferenceTransaction", $nvpstr); 
echo "<pre>"; 
    print_r($resArray); exit; 

    /* Display the API response back to the browser. 
     If the response from PayPal was a success, display the response parameters' 
     If the response was an error, display the errors received using APIError.php. 
    */ 
    $ack = strtoupper($resArray["ACK"]); 

    return $resArray; 
} 

NVP爲DoReferenceTransaction:

&TOKEN=EC-30M31870BS241854X&REFERENCEID=B-81S156104Y376273D&PAYMENTACTION=Sale&AMT=3&CURRENCYCODE=USD&IPADDRESS=paypalrecurring.com&L_ITEMCATEGORY0=Digital&DESC=Test+Recurring+Payment%28+%243+monthly%29&L_PAYMENTREQUEST_0_ITEMCATEGORY0=Digital&L_PAYMENTREQUEST_0_QTY0=Digital&L_PAYMENTREQUEST_0_NAME0=Test Name&L_PAYMENTREQUEST_0_AMT0=3&L_NAME0=Test Name&L_DESC0=Test+Recurring+Payment%28+%243+monthly%29&L_AMT0=3&L_QTY0=1 

回答

1

它是一個活的或沙箱API調用?

您需要在您的PayPal帳戶上激活參考交易才能夠調用此API。

Reference Transaction API不適用於所有人。我建議聯繫您的PayPal代表,要求他們在您的PayPal賬戶上激活此功能。

如果您是在沙箱上執行此操作,則只需將沙箱帳戶升級到專業帳戶即可。這應該激活沙箱帳戶上的引用事務。

可以肯定的是,如果您的沙箱帳戶已啓用參考交易,您應該詢問貝寶。

您可以在您的問題中發送完整的API調用嗎?

更新

我看到你的代碼奇怪的事情:

$nvpstr.="&L_PAYMENTREQUEST_0_ITEMCATEGORY0=Digital"; 
$nvpstr.="&L_PAYMENTREQUEST_0_QTY0=Digital"; 

通過更改:

$nvpstr.="&L_PAYMENTREQUEST_0_ITEMCATEGORY0=Physical"; 
$nvpstr.="&L_PAYMENTREQUEST_0_QTY0=1"; 

更新2

我看到一些錯誤,我n API調用:

&TOKEN=EC-30M31870BS241854X& 
REFERENCEID=B-81S156104Y376273D& 
PAYMENTACTION=Sale& 
AMT=3& 
CURRENCYCODE=USD& 
IPADDRESS=paypalrecurring.com& 
L_ITEMCATEGORY0=Digital& 
DESC=Test+Recurring+Payment%28+%243+monthly%29& 
L_PAYMENTREQUEST_0_ITEMCATEGORY0=Digital& 
L_PAYMENTREQUEST_0_QTY0=Digital& 
L_PAYMENTREQUEST_0_NAME0=Test Name& 
L_PAYMENTREQUEST_0_AMT0=3& 
L_NAME0=Test Name& 
L_DESC0=Test+Recurring+Payment%28+%243+monthly%29& 
L_AMT0=3& 
L_QTY0=1string(606) 

在IP地址變量中提供一個有效的IP地址。

更換

L_PAYMENTREQUEST_0_QTY0=Digital& 

由:

L_PAYMENTREQUEST_0_QTY0=1& 

在最後一個參數是有錯誤的參數替代:

L_QTY0=1string(606) 

由:

L_QTY0=1 

最終將項目類別從數字更改爲物理。我知道你需要使用PayPal進行數字商品的特殊權利。

L_ITEMCATEGORY0=Physical& 
L_PAYMENTREQUEST_0_ITEMCATEGORY0=Physical& 
+0

貝寶團隊說:RT啓用。 – VBMali

+1

嘗試使用更新的版本號。例如105 – Thomas

+0

[VERSION] => 64,哪個版本需要使用? – VBMali