Unicode C Stripe: Retrieve a Source

Back to Index

Retrieves an existing source object. Supply the unique source ID from a source creation request and Stripe will return the corresponding up-to-date source object information.

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

CURL Command

curl https://api.stripe.com/v1/sources/src_1BnETLGswQrCoh0X5KOorXEP \
   -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;
    int amount;
    const wchar_t *client_secret;
    int created;
    const wchar_t *currency;
    const wchar_t *flow;
    BOOL livemode;
    BOOL ownerAddress;
    const wchar_t *ownerEmail;
    BOOL ownerName;
    BOOL ownerPhone;
    BOOL ownerVerified_address;
    BOOL ownerVerified_email;
    BOOL ownerVerified_name;
    BOOL ownerVerified_phone;
    const wchar_t *receiverAddress;
    int receiverAmount_charged;
    int receiverAmount_received;
    int receiverAmount_returned;
    const wchar_t *receiverRefund_attributes_method;
    const wchar_t *receiverRefund_attributes_status;
    BOOL statement_descriptor;
    const wchar_t *status;
    const wchar_t *type;
    const wchar_t *usage;
    const wchar_t *bitcoinAddress;
    int bitcoinAmount;
    int bitcoinAmount_charged;
    int bitcoinAmount_received;
    int bitcoinAmount_returned;
    const wchar_t *bitcoinUri;

    rest = CkRestW_Create();

    //  URL: https://api.stripe.com/v1/sources/src_1BnETLGswQrCoh0X5KOorXEP
    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/sources/src_1BnETLGswQrCoh0X5KOorXEP",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");
    amount = CkJsonObjectW_IntOf(jsonResponse,L"amount");
    client_secret = CkJsonObjectW_stringOf(jsonResponse,L"client_secret");
    created = CkJsonObjectW_IntOf(jsonResponse,L"created");
    currency = CkJsonObjectW_stringOf(jsonResponse,L"currency");
    flow = CkJsonObjectW_stringOf(jsonResponse,L"flow");
    livemode = CkJsonObjectW_BoolOf(jsonResponse,L"livemode");
    ownerAddress = CkJsonObjectW_IsNullOf(jsonResponse,L"owner.address");
    ownerEmail = CkJsonObjectW_stringOf(jsonResponse,L"owner.email");
    ownerName = CkJsonObjectW_IsNullOf(jsonResponse,L"owner.name");
    ownerPhone = CkJsonObjectW_IsNullOf(jsonResponse,L"owner.phone");
    ownerVerified_address = CkJsonObjectW_IsNullOf(jsonResponse,L"owner.verified_address");
    ownerVerified_email = CkJsonObjectW_IsNullOf(jsonResponse,L"owner.verified_email");
    ownerVerified_name = CkJsonObjectW_IsNullOf(jsonResponse,L"owner.verified_name");
    ownerVerified_phone = CkJsonObjectW_IsNullOf(jsonResponse,L"owner.verified_phone");
    receiverAddress = CkJsonObjectW_stringOf(jsonResponse,L"receiver.address");
    receiverAmount_charged = CkJsonObjectW_IntOf(jsonResponse,L"receiver.amount_charged");
    receiverAmount_received = CkJsonObjectW_IntOf(jsonResponse,L"receiver.amount_received");
    receiverAmount_returned = CkJsonObjectW_IntOf(jsonResponse,L"receiver.amount_returned");
    receiverRefund_attributes_method = CkJsonObjectW_stringOf(jsonResponse,L"receiver.refund_attributes_method");
    receiverRefund_attributes_status = CkJsonObjectW_stringOf(jsonResponse,L"receiver.refund_attributes_status");
    statement_descriptor = CkJsonObjectW_IsNullOf(jsonResponse,L"statement_descriptor");
    status = CkJsonObjectW_stringOf(jsonResponse,L"status");
    type = CkJsonObjectW_stringOf(jsonResponse,L"type");
    usage = CkJsonObjectW_stringOf(jsonResponse,L"usage");
    bitcoinAddress = CkJsonObjectW_stringOf(jsonResponse,L"bitcoin.address");
    bitcoinAmount = CkJsonObjectW_IntOf(jsonResponse,L"bitcoin.amount");
    bitcoinAmount_charged = CkJsonObjectW_IntOf(jsonResponse,L"bitcoin.amount_charged");
    bitcoinAmount_received = CkJsonObjectW_IntOf(jsonResponse,L"bitcoin.amount_received");
    bitcoinAmount_returned = CkJsonObjectW_IntOf(jsonResponse,L"bitcoin.amount_returned");
    bitcoinUri = CkJsonObjectW_stringOf(jsonResponse,L"bitcoin.uri");


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

    }

Sample JSON Response Body

{
  "id": "src_1BnETLGswQrCoh0X5KOorXEP",
  "object": "source",
  "amount": 1000,
  "client_secret": "src_client_secret_CBbgdvc1AflN5jN0wQevA2jA",
  "created": 1516662783,
  "currency": "usd",
  "flow": "receiver",
  "livemode": false,
  "metadata": {},
  "owner": {
    "address": null,
    "email": "jenny.rosen@example.com",
    "name": null,
    "phone": null,
    "verified_address": null,
    "verified_email": null,
    "verified_name": null,
    "verified_phone": null
  },
  "receiver": {
    "address": "test_1MBhWS3uv4ynCfQXF3xQjJkzFPukr4K56N",
    "amount_charged": 0,
    "amount_received": 0,
    "amount_returned": 0,
    "refund_attributes_method": "email",
    "refund_attributes_status": "missing"
  },
  "statement_descriptor": null,
  "status": "pending",
  "type": "bitcoin",
  "usage": "single_use",
  "bitcoin": {
    "address": "test_1MBhWS3uv4ynCfQXF3xQjJkzFPukr4K56N",
    "amount": 2371000,
    "amount_charged": 0,
    "amount_received": 0,
    "amount_returned": 0,
    "uri": "bitcoin:test_1MBhWS3uv4ynCfQXF3xQjJkzFPukr4K56N?amount=0.02371000"
  }
}