Creates a new customer object.
curl -X POST https://api.stripe.com/v1/customers \
-u STRIPE_SECRET_KEY: \
-d description="Customer for isabella.williams@example.com" \
-d source=tok_amex
load ./chilkat.dll
set rest [new_CkRest]
# URL: https://api.stripe.com/v1/customers
set bTls 1
set port 443
set bAutoReconnect 1
set success [CkRest_Connect $rest "api.stripe.com" $port $bTls $bAutoReconnect]
if {[expr $success != 1]} then {
puts "ConnectFailReason: [CkRest_ConnectFailReason $rest]"
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
exit
}
CkRest_SetAuthBasic $rest "STRIPE_SECRET_KEY" ""
CkRest_AddQueryParam $rest "description" "Customer for isabella.williams@example.com"
CkRest_AddQueryParam $rest "source" "tok_amex"
set strResponseBody [CkRest_fullRequestFormUrlEncoded $rest "POST" "/v1/customers"]
if {[expr [CkRest_LastMethodSuccess $rest] != 1]} then {
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
exit
}
set jsonResponse [new_CkJsonObject]
CkJsonObject_Load $jsonResponse $strResponseBody
set id [CkJsonObject_stringOf $jsonResponse "id"]
set object [CkJsonObject_stringOf $jsonResponse "object"]
set account_balance [CkJsonObject_IntOf $jsonResponse "account_balance"]
set created [CkJsonObject_IntOf $jsonResponse "created"]
set currency [CkJsonObject_stringOf $jsonResponse "currency"]
set default_source [CkJsonObject_IsNullOf $jsonResponse "default_source"]
set delinquent [CkJsonObject_BoolOf $jsonResponse "delinquent"]
set description [CkJsonObject_IsNullOf $jsonResponse "description"]
set discount [CkJsonObject_IsNullOf $jsonResponse "discount"]
set email [CkJsonObject_IsNullOf $jsonResponse "email"]
set livemode [CkJsonObject_BoolOf $jsonResponse "livemode"]
set shipping [CkJsonObject_IsNullOf $jsonResponse "shipping"]
set sourcesObject [CkJsonObject_stringOf $jsonResponse "sources.object"]
set sourcesHas_more [CkJsonObject_BoolOf $jsonResponse "sources.has_more"]
set sourcesTotal_count [CkJsonObject_IntOf $jsonResponse "sources.total_count"]
set sourcesUrl [CkJsonObject_stringOf $jsonResponse "sources.url"]
set subscriptionsObject [CkJsonObject_stringOf $jsonResponse "subscriptions.object"]
set subscriptionsHas_more [CkJsonObject_BoolOf $jsonResponse "subscriptions.has_more"]
set subscriptionsTotal_count [CkJsonObject_IntOf $jsonResponse "subscriptions.total_count"]
set subscriptionsUrl [CkJsonObject_stringOf $jsonResponse "subscriptions.url"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jsonResponse "sources.data"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $jsonResponse $i
set i [expr $i + 1]
}
set i 0
set count_i [CkJsonObject_SizeOfArray $jsonResponse "subscriptions.data"]
while {[expr $i < $count_i]} {
CkJsonObject_put_I $jsonResponse $i
set i [expr $i + 1]
}
delete_CkRest $rest
delete_CkJsonObject $jsonResponse
{
"id": "cus_CBbgVLJqv487Oq",
"object": "customer",
"account_balance": 0,
"created": 1516662781,
"currency": "usd",
"default_source": null,
"delinquent": false,
"description": null,
"discount": null,
"email": null,
"livemode": false,
"metadata": {},
"shipping": null,
"sources": {
"object": "list",
"data": [
],
"has_more": false,
"total_count": 0,
"url": "/v1/customers/cus_CBbgVLJqv487Oq/sources"
},
"subscriptions": {
"object": "list",
"data": [
],
"has_more": false,
"total_count": 0,
"url": "/v1/customers/cus_CBbgVLJqv487Oq/subscriptions"
}
}