Johnny
Johnny

Reputation: 9984

PayPal Subscription API for auto-renewed Subscriptions

I have a subscription system built where a user signs up for a 7 day free trial and then after 7 days they are charged for the month. I then have the plan cycles in the paypal API set to 1, so users can cancel at any time. My understanding of this previously was that after the first month, paypal would auto-renew the subscription with the same subscription ID, but the subscription ID is now no longer valid after this first month.

I assume then that PayPal either renews under a different PayPal subscription ID and removes the old one, or the auto-renewal isn't available for PayPal? The first one seems more likely, and if it is, how do I track a renewed subscription ID?

Or is there a better way for me to do this? To be clear, what I am trying to do is have a 7 day free trial, and then a monthly subscription which users can cancel at any time. I am storing the subscription ID in a database so I can check if it is still valid when the user logs in. This is why I noticed the problem.

Upvotes: 0

Views: 777

Answers (1)

Preston PHX
Preston PHX

Reputation: 30477

You want the "regular" period to have a frequency with an interval_unit of "month" and an interval_count of 1.

If you have the total_cycles set to 1, the subscription will only cycle once and then expire. There is no auto renewal. You want the total_cycles to be 0 for no expiration.

See the billing_cycle documentation at https://developer.paypal.com/docs/api/subscriptions/v1/#definition-billing_cycle

Upvotes: 4

Related Questions