X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/8887547a016bbf665ffc4175346f655f0dfa63fb..d679452e8cede72656beb1e14b48a1b3e82e79c0:/src/paypal/rest.py?ds=inline diff --git a/src/paypal/rest.py b/src/paypal/rest.py index 1e0811b10..9d9f45ab9 100644 --- a/src/paypal/rest.py +++ b/src/paypal/rest.py @@ -11,7 +11,7 @@ from django.core.urlresolvers import reverse from django.utils import timezone from paypalrestsdk import BillingPlan, BillingAgreement, ResourceNotFound from django.conf import settings -from .models import BillingPlan as BillingPlanModel +from .models import BillingPlan as BillingPlanModel, BillingAgreement as BillingAgreementModel paypalrestsdk.configure(settings.PAYPAL_CONFIG) @@ -114,5 +114,13 @@ def check_agreement(agreement_id): return a.state == 'Active' +def user_is_subscribed(user): + try: + agreement = BillingAgreementModel.objects.get(user=user) + except BillingAgreementModel.DoesNotExist: + return False + return agreement.check_agreement() + + def execute_agreement(token): return BillingAgreement.execute(token)