【问题标题】:Invalid billing period and Frequency PayPal Merchant SDK for PHP无效的计费周期和频率 PayPal Merchant SDK for PHP
【发布时间】:2015-12-30 10:00:57
【问题描述】:

我真的对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
)

【问题讨论】:

    标签: paypal


    【解决方案1】:

    如果你修改了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']);
    

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

    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 API 使用从merchant-sdk-php/samples/RecurringPayments/CreateRecurringPaymentsProfile.html.php 发布的表单数据,因此如果您想自定义自己的有效负载功能,请确保传递所有强制参数。

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

    【讨论】:

    • 如果仍有问题,请在此处发布您的 SDK API 响应
    • 添加源和响应
    • @Bender,请求源中缺少某些内容,添加此行并尝试运行它:$scheduleDetails->PaymentPeriod = $paymentBillingPeriod;
    【解决方案2】:

    从贝宝的文档来看;

    https://developer.paypal.com/docs/classic/api/merchant/CreateRecurringPaymentsProfile_API_Operation_NVP/

    你的变量应该是这样的;

    $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 值,这会清理代码,因为您可以少写一行代码。

    【讨论】:

    • 变量变了,还是一样的问题
    猜你喜欢
    • 1970-01-01
    • 2015-05-27
    • 2012-12-03
    • 2017-09-17
    • 2012-03-05
    • 2015-10-04
    • 2017-07-12
    • 2015-05-22
    • 2023-04-02
    相关资源
    最近更新 更多