Paypal 为定期付款设置无限周期

Mis*_*lad 4 php payment sdk paypal recurring

我正在尝试为我的移动应用程序集成 Paypal 定期付款。到目前为止,我设法使用https://github.com/paypal/PayPal-PHP-SDK在各种 PHP 应用程序上实现 Paypal 付款,但这是我第一次实现定期付款

我正在尝试使用以下代码为计费计划构建付款:

        $paymentDefinition = new PaymentDefinition();
        $paymentDefinition->setName('Mobile App subscription')
            ->setType('REGULAR')
            ->setFrequency('Month')
            ->setFrequencyInterval("1")
            ->setCycles("1")
            ->setAmount(
                new Currency(
                    array(
                        'value' => 50, 
                        'currency' => 'USD'
                    )
                )
            );
Run Code Online (Sandbox Code Playgroud)

从 Paypal 文档中,我了解到“setCycles”应设置为 0 以进行无限制订阅。使用 PHP SDK 将其设置为 0 会返回 400 错误。

一切看起来都很好,我收到了第一笔付款,但我不确定将 Cycle 设置为“1”是否会完成我正在寻找的工作。

Jam*_*rry 5

我遇到了同样的问题,我的解决方案是完全删除 setCylcles,请参阅此处的计划和付款定义类的示例:

$plan = new Plan();
    $plan->setName('Some example name')
        ->setDescription('A short description of the plan')
        ->setType('INFINITE');

$paymentDefinition = new PaymentDefinition();
    $paymentDefinition->setName('Regular Payments')
        ->setType('REGULAR')
        ->setFrequency('Month')
        ->setFrequencyInterval("1")
        ->setAmount(new Currency(array('value' => 100, 'currency' => 'USD')));enter code here
Run Code Online (Sandbox Code Playgroud)