-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpayment_form.py
More file actions
53 lines (47 loc) · 1.41 KB
/
payment_form.py
File metadata and controls
53 lines (47 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Local imports
import datetime
# External imports
from flask_wtf import FlaskForm
from wtforms import StringField, IntegerField, SubmitField, DateField, DecimalField
from wtforms.validators import DataRequired, Length, Optional
from wtforms_components import DateTimeField, DateRange
class PaymentForm(FlaskForm):
"""Flask Payment Form"""
# Field types followed by label and data validators
CreditCardNumber = StringField(
'Credit Card Number',
[
DataRequired(),
Length(min=13, max=16, message="Invalid Credit Card Number")
]
)
CardHolder = StringField(
'Credit Card Holder',
[
DataRequired(),
Length(min=5,max=49, message="Invalid Length")
]
)
ExpirationDate = DateField( 'Expiry Date (YYYY-MM-DD)',
[
DataRequired(),
DateRange(
min=datetime.datetime.today().date(),
max=datetime.date(2030, 12, 31)
)
],
format='%Y-%m-%d'
)
SecurityCode = StringField('Security Code',
[
Optional(),
Length(min=3, max=3, message="Length should be 3 digits")
]
)
Amount = DecimalField( 'Amount',
[
DataRequired()
],
places=2
)
submit = SubmitField('Submit')