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 <CkRest.h>
#include <CkJsonObject.h>
void ChilkatSample(void)
{
CkRest rest;
bool success;
// URL: https://api.stripe.com/v1/tokens
bool bTls = true;
int port = 443;
bool bAutoReconnect = true;
success = rest.Connect("api.stripe.com",port,bTls,bAutoReconnect);
if (success != true) {
std::cout << "ConnectFailReason: " << rest.get_ConnectFailReason() << "\r\n";
std::cout << rest.lastErrorText() << "\r\n";
return;
}
rest.SetAuthBasic("STRIPE_SECRET_KEY","");
rest.AddQueryParam("pii[personal_id_number]","000000000");
const char *strResponseBody = rest.fullRequestFormUrlEncoded("POST","/v1/tokens");
if (rest.get_LastMethodSuccess() != true) {
std::cout << rest.lastErrorText() << "\r\n";
return;
}
CkJsonObject jsonResponse;
jsonResponse.Load(strResponseBody);
const char *id = 0;
const char *object = 0;
bool client_ip;
int created;
bool livemode;
const char *type = 0;
bool used;
id = jsonResponse.stringOf("id");
object = jsonResponse.stringOf("object");
client_ip = jsonResponse.IsNullOf("client_ip");
created = jsonResponse.IntOf("created");
livemode = jsonResponse.BoolOf("livemode");
type = jsonResponse.stringOf("type");
used = jsonResponse.BoolOf("used");
}
{
"id": "pii_1BnETKGswQrCoh0XMUBp4DiD",
"object": "token",
"client_ip": null,
"created": 1516662782,
"livemode": false,
"type": "pii",
"used": false
}