Visual Basic 6.0 Stripe: Retrieve an Invoice's Line Items

Back to Index

Retrieves the line items for a given invoice.

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

CURL Command

curl https://api.stripe.com/v1/invoices/in_1BnETLGswQrCoh0X6M67Qy9c/lines?limit=5 \
   -u STRIPE_SECRET_KEY:

Visual Basic 6.0 Example

Dim rest As New ChilkatRest
Dim success As Long

'  URL: https://api.stripe.com/v1/invoices/in_1BnETLGswQrCoh0X6M67Qy9c/lines?limit=5
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/invoices/in_1BnETLGswQrCoh0X6M67Qy9c/lines?limit=5",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 amount As Long
Dim currency As String
Dim description As String
Dim discountable As Long
Dim livemode As Long
Dim periodStart As Long
Dim periodEnd As Long
Dim plan As Long
Dim proration As Long
Dim quantity As Long
Dim subscription As Long
Dim type As String

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")
    amount = jsonResponse.IntOf("data[i].amount")
    currency = jsonResponse.StringOf("data[i].currency")
    description = jsonResponse.StringOf("data[i].description")
    discountable = jsonResponse.BoolOf("data[i].discountable")
    livemode = jsonResponse.BoolOf("data[i].livemode")
    periodStart = jsonResponse.IntOf("data[i].period.start")
    periodEnd = jsonResponse.IntOf("data[i].period.end")
    plan = jsonResponse.IsNullOf("data[i].plan")
    proration = jsonResponse.BoolOf("data[i].proration")
    quantity = jsonResponse.IsNullOf("data[i].quantity")
    subscription = jsonResponse.IsNullOf("data[i].subscription")
    type = jsonResponse.StringOf("data[i].type")
    i = i + 1
Loop

Sample JSON Response Body

{
  "object": "list",
  "url": "/v1/invoices/in_1BnETLGswQrCoh0X6M67Qy9c/lines",
  "has_more": false,
  "data": [
    {
      "id": "ii_1BnETLGswQrCoh0XhmXYb8CY",
      "object": "line_item",
      "amount": 1000,
      "currency": "usd",
      "description": "My First Invoice Item (created for API docs)",
      "discountable": true,
      "livemode": false,
      "metadata": {},
      "period": {
        "start": 1516662783,
        "end": 1516662783
      },
      "plan": null,
      "proration": false,
      "quantity": null,
      "subscription": null,
      "type": "invoiceitem"
    }
  ]
}