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

VB.NET Example

Dim rest As New Chilkat.Rest
Dim success As Boolean

'  URL: https://api.stripe.com/v1/invoices/in_1BnETLGswQrCoh0X6M67Qy9c/lines?limit=5
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","")


Dim sbResponseBody As New Chilkat.StringBuilder
success = rest.FullRequestNoBodySb("GET","/v1/invoices/in_1BnETLGswQrCoh0X6M67Qy9c/lines?limit=5",sbResponseBody)
If (success <> True) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


Dim jsonResponse As New Chilkat.JsonObject
jsonResponse.LoadSb(sbResponseBody)

Dim object As String
Dim url As String
Dim has_more As Boolean
Dim i As Integer
Dim count_i As Integer
Dim id As String
Dim amount As Integer
Dim currency As String
Dim description As String
Dim discountable As Boolean
Dim livemode As Boolean
Dim periodStart As Integer
Dim periodEnd As Integer
Dim plan As Boolean
Dim proration As Boolean
Dim quantity As Boolean
Dim subscription As Boolean
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")
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
End While

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