VB.NET Stripe: Update an Invoice

Back to Index

Updates an invoice.

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

CURL Command

curl https://api.stripe.com/v1/invoices/in_1BnETLGswQrCoh0X6M67Qy9c \
   -u STRIPE_SECRET_KEY: \
   -d closed=true \
   -X POST

VB.NET Example

Dim rest As New Chilkat.Rest
Dim success As Boolean

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

rest.AddQueryParam("closed","true")


Dim strResponseBody As String = rest.FullRequestFormUrlEncoded("POST","/v1/invoices/in_1BnETLGswQrCoh0X6M67Qy9c")
If (rest.LastMethodSuccess <> True) Then
    Debug.WriteLine(rest.LastErrorText)
    Exit Sub
End If


Dim jsonResponse As New Chilkat.JsonObject
jsonResponse.Load(strResponseBody)

Dim id As String
Dim object As String
Dim amount_due As Integer
Dim application_fee As Boolean
Dim attempt_count As Integer
Dim attempted As Boolean
Dim billing As String
Dim charge As Boolean
Dim closed As Boolean
Dim currency As String
Dim customer As String
Dim date As Integer
Dim description As Boolean
Dim discount As Boolean
Dim due_date As Boolean
Dim ending_balance As Boolean
Dim forgiven As Boolean
Dim linesHas_more As Boolean
Dim linesObject As String
Dim linesUrl As String
Dim livemode As Boolean
Dim next_payment_attempt As Integer
Dim number As String
Dim paid As Boolean
Dim period_end As Integer
Dim period_start As Integer
Dim receipt_number As Boolean
Dim starting_balance As Integer
Dim statement_descriptor As Boolean
Dim subscription As Boolean
Dim subtotal As Integer
Dim tax As Boolean
Dim tax_percent As Boolean
Dim total As Integer
Dim webhooks_delivered_at As Boolean
Dim i As Integer
Dim count_i As Integer
Dim amount As Integer
Dim description_str As String
Dim discountable As Boolean
Dim periodStart As Integer
Dim periodEnd As Integer
Dim planId As String
Dim planObject As String
Dim planAmount As Integer
Dim planCreated As Integer
Dim planCurrency As String
Dim planInterval As String
Dim planInterval_count As Integer
Dim planLivemode As Boolean
Dim planName As String
Dim planStatement_descriptor As Boolean
Dim planTrial_period_days As Boolean
Dim proration As Boolean
Dim quantity As Integer
Dim subscription_item As String
Dim type As String

