Unicode C Stripe: Retrieve a Card

Back to Index

Retrieve details about a specific card stored on the customer or recipient.

Documentation: https://stripe.com/docs/api/curl#retrieve_card

CURL Command

curl https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL \
   -u STRIPE_SECRET_KEY:

Unicode C Example

#include <C_CkRestW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>

void ChilkatSample(void)
    {
    HCkRestW rest;
    BOOL success;
    BOOL bTls;
    int port;
    BOOL bAutoReconnect;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jsonResponse;
    const wchar_t *id;
    const wchar_t *object;
    BOOL address_city;
    BOOL address_country;
    BOOL address_line1;
    BOOL address_line1_check;
    BOOL address_line2;
    BOOL address_state;
    BOOL address_zip;
    BOOL address_zip_check;
    const wchar_t *brand;
    const wchar_t *country;
    const wchar_t *customer;
    BOOL cvc_check;
    BOOL dynamic_last4;
    int exp_month;
    int exp_year;
    const wchar_t *fingerprint;
    const wchar_t *funding;
    const wchar_t *last4;
    BOOL name;
    BOOL tokenization_method;

    rest = CkRestW_Create();

    //  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL
    bTls = TRUE;
    port = 443;
    bAutoReconnect = TRUE;
    success = CkRestW_Connect(rest,L"api.stripe.com",port,bTls,bAutoReconnect);
    if (success != TRUE) {
        wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        return;
    }

    CkRestW_SetAuthBasic(rest,L"STRIPE_SECRET_KEY",L"");

    sbResponseBody = CkStringBuilderW_Create();
    success = CkRestW_FullRequestNoBodySb(rest,L"GET",L"/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL",sbResponseBody);
    if (success != TRUE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }

    jsonResponse = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);

    id = CkJsonObjectW_stringOf(jsonResponse,L"id");
    object = CkJsonObjectW_stringOf(jsonResponse,L"object");
    address_city = CkJsonObjectW_IsNullOf(jsonResponse,L"address_city");
    address_country = CkJsonObjectW_IsNullOf(jsonResponse,L"address_country");
    address_line1 = CkJsonObjectW_IsNullOf(jsonResponse,L"address_line1");
    address_line1_check = CkJsonObjectW_IsNullOf(jsonResponse,L"address_line1_check");
    address_line2 = CkJsonObjectW_IsNullOf(jsonResponse,L"address_line2");
    address_state = CkJsonObjectW_IsNullOf(jsonResponse,L"address_state");
    address_zip = CkJsonObjectW_IsNullOf(jsonResponse,L"address_zip");
    address_zip_check = CkJsonObjectW_IsNullOf(jsonResponse,L"address_zip_check");
    brand = CkJsonObjectW_stringOf(jsonResponse,L"brand");
    country = CkJsonObjectW_stringOf(jsonResponse,L"country");
    customer = CkJsonObjectW_stringOf(jsonResponse,L"customer");
    cvc_check = CkJsonObjectW_IsNullOf(jsonResponse,L"cvc_check");
    dynamic_last4 = CkJsonObjectW_IsNullOf(jsonResponse,L"dynamic_last4");
    exp_month = CkJsonObjectW_IntOf(jsonResponse,L"exp_month");
    exp_year = CkJsonObjectW_IntOf(jsonResponse,L"exp_year");
    fingerprint = CkJsonObjectW_stringOf(jsonResponse,L"fingerprint");
    funding = CkJsonObjectW_stringOf(jsonResponse,L"funding");
    last4 = CkJsonObjectW_stringOf(jsonResponse,L"last4");
    name = CkJsonObjectW_IsNullOf(jsonResponse,L"name");
    tokenization_method = CkJsonObjectW_IsNullOf(jsonResponse,L"tokenization_method");


    CkRestW_Dispose(rest);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jsonResponse);

    }

Sample JSON Response Body

{
  "id": "card_1BnETKGswQrCoh0Xhu1A6BfL",
  "object": "card",
  "address_city": null,
  "address_country": null,
  "address_line1": null,
  "address_line1_check": null,
  "address_line2": null,
  "address_state": null,
  "address_zip": null,
  "address_zip_check": null,
  "brand": "Visa",
  "country": "US",
  "customer": "cus_CBbg3iRMzWBjoe",
  "cvc_check": null,
  "dynamic_last4": null,
  "exp_month": 8,
  "exp_year": 2019,
  "fingerprint": "F9mANtIt1TaukpRJ",
  "funding": "credit",
  "last4": "4242",
  "metadata": {},
  "name": null,
  "tokenization_method": null
}