All subscriptions that are created appear with the status: EXPIRED

AndresBB
Contributor
Contributor

Hi!!

I'm trying to implement a subscription system in my app. using the paypal button from the library: @paypal/react-paypal-js. When the user clicks the button, I first make a fetch to my backend where depending on the options the user has chosen, I will create a personalized plan. Then I send the plan id to the frontend where I create a subscription from the plan id: with the following code:

 

.then((responseData) => { return actions.subscription.create({ 'plan_id': responseData.planID, "subscriber": { "email_address": userInfo.email, "name": { "given_name": userInfo.username, "surname": userInfo.uid } } }) });

 

however. When I receive the onAprove all the subscriptions appear with the status: EXPIRED. I don't understand why this appears and not status:ACTIVE. I already have a webhook that listens when there was a PAYMENT.SALE.COMPLETED and it seems that the payment was correct and at the interface level it also seems that the payment was accepted correctly.

Login to Me Too
1 REPLY 1

AndresBB
Contributor
Contributor

I have found the problem. The reason why it appeared as expired is because the total_cycles when creating the plan from my server had it by default at 1, which means that as soon as the client pays it expires because there are no more cycles to bill. , therefore if you want it to be a subscription with infinite cycles you must assign the value of zero like this: total_cycles: 0.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.