Visual Basic 6.0 Stripe: List all Cards

Back to Index

List the cards belonging to a customer or recipient.

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

CURL Command

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

Visual Basic 6.0 Example

Dim rest As New ChilkatRest
Dim success As Long

'  URL: https://api.stripe.com/v1/customers/cus_CBbg3iRMzWBjoe/sources?object=card&limit=3
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","")

Dim sbResponseBody As New ChilkatStringBuilder
success = rest.FullRequestNoBodySb("GET","/v1/customers/cus_CBbg3iRMzWBjoe/sources?object=card&limit=3",sbResponseBody)
If (success <> 1) Then
    Debug.Print rest.LastErrorText
    Exit Sub
End If

Dim jsonResponse As New ChilkatJsonObject
success = jsonResponse.LoadSb(sbResponseBody)

Dim object As String
Dim url As String
Dim has_more As Long
Dim i As Long
Dim count_i As Long
Dim id As String
Dim address_city As Long
Dim address_country As Long
Dim address_line1 As Long
Dim address_line1_check As Long
Dim address_line2 As Long
Dim address_state As Long
Dim address_zip As Long
Dim address_zip_check As Long
Dim brand As String
Dim country As String
Dim customer As String
Dim cvc_check As Long
Dim dynamic_last4 As Long
Dim exp_month As Long
Dim exp_year As Long
Dim fingerprint As String
Dim funding As String
Dim last4 As String
Dim name As Long
Dim tokenization_method As Long

object = jsonResponse.StringOf("object")
url = jsonResponse.StringOf("url")
has_more = jsonResponse.BoolOf("has_more")
i = 0
count_i = jsonResponse.SizeOfArray("data")
Do While i < count_i
    jsonResponse.I = i
    id = jsonResponse.StringOf("data[i].id")
    object = jsonResponse.StringOf("data[i].object")
    address_city = jsonResponse.IsNullOf("data[i].address_city")
    address_country = jsonResponse.IsNullOf("data[i].address_country")
    address_line1 = jsonResponse.IsNullOf("data[i].address_line1")
    address_line1_check = jsonResponse.IsNullOf("data[i].address_line1_check")
    address_line2 = jsonResponse.IsNullOf("data[i].address_line2")
    address_state = jsonResponse.IsNullOf("data[i].address_state")
    address_zip = jsonResponse.IsNullOf("data[i].address_zip")
    address_zip_check = jsonResponse.IsNullOf("data[i].address_zip_check")
    brand = jsonResponse.StringOf("data[i].brand")
    country = jsonResponse.StringOf("data[i].country")
    customer = jsonResponse.StringOf("data[i].customer")
    cvc_check = jsonResponse.IsNullOf("data[i].cvc_check")
    dynamic_last4 = jsonResponse.IsNullOf("data[i].dynamic_last4")
    exp_month = jsonResponse.IntOf("data[i].exp_month")
    exp_year = jsonResponse.IntOf("data[i].exp_year")
    fingerprint = jsonResponse.StringOf("data[i].fingerprint")
    funding = jsonResponse.StringOf("data[i].funding")
    last4 = jsonResponse.StringOf("data[i].last4")
    name = jsonResponse.IsNullOf("data[i].name")
    tokenization_method = jsonResponse.IsNullOf("data[i].tokenization_method")
    i = i + 1
Loop

Sample JSON Response Body

{
  "object": "list",
  "url": "/v1/customers/cus_CBbg3iRMzWBjoe/sources",
  "has_more": false,
  "data": [
    {
      "id": "card_1BnETKGswQrCoh0Xhu1A6BfL",
      "object": "card",
      "address_city": null,
      "address_country": null,
      "address_line1": null,
      "address_line1_check": null,
      "address_line2": null,
      "address_state": null,
      "address_zip": null,
      "address_zip_check": null,
      "brand": "Visa",
      "country": "US",
      "customer": "cus_CBbg3iRMzWBjoe",
      "cvc_check": null,
      "dynamic_last4": null,
      "exp_month": 8,
      "exp_year": 2019,
      "fingerprint": "F9mANtIt1TaukpRJ",
      "funding": "credit",
      "last4": "4242",
      "metadata": {},
      "name": null,
      "tokenization_method": null
    }
  ]
}