Updates the specified source by setting the values of the parameters passed. Any parameters not provided will be left unchanged.
curl https://api.stripe.com/v1/sources/src_1BnETLGswQrCoh0X5KOorXEP \
-u STRIPE_SECRET_KEY: \
-d metadata[order_id]=6735 \
-X POST
#include <CkRestW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
CkRestW rest;
bool success;
// URL: https://api.stripe.com/v1/sources/src_1BnETLGswQrCoh0X5KOorXEP
bool bTls = true;
int port = 443;
bool bAutoReconnect = true;
success = rest.Connect(L"api.stripe.com",port,bTls,bAutoReconnect);
if (success != true) {
wprintf(L"ConnectFailReason: %d\n",rest.get_ConnectFailReason());
wprintf(L"%s\n",rest.lastErrorText());
return;
}
rest.SetAuthBasic(L"STRIPE_SECRET_KEY",L"");
rest.AddQueryParam(L"metadata[order_id]",L"6735");
const wchar_t *strResponseBody = rest.fullRequestFormUrlEncoded(L"POST",L"/v1/sources/src_1BnETLGswQrCoh0X5KOorXEP");
if (rest.get_LastMethodSuccess() != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
CkJsonObjectW jsonResponse;
jsonResponse.Load(strResponseBody);
const wchar_t *id = 0;
const wchar_t *object = 0;
int amount;
const wchar_t *client_secret = 0;
int created;
const wchar_t *currency = 0;
const wchar_t *flow = 0;
bool livemode;
const wchar_t *metadataOrder_id = 0;
bool ownerAddress;
const wchar_t *ownerEmail = 0;
bool ownerName;
bool ownerPhone;
bool ownerVerified_address;
bool ownerVerified_email;
bool ownerVerified_name;
bool ownerVerified_phone;
const wchar_t *receiverAddress = 0;
int receiverAmount_charged;
int receiverAmount_received;
int receiverAmount_returned;
const wchar_t *receiverRefund_attributes_method = 0;
const wchar_t *receiverRefund_attributes_status = 0;
bool statement_descriptor;
const wchar_t *status = 0;
const wchar_t *type = 0;
const wchar_t *usage = 0;
const wchar_t *bitcoinAddress = 0;
int bitcoinAmount;
int bitcoinAmount_charged;
int bitcoinAmount_received;
int bitcoinAmount_returned;
const wchar_t *bitcoinUri = 0;
id = jsonResponse.stringOf(L"id");
object = jsonResponse.stringOf(L"object");
amount = jsonResponse.IntOf(L"amount");
client_secret = jsonResponse.stringOf(L"client_secret");
created = jsonResponse.IntOf(L"created");
currency = jsonResponse.stringOf(L"currency");
flow = jsonResponse.stringOf(L"flow");
livemode = jsonResponse.BoolOf(L"livemode");
metadataOrder_id = jsonResponse.stringOf(L"metadata.order_id");
ownerAddress = jsonResponse.IsNullOf(L"owner.address");
ownerEmail = jsonResponse.stringOf(L"owner.email");
ownerName = jsonResponse.IsNullOf(L"owner.name");
ownerPhone = jsonResponse.IsNullOf(L"owner.phone");
ownerVerified_address = jsonResponse.IsNullOf(L"owner.verified_address");
ownerVerified_email = jsonResponse.IsNullOf(L"owner.verified_email");
ownerVerified_name = jsonResponse.IsNullOf(L"owner.verified_name");
ownerVerified_phone = jsonResponse.IsNullOf(L"owner.verified_phone");
receiverAddress = jsonResponse.stringOf(L"receiver.address");
receiverAmount_charged = jsonResponse.IntOf(L"receiver.amount_charged");
receiverAmount_received = jsonResponse.IntOf(L"receiver.amount_received");
receiverAmount_returned = jsonResponse.IntOf(L"receiver.amount_returned");
receiverRefund_attributes_method = jsonResponse.stringOf(L"receiver.refund_attributes_method");
receiverRefund_attributes_status = jsonResponse.stringOf(L"receiver.refund_attributes_status");
statement_descriptor = jsonResponse.IsNullOf(L"statement_descriptor");
status = jsonResponse.stringOf(L"status");
type = jsonResponse.stringOf(L"type");
usage = jsonResponse.stringOf(L"usage");
bitcoinAddress = jsonResponse.stringOf(L"bitcoin.address");
bitcoinAmount = jsonResponse.IntOf(L"bitcoin.amount");
bitcoinAmount_charged = jsonResponse.IntOf(L"bitcoin.amount_charged");
bitcoinAmount_received = jsonResponse.IntOf(L"bitcoin.amount_received");
bitcoinAmount_returned = jsonResponse.IntOf(L"bitcoin.amount_returned");
bitcoinUri = jsonResponse.stringOf(L"bitcoin.uri");
}
{
"id": "src_1BnETLGswQrCoh0X5KOorXEP",
"object": "source",
"amount": 1000,
"client_secret": "src_client_secret_CBbgdvc1AflN5jN0wQevA2jA",
"created": 1516662783,
"currency": "usd",
"flow": "receiver",
"livemode": false,
"metadata": {
"order_id": "6735"
},
"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"
}
}