def subscription_pro(request, object_id, queryset=Subscription.objects.filter(price__gt=0)): """Paypal Pro payment method """ s = get_object_or_404(queryset, id=object_id) domain = Site.objects.get_current().domain item = { "amt": s.price, "inv": "inventory", # unique tracking variable paypal "custom": "tracking", # custom tracking variable for you "cancelurl": 'http://%s%s' % (domain, reverse('subscription_cancel')), # Express checkout cancel url "returnurl": 'http://%s%s' % (domain, reverse('subscription_done')) } # Express checkout return url data = { "item": item, "payment_template": "subscription/payment.html", # template name for payment "confirm_template": "subscription/confirmation.html", # template name for confirmation "success_url": reverse('subscription_done') } # redirect location after success o = PaymentMethodFactory.factory('WebsitePaymentsPro', data=data, request=request) # We return o.proceed() just because django-paypal's PayPalPro returns HttpResponse object return o.proceed()
def subscription_detail(request, object_id, payment_method="standard"): FREE_SUBSCRIPTION_URL_NAME = getattr(settings, 'FREE_SUBSCRIPTION_URL_NAME', None) if FREE_SUBSCRIPTION_URL_NAME: return redirect(reverse(FREE_SUBSCRIPTION_URL_NAME)) s = get_object_or_404(Subscription, id=object_id) try: user = request.user.usersubscription_set.get( active=True) except UserSubscription.DoesNotExist: change_denied_reasons = None user = None else: change_denied_reasons = user.try_change(s) if change_denied_reasons: form = None else: get_paypal_extra_args.send(sender=None, user=user, subscription=s, extra_args={}) form = _paypal_form(s, request.user, upgrade_subscription=(user is not None) and (user.subscription != s)) try: s_us = request.user.usersubscription_set.get(subscription=s) except UserSubscription.DoesNotExist: s_us = None from subscription.providers import PaymentMethodFactory # See PROPOSALS section in providers.py if payment_method == "pro": domain = Site.objects.get_current().domain item = {"amt": s.price, "inv": "inventory", # unique tracking variable paypal "custom": "tracking", # custom tracking variable for you "cancelurl": 'http://%s%s' % (domain, reverse('subscription_cancel')), # Express checkout cancel url "returnurl": 'http://%s%s' % (domain, reverse('subscription_done'))} # Express checkout return url data = {"item": item, "payment_template": "payment.html", # template name for payment "confirm_template": "confirmation.html", # template name for confirmation "success_url": reverse('subscription_done')} # redirect location after success o = PaymentMethodFactory.factory('WebsitePaymentsPro', data=data, request=request) # We return o.proceed() just because django-paypal's PayPalPro returns HttpResponse object return o.proceed() elif payment_method == 'standard': template_vars = {'object': s, 'usersubscription': s_us, 'change_denied_reasons': change_denied_reasons, 'form': form, 'cancel_url': cancel_url} template = 'subscription/subscription_detail.html' return render(request, template, template_vars) else: #should never get here raise Http404
def subscription_detail(request, object_id, payment_method="standard"): FREE_SUBSCRIPTION_URL_NAME = getattr(settings, 'FREE_SUBSCRIPTION_URL_NAME', None) if FREE_SUBSCRIPTION_URL_NAME: return redirect(reverse(FREE_SUBSCRIPTION_URL_NAME)) s = get_object_or_404(Subscription, id=object_id) try: user = request.user.usersubscription_set.get( active=True, subscription = s) except UserSubscription.DoesNotExist: change_denied_reasons = None user = None else: change_denied_reasons = user.try_change(s) if change_denied_reasons: form = None else: get_paypal_extra_args.send(sender=None, user=user, subscription=s, extra_args={}) form = _paypal_form(s, request.user, upgrade_subscription=(user is not None) and (user.subscription != s)) try: s_us = request.user.usersubscription_set.get(subscription=s) except UserSubscription.DoesNotExist: s_us = None from subscription.providers import PaymentMethodFactory # See PROPOSALS section in providers.py if payment_method == "pro": domain = Site.objects.get_current().domain item = {"amt": s.price, "inv": "inventory", # unique tracking variable paypal "custom": "tracking", # custom tracking variable for you "cancelurl": 'http://%s%s' % (domain, reverse('subscription_cancel')), # Express checkout cancel url "returnurl": 'http://%s%s' % (domain, reverse('subscription_done'))} # Express checkout return url data = {"item": item, "payment_template": "payment.html", # template name for payment "confirm_template": "confirmation.html", # template name for confirmation "success_url": reverse('subscription_done')} # redirect location after success o = PaymentMethodFactory.factory('WebsitePaymentsPro', data=data, request=request) # We return o.proceed() just because django-paypal's PayPalPro returns HttpResponse object return o.proceed() elif payment_method == 'standard': template_vars = {'object': s, 'usersubscription': s_us, 'change_denied_reasons': change_denied_reasons, 'form': form, 'cancel_url': cancel_url} template = 'subscription/subscription_detail.html' return render(request, template, template_vars) else: #should never get here raise Http404
def subscription_detail(request, object_id, payment_method="standard"): s = get_object_or_404(Subscription, id=object_id) try: us = request.user.usersubscription_set.get( active=True) except UserSubscription.DoesNotExist: change_denied_reasons = None us = None else: change_denied_reasons = us.try_change(s) if change_denied_reasons: form = None else: form = _paypal_form(s, request.user, upgrade_subscription=(us is not None) and (us.subscription<>s)) try: s_us = request.user.usersubscription_set.get(subscription=s) except UserSubscription.DoesNotExist: s_us = None from subscription.providers import PaymentMethodFactory # See PROPOSALS section in providers.py if payment_method == "pro": domain = Site.objects.get_current().domain item = {"amt": s.price, "inv": "inventory", # unique tracking variable paypal "custom": "tracking", # custom tracking variable for you "cancelurl": 'http://%s%s' % (domain, reverse('subscription_cancel')), # Express checkout cancel url "returnurl": 'http://%s%s' % (domain, reverse('subscription_done'))} # Express checkout return url data = {"item": item, "payment_template": "payment.html", # template name for payment "confirm_template": "confirmation.html", # template name for confirmation "success_url": reverse('subscription_done')} # redirect location after success o = PaymentMethodFactory.factory('WebsitePaymentsPro', data=data, request=request) # We return o.proceed() just because django-paypal's PayPalPro returns HttpResponse object return o.proceed() elif payment_method == 'standard': return direct_to_template(request, template='subscription/subscription_detail.html',\ extra_context=dict(object=s, usersubscription=s_us,\ change_denied_reasons=change_denied_reasons,\ form=form, cancel_url=cancel_url)) else: #should never get here raise Http404
def subscription_pro(request, object_id, queryset=Subscription.objects.filter(price__gt=0)): """Paypal Pro payment method """ s = get_object_or_404(queryset, id=object_id) domain = Site.objects.get_current().domain item = {"amt": s.price, "inv": "inventory", # unique tracking variable paypal "custom": "tracking", # custom tracking variable for you "cancelurl": 'http://%s%s' % (domain, reverse('subscription_cancel')), # Express checkout cancel url "returnurl": 'http://%s%s' % (domain, reverse('subscription_done'))} # Express checkout return url data = {"item": item, "payment_template": "subscription/payment.html", # template name for payment "confirm_template": "subscription/confirmation.html", # template name for confirmation "success_url": reverse('subscription_done')} # redirect location after success o = PaymentMethodFactory.factory('WebsitePaymentsPro', data=data, request=request) # We return o.proceed() just because django-paypal's PayPalPro returns HttpResponse object return o.proceed()
def get(self, request, object_id, **kwargs): payment_method = kwargs.get('payment_method', 'standard') from subscription.providers import PaymentMethodFactory # See PROPOSALS section in providers.py if payment_method == "pro": domain = Site.objects.get_current().domain item = {"amt": s.price, "inv": "inventory", # unique tracking variable paypal "custom": "tracking", # custom tracking variable for you "cancelurl": 'http://%s%s' % (domain, reverse('subscription_cancel')), # Express checkout cancel url "returnurl": 'http://%s%s' % (domain, reverse('subscription_done'))} # Express checkout return url data = {"item": item, "payment_template": "payment.html", # template name for payment "confirm_template": "confirmation.html", # template name for confirmation "success_url": reverse('subscription_done')} # redirect location after success o = PaymentMethodFactory.factory('WebsitePaymentsPro', data=data, request=request) # We return o.proceed() just because django-paypal's PayPalPro returns HttpResponse object return o.proceed() return super(SubscriptionDetail, self).get(self, request, object_id, **kwargs)
def get(self, request, object_id, **kwargs): payment_method = kwargs.get('payment_method', 'standard') from subscription.providers import PaymentMethodFactory # See PROPOSALS section in providers.py if payment_method == "pro": domain = Site.objects.get_current().domain item = {"amt": s.price, "inv": "inventory", # unique tracking variable paypal "custom": "tracking", # custom tracking variable for you "cancelurl": 'http://%s%s' % (domain, reverse('subscription_cancel')), # Express checkout cancel url "returnurl": 'http://%s%s' % (domain, reverse('subscription_done'))} # Express checkout return url data = {"item": item, "payment_template": "payment.html", # template name for payment "confirm_template": "confirmation.html", # template name for confirmation "success_url": reverse('subscription_done')} # redirect location after success o = PaymentMethodFactory.factory('WebsitePaymentsPro', data=data, request=request) # We return o.proceed() just because django-paypal's PayPalPro returns HttpResponse object return o.proceed() return super(SubscriptionDetail, self).get(self, request, object_id, **kwargs)
def subscription_detail(request, object_id, payment_method="standard"): s = get_object_or_404(Subscription, id=object_id) try: us = request.user.usersubscription_set.get( active=True) except UserSubscription.DoesNotExist: change_denied_reasons = None us = None else: change_denied_reasons = us.try_change(s) if change_denied_reasons: form = None else: extra_args = {} get_paypal_extra_args.send(sender=None, user=request.user, subscription=s, extra_args={}) form = _paypal_form(s, request.user, upgrade_subscription=(us is not None) and (us.subscription<>s)) try: s_us = request.user.usersubscription_set.get(subscription=s) except UserSubscription.DoesNotExist: s_us = None from subscription.providers import PaymentMethodFactory # See PROPOSALS section in providers.py if payment_method == "pro": domain = Site.objects.get_current().domain item = {"amt": s.price, "inv": "inventory", # unique tracking variable paypal "custom": "tracking", # custom tracking variable for you "cancelurl": 'http://%s%s' % (domain, reverse('subscription_cancel')), # Express checkout cancel url "returnurl": 'http://%s%s' % (domain, reverse('subscription_done'))} # Express checkout return url data = {"item": item, "payment_template": "payment.html", # template name for payment "confirm_template": "confirmation.html", # template name for confirmation "success_url": reverse('subscription_done')} # redirect location after success o = PaymentMethodFactory.factory('WebsitePaymentsPro', data=data, request=request) # We return o.proceed() just because django-paypal's PayPalPro returns HttpResponse object return o.proceed() elif payment_method == 'standard': return render_to_response('subscription/subscription_detail.html', {"object":s, "usersubscription": s_us, 'change_denied_reasons': change_denied_reasons, "current": s_us and (s == s_us.subscription), "change_denied_reasons": change_denied_reasons, "form":form, "cancel_url": cancel_url, "test": settings.PAYPAL_TEST, 'image_url': "https://www.paypal.com/en_US/i/btn/btn_unsubscribe_LG.gif" }, context_instance=RequestContext(request), ) else: #should never get here raise Http404