Watch
1
0
Fork
You've already forked packages
0

packages/ at markup-kit dd1e6eb5270e

A snapshot of packages/ in the Weft repository; the official packages are published from these commits.

Markup-Kit-Commit: dd1e6eb5270e62e0c8b6c202b3d01f0da6e00ddc
This commit is contained in:
Weft packages 2026-11-19 20:43:26 +00:00
commit 306b143104
72 changed files with 10915 additions and 0 deletions

126
stripe/billing.weft Normal file
View file

@ -0,0 +1,126 @@
// The customer portal, discounts and embedded Connect components.
import { request, segment } from "./stripe"
import type { Client, RequestOptions, StripeError } from "./stripe"
/// A session of the customer portal: send the customer to its `url`.
export type PortalSession = {
id: string,
url: string,
customer?: string,
return_url?: string,
created?: float,
}
/// A new portal session.
export type PortalParams = {
customer: string,
return_url?: string,
configuration?: string,
locale?: string,
extra?: json,
}
/// A coupon.
export type Coupon = {
id: string,
name?: string,
valid?: boolean,
percent_off?: float,
amount_off?: float,
currency?: string,
duration?: string,
duration_in_months?: float,
max_redemptions?: float,
times_redeemed?: float,
redeem_by?: float,
metadata?: json,
}
/// A promotion code customers can type in. `coupon` and `customer` are expandable: `idOf` gives their ids.
export type PromotionCode = {
id: string,
code: string,
active?: boolean,
coupon?: json,
promotion?: json,
customer?: json,
expires_at?: float,
max_redemptions?: float,
times_redeemed?: float,
metadata?: json,
}
/// A session for Stripe's embedded Connect components: give its `client_secret` to the browser.
export type AccountSession = {
account: string,
client_secret: string,
expires_at?: float,
livemode?: boolean,
}
/// A new account session. `components` says which embedded components it may show.
export type AccountSessionParams = { account: string, components: json }
/// Opens the customer portal for a customer.
export async fn createPortalSession(
c: Client,
params: PortalParams,
options: RequestOptions = {},
): PortalSession ! StripeError {
return try await request(
c,
"POST",
"/v1/billing_portal/sessions",
params,
options,
j => try j as PortalSession,
)
}
/// Gets a coupon by id.
export async fn retrieveCoupon(
c: Client,
id: string,
options: RequestOptions = {},
): Coupon ! StripeError {
return try await request(
c,
"GET",
`/v1/coupons/${segment(id)}`,
null,
options,
j => try j as Coupon,
)
}
/// Gets a promotion code by id.
export async fn retrievePromotionCode(
c: Client,
id: string,
options: RequestOptions = {},
): PromotionCode ! StripeError {
return try await request(
c,
"GET",
`/v1/promotion_codes/${segment(id)}`,
null,
options,
j => try j as PromotionCode,
)
}
/// Creates a session for a connected account's embedded components.
export async fn createAccountSession(
c: Client,
params: AccountSessionParams,
options: RequestOptions = {},
): AccountSession ! StripeError {
return try await request(
c,
"POST",
"/v1/account_sessions",
params,
options,
j => try j as AccountSession,
)
}