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

90
stripe/refunds.weft Normal file
View file

@ -0,0 +1,90 @@
// Refunds.
import { collect, request, segment } from "./stripe"
import type { Client, Page, RequestOptions, StripeError } from "./stripe"
/// A refund. `charge` and `payment_intent` are expandable: `idOf` gives their ids.
export type Refund = {
id: string,
amount: float,
currency: string,
status?: string,
reason?: string,
charge?: json,
payment_intent?: json,
failure_reason?: string,
receipt_number?: string,
metadata?: json,
created?: float,
}
/// A new refund of a `payment_intent` or a `charge`: all of it unless `amount` is given.
export type RefundParams = {
payment_intent?: string,
charge?: string,
amount?: float,
reason?: "duplicate" | "fraudulent" | "requested_by_customer",
metadata?: Map<string, string>,
refund_application_fee?: boolean,
reverse_transfer?: boolean,
extra?: json,
}
/// What to list.
export type RefundListParams = {
payment_intent?: string,
charge?: string,
limit?: float,
starting_after?: string,
ending_before?: string,
extra?: json,
}
/// Refunds a payment.
export async fn create(
c: Client,
params: RefundParams,
options: RequestOptions = {},
): Refund ! StripeError {
return try await request(c, "POST", "/v1/refunds", params, options, j => try j as Refund)
}
/// Gets a refund by id.
export async fn retrieve(
c: Client,
id: string,
options: RequestOptions = {},
): Refund ! StripeError {
return try await request(
c,
"GET",
`/v1/refunds/${segment(id)}`,
null,
options,
j => try j as Refund,
)
}
/// One page of refunds, newest first.
export async fn list(c: Client, params: RefundListParams = {}, options: RequestOptions = {}): Page<
Refund,
> ! StripeError {
return try await request(c, "GET", "/v1/refunds", params, options, j => try j as Page<Refund>)
}
/// Every refund matching `params`, up to `max`.
export async fn listAll(
c: Client,
params: RefundListParams = {},
options: RequestOptions = {},
max: int = 10000,
): Refund[] ! StripeError {
return try await collect(
c,
"/v1/refunds",
params,
options,
j => try j as Page<Refund>,
x => x.id,
max,
)
}