Chilkat Online Tools

Android / New FreshBooks / 1a. [STRIPE] - Get Publishable Key

Back to Collection Items

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

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

    CkHttp http = new CkHttp();
    boolean success;

    // Adds the "Authorization: Bearer <access_token>" header.
    http.put_AuthToken("<access_token>");

    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = http.QuickGetSb("https://api.freshbooks.com/payments/account/E86Qp/gateway",sbResponseBody);
    if (success == false) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    CkJsonObject jResp = new CkJsonObject();
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    Log.i(TAG, "Response Body:");
    Log.i(TAG, jResp.emit());

    int respStatusCode = http.get_LastStatus();
    Log.i(TAG, "Response Status Code = " + String.valueOf(respStatusCode));
    if (respStatusCode >= 400) {
        Log.i(TAG, "Response Header:");
        Log.i(TAG, http.lastHeader());
        Log.i(TAG, "Failed.");
        return;
        }

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "gateway_connections": [
    //     {
    //       "fbpay": {
    //         "id": "89dsyfaiosuhlasdjkhcsaldc89879875ih435h",
    //         "account_id": "45435345345",
    //         "visa_debit_accepted": true,
    //         "pricing": {
    //           "tier_id": 105,
    //           "percent_ach": "0.00",
    //           "percent_non_amex": "2.90",
    //           "percent_non_amex_with_card": "2.70",
    //           "percent_amex": "3.50",
    //           "percent_amex_with_card": "3.40",
    //           "percent_virtual_terminal": "3.50",
    //           "ach_tier_1": null,
    //           "ach_tier_2": null,
    //           "ach_tier_3": null,
    //           "per_transaction_fee": "0.30",
    //           "default_pricing_tier_id": null,
    //           "promo_expiry_date": null,
    //           "max_ach_fee": null
    //         },
    //         "bank_transfer_enabled": false,
    //         "tos_accepted": true,
    //         "state": "active",
    //         "email": "mjohnston@freshbooks.com",
    //         "bank_info": {
    //           "total_payout": "0",
    //           "next_payout_date": null,
    //           "bank_name": "Gotham Bank XXXXXX2020",
    //           "last_payment_date": "2020-06-10T22:47:54Z",
    //           "last_payment_amount": "1240.79",
    //           "withdrawal_period": "daily",
    //           "withdrawal_type": "ach",
    //           "withdrawal_schedule": [
    //           ],
    //           "incoming_pending_amount": "0",
    //           "outgoing_withdrawal_schedule": [
    //           ]
    //         },
    //         "manage_account_url": "https://wepay.com/account/15524535345",
    //         "currencies": [
    //           "CAD"
    //         ],
    //         "country": "CA",
    //         "action_reasons": [
    //         ]
    //       },
    //       "stripe": {
    //         "id": "63kljSDHfglsfjhsf88sdfsd98dsflkjhav",
    //         "gateway_user_id": "acct_jdhaklsdjnc345",
    //         "user_state": "registered",
    //         "email": "mjohnston@freshbooks.com",
    //         "country": "CA",
    //         "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"
    //         ],
    //         "publishable_key": "pk_live_kha8dfy9oahvoi4h3qpj12qfp0234q9fuqp4938fh34pufh34pf84334f934hfp34uqif43345634oi5y4",
    //         "bank_transfer_enabled": false,
    //         "max_ach_fee": 5000
    //       },
    //       "paypal": null
    //     }
    //   ]
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    String Id;
    String Account_id;
    boolean Visa_debit_accepted;
    int Tier_id;
    String Percent_ach;
    String Percent_non_amex;
    String Percent_non_amex_with_card;
    String Percent_amex;
    String Percent_amex_with_card;
    String Percent_virtual_terminal;
    String Ach_tier_1;
    String Ach_tier_2;
    String Ach_tier_3;
    String Per_transaction_fee;
    String Default_pricing_tier_id;
    String Promo_expiry_date;
    String Max_ach_fee;
    boolean Bank_transfer_enabled;
    boolean Tos_accepted;
    String State;
    String v_Email;
    String Total_payout;
    String Next_payout_date;
    String Bank_name;
    String Last_payment_date;
    String Last_payment_amount;
    String Withdrawal_period;
    String Withdrawal_type;
    String Incoming_pending_amount;
    String Manage_account_url;
    String Country;
    String stripeId;
    String Gateway_user_id;
    String User_state;
    String stripeEmail;
    String stripeCountry;
    String Publishable_key;
    boolean stripeBank_transfer_enabled;
    int stripeMax_ach_fee;
    String paypal;
    int j;
    int count_j;
    String strVal;

    int i = 0;
    int count_i = jResp.SizeOfArray("gateway_connections");
    while (i < count_i) {
        jResp.put_I(i);
        Id = jResp.stringOf("gateway_connections[i].fbpay.id");
        Account_id = jResp.stringOf("gateway_connections[i].fbpay.account_id");
        Visa_debit_accepted = jResp.BoolOf("gateway_connections[i].fbpay.visa_debit_accepted");
        Tier_id = jResp.IntOf("gateway_connections[i].fbpay.pricing.tier_id");
        Percent_ach = jResp.stringOf("gateway_connections[i].fbpay.pricing.percent_ach");
        Percent_non_amex = jResp.stringOf("gateway_connections[i].fbpay.pricing.percent_non_amex");
        Percent_non_amex_with_card = jResp.stringOf("gateway_connections[i].fbpay.pricing.percent_non_amex_with_card");
        Percent_amex = jResp.stringOf("gateway_connections[i].fbpay.pricing.percent_amex");
        Percent_amex_with_card = jResp.stringOf("gateway_connections[i].fbpay.pricing.percent_amex_with_card");
        Percent_virtual_terminal = jResp.stringOf("gateway_connections[i].fbpay.pricing.percent_virtual_terminal");
        Ach_tier_1 = jResp.stringOf("gateway_connections[i].fbpay.pricing.ach_tier_1");
        Ach_tier_2 = jResp.stringOf("gateway_connections[i].fbpay.pricing.ach_tier_2");
        Ach_tier_3 = jResp.stringOf("gateway_connections[i].fbpay.pricing.ach_tier_3");
        Per_transaction_fee = jResp.stringOf("gateway_connections[i].fbpay.pricing.per_transaction_fee");
        Default_pricing_tier_id = jResp.stringOf("gateway_connections[i].fbpay.pricing.default_pricing_tier_id");
        Promo_expiry_date = jResp.stringOf("gateway_connections[i].fbpay.pricing.promo_expiry_date");
        Max_ach_fee = jResp.stringOf("gateway_connections[i].fbpay.pricing.max_ach_fee");
        Bank_transfer_enabled = jResp.BoolOf("gateway_connections[i].fbpay.bank_transfer_enabled");
        Tos_accepted = jResp.BoolOf("gateway_connections[i].fbpay.tos_accepted");
        State = jResp.stringOf("gateway_connections[i].fbpay.state");
        v_Email = jResp.stringOf("gateway_connections[i].fbpay.email");
        Total_payout = jResp.stringOf("gateway_connections[i].fbpay.bank_info.total_payout");
        Next_payout_date = jResp.stringOf("gateway_connections[i].fbpay.bank_info.next_payout_date");
        Bank_name = jResp.stringOf("gateway_connections[i].fbpay.bank_info.bank_name");
        Last_payment_date = jResp.stringOf("gateway_connections[i].fbpay.bank_info.last_payment_date");
        Last_payment_amount = jResp.stringOf("gateway_connections[i].fbpay.bank_info.last_payment_amount");
        Withdrawal_period = jResp.stringOf("gateway_connections[i].fbpay.bank_info.withdrawal_period");
        Withdrawal_type = jResp.stringOf("gateway_connections[i].fbpay.bank_info.withdrawal_type");
        Incoming_pending_amount = jResp.stringOf("gateway_connections[i].fbpay.bank_info.incoming_pending_amount");
        Manage_account_url = jResp.stringOf("gateway_connections[i].fbpay.manage_account_url");
        Country = jResp.stringOf("gateway_connections[i].fbpay.country");
        stripeId = jResp.stringOf("gateway_connections[i].stripe.id");
        Gateway_user_id = jResp.stringOf("gateway_connections[i].stripe.gateway_user_id");
        User_state = jResp.stringOf("gateway_connections[i].stripe.user_state");
        stripeEmail = jResp.stringOf("gateway_connections[i].stripe.email");
        stripeCountry = jResp.stringOf("gateway_connections[i].stripe.country");
        Publishable_key = jResp.stringOf("gateway_connections[i].stripe.publishable_key");
        stripeBank_transfer_enabled = jResp.BoolOf("gateway_connections[i].stripe.bank_transfer_enabled");
        stripeMax_ach_fee = jResp.IntOf("gateway_connections[i].stripe.max_ach_fee");
        paypal = jResp.stringOf("gateway_connections[i].paypal");
        j = 0;
        count_j = jResp.SizeOfArray("gateway_connections[i].fbpay.bank_info.withdrawal_schedule");
        while (j < count_j) {
            jResp.put_J(j);
            j = j + 1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("gateway_connections[i].fbpay.bank_info.outgoing_withdrawal_schedule");
        while (j < count_j) {
            jResp.put_J(j);
            j = j + 1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("gateway_connections[i].fbpay.currencies");
        while (j < count_j) {
            jResp.put_J(j);
            strVal = jResp.stringOf("gateway_connections[i].fbpay.currencies[j]");
            j = j + 1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("gateway_connections[i].fbpay.action_reasons");
        while (j < count_j) {
            jResp.put_J(j);
            j = j + 1;
            }

        j = 0;
        count_j = jResp.SizeOfArray("gateway_connections[i].stripe.currencies");
        while (j < count_j) {
            jResp.put_J(j);
            strVal = jResp.stringOf("gateway_connections[i].stripe.currencies[j]");
            j = j + 1;
            }

        i = i + 1;
        }


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
https://api.freshbooks.com/payments/account/E86Qp/gateway

Postman Collection Item JSON

{
  "name": "1a. [STRIPE] -  Get Publishable Key",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "https://api.freshbooks.com/payments/account/E86Qp/gateway",
      "protocol": "https",
      "host": [
        "api",
        "freshbooks",
        "com"
      ],
      "path": [
        "payments",
        "account",
        "E86Qp",
        "gateway"
      ]
    }
  },
  "response": [
    {
      "name": "1a. [STRIPE] -  Get Publishable Key",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "https://api.freshbooks.com/payments/account/E86Qp/gateway",
          "protocol": "https",
          "host": [
            "api",
            "freshbooks",
            "com"
          ],
          "path": [
            "payments",
            "account",
            "E86Qp",
            "gateway"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Server",
          "value": "nginx"
        },
        {
          "key": "Date",
          "value": "Mon, 10 Aug 2020 19:15:46 GMT"
        },
        {
          "key": "Content-Type",
          "value": "application/vnd.api+json"
        },
        {
          "key": "Vary",
          "value": "Accept-Encoding"
        },
        {
          "key": "X-CardApp-Version",
          "value": "2008.16.0"
        },
        {
          "key": "X-NewRelic-App-Data",
          "value": "PxQBWV5TCBABV1FUDwYGV1QTGhE1AwE2QgNWEVlbQFtcCxYnRA9QFg1ZWU4FAkpXURQRTEVURAkRQ1VWEUgEA0QHTwNBFkZXQApME1IECQUFQlIWBxpKVkMLFBBUVBVKVB0GHVZfUFYJVwxUDAsGBgpQCFAGTR5TSBRUUAMFCgBSAFMHBFUBAABXFB8EBw8RVT8="
        },
        {
          "key": "X-Frame-Options",
          "value": "SAMEORIGIN"
        },
        {
          "key": "X-XSS-Protection",
          "value": "1; mode=block"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "Content-Security-Policy",
          "value": "default-src 'self'"
        },
        {
          "key": "X-Content-Security-Policy",
          "value": "default-src 'self'"
        },
        {
          "key": "Strict-Transport-Security",
          "value": "max-age=31556926; includeSubDomains; preload"
        },
        {
          "key": "Referrer-Policy",
          "value": "strict-origin-when-cross-origin"
        },
        {
          "key": "X-RateLimit-Limit",
          "value": "600"
        },
        {
          "key": "X-RateLimit-Remaining",
          "value": "599"
        },
        {
          "key": "X-RateLimit-Reset",
          "value": "1597087006"
        },
        {
          "key": "Retry-After",
          "value": "59"
        },
        {
          "key": "Access-Control-Allow-Origin",
          "value": "*"
        },
        {
          "key": "Content-Encoding",
          "value": "gzip"
        },
        {
          "key": "Via",
          "value": "1.1 google"
        },
        {
          "key": "Alt-Svc",
          "value": "h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""
        },
        {
          "key": "Transfer-Encoding",
          "value": "chunked"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"gateway_connections\": [\n        {\n            \"fbpay\": {\n                \"id\": \"89dsyfaiosuhlasdjkhcsaldc89879875ih435h\",\n                \"account_id\": \"45435345345\",\n                \"visa_debit_accepted\": true,\n                \"pricing\": {\n                    \"tier_id\": 105,\n                    \"percent_ach\": \"0.00\",\n                    \"percent_non_amex\": \"2.90\",\n                    \"percent_non_amex_with_card\": \"2.70\",\n                    \"percent_amex\": \"3.50\",\n                    \"percent_amex_with_card\": \"3.40\",\n                    \"percent_virtual_terminal\": \"3.50\",\n                    \"ach_tier_1\": null,\n                    \"ach_tier_2\": null,\n                    \"ach_tier_3\": null,\n                    \"per_transaction_fee\": \"0.30\",\n                    \"default_pricing_tier_id\": null,\n                    \"promo_expiry_date\": null,\n                    \"max_ach_fee\": null\n                },\n                \"bank_transfer_enabled\": false,\n                \"tos_accepted\": true,\n                \"state\": \"active\",\n                \"email\": \"mjohnston@freshbooks.com\",\n                \"bank_info\": {\n                    \"total_payout\": \"0\",\n                    \"next_payout_date\": null,\n                    \"bank_name\": \"Gotham Bank XXXXXX2020\",\n                    \"last_payment_date\": \"2020-06-10T22:47:54Z\",\n                    \"last_payment_amount\": \"1240.79\",\n                    \"withdrawal_period\": \"daily\",\n                    \"withdrawal_type\": \"ach\",\n                    \"withdrawal_schedule\": [],\n                    \"incoming_pending_amount\": \"0\",\n                    \"outgoing_withdrawal_schedule\": []\n                },\n                \"manage_account_url\": \"https://wepay.com/account/15524535345\",\n                \"currencies\": [\n                    \"CAD\"\n                ],\n                \"country\": \"CA\",\n                \"action_reasons\": []\n            },\n            \"stripe\": {\n                \"id\": \"63kljSDHfglsfjhsf88sdfsd98dsflkjhav\",\n                \"gateway_user_id\": \"acct_jdhaklsdjnc345\",\n                \"user_state\": \"registered\",\n                \"email\": \"mjohnston@freshbooks.com\",\n                \"country\": \"CA\",\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                \"publishable_key\": \"pk_live_kha8dfy9oahvoi4h3qpj12qfp0234q9fuqp4938fh34pufh34pf84334f934hfp34uqif43345634oi5y4\",\n                \"bank_transfer_enabled\": false,\n                \"max_ach_fee\": 5000\n            },\n            \"paypal\": null\n        }\n    ]\n}"
    }
  ]
}