Chilkat Online Tools

unicodeC / Bond APIs / activate a physical card [w/optional fields]

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW json;
    HCkStringBuilderW sbRequestBody;
    HCkHttpResponseW resp;

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

    http = CkHttpW_Create();

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

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

    // {
    //   "cvv": "XXX",
    //   "expiry_date": "MMYYYY"
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"cvv",L"XXX");
    CkJsonObjectW_UpdateString(json,L"expiry_date",L"MMYYYY");

    CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
    CkHttpW_SetRequestHeader(http,L"Authorization",L"{{authorization}}");
    CkHttpW_SetRequestHeader(http,L"Identity",L"{{identity}}");

    sbRequestBody = CkStringBuilderW_Create();
    CkJsonObjectW_EmitSb(json,sbRequestBody);

    resp = CkHttpW_PTextSb(http,L"PATCH",L"https://{{environment}}.bond.tech/api/v0/cards/:card_id/activate_physical_card",sbRequestBody,L"utf-8",L"application/json",FALSE,FALSE);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        CkStringBuilderW_Dispose(sbRequestBody);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
    CkHttpResponseW_Dispose(resp);


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);
    CkStringBuilderW_Dispose(sbRequestBody);

    }

Curl Command

curl -X PATCH
	-H "Content-Type: application/json"
	-H "Authorization: {{authorization}}"
	-H "Identity: {{identity}}"
	-d '{
    "cvv": "XXX",
    "expiry_date": "MMYYYY"
}'
https://{{environment}}.bond.tech/api/v0/cards/:card_id/activate_physical_card

Postman Collection Item JSON

{
  "name": "activate a physical card [w/optional fields]",
  "request": {
    "method": "PATCH",
    "header": [
      {
        "key": "Content-Type",
        "type": "text",
        "value": "application/json",
        "disabled": true
      },
      {
        "key": "Authorization",
        "type": "text",
        "value": "{{authorization}}"
      },
      {
        "key": "Identity",
        "type": "text",
        "value": "{{identity}}"
      },
      {
        "key": "",
        "value": "",
        "type": "text",
        "disabled": true
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"cvv\": \"XXX\",\n    \"expiry_date\": \"MMYYYY\"\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "https://{{environment}}.bond.tech/api/v0/cards/:card_id/activate_physical_card",
      "protocol": "https",
      "host": [
        "{{environment}}",
        "bond",
        "tech"
      ],
      "path": [
        "api",
        "v0",
        "cards",
        ":card_id",
        "activate_physical_card"
      ],
      "variable": [
        {
          "key": "card_id",
          "value": "{{card_id}}"
        }
      ]
    },
    "description": "Add Card financial Core"
  },
  "response": [
    {
      "name": "activate a physical card [w/optional fields]",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "type": "text",
            "value": "application/json",
            "disabled": true
          },
          {
            "key": "Authorization",
            "type": "text",
            "value": "{{authorization}}"
          },
          {
            "key": "Identity",
            "type": "text",
            "value": "{{identity}}"
          },
          {
            "key": "",
            "value": "",
            "type": "text",
            "disabled": true
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"cvv\": \"XXX\",\n    \"expiry_date\": \"MMYYYY\"\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "https://{{environment}}.bond.tech/api/v0/cards/:card_id/activate_physical_card",
          "protocol": "https",
          "host": [
            "{{environment}}",
            "bond",
            "tech"
          ],
          "path": [
            "api",
            "v0",
            "cards",
            ":card_id",
            "activate_physical_card"
          ],
          "variable": [
            {
              "key": "card_id",
              "value": null
            }
          ]
        }
      },
      "_postman_previewlanguage": "json",
      "header": null,
      "cookie": [
      ],
      "body": "{\n\"card_id\":\"2742ff6a-7455-4066-8b45-ae12d3acca34\",\n\"last_four\":\"6169\",\n\"status\":\"Active\"\n}"
    }
  ]
}