Creates a single use token that wraps the details of personally identifiable information (PII). This token can be used in place of a personal_id_number in the Account Update API method. These tokens can only be used once.
curl https://api.stripe.com/v1/tokens \
-u STRIPE_SECRET_KEY: \
-d pii[personal_id_number]=000000000 \
-X POST
#include <CkRestW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
CkRestW rest;
bool success;
// URL: https://api.stripe.com/v1/tokens
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"pii[personal_id_number]",L"000000000");
const wchar_t *strResponseBody = rest.fullRequestFormUrlEncoded(L"POST",L"/v1/tokens");
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;
bool client_ip;
int created;
bool livemode;
const wchar_t *type = 0;
bool used;
id = jsonResponse.stringOf(L"id");
object = jsonResponse.stringOf(L"object");
client_ip = jsonResponse.IsNullOf(L"client_ip");
created = jsonResponse.IntOf(L"created");
livemode = jsonResponse.BoolOf(L"livemode");
type = jsonResponse.stringOf(L"type");
used = jsonResponse.BoolOf(L"used");
}
{
"id": "pii_1BnETKGswQrCoh0XMUBp4DiD",
"object": "token",
"client_ip": null,
"created": 1516662782,
"livemode": false,
"type": "pii",
"used": false
}