Creates a new source object.
curl https://api.stripe.com/v1/sources \
-u STRIPE_SECRET_KEY: \
-d type=bitcoin \
-d amount=1000 \
-d currency=usd \
-d owner[email]="jenny.rosen@example.com" \
-X POST
#include <C_CkRest.h>
#include <C_CkJsonObject.h>
void ChilkatSample(void)
{
HCkRest rest;
BOOL success;
BOOL bTls;
int port;
BOOL bAutoReconnect;
const char *strResponseBody;
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
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","");
CkRest_AddQueryParam(rest,"type","bitcoin");
CkRest_AddQueryParam(rest,"amount","1000");
CkRest_AddQueryParam(rest,"currency","usd");
CkRest_AddQueryParam(rest,"owner[email]","jenny.rosen@example.com");
strResponseBody = CkRest_fullRequestFormUrlEncoded(rest,"POST","/v1/sources");
if (CkRest_getLastMethodSuccess(rest) != TRUE) {
printf("%s\n",CkRest_lastErrorText(rest));
CkRest_Dispose(rest);
return;
}
jsonResponse = CkJsonObject_Create();
CkJsonObject_Load(jsonResponse,strResponseBody);
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);
CkJsonObject_Dispose(jsonResponse);
}
{
"id": "src_1BnETKGswQrCoh0XUrU9xVhU",
"object": "source",
"amount": 1000,
"client_secret": "src_client_secret_CBbgwhcWX2mz2uzcVsX3vjfe",
"created": 1516662782,
"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"
}
}