gpt4 book ai didi

paypal - 用于 PHP 的无效计费周期和频率 PayPal Merchant SDK

转载 作者:太空宇宙 更新时间:2023-11-03 15:48:26 27 4
gpt4 key购买 nike

我真的对 BillingFrequencyBillingPeriodTotalBillingCycles 感到困惑,我想要实现的是设置 12 个月的月度账单.

  $paymentBillingPeriod =  new BillingPeriodDetailsType();
$paymentBillingPeriod->BillingFrequency = "1"; //can not be more than a year
$paymentBillingPeriod->BillingPeriod = "Year";
$paymentBillingPeriod->TotalBillingCycles ="12";
$paymentBillingPeriod->Amount = new BasicAmountType($currencyCode, 18); // GET Amount from Session
$paymentBillingPeriod->ShippingAmount = new BasicAmountType($currencyCode, "0");
$paymentBillingPeriod->TaxAmount = new BasicAmountType($currencyCode, "0");

这是API的错误响应

  • 计费周期必须是日计费、周计费、半月计费或年计费之一

  • 频率必须>0且小于或等于一年

我做错了什么?

来源

$currencyCode = "USD";
$billingStartDate = date("Y-m-d\TH:i:s\Z");
$subscriberName = "Name";// Session var
$token = "" ; //
$amount = "10.00"

$RPProfileDetails = new RecurringPaymentsProfileDetailsType();
$RPProfileDetails->SubscriberName = $subscriberName;
$RPProfileDetails->BillingStartDate = $billingStartDate;

$activationDetails = new ActivationDetailsType();

$paymentBillingPeriod = new BillingPeriodDetailsType();
$paymentBillingPeriod->BillingFrequency = '12';
$paymentBillingPeriod->BillingPeriod = 'Month';

$paymentBillingPeriod->Amount = new BasicAmountType($currencyCode, $amount);
$paymentBillingPeriod->ShippingAmount = new BasicAmountType($currencyCode, 0.0);
$paymentBillingPeriod->TaxAmount = new BasicAmountType($currencyCode, 0.0);

$scheduleDetails = new ScheduleDetailsType();
$scheduleDetails->Description = "This is recurring payment";
$scheduleDetails->ActivationDetails = $activationDetails;

$createRPProfileRequestDetail = new CreateRecurringPaymentsProfileRequestDetailsType();
$createRPProfileRequestDetail->Token = $token;

$createRPProfileRequestDetail->ScheduleDetails = $scheduleDetails;
$createRPProfileRequestDetail->RecurringPaymentsProfileDetails = $RPProfileDetails;
$createRPProfileRequest = new CreateRecurringPaymentsProfileRequestType();
$createRPProfileRequest->CreateRecurringPaymentsProfileRequestDetails = $createRPProfileRequestDetail;

$createRPProfileReq = new CreateRecurringPaymentsProfileReq();
$createRPProfileReq->CreateRecurringPaymentsProfileRequest = $createRPProfileRequest;

$paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
try {
/* wrap API method calls on the service object with a try catch */
$createRPProfileResponse = $paypalService->CreateRecurringPaymentsProfile($createRPProfileReq);
} catch (Exception $ex) {
include_once("Error.php");
exit;
}

回应

Ack :   
Failure
ProfileID :
PayPal\PayPalAPI\CreateRecurringPaymentsProfileResponseType Object
(
[CreateRecurringPaymentsProfileResponseDetails] => PayPal\EBLBaseComponents\CreateRecurringPaymentsProfileResponseDetailsType Object
(
[ProfileID] =>
[ProfileStatus] =>
[TransactionID] =>
[DCCProcessorResponse] =>
[DCCReturnCode] =>
)

[Timestamp] => 2015-10-07T09:14:22Z
[Ack] => Failure
[CorrelationID] => 1d7177ca754
[Errors] => Array
(
[0] => PayPal\EBLBaseComponents\ErrorType Object
(
[ShortMessage] => Invalid billing period.
[LongMessage] => Billing period must be one of Day, Week, SemiMonth, or Year
[ErrorCode] => 11518
[SeverityCode] => Error
[ErrorParameters] =>
)

[1] => PayPal\EBLBaseComponents\ErrorType Object
(
[ShortMessage] => Invalid billing frequency
[LongMessage] => Billing frequency must be > 0 and be less than or equal to one year
[ErrorCode] => 11516
[SeverityCode] => Error
[ErrorParameters] =>
)

[2] => PayPal\EBLBaseComponents\ErrorType Object
(
[ShortMessage] => Invalid amount
[LongMessage] => Bill amount must be greater than 0
[ErrorCode] => 11519
[SeverityCode] => Error
[ErrorParameters] =>
)

)

[Version] => 106.0
[Build] => 000000
)

最佳答案

如果您修改 BillingFrequencyBillingPeriod 组合并保留所有其余参数,它将起作用,如下所示,

$paymentBillingPeriod =  new BillingPeriodDetailsType();
//$paymentBillingPeriod->BillingFrequency = $_REQUEST['billingFrequency'];
//$paymentBillingPeriod->BillingPeriod = $_REQUEST['billingPeriod'];
$paymentBillingPeriod->BillingFrequency = "12";
$paymentBillingPeriod->BillingPeriod = "Month";
$paymentBillingPeriod->TotalBillingCycles = $_REQUEST['totalBillingCycles'];
$paymentBillingPeriod->Amount = new BasicAmountType($currencyCode, $_REQUEST['paymentAmount']);
$paymentBillingPeriod->ShippingAmount = new BasicAmountType($currencyCode, $_REQUEST['paymentShippingAmount']);
$paymentBillingPeriod->TaxAmount = new BasicAmountType($currencyCode, $_REQUEST['paymentTaxAmount']);

在您的情况下,解释是(您可能会在修改行上方的代码注释中找到相同的解释):

BillingFrequency:“您要向客户收取多少期的费用”

BillingPeriod:“定义您的周期单位”

TotalBillingCycles:“在这种情况下是可选的,因为上述 2 项的组合不能超过一年”

*请注意,SDK 示例使用从 merchant-sdk-php/samples/RecurringPayments/CreateRecurringPaymentsProfile.html.php 发布的表单数据调用 CreateRecurringPaymentsProfile API,因此如果您想自定义您自己的有效负载功能,请确保传递所有必需参数。

请参阅 API 规范 Here ,在描述中查找所有“(必需)”参数,并与您的代码进行交叉检查。

关于paypal - 用于 PHP 的无效计费周期和频率 PayPal Merchant SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32902990/

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