type Stripe = {
token: string;
};
/**
* Post invoices
* This endpoint creates a draft invoice for a given customer. The invoice remains a draft until you finalize the invoice, which allows you to pay or send the invoice to your customers.
*/
export async function main(
auth: Stripe,
body: {
account_tax_ids?: string[] | "";
application_fee_amount?: number;
auto_advance?: boolean;
automatic_tax?: {
enabled: boolean;
liability?: {
account?: string;
type: "account" | "self";
[k: string]: unknown;
};
[k: string]: unknown;
};
collection_method?: "charge_automatically" | "send_invoice";
currency?: string;
custom_fields?:
| { name: string; value: string; [k: string]: unknown }[]
| "";
customer?: string;
days_until_due?: number;
default_payment_method?: string;
default_source?: string;
default_tax_rates?: string[];
description?: string;
discounts?:
| { coupon?: string; discount?: string; [k: string]: unknown }[]
| "";
due_date?: number;
effective_at?: number;
expand?: string[];
footer?: string;
from_invoice?: {
action: "revision";
invoice: string;
[k: string]: unknown;
};
issuer?: {
account?: string;
type: "account" | "self";
[k: string]: unknown;
};
metadata?: { [k: string]: string } | "";
number?: string;
on_behalf_of?: string;
payment_settings?: {
default_mandate?: string | "";
payment_method_options?: {
acss_debit?:
| {
mandate_options?: {
transaction_type?: "business" | "personal";
[k: string]: unknown;
};
verification_method?: "automatic" | "instant" | "microdeposits";
[k: string]: unknown;
}
| "";
bancontact?:
| {
preferred_language?: "de" | "en" | "fr" | "nl";
[k: string]: unknown;
}
| "";
card?:
| {
installments?: {
enabled?: boolean;
plan?:
| {
count: number;
interval: "month";
type: "fixed_count";
[k: string]: unknown;
}
| "";
[k: string]: unknown;
};
request_three_d_secure?: "any" | "automatic" | "challenge";
[k: string]: unknown;
}
| "";
customer_balance?:
| {
bank_transfer?: {
eu_bank_transfer?: { country: string; [k: string]: unknown };
type?: string;
[k: string]: unknown;
};
funding_type?: string;
[k: string]: unknown;
}
| "";
konbini?: { [k: string]: unknown } | "";
us_bank_account?:
| {
financial_connections?: {
permissions?: (
| "balances"
| "ownership"
| "payment_method"
| "transactions"
)[];
prefetch?: ("balances" | "transactions")[];
[k: string]: unknown;
};
verification_method?: "automatic" | "instant" | "microdeposits";
[k: string]: unknown;
}
| "";
[k: string]: unknown;
};
payment_method_types?:
| (
| "ach_credit_transfer"
| "ach_debit"
| "acss_debit"
| "au_becs_debit"
| "bacs_debit"
| "bancontact"
| "boleto"
| "card"
| "cashapp"
| "customer_balance"
| "eps"
| "fpx"
| "giropay"
| "grabpay"
| "ideal"
| "konbini"
| "link"
| "p24"
| "paynow"
| "paypal"
| "promptpay"
| "sepa_debit"
| "sofort"
| "us_bank_account"
| "wechat_pay"
)[]
| "";
[k: string]: unknown;
};
pending_invoice_items_behavior?: "exclude" | "include";
rendering?: {
amount_tax_display?: "" | "exclude_tax" | "include_inclusive_tax";
pdf?: { page_size?: "a4" | "auto" | "letter"; [k: string]: unknown };
[k: string]: unknown;
};
shipping_cost?: {
shipping_rate?: string;
shipping_rate_data?: {
delivery_estimate?: {
maximum?: {
unit: "business_day" | "day" | "hour" | "month" | "week";
value: number;
[k: string]: unknown;
};
minimum?: {
unit: "business_day" | "day" | "hour" | "month" | "week";
value: number;
[k: string]: unknown;
};
[k: string]: unknown;
};
display_name: string;
fixed_amount?: {
amount: number;
currency: string;
currency_options?: {
[k: string]: {
amount: number;
tax_behavior?: "exclusive" | "inclusive" | "unspecified";
[k: string]: unknown;
};
};
[k: string]: unknown;
};
metadata?: { [k: string]: string };
tax_behavior?: "exclusive" | "inclusive" | "unspecified";
tax_code?: string;
type?: "fixed_amount";
[k: string]: unknown;
};
[k: string]: unknown;
};
shipping_details?: {
address: {
city?: string;
country?: string;
line1?: string;
line2?: string;
postal_code?: string;
state?: string;
[k: string]: unknown;
};
name: string;
phone?: string | "";
[k: string]: unknown;
};
statement_descriptor?: string;
subscription?: string;
transfer_data?: {
amount?: number;
destination: string;
[k: string]: unknown;
};
}
) {
const url = new URL(`https://api.stripe.com/v1/invoices`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "Bearer " + auth.token,
},
body: encodeParams(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
function encodeParams(o: any) {
function iter(o: any, path: string) {
if (Array.isArray(o)) {
o.forEach(function (a) {
iter(a, path + "[]");
});
return;
}
if (o !== null && typeof o === "object") {
Object.keys(o).forEach(function (k) {
iter(o[k], path + "[" + k + "]");
});
return;
}
data.push(path + "=" + o);
}
const data: string[] = [];
Object.keys(o).forEach(function (k) {
if (o[k] !== undefined) {
iter(o[k], k);
}
});
return new URLSearchParams(data.join("&"));
}
Submitted by hugo697 368 days ago
type Stripe = {
token: string;
};
/**
* Post invoices
* This endpoint creates a draft invoice for a given customer. The invoice remains a draft until you finalize the invoice, which allows you to pay or send the invoice to your customers.
*/
export async function main(
auth: Stripe,
body: {
account_tax_ids?: string[] | "";
application_fee_amount?: number;
auto_advance?: boolean;
automatic_tax?: {
enabled: boolean;
liability?: {
account?: string;
type: "account" | "self";
[k: string]: unknown;
};
[k: string]: unknown;
};
collection_method?: "charge_automatically" | "send_invoice";
currency?: string;
custom_fields?:
| { name: string; value: string; [k: string]: unknown }[]
| "";
customer?: string;
days_until_due?: number;
default_payment_method?: string;
default_source?: string;
default_tax_rates?: string[];
description?: string;
discounts?:
| { coupon?: string; discount?: string; [k: string]: unknown }[]
| "";
due_date?: number;
effective_at?: number;
expand?: string[];
footer?: string;
from_invoice?: {
action: "revision";
invoice: string;
[k: string]: unknown;
};
issuer?: {
account?: string;
type: "account" | "self";
[k: string]: unknown;
};
metadata?: { [k: string]: string } | "";
number?: string;
on_behalf_of?: string;
payment_settings?: {
default_mandate?: string | "";
payment_method_options?: {
acss_debit?:
| {
mandate_options?: {
transaction_type?: "business" | "personal";
[k: string]: unknown;
};
verification_method?: "automatic" | "instant" | "microdeposits";
[k: string]: unknown;
}
| "";
bancontact?:
| {
preferred_language?: "de" | "en" | "fr" | "nl";
[k: string]: unknown;
}
| "";
card?:
| {
installments?: {
enabled?: boolean;
plan?:
| {
count: number;
interval: "month";
type: "fixed_count";
[k: string]: unknown;
}
| "";
[k: string]: unknown;
};
request_three_d_secure?: "any" | "automatic" | "challenge";
[k: string]: unknown;
}
| "";
customer_balance?:
| {
bank_transfer?: {
eu_bank_transfer?: { country: string; [k: string]: unknown };
type?: string;
[k: string]: unknown;
};
funding_type?: string;
[k: string]: unknown;
}
| "";
konbini?: { [k: string]: unknown } | "";
us_bank_account?:
| {
financial_connections?: {
permissions?: (
| "balances"
| "ownership"
| "payment_method"
| "transactions"
)[];
prefetch?: ("balances" | "transactions")[];
[k: string]: unknown;
};
verification_method?: "automatic" | "instant" | "microdeposits";
[k: string]: unknown;
}
| "";
[k: string]: unknown;
};
payment_method_types?:
| (
| "ach_credit_transfer"
| "ach_debit"
| "acss_debit"
| "au_becs_debit"
| "bacs_debit"
| "bancontact"
| "boleto"
| "card"
| "cashapp"
| "customer_balance"
| "eps"
| "fpx"
| "giropay"
| "grabpay"
| "ideal"
| "konbini"
| "link"
| "p24"
| "paynow"
| "paypal"
| "promptpay"
| "sepa_debit"
| "sofort"
| "us_bank_account"
| "wechat_pay"
)[]
| "";
[k: string]: unknown;
};
pending_invoice_items_behavior?: "exclude" | "include";
rendering?: {
amount_tax_display?: "" | "exclude_tax" | "include_inclusive_tax";
pdf?: { page_size?: "a4" | "auto" | "letter"; [k: string]: unknown };
[k: string]: unknown;
};
shipping_cost?: {
shipping_rate?: string;
shipping_rate_data?: {
delivery_estimate?: {
maximum?: {
unit: "business_day" | "day" | "hour" | "month" | "week";
value: number;
[k: string]: unknown;
};
minimum?: {
unit: "business_day" | "day" | "hour" | "month" | "week";
value: number;
[k: string]: unknown;
};
[k: string]: unknown;
};
display_name: string;
fixed_amount?: {
amount: number;
currency: string;
currency_options?: {
[k: string]: {
amount: number;
tax_behavior?: "exclusive" | "inclusive" | "unspecified";
[k: string]: unknown;
};
};
[k: string]: unknown;
};
metadata?: { [k: string]: string };
tax_behavior?: "exclusive" | "inclusive" | "unspecified";
tax_code?: string;
type?: "fixed_amount";
[k: string]: unknown;
};
[k: string]: unknown;
};
shipping_details?: {
address: {
city?: string;
country?: string;
line1?: string;
line2?: string;
postal_code?: string;
state?: string;
[k: string]: unknown;
};
name: string;
phone?: string | "";
[k: string]: unknown;
};
statement_descriptor?: string;
subscription?: string;
transfer_data?: {
amount?: number;
destination: string;
[k: string]: unknown;
};
}
) {
const url = new URL(`https://api.stripe.com/v1/invoices`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "Bearer " + auth.token,
},
body: encodeParams(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
function encodeParams(o: any) {
function iter(o: any, path: string) {
if (Array.isArray(o)) {
o.forEach(function (a) {
iter(a, path + "[]");
});
return;
}
if (o !== null && typeof o === "object") {
Object.keys(o).forEach(function (k) {
iter(o[k], path + "[" + k + "]");
});
return;
}
data.push(path + "=" + o);
}
const data: string[] = [];
Object.keys(o).forEach(function (k) {
if (o[k] !== undefined) {
iter(o[k], k);
}
});
return new URLSearchParams(data.join("&"));
}
Submitted by hugo697 795 days ago
type Stripe = {
token: string;
};
/**
* Post invoices
* <p>This endpoint creates a draft invoice for a given customer. The invoice remains a draft until you <a href="#finalize_invoice">finalize</a> the invoice, which allows you to <a href="#pay_invoice">pay</a> or <a href="#send_invoice">send</a> the invoice to your customers.</p>
*/
export async function main(
auth: Stripe,
body: {
account_tax_ids?: string[] | "";
application_fee_amount?: number;
auto_advance?: boolean;
automatic_tax?: { enabled: boolean; [k: string]: unknown };
collection_method?: "charge_automatically" | "send_invoice";
currency?: string;
custom_fields?:
| { name: string; value: string; [k: string]: unknown }[]
| "";
customer?: string;
days_until_due?: number;
default_payment_method?: string;
default_source?: string;
default_tax_rates?: string[];
description?: string;
discounts?:
| { coupon?: string; discount?: string; [k: string]: unknown }[]
| "";
due_date?: number;
effective_at?: number;
expand?: string[];
footer?: string;
from_invoice?: {
action: "revision";
invoice: string;
[k: string]: unknown;
};
metadata?: { [k: string]: string } | "";
on_behalf_of?: string;
payment_settings?: {
default_mandate?: string | "";
payment_method_options?: {
acss_debit?:
| {
mandate_options?: {
transaction_type?: "business" | "personal";
[k: string]: unknown;
};
verification_method?: "automatic" | "instant" | "microdeposits";
[k: string]: unknown;
}
| "";
bancontact?:
| {
preferred_language?: "de" | "en" | "fr" | "nl";
[k: string]: unknown;
}
| "";
card?:
| {
installments?: {
enabled?: boolean;
plan?:
| {
count: number;
interval: "month";
type: "fixed_count";
[k: string]: unknown;
}
| "";
[k: string]: unknown;
};
request_three_d_secure?: "any" | "automatic";
[k: string]: unknown;
}
| "";
customer_balance?:
| {
bank_transfer?: {
eu_bank_transfer?: { country: string; [k: string]: unknown };
type?: string;
[k: string]: unknown;
};
funding_type?: string;
[k: string]: unknown;
}
| "";
konbini?: { [k: string]: unknown } | "";
us_bank_account?:
| {
financial_connections?: {
permissions?: (
| "balances"
| "ownership"
| "payment_method"
| "transactions"
)[];
prefetch?: "balances"[];
[k: string]: unknown;
};
verification_method?: "automatic" | "instant" | "microdeposits";
[k: string]: unknown;
}
| "";
[k: string]: unknown;
};
payment_method_types?:
| (
| "ach_credit_transfer"
| "ach_debit"
| "acss_debit"
| "au_becs_debit"
| "bacs_debit"
| "bancontact"
| "boleto"
| "card"
| "cashapp"
| "customer_balance"
| "fpx"
| "giropay"
| "grabpay"
| "ideal"
| "konbini"
| "link"
| "paynow"
| "paypal"
| "promptpay"
| "sepa_debit"
| "sofort"
| "us_bank_account"
| "wechat_pay"
)[]
| "";
[k: string]: unknown;
};
pending_invoice_items_behavior?:
| "exclude"
| "include"
| "include_and_require";
rendering?: {
amount_tax_display?: "" | "exclude_tax" | "include_inclusive_tax";
pdf?: { page_size?: "a4" | "auto" | "letter"; [k: string]: unknown };
[k: string]: unknown;
};
shipping_cost?: {
shipping_rate?: string;
shipping_rate_data?: {
delivery_estimate?: {
maximum?: {
unit: "business_day" | "day" | "hour" | "month" | "week";
value: number;
[k: string]: unknown;
};
minimum?: {
unit: "business_day" | "day" | "hour" | "month" | "week";
value: number;
[k: string]: unknown;
};
[k: string]: unknown;
};
display_name: string;
fixed_amount?: {
amount: number;
currency: string;
currency_options?: {
[k: string]: {
amount: number;
tax_behavior?: "exclusive" | "inclusive" | "unspecified";
[k: string]: unknown;
};
};
[k: string]: unknown;
};
metadata?: { [k: string]: string };
tax_behavior?: "exclusive" | "inclusive" | "unspecified";
tax_code?: string;
type?: "fixed_amount";
[k: string]: unknown;
};
[k: string]: unknown;
};
shipping_details?: {
address: {
city?: string;
country?: string;
line1?: string;
line2?: string;
postal_code?: string;
state?: string;
[k: string]: unknown;
};
name: string;
phone?: string | "";
[k: string]: unknown;
};
statement_descriptor?: string;
subscription?: string;
transfer_data?: {
amount?: number;
destination: string;
[k: string]: unknown;
};
}
) {
const url = new URL(`https://api.stripe.com/v1/invoices`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "Bearer " + auth.token,
},
body: encodeParams(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
function encodeParams(o: any) {
function iter(o: any, path: string) {
if (Array.isArray(o)) {
o.forEach(function (a) {
iter(a, path + "[]");
});
return;
}
if (o !== null && typeof o === "object") {
Object.keys(o).forEach(function (k) {
iter(o[k], path + "[" + k + "]");
});
return;
}
data.push(path + "=" + o);
}
const data: string[] = [];
Object.keys(o).forEach(function (k) {
if (o[k] !== undefined) {
iter(o[k], k);
}
});
return new URLSearchParams(data.join("&"));
}
Submitted by hugo697 922 days ago