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:

C Example

#include <C_CkRest.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>

void ChilkatSample(void)
    {
    HCkRest rest;
    BOOL success;
    BOOL bTls;
    int port;
    BOOL bAutoReconnect;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jsonResponse;
    const char *id;
    const char *object;
    int amount;
    const char *client_secret;
    int created;
    const char *currency;
    const char *flow;
    BOOL livemode;
    BOOL ownerAddress;
    const char *ownerEmail;
    BOOL ownerName;
    BOOL ownerPhone;
    BOOL ownerVerified_address;
    BOOL ownerVerified_email;
    BOOL ownerVerified_name;
    BOOL ownerVerified_phone;
    const char *receiverAddress;
    int receiverAmount_charged;
    int receiverAmount_received;
    int receiverAmount_returned;
    const char *receiverRefund_attributes_method;
    const char *receiverRefund_attributes_status;
    BOOL statement_descriptor;
    const char *status;
    const char *type;
    const char *usage;
    const char *bitcoinAddress;
    int bitcoinAmount;
    int bitcoinAmount_charged;
    int bitcoinAmount_received;
    int bitcoinAmount_returned;
    const char *bitcoinUri;

    rest = CkRest_Create();

    //  URL: https://api.stripe.com/v1/sources/src_1BnETLGswQrCoh0X5KOorXEP
    bTls = TRUE;
    port = 443;
    bAutoReconnect = TRUE;
    success = CkRest_Connect(rest,"api.stripe.com",port,bTls,bAutoReconnect);
    if (success != TRUE) {
        printf("ConnectFailReason: %d\n",CkRest_getConnectFailReason(rest));
        printf("%s\n",CkRest_lastErrorText(rest));
        CkRest_Dispose(rest);
        return;
    }

    CkRest_SetAuthBasic(rest,"STRIPE_SECRET_KEY","");

    sbResponseBody = CkStringBuilder_Create();
    success = CkRest_FullRequestNoBodySb(rest,"GET","/v1/sources/src_1BnETLGswQrCoh0X5KOorXEP",sbResponseBody);
    if (success != TRUE) {
        printf("%s\n",CkRest_lastErrorText(rest));
        CkRest_Dispose(rest);
        CkStringBuilder_Dispose(sbResponseBody);
        return;
    }

    jsonResponse = CkJsonObject_Create();
    CkJsonObject_LoadSb(jsonResponse,sbResponseBody);

    id = CkJsonObject_stringOf(jsonResponse,"id");
    object = CkJsonObject_stringOf(jsonResponse,"object");
    amount = CkJsonObject_IntOf(jsonResponse,"amount");
    client_secret = CkJsonObject_stringOf(jsonResponse,"client_secret");
    created = CkJsonObject_IntOf(jsonResponse,"created");
    currency = CkJsonObject_stringOf(jsonResponse,"currency");
    flow = CkJsonObject_stringOf(jsonResponse,"flow");
    livemode = CkJsonObject_BoolOf(jsonResponse,"livemode");
    ownerAddress = CkJsonObject_IsNullOf(jsonResponse,"owner.address");
    ownerEmail = CkJsonObject_stringOf(jsonResponse,"owner.email");
    ownerName = CkJsonObject_IsNullOf(jsonResponse,"owner.name");
    ownerPhone = CkJsonObject_IsNullOf(jsonResponse,"owner.phone");
    ownerVerified_address = CkJsonObject_IsNullOf(jsonResponse,"owner.verified_address");
    ownerVerified_email = CkJsonObject_IsNullOf(jsonResponse,"owner.verified_email");
    ownerVerified_name = CkJsonObject_IsNullOf(jsonResponse,"owner.verified_name");
    ownerVerified_phone = CkJsonObject_IsNullOf(jsonResponse,"owner.verified_phone");
    receiverAddress = CkJsonObject_stringOf(jsonResponse,"receiver.address");
    receiverAmount_charged = CkJsonObject_IntOf(jsonResponse,"receiver.amount_charged");
    receiverAmount_received = CkJsonObject_IntOf(jsonResponse,"receiver.amount_received");
    receiverAmount_returned = CkJsonObject_IntOf(jsonResponse,"receiver.amount_returned");
    receiverRefund_attributes_method = CkJsonObject_stringOf(jsonResponse,"receiver.refund_attributes_method");
    receiverRefund_attributes_status = CkJsonObject_stringOf(jsonResponse,"receiver.refund_attributes_status");
    statement_descriptor = CkJsonObject_IsNullOf(jsonResponse,"statement_descriptor");
    status = CkJsonObject_stringOf(jsonResponse,"status");
    type = CkJsonObject_stringOf(jsonResponse,"type");
    usage = CkJsonObject_stringOf(jsonResponse,"usage");
    bitcoinAddress = CkJsonObject_stringOf(jsonResponse,"bitcoin.address");
    bitcoinAmount = CkJsonObject_IntOf(jsonResponse,"bitcoin.amount");
    bitcoinAmount_charged = CkJsonObject_IntOf(jsonResponse,"bitcoin.amount_charged");
    bitcoinAmount_received = CkJsonObject_IntOf(jsonResponse,"bitcoin.amount_received");
    bitcoinAmount_returned = CkJsonObject_IntOf(jsonResponse,"bitcoin.amount_returned");
    bitcoinUri = CkJsonObject_stringOf(jsonResponse,"bitcoin.uri");


    CkRest_Dispose(rest);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_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"
  }
}