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:

C++ Example

#include <CkRest.h>
#include <CkStringBuilder.h>
#include <CkJsonObject.h>

void ChilkatSample(void)
    {
    CkRest rest;
    bool success;

    //  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL
    bool bTls = true;
    int port = 443;
    bool bAutoReconnect = true;
    success = rest.Connect("api.stripe.com",port,bTls,bAutoReconnect);
    if (success != true) {
        std::cout << "ConnectFailReason: " << rest.get_ConnectFailReason() << "\r\n";
        std::cout << rest.lastErrorText() << "\r\n";
        return;
    }

    rest.SetAuthBasic("STRIPE_SECRET_KEY","");

    CkStringBuilder sbResponseBody;
    success = rest.FullRequestNoBodySb("GET","/v1/customers/cus_CBbg3iRMzWBjoe/sources/card_1BnETKGswQrCoh0Xhu1A6BfL",sbResponseBody);
    if (success != true) {
        std::cout << rest.lastErrorText() << "\r\n";
        return;
    }

    CkJsonObject jsonResponse;
    jsonResponse.LoadSb(sbResponseBody);

    const char *id = 0;
    const char *object = 0;
    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 char *brand = 0;
    const char *country = 0;
    const char *customer = 0;
    bool cvc_check;
    bool dynamic_last4;
    int exp_month;
    int exp_year;
    const char *fingerprint = 0;
    const char *funding = 0;
    const char *last4 = 0;
    bool name;
    bool tokenization_method;

    id = jsonResponse.stringOf("id");
    object = jsonResponse.stringOf("object");
    address_city = jsonResponse.IsNullOf("address_city");
    address_country = jsonResponse.IsNullOf("address_country");
    address_line1 = jsonResponse.IsNullOf("address_line1");
    address_line1_check = jsonResponse.IsNullOf("address_line1_check");
    address_line2 = jsonResponse.IsNullOf("address_line2");
    address_state = jsonResponse.IsNullOf("address_state");
    address_zip = jsonResponse.IsNullOf("address_zip");
    address_zip_check = jsonResponse.IsNullOf("address_zip_check");
    brand = jsonResponse.stringOf("brand");
    country = jsonResponse.stringOf("country");
    customer = jsonResponse.stringOf("customer");
    cvc_check = jsonResponse.IsNullOf("cvc_check");
    dynamic_last4 = jsonResponse.IsNullOf("dynamic_last4");
    exp_month = jsonResponse.IntOf("exp_month");
    exp_year = jsonResponse.IntOf("exp_year");
    fingerprint = jsonResponse.stringOf("fingerprint");
    funding = jsonResponse.stringOf("funding");
    last4 = jsonResponse.stringOf("last4");
    name = jsonResponse.IsNullOf("name");
    tokenization_method = jsonResponse.IsNullOf("tokenization_method");
    }

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
}