DataFlex 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

DataFlex Example

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoRest
    Boolean iSuccess
    Boolean iBTls
    Integer iPort
    Boolean iBAutoReconnect
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJsonResponse
    String sObject
    String sUrl
    Boolean iHas_more
    Integer i
    Integer iCount_i
    String sId
    String sAccount
    String sAccount_holder_name
    String sAccount_holder_type
    String sBank_name
    String sCountry
    String sCurrency
    Boolean iDefault_for_currency
    String sFingerprint
    String sLast4
    String sRouting_number
    String sStatus
    String sCustomer
    String sTemp1
    Integer iTemp1

    Get Create (RefClass(cComChilkatRest)) To hoRest
    If (Not(IsComObjectCreated(hoRest))) Begin
        Send CreateComObject of hoRest
    End

    //  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources?object=bank_account&limit=3
    Move True To iBTls
    Move 443 To iPort
    Move True To iBAutoReconnect
    Get ComConnect Of hoRest "api.stripe.com" iPort iBTls iBAutoReconnect To iSuccess
    If (iSuccess <> True) Begin
        Get ComConnectFailReason Of hoRest To iTemp1
        Showln "ConnectFailReason: " iTemp1
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComSetAuthBasic Of hoRest "STRIPE_SECRET_KEY" "" To iSuccess

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComFullRequestNoBodySb Of hoRest "GET" "/v1/customers/cus_CBbg3iRMzWBjoe/sources?object=bank_account&limit=3" vSbResponseBody To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRest To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonResponse
    If (Not(IsComObjectCreated(hoJsonResponse))) Begin
        Send CreateComObject of hoJsonResponse
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJsonResponse vSbResponseBody To iSuccess

    Get ComStringOf Of hoJsonResponse "object" To sObject
    Get ComStringOf Of hoJsonResponse "url" To sUrl
    Get ComBoolOf Of hoJsonResponse "has_more" To iHas_more
    Move 0 To i
    Get ComSizeOfArray Of hoJsonResponse "data" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJsonResponse To i
        Get ComStringOf Of hoJsonResponse "data[i].id" To sId
        Get ComStringOf Of hoJsonResponse "data[i].object" To sObject
        Get ComStringOf Of hoJsonResponse "data[i].account" To sAccount
        Get ComStringOf Of hoJsonResponse "data[i].account_holder_name" To sAccount_holder_name
        Get ComStringOf Of hoJsonResponse "data[i].account_holder_type" To sAccount_holder_type
        Get ComStringOf Of hoJsonResponse "data[i].bank_name" To sBank_name
        Get ComStringOf Of hoJsonResponse "data[i].country" To sCountry
        Get ComStringOf Of hoJsonResponse "data[i].currency" To sCurrency
        Get ComBoolOf Of hoJsonResponse "data[i].default_for_currency" To iDefault_for_currency
        Get ComStringOf Of hoJsonResponse "data[i].fingerprint" To sFingerprint
        Get ComStringOf Of hoJsonResponse "data[i].last4" To sLast4
        Get ComStringOf Of hoJsonResponse "data[i].routing_number" To sRouting_number
        Get ComStringOf Of hoJsonResponse "data[i].status" To sStatus
        Get ComStringOf Of hoJsonResponse "data[i].customer" To sCustomer
        Move i + 1 To i
    Loop



End_Procedure

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"
    }
  ]
}