Visual Basic 6.0 Stripe: Create a Bank Account Token

Back to Index

Creates a single use token that wraps the details of a bank account. This token can be used in place of a bank account dictionary with any API method.

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

CURL Command

curl https://api.stripe.com/v1/tokens \
   -u STRIPE_SECRET_KEY: \
   -d bank_account[country]=US \
   -d bank_account[currency]=usd \
   -d bank_account[account_holder_name]="Chloe White" \
   -d bank_account[account_holder_type]=individual \
   -d bank_account[routing_number]=110000000 \
   -d bank_account[account_number]=000123456789 \
   -X POST

Visual Basic 6.0 Example

Dim rest As New ChilkatRest
Dim success As Long

'  URL: https://api.stripe.com/v1/tokens
Dim bTls As Long
bTls = 1
Dim port As Long
port = 443
Dim bAutoReconnect As Long
bAutoReconnect = 1
success = rest.Connect("api.stripe.com",port,bTls,bAutoReconnect)
If (success <> 1) Then
    Debug.Print "ConnectFailReason: " & rest.ConnectFailReason
    Debug.Print rest.LastErrorText
    Exit Sub
End If

success = rest.SetAuthBasic("STRIPE_SECRET_KEY","")

success = rest.AddQueryParam("bank_account[country]","US")
success = rest.AddQueryParam("bank_account[currency]","usd")
success = rest.AddQueryParam("bank_account[account_holder_name]","Chloe White")
success = rest.AddQueryParam("bank_account[account_holder_type]","individual")
success = rest.AddQueryParam("bank_account[routing_number]","110000000")
success = rest.AddQueryParam("bank_account[account_number]","000123456789")

Dim strResponseBody As String
strResponseBody = rest.FullRequestFormUrlEncoded("POST","/v1/tokens")
If (rest.LastMethodSuccess <> 1) Then
    Debug.Print rest.LastErrorText
    Exit Sub
End If

Dim jsonResponse As New ChilkatJsonObject
success = jsonResponse.Load(strResponseBody)

Dim id As String
Dim object As String
Dim bank_accountId As String
Dim bank_accountObject As String
Dim bank_accountAccount_holder_name As String
Dim bank_accountAccount_holder_type As String
Dim bank_accountBank_name As String
Dim bank_accountCountry As String
Dim bank_accountCurrency As String
Dim bank_accountFingerprint As String
Dim bank_accountLast4 As String
Dim bank_accountRouting_number As String
Dim bank_accountStatus As String
Dim client_ip As Long
Dim created As Long
Dim livemode As Long
Dim type As String
Dim used As Long

id = jsonResponse.StringOf("id")
object = jsonResponse.StringOf("object")
bank_accountId = jsonResponse.StringOf("bank_account.id")
bank_accountObject = jsonResponse.StringOf("bank_account.object")
bank_accountAccount_holder_name = jsonResponse.StringOf("bank_account.account_holder_name")
bank_accountAccount_holder_type = jsonResponse.StringOf("bank_account.account_holder_type")
bank_accountBank_name = jsonResponse.StringOf("bank_account.bank_name")
bank_accountCountry = jsonResponse.StringOf("bank_account.country")
bank_accountCurrency = jsonResponse.StringOf("bank_account.currency")
bank_accountFingerprint = jsonResponse.StringOf("bank_account.fingerprint")
bank_accountLast4 = jsonResponse.StringOf("bank_account.last4")
bank_accountRouting_number = jsonResponse.StringOf("bank_account.routing_number")
bank_accountStatus = jsonResponse.StringOf("bank_account.status")
client_ip = jsonResponse.IsNullOf("client_ip")
created = jsonResponse.IntOf("created")
livemode = jsonResponse.BoolOf("livemode")
type = jsonResponse.StringOf("type")
used = jsonResponse.BoolOf("used")

Sample JSON Response Body

{
  "id": "btok_1BnETKGswQrCoh0X86abg4gM",
  "object": "token",
  "bank_account": {
    "id": "ba_1BnETKGswQrCoh0XptCSwzal",
    "object": "bank_account",
    "account_holder_name": "Jane Austen",
    "account_holder_type": "individual",
    "bank_name": "STRIPE TEST BANK",
    "country": "US",
    "currency": "usd",
    "fingerprint": "L2j4aSuWk1MZMDZ5",
    "last4": "6789",
    "routing_number": "110000000",
    "status": "new"
  },
  "client_ip": null,
  "created": 1516662782,
  "livemode": false,
  "type": "bank_account",
  "used": false
}