Custom fields at checkout
Custom fields add your own questions to a Flint checkout: a PO number for a business buyer, a gift note, a shirt size, a delivery instruction. You define each question once, Flint's hosted checkout renders it, and the buyer's answer lands on the order as typed data, ready for fulfillment from the order.paid webhook. Answers never use your metadata space.
The same field model works on payment links and on checkout sessions, so a question you design for a link moves to a session unchanged. Beside custom fields, checkout can also ask for a company name and offer a marketing opt-in.
| Where | How you add questions | When the buyer answers |
|---|---|---|
| Payment link | custom_fields on POST /v1/payment-links or PATCH /v1/payment-links/{payment_link_id} | On the link's page, before checkout starts |
| Checkout session | custom_fields on POST /v1/checkout-sessions, with type order, quick_pay, or subscription_plan | In checkout, before paying |
Invoices, return checkouts, and shops don't take custom fields. A session that a payment link or shop starts has no questions of its own: a link asks its questions on the link page.
The field model#
Each field in custom_fields is one question. The array order is the order the buyer sees.
| Member | Type | Rules |
|---|---|---|
key | string | Required. 1 to 243 characters, no leading or trailing spaces, unique among the fields. It names the answer in custom_field_values and custom_field_answers. |
label | string | Required. 1 to 255 characters. The question the buyer sees. |
custom_field_type | string | Required. text, textarea, dropdown, or checkbox. |
required | boolean | Defaults to false. The buyer can't pay until they answer. A required checkbox must be checked. |
placeholder | string | Optional. Up to 500 characters of hint text shown inside the empty input. |
options | string array | Required for dropdown, which needs at least one; an empty list returns detail REQUIRED. Each option is 1 to 4,096 characters, with no leading or trailing spaces. |
max_length | integer | text and textarea only. The longest answer, from 1 to 4,096 characters, counted in Unicode code points. Defaults to 255 for text and 1,000 for textarea. |
custom_field_type | Hosted checkout shows | The answer is |
|---|---|---|
text | A single-line input | The buyer's text |
textarea | A multi-line input | The buyer's text, which can contain line breaks |
dropdown | A select with your options | The option the buyer picked, exactly as listed |
checkbox | One checkbox, unchecked | true when checked, false when not |
A link or session holds at most 20 fields. Hosted checkout marks optional fields "(optional)" and leaves required ones unmarked.
Payment links add two members, because a link is edited after you create it: payment_link_custom_field_id, the stable ID that keeps a field through an update, and position, its display order. A session's questions can't change after you create it, so its fields have neither: key identifies each one and the array sets the order. To ask different questions, create a new session; for an order session, pass the old one as replace_checkout_session_id.
A definition that breaks a rule returns 400 INVALID_REQUEST, with param naming the member, such as custom_fields[2].key. The link and session routes check the same rules and return the same detail codes.
Flint rejects questions that appear to ask for account passwords, one-time passcodes, verification codes, account or bank PINs, full card numbers, card security codes, card expiry dates, account logins, seed phrases, or private keys. The API returns 400 INVALID_REQUEST with detail code INVALID_VALUE and the label or placeholder at param, such as custom_fields[1].placeholder. Buyers can skip previously saved questions in these categories because Flint hides them and rejects answers to them.
General delivery codes, booking references, and event passcodes can still be collected. Other sensitive wording, such as a request for a Social Security number or bank routing number, returns a custom_field_sensitive_prompt warning in meta.warnings when the API saves a question. The warning's param identifies the label or placeholder to edit.
Add questions to a checkout#
This quick pay session takes a $2,500 deposit on a bulk order and asks four questions, a company name, and an optional marketing opt-in:
curl -X POST https://api.withflintpay.com/v1/checkout-sessions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: checkout-bulk-deposit-001" \
-d '{
"type": "quick_pay",
"quick_pay_item": {
"name": "Bulk order deposit",
"amount_money": {"amount": 250000, "currency": "USD"}
},
"custom_fields": [
{"key": "po_number", "label": "PO number", "custom_field_type": "text", "required": true, "max_length": 40},
{"key": "carrier_account", "label": "Carrier account number", "custom_field_type": "text"},
{"key": "gift_note", "label": "Gift note", "custom_field_type": "textarea", "max_length": 300},
{"key": "liftgate", "label": "Delivery needs a liftgate", "custom_field_type": "checkbox"}
],
"buyer_fields": {
"require_email": true,
"company_name_collection": "required",
"marketing_opt_in": {"enabled": true, "consent_text": "Email me news and offers from Northwind."}
}
}'
Send the buyer to the session's url, and hosted checkout asks the questions. A payment link takes the same field objects in its own custom_fields; Payment links has an example.
Collect answers#
Flint's hosted checkout renders the questions, checks each answer as the buyer fills it in, saves the answers to the session, and keeps the buyer from paying until every required question has an answer. Apple Pay and Google Pay wait until required questions are answered too. You write no frontend code.
On your own checkout page, save answers as the buyer gives them.
When you resolve a payment link or save checkout session answers, Flint refuses a text or textarea answer that contains a sequence of 13 to 19 digits that passes the Luhn check, allowing up to three spaces, tabs, nonbreaking spaces, or hyphens between adjacent digits. A line break ends the sequence. The API returns 400 INVALID_REQUEST with detail code INVALID_VALUE and param naming the answer, such as custom_field_values.po_number. Remove the card number and retry. Hosted checkout warns buyers when an answer looks like a US Social Security number and lets them continue.
On a payment link#
Send the answers as custom_field_values when you resolve the link. Required fields must be answered there, before checkout starts.
On a checkout session#
Send the answers to PATCH /v1/checkout-sessions/{checkout_session_id} as custom_field_values, with the session's checkout credential. Save each answer once the buyer finishes it, for example when the input loses focus, so a reload can restore the form:
curl -X PATCH https://api.withflintpay.com/v1/checkout-sessions/cs_1kmn0aExample \
-H "Authorization: Bearer ckat_1kmn0aExample" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: save-answers-cart-123-1" \
-d '{
"expected_version": 3,
"custom_field_values": {
"po_number": "PO-1842",
"liftgate": "true",
"gift_note": null
}
}'
- Merged by key. A key you leave out keeps its saved answer.
nullremoves that answer.{}changes nothing. - Values are strings. A checkbox answer is exactly
"true"or"false". A dropdown answer must be one of the field'soptions. An empty string is refused; sendnullto remove an answer. - Checked on save. An unknown key, a value over
max_length, a dropdown value that isn't an option, or a checkbox value other than"true"or"false"returns400 INVALID_REQUESTwith detailINVALID_VALUEandparamnaming the key, such ascustom_field_values.po_number. Nothing in the request is saved. - Required is checked at payment, not on save. A form is incomplete while the buyer fills it in, so a save never fails for a missing required answer.
- Only the checkout credential saves answers. Your API key gets
400 INVALID_REQUESTwith detailNOT_ALLOWED. Answers are the buyer's to give. - Only while the session can take payment. An ended session returns
409 ACTION_NOT_ALLOWEDwith reasonterminal_status. While a payment is in progress, a save returns409 OPERATION_IN_PROGRESS; wait for the payment's outcome before saving again. - One change, one version. An effective save advances the session
versiononce and sends onecheckout_session.updated. Saving the answers already saved changes nothing.expected_versionis optional.
The same request can also save buyer_contact, including the company name and the marketing opt-in.
A session read with the checkout credential returns custom_fields and the saved custom_field_values, in the shape you send them, so your page can rebuild its form after a reload.
Required answers at payment#
Flint checks required answers when the buyer's payment starts, whether you pay with POST /v1/orders/{order_id}/pay or confirm a payment intent with the checkout credential. Every required question needs a saved answer, a required checkbox needs "true", and a session that requires a company name needs one. The pay request itself doesn't carry answers, so save them first.
When something is missing, the payment doesn't start and the request returns 409 ACTION_NOT_ALLOWED with reason configuration_required. The remediation.next_actions list names each missing input in the terms of the session PATCH (abridged):
{
"error": {
"code": "ACTION_NOT_ALLOWED",
"message": "Complete the required checkout details before paying.",
"details": [
{
"code": "ACTION_NOT_ALLOWED",
"reason": "configuration_required",
"resource_type": "checkout_session",
"resource_id": "cs_1kmn0aExample"
}
],
"remediation": {
"retry": "none",
"next_actions": [
{
"action_type": "update_checkout_session",
"url": "/v1/checkout-sessions/cs_1kmn0aExample",
"required_fields": ["custom_field_values.po_number", "buyer_contact.company_name"]
}
]
}
}
}
Show the buyer the inputs required_fields names, save their answers, then pay again with a new Idempotency-Key. Nothing was charged, and the refused key is released.
Read the answers#
The order carries the answers in custom_field_answers, so fulfillment, support, and accounting read them where they read the rest of the sale. Flint records them on the order in the same step that starts the payment, or that places the order on account, so a later edit to the questions or the saved answers never changes what a paid order says.
{
"order_id": "ord_1kmn0aExample",
"custom_field_answers": [
{
"key": "po_number",
"label": "PO number",
"custom_field_type": "text",
"value": "PO-1842"
},
{
"key": "liftgate",
"label": "Delivery needs a liftgate",
"custom_field_type": "checkbox",
"value": true
}
]
}
- Each answer keeps the
key,label, andcustom_field_typethe buyer saw.valueis a string fortext,textarea, anddropdown, and a boolean forcheckbox. - Answers come in the order of the questions. An optional question left blank is left out. When payment starts, the order records an unanswered session checkbox as
false. A checkout session shows a checkbox answer only if it was saved. Hosted checkout answersfalsefor an optional payment link checkbox left unchecked. - Answers to a payment link's questions also carry
payment_link_custom_field_id. Answers to a session's questions don't, so check for it before using it. - An order's answers are those of the checkout that paid it or placed it on account. A link's order keeps the answers its buyer gave on the link page.
- The order, its checkout session, and their webhooks carry
custom_field_answers, includingorder.paidandcheckout_session.updated. A session read shows the answers saved so far. - Only merchant credentials read
custom_field_answers. The checkout credential reads its owncustom_field_valuesinstead, and webhooks never carrycustom_field_values. - Flint masks all but the last four digits of stored card numbers when it returns answers, including in webhook payloads.
Answers aren't metadata. They don't count toward an order's 50 metadata pairs or a payment link's metadata limits, and Flint doesn't copy them into metadata. Orders from payment links created before Flint recorded answers in custom_field_answers return an empty list and keep their answers in metadata as custom_field_<key>.
A PO number for orders on account#
When a buyer places the order on account, Flint puts their PO number on the invoice's po_number, which prints on the PDF. If the place request sends no po_number, Flint uses the answer to a question whose key is exactly po_number. Any other key, such as po or purchase_order, isn't read. When the session sets payments.on_account_po_number_collection: "required", hosted checkout makes that question required for an on-account order and shows no separate PO number field. On a payment link, the buyer answers on the link page, before checkout. Shops have no questions, so hosted checkout asks for the PO number in the on-account option itself.
The invoice carries only the PO number. Every answer, including po_number, stays on the order's custom_field_answers.
How long Flint keeps answers#
Flint clears what a buyer saved on a session, their answers, company name, and opt-in choice, 30 days after the session ends. The order keeps its answers. Deleting the customer removes the answers, company name, and opt-in choice from their orders and sessions, and erases their marketing consent; see Customer deletion requests.
Collect a company name#
Set buyer_fields.company_name_collection to ask business buyers for their company:
| Value | Hosted checkout |
|---|---|
off | Doesn't ask. The default. |
optional | Shows "Company (optional)" after the email and phone. |
required | Shows "Company", which the buyer must fill in before paying. |
It works on checkout sessions, payment links, and shops. A link or shop stores the setting, and every checkout it starts asks.
The buyer's answer is buyer_contact.company_name, up to 255 characters. On your own checkout page, save it with the checkout credential in the session PATCH, inside buyer_contact, and send null to clear it. Sending it to a session whose company_name_collection is off returns 400 INVALID_REQUEST with detail NOT_ALLOWED and param: buyer_contact.company_name. When the payment starts, the order records it as buyer_contact.company_name, and a required company name is enforced like a required answer.
The company name belongs to the order. Flint doesn't copy it to the customer or to addresses.
Offer a marketing opt-in#
Set buyer_fields.marketing_opt_in to show one marketing checkbox under the buyer's email:
{
"buyer_fields": {
"require_email": true,
"marketing_opt_in": {
"enabled": true,
"consent_text": "Email me news and offers from Northwind."
}
}
}
- The checkbox always starts unchecked and is always optional. There is no setting to check it in advance or to require it, so the consent you collect is a buyer's own choice.
consent_textis the exact wording beside the checkbox and the wording Flint records as consent, 1 to 500 characters. Leave it out to use "Email me news and offers from" followed by your business name. A session read returns the wording the buyer sees.- It works on checkout sessions, payment links, and shops. When you update a link or shop,
marketing_opt_inchanges only the members you send, so sendenabled,consent_text, or both. An empty object returns400 INVALID_REQUEST. Sendconsent_text: nullin the update to use Flint's default wording with your business name in new sessions.
The buyer's choice is buyer_contact.accepts_marketing, false until they check the box. On your own checkout page, save it with the checkout credential inside buyer_contact. Sending true to a session that doesn't offer the opt-in returns 400 INVALID_REQUEST with detail NOT_ALLOWED. The order records the choice as buyer_contact.accepts_marketing when the payment starts.
Once the order is paid, Flint records the grant on the customer with the buyer's email in marketing_consent, with the consent text, the session, and the time. An unchecked box records nothing and never withdraws an earlier grant. Collect marketing consent covers reading consent, relaying unsubscribes from your email tool, and how buyers withdraw.
Next steps#
- Ask buyers questions on a checkout session
- Ask buyers questions on a payment link
- Build your own checkout
- Collect marketing consent
Ready to ask your first question? Create a Flint account and add custom_fields to a test checkout session.