/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

midoptionalYour FlexFactor Merchant Identification Number.
Get your Mid
environmentoptionalYour 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

paymentMethodObjectRequiredContains the creditCard object and the optional fields below.
paymentMethod.emailStringOptionalCardholder email address.
paymentMethod.senseKeyStringOptionalProvide the key generated by SenseJS during the checkout.
paymentMethod.metadataObjectOptionalUp to 25 key/value pairs stored with the payment method. Keys up to 50 characters, values up to 500 characters.
paymentMethod.creditCardObjectRequiredRequired fields for this object:
creditCard.firstNameStringOptionalCardholder first name.
creditCard.lastNameStringOptionalCardholder last name.
creditCard.numberStringRequiredProvide credit card number to tokenize.
creditCard.verificationValue (CVV)StringRecommendedCVV: Provide this value if you have it. Leave empty if not.
creditCard.yearStringRequiredFormat: YYYY
creditCard.monthStringRequiredFormat: 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.

idguidThe tokenized payment method. Store this value.
successbooleantrue when errors is empty.
resultstringNot populated on this endpoint.
statusstringNot populated on this endpoint.
statusCodestringNot populated on this endpoint. It is not the HTTP status code.
errorsarray of objectsError details; empty on success.
customPropertiesobjectAdditional 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

SituationHTTPBody
The card was vaulted200Envelope with success: true and id, the FlexFactor token
Missing or invalid mid or environment401—
Not found404Problem details
An internal error occurred500—

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

cardNumberstringrecommendedUse the returned id.
holderNamestringrecommendedUse creditCard.firstName and creditCard.lastName.
cardTypestringrecommendedE.g.: Credit, Debit, Prepaid Card
cardBrandstringrecommendedE.g.: VISA, Mastercard
cardCountrystringrecommendedISO 3166-1 alpha-2 country code (2-letter)
cardIssuerstringoptional
cardLevelstringoptional
cardFingerprintstringoptional
expirationMonthintegerrecommendedFormat: MM
expirationYearintegerrecommendedFormat: YYYY
cardBinNumberstringrecommendedThe first six digits of the card number you tokenized.
cardLast4DigitsstringrecommendedThe 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.


What’s Next

Retrieve that payment method token and use it in /evaluate

Did this page help you?