The payment form model is a special model used to both validate payment parameters and pass them to a payment gateway in a way that is expected by the gateway.
When returning after a validation error a paymentForm
variable will be available to the template and will be set to an instance of craft/commerce/models/payments/BasePaymentForm
.
Each gateway can use it's own payment form, however it must extend craft/commerce/models/payments/BasePaymentForm
. There are generic models available for use, specifically for gateways passing around credit card information, but you should refer to the documentation of the pugin providing the gateway to see if it uses a it's own model or not.
Generally, you shouldn't be concerned with the specific type of the payment form model being used, as that is provided by the gateway and does not need to be configured.
The follow attributes make up the default payment form model for gateways handling credit card information
If a token is found on the payment form, no validation of other field is performed and the data is ignored.
The token represents a pre validated credit card and is provided by a gateways client side javascript library. For example Stripe.js
The first name of the customers credit card.
Validation: required field
The last name of the customers credit card.
Validation: required field
Integer only number representing the month of credit card expiry.
Validation: required field, Min:1 Max: 12
Integer only number representing the year of credit card expiry.
Validation: required field, Min: current year: 2016 Max: Current year plus 12 e.g 2028
Integer only number found on the back side of the card for security.
Validation: minimum char length: 3, maximum char length: 4
The credit card number itself.
Validation: Luhn algorithm
A flag indicating whether 3D Secure authentication is being performed for the transaction.
This property does not get validated.