Chilkat Online Tools

DataFlex / CardPointe API Integration / Tokenize (Card Number)

Back to Collection Items

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoHttp
    Boolean iSuccess
    Variant vJson
    Handle hoJson
    Variant vResp
    Handle hoResp
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "account": "4444333322221111"
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "account" "4444333322221111" To iSuccess

    Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"

    Get pvComObject of hoJson to vJson
    Get ComPostJson3 Of hoHttp "https://domain.com/" "application/json" vJson To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComStatusCode Of hoResp To iTemp1
    Showln iTemp1
    Get ComBodyStr Of hoResp To sTemp1
    Showln sTemp1
    Send Destroy of hoResp


End_Procedure

Curl Command

curl -X POST
	-H "Content-Type: application/json"
	-d '{
  "account" : "4444333322221111"
}'
https://domain.com/

Postman Collection Item JSON

{
  "name": "Tokenize (Card Number)",
  "event": [
    {
      "listen": "test",
      "script": {
        "exec": [
          "var jsonData = JSON.parse(responseBody);",
          "postman.setEnvironmentVariable(\"token\", jsonData.token);"
        ],
        "type": "text/javascript"
      }
    }
  ],
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "name": "Content-Type",
        "value": "application/json",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n  \"account\" : \"4444333322221111\"\n}"
    },
    "url": {
      "raw": "{{csurl}}",
      "host": [
        "{{csurl}}"
      ]
    },
    "description": "CardSecure API v1 Documentation Coming Soon\n\n**Note:** This is not required, but shows a simple call to the CardSecure API to tokenize a credit card number. It can be used to setup the token variable used in this Postman environment."
  },
  "response": [
  ]
}