--- seo: title: Checkout form and token creation description: Learn how to create a checkout form and manage token creation. keywords: 'Developer docs' lang: en-US redirects: '/docs/content/dev-docs/concept/checkout-form-and-token-creation/': {} '/docs/content/concepts-and-features/concept/checkout-form-and-token-creation/': {} '/docs/concepts-and-features/concept/checkout-form-and-token-creation/': {} --- # Checkout form and token creation If you have not used FramePay previously, see [Get started with FramePay](/docs/dev-docs/basic-setup.md). FramePay processes your checkout form and injects UI elements that are rendered into secure, Rebilly hosted, iframes. When a customer submits a valid FramePay form you use `Framepay.createToken(form, extraData)` to generate a payment token. The values of `form` and `extraData` parameters depend on: - the configured payment method/s. - how you manage your customer information. You use the form in 3 contexts: - Specify the mounting points where FramePay injects UI elements. - Specify `data-rebilly` attributes to indicate which customer data is collected. - Create the payment token by passing the form to `Framepay.createToken(form, extraData)`. ## Mounting points The instructions to specify mounting points are detailed in the [Get started with FramePay](/docs/dev-docs/basic-setup.md) topic. ## Checkout form attributes There are only 2 payment methods (`payment card` and `bank account`) that require your customer information. Use `data-rebilly` attributes to specify which customer data is collected by FramePay. ### Customer name When you use the form to create a payment token, the only required customer data is the name of the customer. There are 2 options to specify the name of the customer: #### `fullName` in just one input ```javascript ... ... ``` #### `firstName` and `lastName` in two different inputs ```javascript ... ... ``` ### Other customer data You can optionally add the following `data-rebilly` attributes to your checkout form: - `organization` - `address` - `address2` - `city` - `region` - `country` - `postalCode` (optional: add a custom label using the `data-rebilly-label` attribute) - `phoneNumbers` (optional: add a custom label using the `data-rebilly-label` attribute) - `emails` (optional: add a custom label using the `data-rebilly-label` attribute) - `bic` (exclusive to the [BBAN](framepay-global-reference.md#framepay.bban.mount) methods) - `bankName` (exclusive to the [IBAN](framepay-global-reference.md#framepay.iban.mount) methods) ## Create payment tokens Use `Framepay.createToken(form, extraData)` to create a payment token with the customer data collected in the form. The `form` parameter can be: - a valid string `DOM` selector. - a `jQuery` instance. - a `Zepto` object that wraps an element within the page. - `null` value, when the payment method does not require customer data (only `payment card` and `bank account` payment methods do require customer data). ### Inject token data Is this an alternative way to `createToken`? FramePay can inject the newly created token into your payment form. This is useful for sending the token ID or payment instrument details directly to your own backend, as part of the payment form submission. To automatically inject token data into your form, use `hidden input fields` with one of these specific `data-rebilly` attributes: - `token` The token ID. - `payment-instrument` The [payment instrument](/docs/dev-docs/api/payment-tokens/posttoken/) details as a stringified object. This way, the token data is sent directly to your backend when the form is posted. ## Example This is an example of a checkout form with both visible customer inputs and hidden inputs: ```html
``` --- --- --- --- --- --- --- ## Framepay.errorCodes The errorCodes namespace, uses for overriding default error messages see [configuration i18n](framepay-configuration-reference.md#i18n) ## Framepay.initialize() Use this method to initialize FramePay with your publishable API key and customize the look and feel of elements. It accepts a single [`configuration`](framepay-configuration-reference.md) object. ```JavaScript // the basic configuration must contain your publishable API key Framepay.initialize({ publishableKey: 'pk_sandbox_1234567890', organizationId: 'your-organization-id', // no required property }); ```Option | Description |
---|---|
methodstring
|
When provided FramePay will attempt to process the form data to generate a payment token for this Multiple methodsThis property is required when using multiple payment methods at the same time in a form or when using methods other than Accepts any of the [methods supported by Rebilly](/docs/dev-docs/api/payment-tokens/posttoken/). |
billingAddressobject optional
|
This object defines the billing address of the customer. These keys can be provided:
Required valuesPlease note that the |
leadSourceobject optional
|
A lead source is Rebilly's term for the marketing campaign responsible for a customer interaction (typically a customer purchasing something). There are two ways to collect lead source information: either you provide it explicitly within the If the lead source parameter is defined all UTM parameters from the web address will be ignored. Lead source parametersA lead source is just some additional metadata that attaches to the customer’s record, and contains attributes common from both Google analytics (UTM) and affiliate tracking applications:
These parameters are optional. Prevent automatic attributionIf you want to prevent automatic lead source attribution from Google analytics UTM fields you can define this property as an empty object.
|
BICstring
|
the SWIFT or BIC Code Only for the BBAN and IBAN methods, |
bankNamestring
|
Bank name Only for the BBAN and IBAN methods, |