【问题标题】:call to DoReferenceTransaction method giving error调用 DoReferenceTransaction 方法给出错误
【发布时间】:2016-02-02 04:31:24
【问题描述】:

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

【问题讨论】:

    标签: php paypal express-checkout


    【解决方案1】:

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

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

    并非所有人都可以使用参考事务 API。我建议联系您的 PayPal 代表,让他们在您的 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

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

    【讨论】:

    • Paypal 团队说:RT 已启用。
    • 尝试使用更新的版本号。例如 105
    • 如果 DoReferencTransaction 成功。据我所知,没有其他办法。
    • 能否在您的问题中添加完整的 API 调用?我想看看你在说什么
    • 你能打印 $nvp_str 吗?
    猜你喜欢
    • 2014-10-11
    • 2017-10-16
    • 1970-01-01
    • 1970-01-01
    • 2018-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-20
    相关资源
    最近更新 更多