id = jsonResponse.StringOf("id")
object = jsonResponse.StringOf("object")
amount_due = jsonResponse.IntOf("amount_due")
application_fee = jsonResponse.IsNullOf("application_fee")
attempt_count = jsonResponse.IntOf("attempt_count")
attempted = jsonResponse.BoolOf("attempted")
billing = jsonResponse.StringOf("billing")
charge = jsonResponse.IsNullOf("charge")
closed = jsonResponse.BoolOf("closed")
currency = jsonResponse.StringOf("currency")
customer = jsonResponse.StringOf("customer")
date = jsonResponse.IntOf("date")
description = jsonResponse.IsNullOf("description")
discount = jsonResponse.IsNullOf("discount")
due_date = jsonResponse.IsNullOf("due_date")
ending_balance = jsonResponse.IsNullOf("ending_balance")
forgiven = jsonResponse.BoolOf("forgiven")
linesHas_more = jsonResponse.BoolOf("lines.has_more")
linesObject = jsonResponse.StringOf("lines.object")
linesUrl = jsonResponse.StringOf("lines.url")
livemode = jsonResponse.BoolOf("livemode")
next_payment_attempt = jsonResponse.IntOf("next_payment_attempt")
number = jsonResponse.StringOf("number")
paid = jsonResponse.BoolOf("paid")
period_end = jsonResponse.IntOf("period_end")
period_start = jsonResponse.IntOf("period_start")
receipt_number = jsonResponse.IsNullOf("receipt_number")
starting_balance = jsonResponse.IntOf("starting_balance")
statement_descriptor = jsonResponse.IsNullOf("statement_descriptor")
subscription = jsonResponse.IsNullOf("subscription")
subtotal = jsonResponse.IntOf("subtotal")
tax = jsonResponse.IsNullOf("tax")
tax_percent = jsonResponse.IsNullOf("tax_percent")
total = jsonResponse.IntOf("total")
webhooks_delivered_at = jsonResponse.IsNullOf("webhooks_delivered_at")
i = 0
count_i = jsonResponse.SizeOfArray("lines.data")
While i < count_i
    jsonResponse.I = i
    id = jsonResponse.StringOf("lines.data[i].id")
    object = jsonResponse.StringOf("lines.data[i].object")
    amount = jsonResponse.IntOf("lines.data[i].amount")
    currency = jsonResponse.StringOf("lines.data[i].currency")
    description_str = jsonResponse.StringOf("lines.data[i].description")
    discountable = jsonResponse.BoolOf("lines.data[i].discountable")
    livemode = jsonResponse.BoolOf("lines.data[i].livemode")
    periodStart = jsonResponse.IntOf("lines.data[i].period.start")
    periodEnd = jsonResponse.IntOf("lines.data[i].period.end")
    planId = jsonResponse.StringOf("lines.data[i].plan.id")
    planObject = jsonResponse.StringOf("lines.data[i].plan.object")
    planAmount = jsonResponse.IntOf("lines.data[i].plan.amount")
    planCreated = jsonResponse.IntOf("lines.data[i].plan.created")
    planCurrency = jsonResponse.StringOf("lines.data[i].plan.currency")
    planInterval = jsonResponse.StringOf("lines.data[i].plan.interval")
    planInterval_count = jsonResponse.IntOf("lines.data[i].plan.interval_count")
    planLivemode = jsonResponse.BoolOf("lines.data[i].plan.livemode")
    planName = jsonResponse.StringOf("lines.data[i].plan.name")
    planStatement_descriptor = jsonResponse.IsNullOf("lines.data[i].plan.statement_descriptor")
    planTrial_period_days = jsonResponse.IsNullOf("lines.data[i].plan.trial_period_days")
    proration = jsonResponse.BoolOf("lines.data[i].proration")
    quantity = jsonResponse.IntOf("lines.data[i].quantity")
    subscription = jsonResponse.IsNullOf("lines.data[i].subscription")
    subscription_item = jsonResponse.StringOf("lines.data[i].subscription_item")
    type = jsonResponse.StringOf("lines.data[i].type")
    i = i + 1
End While

Sample JSON Response Body

{
  "id": "in_1BnETLGswQrCoh0X6M67Qy9c",
  "object": "invoice",
  "amount_due": 0,
  "application_fee": null,
  "attempt_count": 0,
  "attempted": false,
  "billing": "charge_automatically",
  "charge": null,
  "closed": true,
  "currency": "usd",
  "customer": "cus_CBbggkUyLoz3pe",
  "date": 1516662783,
  "description": null,
  "discount": null,
  "due_date": null,
  "ending_balance": null,
  "forgiven": false,
  "lines": {
    "data": [
      {
        "id": "sub_CBbgC3EaFZqN3Q",
        "object": "line_item",
        "amount": 999,
        "currency": "usd",
        "description": "1x Silver Express (at $9.99)",
        "discountable": true,
        "livemode": true,
        "metadata": {},
        "period": {
          "start": 1521760383,
          "end": 1524438783
        },
        "plan": {
          "id": "gold",
          "object": "plan",
          "amount": 2000,
          "created": 1516662783,
          "currency": "usd",
          "interval": "month",
          "interval_count": 1,
          "livemode": false,
          "metadata": {},
          "name": "T-shirt",
          "statement_descriptor": null,
          "trial_period_days": null
        },
        "proration": false,
        "quantity": 1,
        "subscription": null,
        "subscription_item": "si_CBbgZxCVF3Ha7P",
        "type": "subscription"
      }
    ],
    "has_more": false,
    "object": "list",
    "url": "/v1/invoices/in_1BnETLGswQrCoh0X6M67Qy9c/lines"
  },
  "livemode": false,
  "metadata": {},
  "next_payment_attempt": 1516666383,
  "number": "330a34b8d5-0001",
  "paid": false,
  "period_end": 1516662783,
  "period_start": 1516662783,
  "receipt_number": null,
  "starting_balance": 0,
  "statement_descriptor": null,
  "subscription": null,
  "subtotal": 0,
  "tax": null,
  "tax_percent": null,
  "total": 0,
  "webhooks_delivered_at": null
}