PowerBuilder Stripe: List all Bank Accounts

Back to Index

List bank accounts belonging to a customer.

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

CURL Command

curl "https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources?object=bank_account&limit=3" \
   -u STRIPE_SECRET_KEY: \
   -G

PowerBuilder Example

integer li_rc
oleobject loo_Rest
integer li_Success
integer li_BTls
integer li_Port
integer li_BAutoReconnect
oleobject loo_SbResponseBody
oleobject loo_JsonResponse
string ls_Object
string ls_Url
integer li_Has_more
integer i
integer li_Count_i
string ls_Id
string ls_Account
string ls_Account_holder_name
string ls_Account_holder_type
string ls_Bank_name
string ls_Country
string ls_Currency
integer li_Default_for_currency
string ls_Fingerprint
string ls_Last4
string ls_Routing_number
string ls_Status
string ls_Customer

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")
    return
end if

//  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources?object=bank_account&limit=3
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
    return
end if

loo_Rest.SetAuthBasic("STRIPE_SECRET_KEY","")

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Rest.FullRequestNoBodySb("GET","/v1/customers/cus_CBbg3iRMzWBjoe/sources?object=bank_account&limit=3",loo_SbResponseBody)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_SbResponseBody
    return
end if

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

loo_JsonResponse.LoadSb(loo_SbResponseBody)

ls_Object = loo_JsonResponse.StringOf("object")
ls_Url = loo_JsonResponse.StringOf("url")
li_Has_more = loo_JsonResponse.BoolOf("has_more")
i = 0
li_Count_i = loo_JsonResponse.SizeOfArray("data")
do while i < li_Count_i
    loo_JsonResponse.I = i
    ls_Id = loo_JsonResponse.StringOf("data[i].id")
    ls_Object = loo_JsonResponse.StringOf("data[i].object")
    ls_Account = loo_JsonResponse.StringOf("data[i].account")
    ls_Account_holder_name = loo_JsonResponse.StringOf("data[i].account_holder_name")
    ls_Account_holder_type = loo_JsonResponse.StringOf("data[i].account_holder_type")
    ls_Bank_name = loo_JsonResponse.StringOf("data[i].bank_name")
    ls_Country = loo_JsonResponse.StringOf("data[i].country")
    ls_Currency = loo_JsonResponse.StringOf("data[i].currency")
    li_Default_for_currency = loo_JsonResponse.BoolOf("data[i].default_for_currency")
    ls_Fingerprint = loo_JsonResponse.StringOf("data[i].fingerprint")
    ls_Last4 = loo_JsonResponse.StringOf("data[i].last4")
    ls_Routing_number = loo_JsonResponse.StringOf("data[i].routing_number")
    ls_Status = loo_JsonResponse.StringOf("data[i].status")
    ls_Customer = loo_JsonResponse.StringOf("data[i].customer")
    i = i + 1
loop


destroy loo_Rest
destroy loo_SbResponseBody
destroy loo_JsonResponse

Sample JSON Response Body

{
  "object": "list",
  "url": "/v1/customers/cus_CBbg3iRMzWBjoe/sources",
  "has_more": false,
  "data": [
    {
      "id": "ba_1BnETKGswQrCoh0XzgjB3t99",
      "object": "bank_account",
      "account": "acct_18qpKxGswQrCoh0X",
      "account_holder_name": "Jane Austen",
      "account_holder_type": "individual",
      "bank_name": "STRIPE TEST BANK",
      "country": "US",
      "currency": "usd",
      "default_for_currency": false,
      "fingerprint": "L2j4aSuWk1MZMDZ5",
      "last4": "6789",
      "metadata": {},
      "routing_number": "110000000",
      "status": "new",
      "customer": "cus_CBbg3iRMzWBjoe"
    }
  ]
}