1

我正在使用 authorize.net 进行月度订阅计划,试用期使用客户资料 API。参考:https ://developer.authorize.net/api/reference/#recurring-billing-create-a-subscription-from-customer-profile 我想设置订阅试用期的间隔。在 api 中,我无法与试用期的间隔相关联。场景:如果我在 2019 年 1 月 1 日订阅,那么用户将获得 7 天的第一个试用期。因此,试用结束日期必须是 2019 年 8 月 1 日,金额为 0。那么实际订阅结束日期必须是 2019 年 8 月 2 日(试用期后 1 个月)和 100 订阅金额。

$subscription = new AnetAPI\ARBSubscriptionType();
$subscription->setName("Sample Subscription");

$interval = new AnetAPI\PaymentScheduleType\IntervalAType();
$interval->setLength('30');
$interval->setUnit("days");

$paymentSchedule = new AnetAPI\PaymentScheduleType();
$paymentSchedule->setInterval($interval);
$paymentSchedule->setStartDate(new DateTime('2019-01-01'));
$paymentSchedule->setTotalOccurrences("9999");
$paymentSchedule->setTrialOccurrences("1");

$subscription->setPaymentSchedule($paymentSchedule);
$subscription->setAmount(100);
$subscription->setTrialAmount("0.00");

使用什么参数我可以在 authorize.net 中传递试用间隔?请帮我解决这个问题。提前致谢。

4

1 回答 1

2

这不是 Authorize.Net 条款中的试用期。这只是开始订阅的延迟。您需要做的就是将开始日期设置为一周后,然后创建一个为期一个月的正常订阅。这里不需要特殊的代码或参数。

所以在你的具体例子中改变

 $paymentSchedule->setStartDate(new DateTime('2019-01-01'));

$paymentSchedule->setStartDate(new DateTime('2019-01-08'));

或者,如果您希望它动态完成:

$paymentSchedule->setStartDate(new DateTime('+7 days'));
于 2019-01-24T11:48:49.400 回答