Create tokenization order

Create tokenization order

To consider

A tokenization order is created to prepare the Greenpay API for create a token from credit or debit card data. The following aspects have to be consider for it:
  1. Use these endpoints:
    1. Sandbox: https://sandbox-merchant.greenpay.me/tokenize
    2. Production: https://merchant.greenpay.me/tokenize
  2. The response is an JSON that contains a transaction token and session.
  3. The transaction token and session is valid for 30 minutes since it  was created. After this time the session and the token will expire.
  4. It is recommended do this process from the backend side of the application.

Steps to use the service

1. Data structure

In order to use the service send a post request with the follow structure.
  1. {
  2.     "secret": "your_secret",
  3.     "merchantId": "your_merchantId",
  4.     "requestId": "xwr1023",
  5.     "callback": "https://yourhost.url/callback"
  6. }
The requiere data are the following:
  1. secret: String key provided by Greenpay.
  2. merchantId: Universal unique id provided by Greenpay.
  3. requestId: Unique id that must be generated by the merchant.
Other data:
  1. callback: If the tokenization process is integrated with the Greenpay tokenization form instead of API integration, then an url have to be sent as callback param. To this url the Greenpay form is going to send the tokenization response. For more details about tokenization with Greenpay form visit this link.

2. Send post request to create the tokenization order

A POST request have to sent in order to create de tokenization order. The body of the request must have the structure of previous step and the response is a JSON with session and token values.

This is an example of POST request made in javascript.
  1. var data= {
  2.     "secret": "your_secret",
  3.     "merchantId": "your_merchantId",
  4.     "requestId": "xwr1023"
  5. }

  6. var unirest = require("unirest");
  7. function postCreateOrder(data) {
  8.     return new Promise(function (resolve, reject) {
  9.         unirest.post("https://sandbox-merchant.greenpay.me/tokenize%22)
  10.         .headers({
  11.             "Accept": "application/json",
  12.             "Content-Type": "application/json",
  13.         })
  14.         .send(JSON.stringify(data))
  15.         .end(function (response) {
  16.             if (response.status === 200) {
  17.                 console.log( JSON.stringify("body:",response.body));
  18.                 resolve(response.body);
  19.             } else {
  20.                 reject(response.body);
  21.             }
  22.         });
  23.     });
  24. }
This is an response example
  1. {
  2.     "statusCode": 200,
  3.     "body": {
  4.         "session": "78de8789-1cc6-4c35-b65f-bdde41e7fc3f",
  5.         "token": "b5eae7a9-66dc-47cd-a008-31267a62dbc8"
  6.     },
  7.     "headers": {
  8.         "...": "..."
  9.     },
  10.     "request": {
  11.         "uri": {
  12.             "...": "..."
  13.         },
  14.         "method": "post",
  15.         "headers": {
  16.             "...": "..."
  17.         }
  18.     }
  19. }

    • Related Articles

    • API Tokenization process

      To consider To invoke the payments api, the following aspects should be considered: Use the service on the endpoints: Sandbox: https://sandbox-checkout.greenpay.me/tokenize Production: https://checkout.greenpay.me/tokenize Get a session and token of ...
    • Tokenization form process

      To consider To use the card tokenization form, the following aspects should be considered: The form is available at: Sandbox: http://sandbox-tokenizeform.greenpay.me/ Producción: https://tokenizeform.greenpay.me/ Get a session and token of a valid ...
    • Create payment order

      To consider A payment order is created to prepare the Greenpay API for a make a payment process. The following aspects have to be consider: Use these endpoints: Sandbox: https://sandbox-merchant.greenpay.me/ Production: https://merchant.greenpay.me/ ...
    • Create subscription

      For this service, the following endpoint must be consumed:  https://sandbox-merchant.greenpay.me/subscriptions Step by step to successfully create a subscription in our API : 1. Create the JSON object to be sent It must contain the following ...
    • General Information

      This functionality allows you to create card tokens. Two ways are provided for this service. 1.  Directly call the API where the encrypted card information is sent. 2. Invoke the tokenization form, which is displayed in a browser window. If this form ...