Django Paypal subscriptions

1.4k Views Asked by At

Thanks to anyone who can help me answer this. I'm running a Django e-learning service that requires a one-time payment subscription that lasts 90 days. I have used django-paypal to integrate my payment. I use IPN (Instant Payment Notification) on Website Payments Standard as my main mode of payment.

The question -- on receiving the IPN signal payment_was_successful, I signal the following permission:

def purchase_success(sender, **kwargs):
    ipn_obj = sender
    student = User.objects.get(username=str(ipn_obj.custom))
    permission = Permission.objects.get(name="Subscribed")
    student.user_permissions.add(permission)
payment_was_successful.connect(purchase_success)

I am trying to figure out how to "expire" the subscription in 90 days automatically. i.e.:

permission - Permission.objects.get(name="Subscribed")
student.user_permissions.remove(permission)
1

There are 1 best solutions below

0
On

No tested but from what I know, it might work.

Paypal can handle subscriptions for you: https://github.com/johnboxall/django-paypal/blob/master/README.md#using-paypal-payments-standard-with-subscriptions

"p3": 90,                          # duration of each unit (depends on unit)
"t3": "D",                         # duration unit ("D for Day")

Your signal will probably not be payment_was_successful but be one of these:

subscription_cancel - Sent when a subscription is cancelled.
subscription_eot - Sent when a subscription expires.
subscription_modify - Sent when a subscription is modified.
subscription_signup - Sent when a subscription is created.

Good luck, I've found django-paypal quite confusing!