1

Retrieve Invoice Item

by
Published Aug 23, 2022

Retrieve an invoice item by id (`ii_...`).

Script stripe Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 2 hours ago
1
//native
2

3
/**
4
 * Retrieve Invoice Item
5
 * Retrieve an invoice item by id (`ii_...`).
6
 */
7
export async function main(auth: RT.Stripe, invoice_item_id: string) {
8
  const response = await fetch(
9
    `https://api.stripe.com/v1/invoiceitems/${invoice_item_id}`,
10
    {
11
      headers: {
12
        Authorization: `Bearer ${auth.token}`,
13
        Accept: "application/json",
14
        "Stripe-Version": "2025-03-31.basil",
15
      },
16
    }
17
  )
18

19
  if (!response.ok) {
20
    throw new Error(`${response.status} ${await response.text()}`)
21
  }
22

23
  return await response.json()
24
}
25

Other submissions
  • Submitted by rossmccrann Deno
    Created 528 days ago
    1
    import Stripe from "https://esm.sh/stripe?target=deno";
    2
    
    
    3
    type Stripe = {
    4
      token: string;
    5
    };
    6
    export async function main(stripe_con: Stripe, invoice_id: string) {
    7
      const token = stripe_con["token"];
    8
      const stripe = Stripe(`${token}`, {
    9
        httpClient: Stripe.createFetchHttpClient(),
    10
      });
    11
    
    
    12
      const invoiceItem = await stripe.invoiceItems.retrieve(`${invoice_id}`);
    13
    
    
    14
      return await invoiceItem.json();
    15
    }
    16
    
    
  • Submitted by hugo989 Bun
    Created 136 days ago
    1
    import StripeClient from "stripe@11";
    2
    
    
    3
    type Stripe = {
    4
      token: string;
    5
    };
    6
    export async function main(stripe_con: Stripe, invoice_id: string) {
    7
      const token = stripe_con["token"];
    8
      const stripe = StripeClient(`${token}`, {
    9
        httpClient: StripeClient.createFetchHttpClient(),
    10
      });
    11
    
    
    12
      const invoiceItem = await stripe.invoiceItems.retrieve(`${invoice_id}`);
    13
    
    
    14
      return await invoiceItem.json();
    15
    }
    16