Returns a list of charges you’ve previously created. The charges are returned in sorted order, with the most recent charges appearing first.
curl https://api.stripe.com/v1/charges?limit=3 \
-u STRIPE_SECRET_KEY: \
-G
#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 *object;
const char *url;
BOOL has_more;
int i;
int count_i;
const char *id;
int amount;
int amount_refunded;
BOOL application;
BOOL application_fee;
const char *balance_transaction;
BOOL captured;
int created;
const char *currency;
BOOL customer;
const char *description;
BOOL destination;
BOOL dispute;
BOOL failure_code;
BOOL failure_message;
BOOL invoice;
BOOL livemode;
BOOL on_behalf_of;
BOOL order;
BOOL outcome;
BOOL paid;
BOOL receipt_email;
BOOL receipt_number;
BOOL refunded;
const char *refundsObject;
BOOL refundsHas_more;
int refundsTotal_count;
const char *refundsUrl;
BOOL review;
BOOL shipping;
const char *sourceId;
const char *sourceObject;
BOOL sourceAddress_city;
BOOL sourceAddress_country;
BOOL sourceAddress_line1;
BOOL sourceAddress_line1_check;
BOOL sourceAddress_line2;
BOOL sourceAddress_state;
BOOL sourceAddress_zip;
BOOL sourceAddress_zip_check;
const char *sourceBrand;
const char *sourceCountry;
BOOL sourceCustomer;
BOOL sourceCvc_check;
BOOL sourceDynamic_last4;
int sourceExp_month;
int sourceExp_year;
const char *sourceFingerprint;
const char *sourceFunding;
const char *sourceLast4;
BOOL sourceName;
BOOL sourceTokenization_method;
BOOL source_transfer;
BOOL statement_descriptor;
const char *status;
BOOL transfer_group;
int j;
int count_j;
rest = CkRest_Create();
// URL: https://api.stripe.com/v1/charges?limit=3
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/charges?limit=3",sbResponseBody);
if (success != TRUE) {
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
CkStringBuilder_Dispose(sbResponseBody);
return;
}
jsonResponse = CkJsonObject_Create();
CkJsonObject_LoadSb(jsonResponse,sbResponseBody);
object = CkJsonObject_stringOf(jsonResponse,"object");
url = CkJsonObject_stringOf(jsonResponse,"url");
has_more = CkJsonObject_BoolOf(jsonResponse,"has_more");
i = 0;
count_i = CkJsonObject_SizeOfArray(jsonResponse,"data");
while (i < count_i) {
CkJsonObject_putI(jsonResponse,i);
id = CkJsonObject_stringOf(jsonResponse,"data[i].id");
object = CkJsonObject_stringOf(jsonResponse,"data[i].object");
amount = CkJsonObject_IntOf(jsonResponse,"data[i].amount");
amount_refunded = CkJsonObject_IntOf(jsonResponse,"data[i].amount_refunded");
application = CkJsonObject_IsNullOf(jsonResponse,"data[i].application");
application_fee = CkJsonObject_IsNullOf(jsonResponse,"data[i].application_fee");
balance_transaction = CkJsonObject_stringOf(jsonResponse,"data[i].balance_transaction");
captured = CkJsonObject_BoolOf(jsonResponse,"data[i].captured");
created = CkJsonObject_IntOf(jsonResponse,"data[i].created");
currency = CkJsonObject_stringOf(jsonResponse,"data[i].currency");
customer = CkJsonObject_IsNullOf(jsonResponse,"data[i].customer");
description = CkJsonObject_stringOf(jsonResponse,"data[i].description");
destination = CkJsonObject_IsNullOf(jsonResponse,"data[i].destination");
dispute = CkJsonObject_IsNullOf(jsonResponse,"data[i].dispute");
failure_code = CkJsonObject_IsNullOf(jsonResponse,"data[i].failure_code");
failure_message = CkJsonObject_IsNullOf(jsonResponse,"data[i].failure_message");
invoice = CkJsonObject_IsNullOf(jsonResponse,"data[i].invoice");
livemode = CkJsonObject_BoolOf(jsonResponse,"data[i].livemode");
on_behalf_of = CkJsonObject_IsNullOf(jsonResponse,"data[i].on_behalf_of");
order = CkJsonObject_IsNullOf(jsonResponse,"data[i].order");
outcome = CkJsonObject_IsNullOf(jsonResponse,"data[i].outcome");
paid = CkJsonObject_BoolOf(jsonResponse,"data[i].paid");
receipt_email = CkJsonObject_IsNullOf(jsonResponse,"data[i].receipt_email");
receipt_number = CkJsonObject_IsNullOf(jsonResponse,"data[i].receipt_number");
refunded = CkJsonObject_BoolOf(jsonResponse,"data[i].refunded");
refundsObject = CkJsonObject_stringOf(jsonResponse,"data[i].refunds.object");
refundsHas_more = CkJsonObject_BoolOf(jsonResponse,"data[i].refunds.has_more");
refundsTotal_count = CkJsonObject_IntOf(jsonResponse,"data[i].refunds.total_count");
refundsUrl = CkJsonObject_stringOf(jsonResponse,"data[i].refunds.url");
review = CkJsonObject_IsNullOf(jsonResponse,"data[i].review");
shipping = CkJsonObject_IsNullOf(jsonResponse,"data[i].shipping");
sourceId = CkJsonObject_stringOf(jsonResponse,"data[i].source.id");
sourceObject = CkJsonObject_stringOf(jsonResponse,"data[i].source.object");
sourceAddress_city = CkJsonObject_IsNullOf(jsonResponse,"data[i].source.address_city");
sourceAddress_country = CkJsonObject_IsNullOf(jsonResponse,"data[i].source.address_country");
sourceAddress_line1 = CkJsonObject_IsNullOf(jsonResponse,"data[i].source.address_line1");
sourceAddress_line1_check = CkJsonObject_IsNullOf(jsonResponse,"data[i].source.address_line1_check");
sourceAddress_line2 = CkJsonObject_IsNullOf(jsonResponse,"data[i].source.address_line2");
sourceAddress_state = CkJsonObject_IsNullOf(jsonResponse,"data[i].source.address_state");
sourceAddress_zip = CkJsonObject_IsNullOf(jsonResponse,"data[i].source.address_zip");
sourceAddress_zip_check = CkJsonObject_IsNullOf(jsonResponse,"data[i].source.address_zip_check");
sourceBrand = CkJsonObject_stringOf(jsonResponse,"data[i].source.brand");
sourceCountry = CkJsonObject_stringOf(jsonResponse,"data[i].source.country");
sourceCustomer = CkJsonObject_IsNullOf(jsonResponse,"data[i].source.customer");
sourceCvc_check = CkJsonObject_IsNullOf(jsonResponse,"data[i].source.cvc_check");
sourceDynamic_last4 = CkJsonObject_IsNullOf(jsonResponse,"data[i].source.dynamic_last4");
sourceExp_month = CkJsonObject_IntOf(jsonResponse,"data[i].source.exp_month");
sourceExp_year = CkJsonObject_IntOf(jsonResponse,"data[i].source.exp_year");
sourceFingerprint = CkJsonObject_stringOf(jsonResponse,"data[i].source.fingerprint");
sourceFunding = CkJsonObject_stringOf(jsonResponse,"data[i].source.funding");
sourceLast4 = CkJsonObject_stringOf(jsonResponse,"data[i].source.last4");
sourceName = CkJsonObject_IsNullOf(jsonResponse,"data[i].source.name");
sourceTokenization_method = CkJsonObject_IsNullOf(jsonResponse,"data[i].source.tokenization_method");
source_transfer = CkJsonObject_IsNullOf(jsonResponse,"data[i].source_transfer");
statement_descriptor = CkJsonObject_IsNullOf(jsonResponse,"data[i].statement_descriptor");
status = CkJsonObject_stringOf(jsonResponse,"data[i].status");
transfer_group = CkJsonObject_IsNullOf(jsonResponse,"data[i].transfer_group");
j = 0;
count_j = CkJsonObject_SizeOfArray(jsonResponse,"data[i].refunds.data");
while (j < count_j) {
CkJsonObject_putJ(jsonResponse,j);
j = j + 1;
}
i = i + 1;
}
CkRest_Dispose(rest);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jsonResponse);
}
{
"object": "list",
"url": "/v1/charges",
"has_more": false,
"data": [
{
"id": "ch_1BnETJGswQrCoh0XTs0EERBj",
"object": "charge",
"amount": 100,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"balance_transaction": "txn_1BnETJGswQrCoh0XxO2tGYr7",
"captured": false,
"created": 1516662781,
"currency": "usd",
"customer": null,
"description": "My First Test Charge (created for API docs)",
"destination": null,
"dispute": null,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {},
"on_behalf_of": null,
"order": null,
"outcome": null,
"paid": true,
"receipt_email": null,
"receipt_number": null,
"refunded": false,
"refunds": {
"object": "list",
"data": [
],
"has_more": false,
"total_count": 0,
"url": "/v1/charges/ch_1BnETJGswQrCoh0XTs0EERBj/refunds"
},
"review": null,
"shipping": null,
"source": {
"id": "card_18ropuGswQrCoh0XjCJ5Zvma",
"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": null,
"cvc_check": null,
"dynamic_last4": null,
"exp_month": 8,
"exp_year": 2017,
"fingerprint": "F9mANtIt1TaukpRJ",
"funding": "credit",
"last4": "4242",
"metadata": {},
"name": null,
"tokenization_method": null
},
"source_transfer": null,
"statement_descriptor": null,
"status": "succeeded",
"transfer_group": null
}
]
}