1
Create Invoice
One script reply has been approved by the moderators Verified

Create an invoice. [See the docs (https://stripe.com/docs/api/invoices/create) for more information

Created by rossmccrann 611 days ago Viewed 4938 times
0
Submitted by rossmccrann Deno
Verified 611 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(
7
  stripe_con: Stripe,
8
  customer_id: string,
9
  price_id: string
10
) {
11
  const token = stripe_con["token"];
12
  const stripe = Stripe(`${token}`, {
13
    httpClient: Stripe.createFetchHttpClient(),
14
  });
15

16
  const invoiceItem = await stripe.invoiceItems.create({
17
    customer: `${customer_id}`,
18
    price: `${price_id}`,
19
  });
20

21
  return await invoiceItem.json();
22
}
23