Chilkat Online Tools

PowerBuilder / Zoom API / Get invoice details

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Charge_name
string ls_Charge_type
string ls_Charge_number
integer li_Quantity
string ls_Start_date
string ls_End_date
string ls_Purchase_order_number
string ls_Partner_sku
string ls_Id
string ls_Invoice_number
integer li_Total_amount
integer li_Tax_amount
integer li_Balance
string ls_Due_date
string ls_Invoice_date
string ls_Target_date
string ls_Status
string ls_V_currency
integer i
integer li_Count_i

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

// Adds the "Authorization: Bearer <access_token>" header.
loo_Http.AuthToken = "<access_token>"

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

li_Success = loo_Http.QuickGetSb("https://api.zoom.us/v2/accounts/:accountId/billing/invoices/:invoiceId",loo_SbResponseBody)
if li_Success = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Http.LastStatus
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Http.LastHeader
    Write-Debug "Failed."
    destroy loo_Http
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "id": "2c92fghvb0580",
//   "invoice_number": "Shjmr5INV00000001",
//   "total_amount": 2039,
//   "tax_amount": 0,
//   "balance": 2039,
//   "due_date": "2020-08-07",
//   "invoice_date": "2020-08-07",
//   "target_date": "2020-08-07",
//   "status": "Draft",
//   "invoice_items": [
//     {
//       "charge_name": "Standard Biz Annual",
//       "charge_type": "Recurring",
//       "charge_number": "C-00000004",
//       "total_amount": 1999,
//       "tax_amount": 0,
//       "quantity": 10,
//       "start_date": "2020-08-07",
//       "end_date": "2021-08-06",
//       "purchase_order_number": "1234556",
//       "partner_sku": "PAR1-PRO-BASE-NH2Y"
//     },
//     {
//       "charge_name": "Cloud Recording 100 GB",
//       "charge_type": "Recurring",
//       "charge_number": "C-00000005",
//       "total_amount": 40,
//       "tax_amount": 0,
//       "quantity": 1,
//       "start_date": "2020-08-07",
//       "end_date": "2020-09-06",
//       "purchase_order_number": "1234567",
//       "partner_sku": "PAR-PAYONGO-INCL"
//     }
//   ],
//   "currency": "USD"
// }

// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

ls_Id = loo_JResp.StringOf("id")
ls_Invoice_number = loo_JResp.StringOf("invoice_number")
li_Total_amount = loo_JResp.IntOf("total_amount")
li_Tax_amount = loo_JResp.IntOf("tax_amount")
li_Balance = loo_JResp.IntOf("balance")
ls_Due_date = loo_JResp.StringOf("due_date")
ls_Invoice_date = loo_JResp.StringOf("invoice_date")
ls_Target_date = loo_JResp.StringOf("target_date")
ls_Status = loo_JResp.StringOf("status")
ls_V_currency = loo_JResp.StringOf("currency")
i = 0
li_Count_i = loo_JResp.SizeOfArray("invoice_items")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Charge_name = loo_JResp.StringOf("invoice_items[i].charge_name")
    ls_Charge_type = loo_JResp.StringOf("invoice_items[i].charge_type")
    ls_Charge_number = loo_JResp.StringOf("invoice_items[i].charge_number")
    li_Total_amount = loo_JResp.IntOf("invoice_items[i].total_amount")
    li_Tax_amount = loo_JResp.IntOf("invoice_items[i].tax_amount")
    li_Quantity = loo_JResp.IntOf("invoice_items[i].quantity")
    ls_Start_date = loo_JResp.StringOf("invoice_items[i].start_date")
    ls_End_date = loo_JResp.StringOf("invoice_items[i].end_date")
    ls_Purchase_order_number = loo_JResp.StringOf("invoice_items[i].purchase_order_number")
    ls_Partner_sku = loo_JResp.StringOf("invoice_items[i].partner_sku")
    i = i + 1
loop


destroy loo_Http
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
https://api.zoom.us/v2/accounts/:accountId/billing/invoices/:invoiceId

Postman Collection Item JSON

{
  "name": "Get invoice details",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/accounts/:accountId/billing/invoices/:invoiceId",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "accounts",
        ":accountId",
        "billing",
        "invoices",
        ":invoiceId"
      ],
      "variable": [
        {
          "key": "accountId"
        },
        {
          "key": "invoiceId"
        }
      ]
    },
    "description": "Get detailed information about a specific [invoice](https://support.zoom.us/hc/en-us/articles/207276556-Viewing-your-invoice-history#h_6710542f-23cc-4059-9cc7-ff02bec7314e). <br>To retrieve a regular Zoom account's invoice details or a master account's invoice details, provide `me` as the value of `accountId` path parameter. To list a sub account's invoice details, provide the account ID of the sub account in the `accountId` path parameter. \n\n**Prerequisites:**\n* Account must be enrolled in Pro or a higher plan. <br>\n\n**Scope**:`billing:master`<br>\n<br>**[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Heavy`<br>\n**Additional Rate Limit:** You can make **one** API request every **thirty** minutes until the daily limit is reached. This API has a daily limit of **100** requests per **account**."
  },
  "response": [
    {
      "name": "**HTTP Status Code:** `200`<br>\nAccount billing invoice information returned.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/accounts/:accountId/billing/invoices/:invoiceId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "accounts",
            ":accountId",
            "billing",
            "invoices",
            ":invoiceId"
          ],
          "variable": [
            {
              "key": "accountId"
            },
            {
              "key": "invoiceId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"id\": \"2c92fghvb0580\",\n \"invoice_number\": \"Shjmr5INV00000001\",\n \"total_amount\": 2039,\n \"tax_amount\": 0,\n \"balance\": 2039,\n \"due_date\": \"2020-08-07\",\n \"invoice_date\": \"2020-08-07\",\n \"target_date\": \"2020-08-07\",\n \"status\": \"Draft\",\n \"invoice_items\": [\n  {\n   \"charge_name\": \"Standard Biz Annual\",\n   \"charge_type\": \"Recurring\",\n   \"charge_number\": \"C-00000004\",\n   \"total_amount\": 1999,\n   \"tax_amount\": 0,\n   \"quantity\": 10,\n   \"start_date\": \"2020-08-07\",\n   \"end_date\": \"2021-08-06\",\n   \"purchase_order_number\": \"1234556\",\n   \"partner_sku\": \"PAR1-PRO-BASE-NH2Y\"\n  },\n  {\n   \"charge_name\": \"Cloud Recording 100 GB\",\n   \"charge_type\": \"Recurring\",\n   \"charge_number\": \"C-00000005\",\n   \"total_amount\": 40,\n   \"tax_amount\": 0,\n   \"quantity\": 1,\n   \"start_date\": \"2020-08-07\",\n   \"end_date\": \"2020-09-06\",\n   \"purchase_order_number\": \"1234567\",\n   \"partner_sku\": \"PAR-PAYONGO-INCL\"\n  }\n ],\n \"currency\": \"USD\"\n}"
    },
    {
      "name": "**HTTP Status Code:** `400`<br>\n**Error Code:** `2001`<br>\nAccount does not exist: {subAccountId}.<br>\nInvoiceId does not exist: {invoiceId}.",
      "originalRequest": {
        "method": "GET",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/accounts/:accountId/billing/invoices/:invoiceId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "accounts",
            ":accountId",
            "billing",
            "invoices",
            ":invoiceId"
          ],
          "variable": [
            {
              "key": "accountId"
            },
            {
              "key": "invoiceId"
            }
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}