VB.NET 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

VB.NET Example

Dim rest As New Chilkat.Rest
Dim success As Boolean

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


rest.SetAuthBasic("STRIPE_SECRET_KEY","")

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


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


Dim jsonResponse As New Chilkat.JsonObject
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 Boolean
Dim created As Integer
Dim livemode As Boolean
Dim type As String
Dim used As Boolean

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
}