Django Paypal订阅

问题描述:

感谢任何人可以帮助我回答这个问题。我正在运行一项Django电子学习服务,需要一次性付款订阅,持续90天。我用django-paypal来整合我的付款。我使用网站付款标准中的IPN(即时付款通知)作为我的主要付款方式。Django Paypal订阅

的问题 - 在收到IPN信号payment_was_successful,I信号以下权限:

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) 

我试图找出如何在90天内“过期”的订阅自动。即:

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

将“subscription_date”添加到相关模型中,并检查相应的模型?这也使您能够:a)监控订阅费率和模式; b)如果稍后想要提供不同的长度,稍后添加另一列以跟踪'subscription_type'或'subscription_duration'。 – elithrar 2012-08-06 02:27:14

+0

耶谢谢。我正在考虑这样做。但是我不得不打电话给我检查日期的函数吗?有没有办法自动做到这一点? – user1578053 2012-08-06 06:38:35

+0

你不会在django项目中运行。此任务应该每天在您的所有用户上运行,以确定订阅是否结束。 – 2012-08-06 07:28:40

没有测试,但从我所知道的,它可能工作。

贝宝可以处理订阅内容: 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") 

你的信号可能不会payment_was_successful但是是其中之一:

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. 

祝你好运,我发现Django的贝宝很混乱!