Tokenize (encrypt and store) the card information

Sensitive card information must be tokenized from the front end of your website for security reasons.

Step 1

Add conekta.js to your site.

  • Note: jQuery is not not required to use conekta.js and is used in this tutorial for practicality.
  • Our frontend library conekta.js only tokenizes the cards.

If you are building an app, please tokenize card information using one of our SDKs: Android, iOS o Xamarin.

Conekta.js Response Objects

  • Token object: the object we return when the card is tokenized with success.
  • Error object: the object we return when something goes wrong.

Step 1.1

Add your tokenization script.


  • Conekta.setPublicKey() adds your public key to allow the card tokenization.
  • conektaSuccessResponseHandler returns the token object when the call is successful.
  • conektaErrorResponseHandler returns the error object when the call goes wrong.
  • Conekta.Token.create() sends the info to our server.

Tokens can only be used once and unused tokens will expire in one hour.

Step 1.2

Add the card form to your site.

Conekta.js collects card info using the data-attributes of your form but if you prefer, you can capture card information yourself. See conekta.js for more details.

Charge your client

Step 2

Initialize your Conekta client by adding your private key and API version

If you don't already have your private key, you can get it here.

Step 2.1

Create an order and add the token

Creating an ordergenerates a charge to your client. If you do not want to create a charge immediately, you can prepare an order and generate the charge later by sending the charges array information.

It is important that all information sent to Conekta be correct as it will be used by our antifraud system to approve payments. Incorrect information will decrease decision accuracy and lead to lower acceptance rates and/or higher chargeback rates.

The fields shown in the example are the minimum set of attributes required. If you want to improve the speed of your transaction you will need to know more about the order object, to do this review our REST API.

Step 2.2

Process the response

You will receive a JSON object with a lot of information, you can choose to show only the fields you deem necessary.

Conekta recommends that you notify your user via email.

That's it! Please remember to exchange your sandbox keys for the production keys.

Sometimes your client's selected payment method will not process the charge, if so, offer your client the option to try with another payment source.

Try with another card

You will need the payment_source_id in order to process the charge with a non-default payment source.

Offline retry

We recommend that you suggest another payment method, such as Oxxo Pay or SPEI, after more than 2 failed card attempts.