我在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
貝寶團隊說:RT啓用。 – VBMali
嘗試使用更新的版本號。例如105 – Thomas
[VERSION] => 64,哪個版本需要使用? – VBMali