Save address form in payment post itself
This commit is contained in:
parent
825e716625
commit
c393902396
1 changed files with 4 additions and 4 deletions
|
@ -525,6 +525,8 @@ class PaymentOrderView(FormView):
|
||||||
token=token,
|
token=token,
|
||||||
customer_name=user_name)
|
customer_name=user_name)
|
||||||
|
|
||||||
|
billing_address = address_form.save()
|
||||||
|
request.session["billing_address_id"] = billing_address.id
|
||||||
request.session['billing_address_data'] = address_form.cleaned_data
|
request.session['billing_address_data'] = address_form.cleaned_data
|
||||||
request.session['user'] = this_user
|
request.session['user'] = this_user
|
||||||
# Get or create stripe customer
|
# Get or create stripe customer
|
||||||
|
@ -546,11 +548,10 @@ class PaymentOrderView(FormView):
|
||||||
if vat_number:
|
if vat_number:
|
||||||
validate_result = validate_vat_number(
|
validate_result = validate_vat_number(
|
||||||
stripe_customer_id=request.session['customer'],
|
stripe_customer_id=request.session['customer'],
|
||||||
vat_number=address_form.cleaned_data.get('vat_number'),
|
billing_address_id=billing_address.id
|
||||||
country=address_form.cleaned_data.get("country").strip()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if 'response_object' in validate_result:
|
if 'error' in validate_result and validate_result['error']:
|
||||||
messages.add_message(
|
messages.add_message(
|
||||||
request, messages.ERROR, validate_result["error"],
|
request, messages.ERROR, validate_result["error"],
|
||||||
extra_tags='vat_error'
|
extra_tags='vat_error'
|
||||||
|
@ -558,7 +559,6 @@ class PaymentOrderView(FormView):
|
||||||
return HttpResponseRedirect(
|
return HttpResponseRedirect(
|
||||||
reverse('datacenterlight:payment') + '#vat_error'
|
reverse('datacenterlight:payment') + '#vat_error'
|
||||||
)
|
)
|
||||||
|
|
||||||
request.session["vat_validation_status"] = validate_result["status"]
|
request.session["vat_validation_status"] = validate_result["status"]
|
||||||
request.session["vat_validated_on"] = validate_result["validated_on"]
|
request.session["vat_validated_on"] = validate_result["validated_on"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue