dtvx3420 2015-11-02 10:07
浏览 29
已采纳

调用DoReferenceTransaction方法给出错误

I am calling CreateBillingAgreement after SetExpressCheckout, both are successfull. BILLINGAGREEMENTID is returnd by CreateBillingAgreement.

This BILLINGAGREEMENTID is passed as REFERENCEID to DoReferenceTransaction.

NVP is constructed as :

$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";

call to DoReferenceTransaction method giving error:

  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
)

Note: Using Sandbox account for testing.

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 for 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条回答 默认 最新

  • doxqszx09742 2015-11-02 11:45
    关注

    Is it a live or a sandbox API call?

    You need to have Reference Transaction activated on your PayPal account to be able to call this API.

    The Reference Transaction API is not available for everybody. I would advise to contact your PayPal representative to ask them to activate this on your PayPal account.

    If you are doing this on the sandbox, you should simply upgrade your sandbox account to a Pro account. This should activate Reference Transaction on the sandbox account.

    To be sure, you should ask PayPal if your sandbox account has Reference Transaction enabled.

    Can you send the full API call in your question please?

    Update

    I see something strange in your code:

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

    Change it by:

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

    Update 2

    I see few errors in the API call:

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

    Provide a valid IP address in the IP address variable.

    Replace

    L_PAYMENTREQUEST_0_QTY0=Digital&
    

    by:

    L_PAYMENTREQUEST_0_QTY0=1&
    

    In the last parameter there is a wrong parameter replace:

    L_QTY0=1string(606) 
    

    by:

    L_QTY0=1
    

    Eventually change the item category from Digital to Physical. I know you need special rights to do Digital Goods with PayPal.

    L_ITEMCATEGORY0=Physical&
    L_PAYMENTREQUEST_0_ITEMCATEGORY0=Physical&
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等