/tokenize
Add POST /tokenize to your checkout flow, and store the FlexFactor token for later use.
The /tokenize endpoint is designed to securely vault credit card information after every checkout. A tokenized representation of the card information is returned.
Store that token for later use in case of payment decline.
You can send that request in parallel to the Payment Authorization request. If you are already tokenizing with a partner, you can tokenize twice.
1. Request
Query parameters
mid | optional | Your FlexFactor Merchant Identification Number. Get your Mid |
environment | optional | Your unique Tokenization key. Get your key. |
The schema does not enforce these parameters, but the call is authenticated by them. A request without a valid mid and environment returns HTTP 401.
Log into into your Sandbox. Go to section Developers > Tokenization get both your Tokenization endpoint and Environment.
Body parameters
paymentMethod | Object | Required | Contains the creditCard object and the optional fields below. |
paymentMethod.email | String | Optional | Cardholder email address. |
paymentMethod.senseKey | String | Optional | Provide the key generated by SenseJS during the checkout. |
paymentMethod.metadata | Object | Optional | Up to 25 key/value pairs stored with the payment method. Keys up to 50 characters, values up to 500 characters. |
paymentMethod.creditCard | Object | Required | Required fields for this object: |
creditCard.firstName | String | Optional | Cardholder first name. |
creditCard.lastName | String | Optional | Cardholder last name. |
creditCard.number | String | Required | Provide credit card number to tokenize. |
creditCard.verificationValue (CVV) | String | Recommended | CVV: Provide this value if you have it. Leave empty if not. |
creditCard.year | String | Required | Format: YYYY |
creditCard.month | String | Required | Format: MM |
Real financial data cannot be used in the Sandbox.
Please use our whitelisted test credit cards.
Request example
curl --location -g --request POST '
https://api-sandbox.flexfactor.io/v1/tokenize?mid={Your mid}&environment={Your Tokenization Key}' \
--header 'Content-Type: application/json' \
--data-raw '{
"paymentMethod": {
"senseKey": "XXX", //provide the key generated by SenseJS during the checkout
"email": "[email protected]",
"creditCard": {
"firstName": "Joe",
"lastName": "Jones",
"number": "4111111111111111",
"verificationValue": "999", //That's the CVV
"month": "03", // provide 2 numbers
"year": "2025" // provide 4 numbers
},
"metadata": {
"customerId": "cust_123"
}
}
}'2. Response
The response uses the common FlexFactor envelope plus one field, id, which is the FlexFactor token for the vaulted card.
id | guid | The tokenized payment method. Store this value. |
success | boolean | true when errors is empty. |
result | string | Not populated on this endpoint. |
status | string | Not populated on this endpoint. |
statusCode | string | Not populated on this endpoint. It is not the HTTP status code. |
errors | array of objects | Error details; empty on success. |
customProperties | object | Additional properties. Optional |
{
"id": "baf4abdc-14a3-4458-abfb-c856c711b9c7", //this is the tokenized payment method
"success": true,
"result": null,
"status": null,
"statusCode": null,
"errors": [],
"customProperties": {}
}HTTP status codes
| Situation | HTTP | Body |
|---|---|---|
| The card was vaulted | 200 | Envelope with success: true and id, the FlexFactor token |
Missing or invalid mid or environment | 401 | — |
| Not found | 404 | Problem details |
| An internal error occurred | 500 | — |
3. Token storage
The returned token must be stored in your database for future use, you will need it in case of payment decline.
A payment decline can happen immediately after tokenization (in case of CIT) of a few months after tokenization (in case of MIT).
This vaulted token will not expire.
Store the returned id alongside the card details below. The response does not return the BIN or the last four digits, so take them from the card number you tokenized before you discard it.
paymentMethod information
cardNumber | string | recommended | Use the returned id. |
holderName | string | recommended | Use creditCard.firstName and creditCard.lastName. |
cardType | string | recommended | E.g.: Credit, Debit, Prepaid Card |
cardBrand | string | recommended | E.g.: VISA, Mastercard |
cardCountry | string | recommended | ISO 3166-1 alpha-2 country code (2-letter) |
cardIssuer | string | optional | |
cardLevel | string | optional | |
cardFingerprint | string | optional | |
expirationMonth | integer | recommended | Format: MM |
expirationYear | integer | recommended | Format: YYYY |
cardBinNumber | string | recommended | The first six digits of the card number you tokenized. |
cardLast4Digits | string | recommended | The last four digits of the card number you tokenized. |
4. Retrieve that token for /evaluate
On a payment decline, you will need to look up the paymentMethod information and include it in your call to /evaluate.
Updated 11 days ago

