gpt4 book ai didi

php - 调用 DoReferenceTransaction 方法给出错误

转载 作者:太空宇宙 更新时间:2023-11-03 16:25:44 25 4
gpt4 key购买 nike

我在 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 调用还是沙盒 API 调用?

您需要在您的 PayPal 账户上激活引用交易才能调用此 API。

Reference Transaction 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&

在最后一个参数中有一个错误的参数replace:

L_QTY0=1string(606) 

通过:

L_QTY0=1

最终将项目类别从数字更改为物理。我知道您需要特殊权利才能使用 PayPal 购买数字商品。

L_ITEMCATEGORY0=Physical&
L_PAYMENTREQUEST_0_ITEMCATEGORY0=Physical&

关于php - 调用 DoReferenceTransaction 方法给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33475113/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com