Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Use authorizenet field

Michal Ociepkafabb2c3e358e
diff --git a/order/templates/order/payment.html b/order/templates/order/payment.html
index a697165f58..b16c63b298 100644
--- a/order/templates/order/payment.html
+++ b/order/templates/order/payment.html
@@ -12,8 +12,7 @@
<div class="control-group name required">
<label class="control-label">Expiry date</label>
<div class="controls controls-row">
- {{ form.expiration_month }}
- {{ form.expiration_year }}
+ {{ form.expiration }}
</div>
</div>
{{ form.cvv2|as_bootstrap }}
diff --git a/payment/forms.py b/payment/forms.py
index 7f083a2c96..c3cefe396f 100644
--- a/payment/forms.py
+++ b/payment/forms.py
@@ -1,9 +1,10 @@
from .fields import CreditCardExpirationYearField, CreditCardNumberField
+from authorizenet.fields import CreditCardExpiryField
+from datetime import date
from django import forms
from django.core import validators
from django.utils.translation import ugettext_lazy as _
from payment.fields import CreditCardExpirationMonthField
-from datetime import date
CVV_VALIDATOR = validators.RegexValidator('^[0-9]{1,4}$',
_('Enter a valid security number.'))
@@ -13,20 +14,6 @@ class PaymentForm(forms.Form):
name = forms.CharField(label=_('Name on Credit Card'), max_length=128)
number = CreditCardNumberField(label=_('Card Number'), max_length=32,
required=True)
- expiration_year = CreditCardExpirationYearField(label=_('Exp. date'))
- expiration_month = CreditCardExpirationMonthField(label=_('Exp. date'))
+ expiration = CreditCardExpiryField()
cvv2 = forms.CharField(validators=[CVV_VALIDATOR], required=False,
label=_('CVV2 Security Number'), max_length=4)
-
- def clean(self):
- cleaned_data = super(PaymentForm, self).clean()
- month = cleaned_data.get('expiration_month')
- year = cleaned_data.get('expiration_year')
- try:
- expiration = date(int(year), int(month), 01)
- except ValueError:
- raise forms.ValidationError(_('Enter a valid value.'))
- if expiration < date.today():
- raise forms.ValidationError(_('This credit card has '
- 'already expired'))
- return cleaned_data