Chilkat Online Tools

SQL Server / Zoom API / Get invoice details

Back to Collection Items

-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    -- Important: Do not use nvarchar(max).  See the warning about using nvarchar(max).
    DECLARE @sTmp0 nvarchar(4000)
    -- This example assumes the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    -- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    -- Adds the "Authorization: Bearer <access_token>" header.
    EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'

    DECLARE @sbResponseBody int
    -- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://api.zoom.us/v2/accounts/:accountId/billing/invoices/:invoiceId', @sbResponseBody
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END

    DECLARE @jResp int
    -- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
    EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT

    EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
    EXEC sp_OASetProperty @jResp, 'EmitCompact', 0


    PRINT 'Response Body:'
    EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    DECLARE @respStatusCode int
    EXEC sp_OAGetProperty @http, 'LastStatus', @respStatusCode OUT

    PRINT 'Response Status Code = ' + @respStatusCode
    IF @respStatusCode >= 400
      BEGIN

        PRINT 'Response Header:'
        EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
        PRINT @sTmp0

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        EXEC @hr = sp_OADestroy @jResp
        RETURN
      END

    -- 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

    DECLARE @charge_name nvarchar(4000)

    DECLARE @charge_type nvarchar(4000)

    DECLARE @charge_number nvarchar(4000)

    DECLARE @quantity int

    DECLARE @start_date nvarchar(4000)

    DECLARE @end_date nvarchar(4000)

    DECLARE @purchase_order_number nvarchar(4000)

    DECLARE @partner_sku nvarchar(4000)

    DECLARE @id nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @id OUT, 'id'
    DECLARE @invoice_number nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @invoice_number OUT, 'invoice_number'
    DECLARE @total_amount int
    EXEC sp_OAMethod @jResp, 'IntOf', @total_amount OUT, 'total_amount'
    DECLARE @tax_amount int
    EXEC sp_OAMethod @jResp, 'IntOf', @tax_amount OUT, 'tax_amount'
    DECLARE @balance int
    EXEC sp_OAMethod @jResp, 'IntOf', @balance OUT, 'balance'
    DECLARE @due_date nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @due_date OUT, 'due_date'
    DECLARE @invoice_date nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @invoice_date OUT, 'invoice_date'
    DECLARE @target_date nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @target_date OUT, 'target_date'
    DECLARE @status nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @status OUT, 'status'
    DECLARE @v_currency nvarchar(4000)
    EXEC sp_OAMethod @jResp, 'StringOf', @v_currency OUT, 'currency'
    DECLARE @i int
    SELECT @i = 0
    DECLARE @count_i int
    EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'invoice_items'
    WHILE @i < @count_i
      BEGIN
        EXEC sp_OASetProperty @jResp, 'I', @i
        EXEC sp_OAMethod @jResp, 'StringOf', @charge_name OUT, 'invoice_items[i].charge_name'
        EXEC sp_OAMethod @jResp, 'StringOf', @charge_type OUT, 'invoice_items[i].charge_type'
        EXEC sp_OAMethod @jResp, 'StringOf', @charge_number OUT, 'invoice_items[i].charge_number'
        EXEC sp_OAMethod @jResp, 'IntOf', @total_amount OUT, 'invoice_items[i].total_amount'
        EXEC sp_OAMethod @jResp, 'IntOf', @tax_amount OUT, 'invoice_items[i].tax_amount'
        EXEC sp_OAMethod @jResp, 'IntOf', @quantity OUT, 'invoice_items[i].quantity'
        EXEC sp_OAMethod @jResp, 'StringOf', @start_date OUT, 'invoice_items[i].start_date'
        EXEC sp_OAMethod @jResp, 'StringOf', @end_date OUT, 'invoice_items[i].end_date'
        EXEC sp_OAMethod @jResp, 'StringOf', @purchase_order_number OUT, 'invoice_items[i].purchase_order_number'
        EXEC sp_OAMethod @jResp, 'StringOf', @partner_sku OUT, 'invoice_items[i].partner_sku'
        SELECT @i = @i + 1
      END

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @sbResponseBody
    EXEC @hr = sp_OADestroy @jResp


END
GO

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