我真的对BillingFrequency
,BillingPeriod
,TotalBillingCycles
感到困惑,我想要实现的目标是每月结算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
)
答案 0 :(得分:1)
如果您修改了BillingFrequency
和BillingPeriod
组合并将所有其余参数保留如下,则会有效,
$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: "How many periods you want to charge the customer"
BillingPeriod: "Define your unit of period"
TotalBillingCycles: "Optional in this case, as the combiniation of the above 2 cannot exceed one year"
*请注意,SDK示例使用CreateRecurringPaymentsProfile
发布的表单数据调用merchant-sdk-php/samples/RecurringPayments/CreateRecurringPaymentsProfile.html.php
API,因此,如果您想自定义自己的有效负载功能,请确保所有必需参数都是过去了。
请参阅API规范Here,在说明中查找所有“(必填)”参数,并与您的代码进行交叉核对。
答案 1 :(得分:0)
根据paypal的文件判断;
您的变量应该看起来像;
$paymentBillingPeriod->BillingFrequency = "12"; //can not be more than a year
$paymentBillingPeriod->BillingPeriod = "Month";
这是因为付款期限是每月,频率为12,即1年。
根据文件引用;
The combination of billing frequency and billing period must be less than or equal to one year. For example, if the billing cycle is Month, the maximum value for billing frequency is 12. Similarly, if the billing cycle is Week, the maximum value for billing frequency is 52.
修改强>
这样做意味着您可以省略TOTALBILLINGCYCLES
值,这样可以清除代码,因为您只需要少一行来处理。