django-plans icon indicating copy to clipboard operation
django-plans copied to clipboard

Using django-plans with recurring payments

Open amitjindal opened this issue 7 years ago • 8 comments
trafficstars

Hi, thanks for a great module. I installed and played with the demo and this works beautifully with what I am trying to do. However I need this for a subscription model where someone who is in a plan is on monthly or yearly payments. So I need to generate invoices for that on the same frequency.

Is there a built-in way to handle such payments?

Thanks Amit

amitjindal avatar Dec 20 '17 03:12 amitjindal

@amitjindal Let me maybe describe what was the architectural idea behind django-plans and then you will be able to answer yourself if this fits your needs.

In django-plans each user has object UserPlan that describes which type of plan did he purchased and what is the expiration date of this plan. System is automatically checking when this expiration date happens and sends some mailing before. User is asked to manualy create new order for next period, this will generate Order Confirmation document, and then once paid user gets updated UserPlan with additional expiration time.

There is one extra thing, django-plans have also support different periods for plans, so you can define anything you want like 30 days or 365 days plan extend.

At this moment there is no support for automatic subscriptions, however I can easily see how this could be implemented as some feature. Here are my tips:

  • I would add a field to UserPlan automatic_renewal = True/False
  • I would add a field to PlanPricing definiton default_for_automatic_renewal=True/False
  • Add setting PLANS_AUTOMATIC_RENEWAL=True/False that would set the default state of the field in UserPlan when new user is created.

And then I would add an extra logic that when it sees that account is just going to be expired it first checks what kind of account it is (automatic renewal off or on) and then decide if its off - send email reminding customer to pay manualy, if its on it will search for PlanPricing matching user's current Plan that have attribute default_for_automatic_renewal=True.

That should do the trick and still be as flexible as possible.

cypreess avatar Dec 20 '17 08:12 cypreess

@cypreess Awesome. Thank you so much. I will try to figure this out and ask if I need help. I am also making changes to handle multi-tenant support since you use User objects in models and in multitenant the user is not in shared database.

Really appreciate your quick reply and help.

Regards Amit

amitjindal avatar Dec 20 '17 10:12 amitjindal

@amitjindal were you able to get anywhere with this ? Would love to know if you could get it done

Alir3z4 avatar May 18 '18 16:05 Alir3z4

@Alir3z4 Nope. I didn't end up completing this and its still on back burner. It seemed much more complex to handle multi-tenancy with this.

However I do home to get back to this sometime soon.

amitjindal avatar May 19 '18 06:05 amitjindal

Oh, I see. Thanks for letting us know about the result.

I leave this issue open for future discussion and possible implementation of this future.

Alir3z4 avatar May 19 '18 10:05 Alir3z4

#100 This pull has added is_recurring flag to mark orders as recurring and one can easily use this field to do tasks accordingly.

anuj9196 avatar May 29 '19 11:05 anuj9196

Hi,

I started with experimental implementation of recurring payments with the django-paypal. I have written the code in the django-plans-paypal as connector to the django-plans.

Currently it doesn't need any support from the django-plans to have basic functionality. It simply creates new Order (uses the existing for first payment) and calls order.complete_order() when the succesfull PayPal IPN notification arrives.

Of course I would need to give the user information about state of his/hers subscribtion, so I will have to add some fields like those suggested by @cypreess and @anuj9196. I will try to make PR from this, when my implementation progress.

PetrDlouhy avatar Jan 09 '20 06:01 PetrDlouhy

Please review recurring code in PR #106

PetrDlouhy avatar Apr 13 '20 15:04 PetrDlouhy