调用 DoReferenceTransaction 方法给出错误

call to DoReferenceTransaction method giving error

我在 SetExpressCheckout 之后调用 CreateBillingAgreement,两者都成功了。 BILLINGAGREEMENTID 由 CreateBillingAgreement 返回。

此 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
)

注意:使用沙盒帐户进行测试。

更新:

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;
}

DoReferenceTransaction 的 NVP:

&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

它是实时调用还是沙盒调用 API?

您需要在您的 PayPal 帐户上激活参考交易才能调用此 API。

参考交易 API 并非对所有人都可用。我建议联系您的 PayPal 代表,要求他们在您的 PayPal 帐户上激活此功能。

如果您在沙盒上执行此操作,则只需将您的沙盒帐户升级为 Pro 帐户即可。这应该会激活沙盒帐户上的参考交易。

当然,您应该询问 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

我在 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&