def update(request): user = request.user success_updating = False if request.method == 'POST': zebra_form = StripePaymentForm(request.POST) if zebra_form.is_valid(): customer = stripe.Customer.retrieve(user.stripe_id) customer.card = zebra_form.cleaned_data['stripe_token'] customer.save() profile = user.get_profile() profile.last_4_digits = zebra_form.cleaned_data['last_4_digits'] profile.stripe_customer_id = customer.id profile.save() success_updating = True else: zebra_form = StripePaymentForm() return render( request, 'marty/basic_update.html', { 'zebra_form': zebra_form, 'publishable': options.STRIPE_PUBLISHABLE, 'success_updating': success_updating, })
def update(request): user = request.user success_updating = False if request.method == 'POST': zebra_form = StripePaymentForm(request.POST) if zebra_form.is_valid(): customer = stripe.Customer.retrieve(user.stripe_id) customer.card = zebra_form.cleaned_data['stripe_token'] customer.save() profile = user.get_profile() profile.last_4_digits = zebra_form.cleaned_data['last_4_digits'] profile.stripe_customer_id = customer.id profile.save() success_updating = True else: zebra_form = StripePaymentForm() return render(request, 'marty/basic_update.html', { 'zebra_form': zebra_form, 'publishable': options.STRIPE_PUBLISHABLE, 'success_updating': success_updating, })
def manage_account(request): section = "admin" STRIPE_PUBLISHABLE = settings.STRIPE_PUBLISHABLE form = AccountForm(instance=request.account) if request.method == 'POST': zebra_form = StripePaymentForm(request.POST) if zebra_form.is_valid(): customer = request.account.stripe_customer customer.card = zebra_form.cleaned_data['stripe_token'] customer.save() account = request.account account.last_four = zebra_form.cleaned_data['last_4_digits'] account.stripe_customer_id = customer.id account.save() request.account = account request.account.update_account_status() else: zebra_form = StripePaymentForm() return locals()
def premium(request): me = request.user poet = me.get_profile() changes_saved = False if request.method == 'POST': zebra_form = StripePaymentForm(request.POST) if zebra_form.is_valid(): my_profile = request.user.get_profile() # stripe_customer = stripe.Customer.retrieve(my_profile.stripe_customer_id) # stripe_customer.card = zebra_form.cleaned_data['stripe_token'] # stripe_customer.save() # my_profile.last_4_digits = zebra_form.cleaned_data['last_4_digits'] # my_profile.stripe_customer_id = stripe_customer.id my_profile.premium_user = True my_profile.save() # Do something kind for the user changes_saved = True else: zebra_form = StripePaymentForm() return locals()