From 1f85273fd01bb311aaabda3762ecd6bc087d7e96 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 23 Dec 2017 22:59:16 +0100 Subject: [PATCH 1/2] Set cardholder_name field for UserBillingAddressForm in digital glarus membership payment post --- digitalglarus/views.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/digitalglarus/views.py b/digitalglarus/views.py index 87c1ccd2..2c438f04 100644 --- a/digitalglarus/views.py +++ b/digitalglarus/views.py @@ -376,6 +376,10 @@ class MembershipPaymentView(LoginRequiredMixin, IsNotMemberMixin, FormView): return render(request, self.template_name, context) charge = charge_response.get('response_object') + if 'source' in charge: + cardholder_name = charge['source']['name'] + else: + cardholder_name = customer.user.email # Create Billing Address billing_address = form.save() @@ -383,7 +387,8 @@ class MembershipPaymentView(LoginRequiredMixin, IsNotMemberMixin, FormView): # Create Billing Address for User if he does not have one if not customer.user.billing_addresses.count(): data.update({ - 'user': customer.user.id + 'user': customer.user.id, + 'cardholder_name': cardholder_name }) billing_address_user_form = UserBillingAddressForm(data) billing_address_user_form.is_valid() From 10bc05f7004d7a7fed32a509a9b27695b85e1bb6 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 23 Dec 2017 23:07:53 +0100 Subject: [PATCH 2/2] User customer's name instead of email for cardholder_name if not provided --- digitalglarus/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/digitalglarus/views.py b/digitalglarus/views.py index 2c438f04..96983d9b 100644 --- a/digitalglarus/views.py +++ b/digitalglarus/views.py @@ -379,7 +379,7 @@ class MembershipPaymentView(LoginRequiredMixin, IsNotMemberMixin, FormView): if 'source' in charge: cardholder_name = charge['source']['name'] else: - cardholder_name = customer.user.email + cardholder_name = customer.user.name # Create Billing Address billing_address = form.save()