call to DoReferenceTransaction method giving error

青春壹個敷衍的年華 提交于 2019-12-12 03:23:11

问题


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:


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&


来源:https://stackoverflow.com/questions/33475113/call-to-doreferencetransaction-method-giving-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!