Adds verification data to the payments form.

This commit is contained in:
Christopher Neugebauer 2016-09-21 19:07:10 +10:00
parent 8334d40fe9
commit 830864df2c

View file

@ -1,9 +1,12 @@
from functools import partial from functools import partial
from django import forms from django import forms
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.forms import widgets from django.forms import widgets
from django.utils import timezone
from django_countries import countries from django_countries import countries
from django_countries.fields import LazyTypedChoiceField from django_countries.fields import LazyTypedChoiceField
@ -66,21 +69,28 @@ class CreditCardForm(forms.Form):
number = forms.CharField( number = forms.CharField(
required=False, required=False,
label="Credit card Number",
help_text="Your credit card number, with or without spaces.",
max_length=255, max_length=255,
widget=secure_striped(widgets.TextInput)(), widget=secure_striped(widgets.TextInput)(),
) )
exp_month = forms.CharField( exp_month = forms.IntegerField(
required=False, required=False,
max_length=2, label="Card expiry month",
min_value=1,
max_value=12,
widget=secure_striped(widgets.TextInput)(), widget=secure_striped(widgets.TextInput)(),
) )
exp_year = forms.CharField( exp_year = forms.IntegerField(
required=False, required=False,
max_length=4, label="Card expiry year",
help_text="The expiry year for your card in 4-digit form",
min_value=lambda: timezone.now().year,
widget=secure_striped(widgets.TextInput)(), widget=secure_striped(widgets.TextInput)(),
) )
cvc = forms.CharField( cvc = forms.CharField(
required=False, required=False,
min_length=3,
max_length=4, max_length=4,
widget=secure_striped(widgets.TextInput)(), widget=secure_striped(widgets.TextInput)(),
) )
@ -93,34 +103,43 @@ class CreditCardForm(forms.Form):
name = forms.CharField( name = forms.CharField(
required=True, required=True,
label="Cardholder name",
help_text="The cardholder's name, as it appears on the credit card",
max_length=255, max_length=255,
widget=striped(widgets.TextInput), widget=striped(widgets.TextInput),
) )
address_line1 = forms.CharField( address_line1 = forms.CharField(
required=True, required=True,
label="Cardholder account address, line 1",
max_length=255, max_length=255,
widget=striped(widgets.TextInput), widget=striped(widgets.TextInput),
) )
address_line2 = forms.CharField( address_line2 = forms.CharField(
required=False, required=False,
label="Cardholder account address, line 2",
max_length=255, max_length=255,
widget=striped(widgets.TextInput), widget=striped(widgets.TextInput),
) )
address_city = forms.CharField( address_city = forms.CharField(
required=True, required=True,
label="Cardholder account city",
max_length=255, max_length=255,
widget=striped(widgets.TextInput), widget=striped(widgets.TextInput),
) )
address_state = forms.CharField( address_state = forms.CharField(
required=True, max_length=255, required=True,
max_length=255,
label="Cardholder account state or province",
widget=striped(widgets.TextInput), widget=striped(widgets.TextInput),
) )
address_zip = forms.CharField( address_zip = forms.CharField(
required=True, required=True,
max_length=255, max_length=255,
label="Cardholder account postal code",
widget=striped(widgets.TextInput), widget=striped(widgets.TextInput),
) )
address_country = LazyTypedChoiceField( address_country = LazyTypedChoiceField(
label="Cardholder account country",
choices=countries, choices=countries,
widget=striped(CountrySelectWidget), widget=striped(CountrySelectWidget),
) )