Back to Collection Items
#include <C_CkHttpW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
HCkHttpW http;
BOOL success;
HCkStringBuilderW sbResponseBody;
HCkJsonObjectW jResp;
int respStatusCode;
const wchar_t *Country;
const wchar_t *Gateway_user_id;
const wchar_t *Id;
const wchar_t *User_state;
const wchar_t *v_Email;
const wchar_t *Account_id;
const wchar_t *fbpayCountry;
BOOL Tos_accepted;
const wchar_t *fbpayEmail;
const wchar_t *Manage_account_url;
const wchar_t *State;
const wchar_t *Bank_name;
const wchar_t *Withdrawal_period;
const wchar_t *Last_payment_date;
const wchar_t *Next_payout_date;
const wchar_t *Incoming_pending_amount;
const wchar_t *Last_payment_amount;
const wchar_t *Withdrawal_type;
const wchar_t *Total_payout;
const wchar_t *Ach_tier_3;
const wchar_t *Percent_amex;
const wchar_t *Percent_non_amex_with_card;
const wchar_t *Percent_non_amex;
const wchar_t *Percent_virtual_terminal;
const wchar_t *Percent_amex_with_card;
const wchar_t *Ach_tier_1;
const wchar_t *Ach_tier_2;
int Tier_id;
const wchar_t *Per_transaction_fee;
BOOL Visa_debit_accepted;
const wchar_t *fbpayId;
BOOL Bank_transfer_enabled;
int j;
int count_j;
const wchar_t *strVal;
int i;
int count_i;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Adds the "Authorization: Bearer <access_token>" header.
CkHttpW_putAuthToken(http,L"<access_token>");
CkHttpW_SetRequestHeader(http,L"Content-Type",L"application/json");
sbResponseBody = CkStringBuilderW_Create();
success = CkHttpW_QuickGetSb(http,L"https://api.freshbooks.com/payments/account/{{accountId}}/gateway",sbResponseBody);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jResp = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jResp,sbResponseBody);
CkJsonObjectW_putEmitCompact(jResp,FALSE);
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkJsonObjectW_emit(jResp));
respStatusCode = CkHttpW_getLastStatus(http);
wprintf(L"Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkHttpW_lastHeader(http));
wprintf(L"Failed.\n");
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
return;
}
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "gateway_connections": [
// {
// "stripe": {
// "currencies": [
// "AED",
// "AFN",
// "ALL",
// "AMD",
// "ANG",
// "AOA",
// "ARS",
// "AUD",
// "AWG",
// "AZN",
// "BAM",
// "BBD",
// "BDT",
// "BGN",
// "BIF",
// "BMD",
// "BND",
// "BOB",
// "BRL",
// "BSD",
// "BWP",
// "BZD",
// "CAD",
// "CDF",
// "CHF",
// "CLP",
// "CNY",
// "COP",
// "CRC",
// "CVE",
// "CZK",
// "DJF",
// "DKK",
// "DOP",
// "DZD",
// "EGP",
// "ETB",
// "EUR",
// "FJD",
// "FKP",
// "GBP",
// "GEL",
// "GIP",
// "GMD",
// "GNF",
// "GTQ",
// "GYD",
// "HKD",
// "HNL",
// "HRK",
// "HTG",
// "HUF",
// "IDR",
// "ILS",
// "INR",
// "ISK",
// "JMD",
// "JPY",
// "KES",
// "KGS",
// "KHR",
// "KMF",
// "KRW",
// "KYD",
// "KZT",
// "LAK",
// "LBP",
// "LKR",
// "LRD",
// "LSL",
// "MAD",
// "MDL",
// "MGA",
// "MKD",
// "MMK",
// "MNT",
// "MOP",
// "MRO",
// "MUR",
// "MVR",
// "MWK",
// "MXN",
// "MYR",
// "MZN",
// "NAD",
// "NGN",
// "NIO",
// "NOK",
// "NPR",
// "NZD",
// "PAB",
// "PEN",
// "PGK",
// "PHP",
// "PKR",
// "PLN",
// "PYG",
// "QAR",
// "RON",
// "RSD",
// "RUB",
// "RWF",
// "SAR",
// "SBD",
// "SCR",
// "SEK",
// "SGD",
// "SHP",
// "SLL",
// "SOS",
// "SRD",
// "STD",
// "SZL",
// "THB",
// "TJS",
// "TOP",
// "TRY",
// "TTD",
// "TWD",
// "TZS",
// "UAH",
// "UGX",
// "USD",
// "UYU",
// "UZS",
// "VND",
// "VUV",
// "WST",
// "XAF",
// "XCD",
// "XOF",
// "XPF",
// "YER",
// "ZAR",
// "ZMW"
// ],
// "country": "CA",
// "gateway_user_id": "acct_19SW34IY7l9murJy",
// "id": "b5d4f07757ff444db095d4854b8f3bc6",
// "user_state": "registered",
// "email": "mjohnston@freshbooks.com"
// },
// "fbpay": {
// "currencies": [
// "CAD"
// ],
// "account_id": "243033720",
// "action_reasons": [
// "kyc",
// "bank_account"
// ],
// "country": "CA",
// "tos_accepted": true,
// "email": "rmarr@freshbooks.com",
// "manage_account_url": "https://wepay.com/account/243033720",
// "state": "complete_kyc",
// "bank_info": {
// "bank_name": null,
// "withdrawal_period": null,
// "last_payment_date": null,
// "withdrawal_schedule": [
// ],
// "next_payout_date": null,
// "incoming_pending_amount": "0",
// "last_payment_amount": null,
// "withdrawal_type": null,
// "outgoing_withdrawal_schedule": [
// ],
// "total_payout": "0"
// },
// "pricing": {
// "ach_tier_3": null,
// "percent_amex": "3.50",
// "percent_non_amex_with_card": "2.70",
// "percent_non_amex": "2.90",
// "percent_virtual_terminal": "3.50",
// "percent_amex_with_card": "3.40",
// "ach_tier_1": null,
// "ach_tier_2": null,
// "tier_id": 105,
// "per_transaction_fee": "0.30"
// },
// "visa_debit_accepted": false,
// "id": "1074c55d95cd470eb0b60a2f4ffad68c",
// "bank_transfer_enabled": true
// }
// }
// ]
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
i = 0;
count_i = CkJsonObjectW_SizeOfArray(jResp,L"gateway_connections");
while (i < count_i) {
CkJsonObjectW_putI(jResp,i);
Country = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].stripe.country");
Gateway_user_id = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].stripe.gateway_user_id");
Id = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].stripe.id");
User_state = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].stripe.user_state");
v_Email = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].stripe.email");
Account_id = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.account_id");
fbpayCountry = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.country");
Tos_accepted = CkJsonObjectW_BoolOf(jResp,L"gateway_connections[i].fbpay.tos_accepted");
fbpayEmail = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.email");
Manage_account_url = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.manage_account_url");
State = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.state");
Bank_name = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.bank_info.bank_name");
Withdrawal_period = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.bank_info.withdrawal_period");
Last_payment_date = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.bank_info.last_payment_date");
Next_payout_date = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.bank_info.next_payout_date");
Incoming_pending_amount = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.bank_info.incoming_pending_amount");
Last_payment_amount = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.bank_info.last_payment_amount");
Withdrawal_type = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.bank_info.withdrawal_type");
Total_payout = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.bank_info.total_payout");
Ach_tier_3 = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.pricing.ach_tier_3");
Percent_amex = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.pricing.percent_amex");
Percent_non_amex_with_card = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.pricing.percent_non_amex_with_card");
Percent_non_amex = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.pricing.percent_non_amex");
Percent_virtual_terminal = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.pricing.percent_virtual_terminal");
Percent_amex_with_card = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.pricing.percent_amex_with_card");
Ach_tier_1 = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.pricing.ach_tier_1");
Ach_tier_2 = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.pricing.ach_tier_2");
Tier_id = CkJsonObjectW_IntOf(jResp,L"gateway_connections[i].fbpay.pricing.tier_id");
Per_transaction_fee = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.pricing.per_transaction_fee");
Visa_debit_accepted = CkJsonObjectW_BoolOf(jResp,L"gateway_connections[i].fbpay.visa_debit_accepted");
fbpayId = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.id");
Bank_transfer_enabled = CkJsonObjectW_BoolOf(jResp,L"gateway_connections[i].fbpay.bank_transfer_enabled");
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"gateway_connections[i].stripe.currencies");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].stripe.currencies[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"gateway_connections[i].fbpay.currencies");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.currencies[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"gateway_connections[i].fbpay.action_reasons");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
strVal = CkJsonObjectW_stringOf(jResp,L"gateway_connections[i].fbpay.action_reasons[j]");
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"gateway_connections[i].fbpay.bank_info.withdrawal_schedule");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
j = j + 1;
}
j = 0;
count_j = CkJsonObjectW_SizeOfArray(jResp,L"gateway_connections[i].fbpay.bank_info.outgoing_withdrawal_schedule");
while (j < count_j) {
CkJsonObjectW_putJ(jResp,j);
j = j + 1;
}
i = i + 1;
}
CkHttpW_Dispose(http);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_Dispose(jResp);
}
Curl Command
curl -X GET
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
https://api.freshbooks.com/payments/account/{{accountId}}/gateway
Postman Collection Item JSON
{
"name": "List Gateways",
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"url": {
"raw": "https://api.freshbooks.com/payments/account/{{accountId}}/gateway",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"payments",
"account",
"{{accountId}}",
"gateway"
]
}
},
"response": [
{
"name": "List Gateways",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json",
"type": "text"
}
],
"url": {
"raw": "https://api.freshbooks.com/payments/account/{{accountId}}/gateway",
"protocol": "https",
"host": [
"api",
"freshbooks",
"com"
],
"path": [
"payments",
"account",
"{{accountId}}",
"gateway"
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Server",
"value": "nginx"
},
{
"key": "Content-Type",
"value": "application/vnd.api+json"
},
{
"key": "X-CardApp-Version",
"value": "1904.32.0"
},
{
"key": "X-NewRelic-App-Data",
"value": "PxQBWV5TCBABV1FUDwYGV1QTGhE1AwE2QgNWEVlbQFtcCxYnRA9QFg1ZWU4FAkpXURQRTEVURAkRQ1VWEUgEA0QHTwNBFkZXQApME1IECQUFQlIWBxpKVkMLFBBUVBVKVB0HHVJWV1EFUQhWDgwFBQFWD1IdTAJORlcBBVNTCgBTBwUGUVUPX1MTGlUDChAHbQ=="
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
},
{
"key": "Expires",
"value": "Tue, 24 Apr 2018 18:04:28 GMT"
},
{
"key": "Cache-Control",
"value": "no-cache"
},
{
"key": "Via",
"value": "1.1 google"
},
{
"key": "Via",
"value": "1.1 varnish"
},
{
"key": "Accept-Ranges",
"value": "bytes"
},
{
"key": "Accept-Ranges",
"value": "bytes"
},
{
"key": "Age",
"value": "0"
},
{
"key": "Age",
"value": "0"
},
{
"key": "Content-Length",
"value": "2097"
},
{
"key": "Date",
"value": "Wed, 24 Apr 2019 18:04:28 GMT"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "X-Served-By",
"value": "cache-mdw17369-MDW"
},
{
"key": "X-Cache",
"value": "MISS"
},
{
"key": "X-Cache-Hits",
"value": "0"
},
{
"key": "Country",
"value": "CA"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains; preload"
}
],
"cookie": [
],
"body": "{\n \"gateway_connections\": [\n {\n \"stripe\": {\n \"currencies\": [\n \"AED\",\n \"AFN\",\n \"ALL\",\n \"AMD\",\n \"ANG\",\n \"AOA\",\n \"ARS\",\n \"AUD\",\n \"AWG\",\n \"AZN\",\n \"BAM\",\n \"BBD\",\n \"BDT\",\n \"BGN\",\n \"BIF\",\n \"BMD\",\n \"BND\",\n \"BOB\",\n \"BRL\",\n \"BSD\",\n \"BWP\",\n \"BZD\",\n \"CAD\",\n \"CDF\",\n \"CHF\",\n \"CLP\",\n \"CNY\",\n \"COP\",\n \"CRC\",\n \"CVE\",\n \"CZK\",\n \"DJF\",\n \"DKK\",\n \"DOP\",\n \"DZD\",\n \"EGP\",\n \"ETB\",\n \"EUR\",\n \"FJD\",\n \"FKP\",\n \"GBP\",\n \"GEL\",\n \"GIP\",\n \"GMD\",\n \"GNF\",\n \"GTQ\",\n \"GYD\",\n \"HKD\",\n \"HNL\",\n \"HRK\",\n \"HTG\",\n \"HUF\",\n \"IDR\",\n \"ILS\",\n \"INR\",\n \"ISK\",\n \"JMD\",\n \"JPY\",\n \"KES\",\n \"KGS\",\n \"KHR\",\n \"KMF\",\n \"KRW\",\n \"KYD\",\n \"KZT\",\n \"LAK\",\n \"LBP\",\n \"LKR\",\n \"LRD\",\n \"LSL\",\n \"MAD\",\n \"MDL\",\n \"MGA\",\n \"MKD\",\n \"MMK\",\n \"MNT\",\n \"MOP\",\n \"MRO\",\n \"MUR\",\n \"MVR\",\n \"MWK\",\n \"MXN\",\n \"MYR\",\n \"MZN\",\n \"NAD\",\n \"NGN\",\n \"NIO\",\n \"NOK\",\n \"NPR\",\n \"NZD\",\n \"PAB\",\n \"PEN\",\n \"PGK\",\n \"PHP\",\n \"PKR\",\n \"PLN\",\n \"PYG\",\n \"QAR\",\n \"RON\",\n \"RSD\",\n \"RUB\",\n \"RWF\",\n \"SAR\",\n \"SBD\",\n \"SCR\",\n \"SEK\",\n \"SGD\",\n \"SHP\",\n \"SLL\",\n \"SOS\",\n \"SRD\",\n \"STD\",\n \"SZL\",\n \"THB\",\n \"TJS\",\n \"TOP\",\n \"TRY\",\n \"TTD\",\n \"TWD\",\n \"TZS\",\n \"UAH\",\n \"UGX\",\n \"USD\",\n \"UYU\",\n \"UZS\",\n \"VND\",\n \"VUV\",\n \"WST\",\n \"XAF\",\n \"XCD\",\n \"XOF\",\n \"XPF\",\n \"YER\",\n \"ZAR\",\n \"ZMW\"\n ],\n \"country\": \"CA\",\n \"gateway_user_id\": \"acct_19SW34IY7l9murJy\",\n \"id\": \"b5d4f07757ff444db095d4854b8f3bc6\",\n \"user_state\": \"registered\",\n \"email\": \"mjohnston@freshbooks.com\"\n },\n \"fbpay\": {\n \"currencies\": [\n \"CAD\"\n ],\n \"account_id\": \"243033720\",\n \"action_reasons\": [\n \"kyc\",\n \"bank_account\"\n ],\n \"country\": \"CA\",\n \"tos_accepted\": true,\n \"email\": \"rmarr@freshbooks.com\",\n \"manage_account_url\": \"https://wepay.com/account/243033720\",\n \"state\": \"complete_kyc\",\n \"bank_info\": {\n \"bank_name\": null,\n \"withdrawal_period\": null,\n \"last_payment_date\": null,\n \"withdrawal_schedule\": [],\n \"next_payout_date\": null,\n \"incoming_pending_amount\": \"0\",\n \"last_payment_amount\": null,\n \"withdrawal_type\": null,\n \"outgoing_withdrawal_schedule\": [],\n \"total_payout\": \"0\"\n },\n \"pricing\": {\n \"ach_tier_3\": null,\n \"percent_amex\": \"3.50\",\n \"percent_non_amex_with_card\": \"2.70\",\n \"percent_non_amex\": \"2.90\",\n \"percent_virtual_terminal\": \"3.50\",\n \"percent_amex_with_card\": \"3.40\",\n \"ach_tier_1\": null,\n \"ach_tier_2\": null,\n \"tier_id\": 105,\n \"per_transaction_fee\": \"0.30\"\n },\n \"visa_debit_accepted\": false,\n \"id\": \"1074c55d95cd470eb0b60a2f4ffad68c\",\n \"bank_transfer_enabled\": true\n }\n }\n ]\n}"
}
]
}