Objective-C Stripe: Create a PII Token

Back to Index

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.

Documentation: https://stripe.com/docs/api/curl#create_pii_token

CURL Command

curl https://api.stripe.com/v1/tokens \
   -d pii[personal_id_number]=000000000 \
   -X POST

Objective-C Example

#import <CkoRest.h>
#import <NSString.h>
#import <CkoJsonObject.h>

CkoRest *rest = [[CkoRest alloc] init];
BOOL success;

//  URL: https://api.stripe.com/v1/tokens
BOOL bTls = YES;
int port = 443;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"api.stripe.com" port: [NSNumber numberWithInt: port] tls: bTls autoReconnect: bAutoReconnect];
if (success != YES) {
    NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);

[rest SetAuthBasic: @"STRIPE_SECRET_KEY" password: @""];

[rest AddQueryParam: @"pii[personal_id_number]" value: @"000000000"];

NSString *strResponseBody = [rest FullRequestFormUrlEncoded: @"POST" uriPath: @"/v1/tokens"];
if (rest.LastMethodSuccess != YES) {

CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse Load: strResponseBody];

NSString *id = 0;
NSString *object = 0;
BOOL client_ip;
int created;
BOOL livemode;
NSString *type = 0;
BOOL used;

id = [jsonResponse StringOf: @"id"];
object = [jsonResponse StringOf: @"object"];
client_ip = [jsonResponse IsNullOf: @"client_ip"];
created = [[jsonResponse IntOf: @"created"] intValue];
livemode = [jsonResponse BoolOf: @"livemode"];
type = [jsonResponse StringOf: @"type"];
used = [jsonResponse BoolOf: @"used"];

Sample JSON Response Body

  "id": "pii_1BnETKGswQrCoh0XMUBp4DiD",
  "object": "token",
  "client_ip": null,
  "created": 1516662782,
  "livemode": false,
  "type": "pii",
  "used": false