Learn how to collect a shopper's payment details using your own payment form.
Before you can make a payment with our API integration, you need to collect any required payment details from your shopper. Here we describe how to do this by building your own payment form.
This guide assumes that you've already completed Step 1 of our API integration guide, and have presented a list of payment methods to the shopper.
To collect payment details from the shopper, your payment form can be either:
A hard-coded form is quicker to implement, but the payment details you need to collect from a shopper can change. You should regularly poll the
/paymentMethodsendpoint to check for any updates to required payment details. We recommend this approach if you're only working with a small number of payment methods or countries.
Dynamically generated: For each transaction, you make a
/paymentMethodscall to determine the payment details you need to collect. Then use the response to generate a form that collects them from the shopper.
This takes more time to implement, but ensures that the required payment details you collect from the shopper are up-to-date.
After you decide which form you will build, follow the steps below to:
- Determine which shopper details you need to collect in your form. These are different for each payment method.
Step 1: Determine required shopper details
To determine what payment details you need to collect from the shopper:
countryCode: The shopper's country.
valueof the payment.
A list of available
paymentMethodswill be returned in the response. Most of these will have a
detailsarray of each payment method to determine what you need to collect from the shopper:
key: Shopper detail you need to collect using your payments form.
type: Input type for collecting the payment detail from the shopper:
select A list displaying the options specified within the
itemsarray. Present each
namein this array to the shopper.
tel Telephone number. text Generic string.
If a payment method does not have a
detailsarray, you do not need to collect any shopper details in your form.
In the example below, for SEPA Direct Debit, you'd use text fields to collect:
sepa.ownerName: Name on the shopper's bank account.
sepa.ibanNumber: IBAN number of this account.
Collect shopper details with Secured FieldsStep 2:
When the shopper enters their card details on your website, Secured Fields collects the sensitive data, and creates an encrypted version that you can safely transmit when you make the payment.
If you are PCI Level 1 or 2 certified you can alternatively collect and submit raw card data. See Collecting raw card data for more information.
To integrate Secured Fields in your payment form:
Include the following script in the
<head>of your payments page:
This will embed the Secured Fields library.
<body>of your payments page, with the following
encryptedCardNumber: Card number.
- For card expiration:
- Collect as separate fields:
encryptedExpiryMonth: Card expiry month.
encryptedExpiryYear: Card expiry year.
- Collect as a single field:
encryptedExpiryDate: Card expiry for both month and year.
- Collect as separate fields:
encryptedSecurityCode: Card security code.
These will render as iframes, where the shopper can securely enter their card details.
Add the following code to the bottom of the
originKey: Your Origin Key. To find out how to generate one, see How to get an Origin Key.
When the shopper enters their card details, Secured Fields will perform validation on the card details. When the shopper submits the payment, their card details are replaced by encrypted values. These are added to hidden
<input>fields in the
<div>that holds the
Loop through and collect the encrypted card details from the corresponding
data-csevalues. You'll use these to make the payment.
To configure how Secured Fields render in your payment form, see Configure Secured Fields.
Make a payment
Make a payment with the shopper's payment details.
Add payment methods
Learn about payment methods and how to integrate them.