PowerBuilder 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

PowerBuilder Example

integer li_rc
oleobject loo_Rest
integer li_Success
integer li_BTls
integer li_Port
integer li_BAutoReconnect
string ls_StrResponseBody
oleobject loo_JsonResponse
string ls_Id
string ls_Object
integer li_Client_ip
integer li_Created
integer li_Livemode
string ls_Type
integer li_Used

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
    destroy loo_Rest
    MessageBox("Error","Connecting to COM object failed")
end if

//  URL: https://api.stripe.com/v1/tokens
li_BTls = 1
li_Port = 443
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("api.stripe.com",li_Port,li_BTls,li_BAutoReconnect)
if li_Success <> 1 then
    Write-Debug "ConnectFailReason: " + string(loo_Rest.ConnectFailReason)
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
end if



ls_StrResponseBody = loo_Rest.FullRequestFormUrlEncoded("POST","/v1/tokens")
if loo_Rest.LastMethodSuccess <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
end if

loo_JsonResponse = create oleobject
li_rc = loo_JsonResponse.ConnectToNewObject("Chilkat_9_5_0.JsonObject")


ls_Id = loo_JsonResponse.StringOf("id")
ls_Object = loo_JsonResponse.StringOf("object")
li_Client_ip = loo_JsonResponse.IsNullOf("client_ip")
li_Created = loo_JsonResponse.IntOf("created")
li_Livemode = loo_JsonResponse.BoolOf("livemode")
ls_Type = loo_JsonResponse.StringOf("type")
li_Used = loo_JsonResponse.BoolOf("used")

destroy loo_Rest
destroy loo_JsonResponse

Sample JSON Response Body

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