I am trying to integrate the Paypal recurring payments for my mobile app. So far I managed to implement Paypal payments on various PHP apps using using https://github.com/paypal/PayPal-PHP-SDK, but this is the first time I am implementing recurring payments
I am trying to build the payment for the billing plan using the following code:
$paymentDefinition = new PaymentDefinition();
$paymentDefinition->setName('Mobile App subscription')
->setType('REGULAR')
->setFrequency('Month')
->setFrequencyInterval("1")
->setCycles("1")
->setAmount(
new Currency(
array(
'value' => 50,
'currency' => 'USD'
)
)
);
From the Paypal documentation, I understood that "setCycles" should be set to 0 for unlimited subscriptions. Setting it to 0 using the PHP SDK returns a 400 error.
Everything looks fine and I am receiving the first payment, but I am not sure that setting the Cycle to "1" will do the job I am looking for.
I had the same problem, my solution was to just remove the setCylcles altogther, see here an example of how the plan and payment definition classes should look:
$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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With