munim-billing 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +550 -2
  3. package/lib/cjs/client.js +233 -0
  4. package/lib/cjs/client.js.map +1 -0
  5. package/lib/cjs/errors.js +55 -0
  6. package/lib/cjs/errors.js.map +1 -0
  7. package/lib/cjs/index.js +28 -0
  8. package/lib/cjs/index.js.map +1 -0
  9. package/lib/cjs/package.json +1 -0
  10. package/lib/cjs/react-native.js +118 -0
  11. package/lib/cjs/react-native.js.map +1 -0
  12. package/lib/cjs/types.js +21 -0
  13. package/lib/cjs/types.js.map +1 -0
  14. package/lib/cjs/version.js +6 -0
  15. package/lib/cjs/version.js.map +1 -0
  16. package/lib/cjs/web.js +157 -0
  17. package/lib/cjs/web.js.map +1 -0
  18. package/lib/cjs/webhooks.js +137 -0
  19. package/lib/cjs/webhooks.js.map +1 -0
  20. package/lib/esm/client.d.ts +131 -0
  21. package/lib/esm/client.d.ts.map +1 -0
  22. package/lib/esm/client.js +226 -0
  23. package/lib/esm/client.js.map +1 -0
  24. package/lib/esm/errors.d.ts +22 -0
  25. package/lib/esm/errors.d.ts.map +1 -0
  26. package/lib/esm/errors.js +50 -0
  27. package/lib/esm/errors.js.map +1 -0
  28. package/lib/esm/index.d.ts +10 -0
  29. package/lib/esm/index.d.ts.map +1 -0
  30. package/lib/esm/index.js +6 -0
  31. package/lib/esm/index.js.map +1 -0
  32. package/lib/esm/package.json +1 -0
  33. package/lib/esm/react-native.d.ts +72 -0
  34. package/lib/esm/react-native.d.ts.map +1 -0
  35. package/lib/esm/react-native.js +114 -0
  36. package/lib/esm/react-native.js.map +1 -0
  37. package/lib/esm/types.d.ts +303 -0
  38. package/lib/esm/types.d.ts.map +1 -0
  39. package/lib/esm/types.js +18 -0
  40. package/lib/esm/types.js.map +1 -0
  41. package/lib/esm/version.d.ts +3 -0
  42. package/lib/esm/version.d.ts.map +1 -0
  43. package/lib/esm/version.js +3 -0
  44. package/lib/esm/version.js.map +1 -0
  45. package/lib/esm/web.d.ts +40 -0
  46. package/lib/esm/web.d.ts.map +1 -0
  47. package/lib/esm/web.js +152 -0
  48. package/lib/esm/web.js.map +1 -0
  49. package/lib/esm/webhooks.d.ts +59 -0
  50. package/lib/esm/webhooks.d.ts.map +1 -0
  51. package/lib/esm/webhooks.js +129 -0
  52. package/lib/esm/webhooks.js.map +1 -0
  53. package/package.json +116 -4
  54. package/src/client.ts +314 -0
  55. package/src/errors.ts +74 -0
  56. package/src/index.ts +26 -0
  57. package/src/react-native.ts +154 -0
  58. package/src/types.ts +366 -0
  59. package/src/version.ts +2 -0
  60. package/src/web.ts +182 -0
  61. package/src/webhooks.ts +169 -0
package/lib/cjs/web.js ADDED
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ /**
3
+ * munim-billing/web: open a Munim checkout from a web page.
4
+ *
5
+ * Create the checkout on your server (`munim.checkouts.create`) and pass its
6
+ * `url` here. Never put your secret key in browser code.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.redirectToCheckout = redirectToCheckout;
10
+ exports.isCheckoutMessage = isCheckoutMessage;
11
+ exports.openCheckout = openCheckout;
12
+ /** Sends the whole page to the checkout. */
13
+ function redirectToCheckout(url) {
14
+ assertCheckoutUrl(url);
15
+ window.location.assign(url);
16
+ }
17
+ function assertCheckoutUrl(url) {
18
+ let parsed;
19
+ try {
20
+ parsed = new URL(url);
21
+ }
22
+ catch {
23
+ throw new Error(`munim-billing: not a checkout URL: ${url}`);
24
+ }
25
+ if (parsed.protocol !== 'https:' && parsed.hostname !== 'localhost' && parsed.hostname !== '127.0.0.1') {
26
+ throw new Error('munim-billing: checkout URLs must be https.');
27
+ }
28
+ return parsed;
29
+ }
30
+ /** Whether a `postMessage` payload is one of the checkout page's messages. */
31
+ function isCheckoutMessage(data) {
32
+ if (!data || typeof data !== 'object')
33
+ return false;
34
+ const message = data;
35
+ return (message.source === 'munim-billing' &&
36
+ (message.type === 'checkout.completed' || message.type === 'checkout.closed') &&
37
+ typeof message.checkout_id === 'string');
38
+ }
39
+ /**
40
+ * Shows the checkout in a full-screen overlay on top of your page.
41
+ *
42
+ * The checkout page tells the overlay when the customer has paid (or wants
43
+ * out) with `postMessage`; only messages from the checkout's own origin
44
+ * count. Card wallets that need the top window (some bank redirects) still
45
+ * work: the checkout page handles those itself.
46
+ */
47
+ function openCheckout(url, options = {}) {
48
+ const parsed = assertCheckoutUrl(url);
49
+ const origin = parsed.origin;
50
+ // Tell the page it's embedded, so it posts messages instead of redirecting.
51
+ parsed.searchParams.set('embed', '1');
52
+ const doc = window.document;
53
+ const overlay = doc.createElement('div');
54
+ overlay.setAttribute('role', 'dialog');
55
+ overlay.setAttribute('aria-modal', 'true');
56
+ overlay.setAttribute('aria-label', 'Checkout');
57
+ overlay.setAttribute('data-munim-billing-overlay', '');
58
+ Object.assign(overlay.style, {
59
+ position: 'fixed',
60
+ inset: '0',
61
+ zIndex: String(options.zIndex ?? 2147483000),
62
+ background: 'rgba(15, 15, 20, 0.55)',
63
+ display: 'flex',
64
+ alignItems: 'center',
65
+ justifyContent: 'center',
66
+ });
67
+ const frame = doc.createElement('iframe');
68
+ frame.src = parsed.toString();
69
+ frame.title = 'Checkout';
70
+ // Payment Request (Apple Pay, Google Pay) needs this inside an iframe.
71
+ frame.setAttribute('allow', 'payment *');
72
+ Object.assign(frame.style, {
73
+ width: '100%',
74
+ height: '100%',
75
+ maxWidth: '480px',
76
+ maxHeight: '760px',
77
+ border: '0',
78
+ borderRadius: '14px',
79
+ background: '#ffffff',
80
+ boxShadow: '0 20px 60px rgba(0,0,0,0.35)',
81
+ });
82
+ if (window.matchMedia?.('(max-width: 520px)').matches) {
83
+ frame.style.maxWidth = 'none';
84
+ frame.style.maxHeight = 'none';
85
+ frame.style.borderRadius = '0';
86
+ }
87
+ const closeButton = doc.createElement('button');
88
+ closeButton.type = 'button';
89
+ closeButton.setAttribute('aria-label', 'Close checkout');
90
+ closeButton.textContent = '×';
91
+ Object.assign(closeButton.style, {
92
+ position: 'absolute',
93
+ top: '12px',
94
+ right: '12px',
95
+ width: '36px',
96
+ height: '36px',
97
+ borderRadius: '18px',
98
+ border: '0',
99
+ background: 'rgba(255,255,255,0.92)',
100
+ color: '#111',
101
+ fontSize: '24px',
102
+ lineHeight: '36px',
103
+ cursor: 'pointer',
104
+ boxShadow: '0 2px 8px rgba(0,0,0,0.25)',
105
+ });
106
+ overlay.appendChild(frame);
107
+ overlay.appendChild(closeButton);
108
+ const previousOverflow = doc.body.style.overflow;
109
+ doc.body.style.overflow = 'hidden';
110
+ doc.body.appendChild(overlay);
111
+ let done = false;
112
+ const teardown = () => {
113
+ window.removeEventListener('message', onMessage);
114
+ doc.removeEventListener('keydown', onKeyDown);
115
+ overlay.remove();
116
+ doc.body.style.overflow = previousOverflow;
117
+ };
118
+ const close = () => {
119
+ if (done)
120
+ return;
121
+ done = true;
122
+ teardown();
123
+ options.onClose?.();
124
+ };
125
+ const complete = (checkoutId) => {
126
+ if (done)
127
+ return;
128
+ done = true;
129
+ teardown();
130
+ options.onComplete?.({ checkoutId });
131
+ };
132
+ function onMessage(event) {
133
+ if (event.origin !== origin || event.source !== frame.contentWindow)
134
+ return;
135
+ if (!isCheckoutMessage(event.data))
136
+ return;
137
+ if (event.data.type === 'checkout.completed') {
138
+ complete(event.data.checkout_id);
139
+ }
140
+ else {
141
+ close();
142
+ }
143
+ }
144
+ function onKeyDown(event) {
145
+ if (event.key === 'Escape')
146
+ close();
147
+ }
148
+ window.addEventListener('message', onMessage);
149
+ doc.addEventListener('keydown', onKeyDown);
150
+ closeButton.addEventListener('click', close);
151
+ overlay.addEventListener('click', (event) => {
152
+ if (event.target === overlay)
153
+ close();
154
+ });
155
+ return { close };
156
+ }
157
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.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S,EAAE,SAAS,CAAC,CAAA;IAC7C,GAAG,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;IAC1C,WAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC5C,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QAC1C,IAAI,KAAK,CAAC,MAAM,KAAK,OAAO;YAAE,KAAK,EAAE,CAAA;IACvC,CAAC,CAAC,CAAA;IAEF,OAAO,EAAE,KAAK,EAAE,CAAA;AAClB,CAAC"}
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.webhooks = exports.DEFAULT_TOLERANCE_SECONDS = exports.EVENT_ID_HEADER = exports.SIGNATURE_HEADER = void 0;
4
+ exports.computeSignature = computeSignature;
5
+ exports.signWebhookPayload = signWebhookPayload;
6
+ exports.parseSignatureHeader = parseSignatureHeader;
7
+ exports.timingSafeEqual = timingSafeEqual;
8
+ exports.verifyWebhook = verifyWebhook;
9
+ const errors_js_1 = require("./errors.js");
10
+ /**
11
+ * Webhook signatures.
12
+ *
13
+ * Munim signs each delivery with the endpoint's secret (`whsec_…`):
14
+ *
15
+ * Munim-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256(secret, `${t}.${rawBody}`)>
16
+ *
17
+ * The HMAC key is the whole secret string, `whsec_` prefix included, as
18
+ * UTF-8. A header may carry several `v1=` values (while a secret rotates);
19
+ * any one matching is enough.
20
+ *
21
+ * Uses WebCrypto (`crypto.subtle`), so it runs in Node 20+, Deno, Bun,
22
+ * edge runtimes, Convex and browsers. Node 18 needs
23
+ * `--experimental-global-webcrypto`.
24
+ */
25
+ exports.SIGNATURE_HEADER = 'Munim-Signature';
26
+ exports.EVENT_ID_HEADER = 'Munim-Event-Id';
27
+ exports.DEFAULT_TOLERANCE_SECONDS = 300;
28
+ const encoder = new TextEncoder();
29
+ function subtle() {
30
+ const value = globalThis.crypto?.subtle;
31
+ if (!value) {
32
+ throw new errors_js_1.MunimBillingError('Web Crypto (crypto.subtle) is not available in this runtime. Use Node 20+ or another runtime with WebCrypto.', { type: 'internal' });
33
+ }
34
+ return value;
35
+ }
36
+ function toHex(buffer) {
37
+ return Array.from(new Uint8Array(buffer), (byte) => byte.toString(16).padStart(2, '0')).join('');
38
+ }
39
+ function asString(body) {
40
+ return typeof body === 'string' ? body : new TextDecoder().decode(body);
41
+ }
42
+ /** Hex HMAC-SHA256 of `${timestamp}.${rawBody}` with `secret` as the key. */
43
+ async function computeSignature(secret, rawBody, timestamp) {
44
+ const key = await subtle().importKey('raw', encoder.encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);
45
+ const mac = await subtle().sign('HMAC', key, encoder.encode(`${timestamp}.${asString(rawBody)}`));
46
+ return toHex(mac);
47
+ }
48
+ /**
49
+ * The `Munim-Signature` header value for a payload: `t=<timestamp>,v1=<hex>`.
50
+ *
51
+ * @param timestamp Unix **seconds**. Defaults to now.
52
+ */
53
+ async function signWebhookPayload(secret, rawBody, timestamp = Math.floor(Date.now() / 1000)) {
54
+ const t = Math.floor(timestamp);
55
+ return `t=${t},v1=${await computeSignature(secret, rawBody, t)}`;
56
+ }
57
+ /** Splits `t=…,v1=…,v1=…` into its timestamp and signatures. */
58
+ function parseSignatureHeader(header) {
59
+ let timestamp = null;
60
+ const signatures = [];
61
+ for (const part of header.split(',')) {
62
+ const index = part.indexOf('=');
63
+ if (index < 0)
64
+ continue;
65
+ const key = part.slice(0, index).trim();
66
+ const value = part.slice(index + 1).trim();
67
+ if (key === 't' && /^\d+$/.test(value)) {
68
+ timestamp = Number(value);
69
+ }
70
+ else if (key === 'v1' && value) {
71
+ signatures.push(value.toLowerCase());
72
+ }
73
+ }
74
+ return { timestamp, signatures };
75
+ }
76
+ /** Compares two strings in time that depends only on their length. */
77
+ function timingSafeEqual(a, b) {
78
+ if (a.length !== b.length)
79
+ return false;
80
+ let diff = 0;
81
+ for (let i = 0; i < a.length; i++) {
82
+ diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
83
+ }
84
+ return diff === 0;
85
+ }
86
+ function fail(message) {
87
+ throw new errors_js_1.MunimBillingError(message, { type: 'signature_verification', status: 400 });
88
+ }
89
+ /**
90
+ * Checks a webhook delivery and returns its event.
91
+ *
92
+ * Pass the request body exactly as received (before any JSON parsing), the
93
+ * `Munim-Signature` header, and the endpoint's `whsec_…` secret. Throws a
94
+ * `MunimBillingError` with `type: 'signature_verification'` when the
95
+ * signature doesn't match or the timestamp is outside the tolerance.
96
+ */
97
+ async function verifyWebhook(rawBody, signatureHeader, secret, options = {}) {
98
+ if (!secret)
99
+ fail('No webhook secret was given.');
100
+ if (!signatureHeader)
101
+ fail(`Missing ${exports.SIGNATURE_HEADER} header.`);
102
+ const { timestamp, signatures } = parseSignatureHeader(signatureHeader);
103
+ if (timestamp === null || signatures.length === 0) {
104
+ fail(`Malformed ${exports.SIGNATURE_HEADER} header.`);
105
+ }
106
+ const expected = await computeSignature(secret, rawBody, timestamp);
107
+ if (!signatures.some((signature) => timingSafeEqual(signature, expected))) {
108
+ fail('Webhook signature does not match. Check the secret and that the body is the raw, unparsed request body.');
109
+ }
110
+ const tolerance = options.toleranceSeconds ?? exports.DEFAULT_TOLERANCE_SECONDS;
111
+ if (tolerance > 0) {
112
+ const nowSeconds = Math.floor((options.now ?? Date.now()) / 1000);
113
+ if (Math.abs(nowSeconds - timestamp) > tolerance) {
114
+ fail('Webhook timestamp is outside the tolerance.');
115
+ }
116
+ }
117
+ try {
118
+ return JSON.parse(asString(rawBody));
119
+ }
120
+ catch (cause) {
121
+ throw new errors_js_1.MunimBillingError('Webhook body is not valid JSON.', {
122
+ type: 'signature_verification',
123
+ status: 400,
124
+ cause,
125
+ });
126
+ }
127
+ }
128
+ /** `munim.webhooks` / `MunimBilling.webhooks`. */
129
+ exports.webhooks = {
130
+ verify: verifyWebhook,
131
+ sign: signWebhookPayload,
132
+ computeSignature,
133
+ parseHeader: parseSignatureHeader,
134
+ SIGNATURE_HEADER: exports.SIGNATURE_HEADER,
135
+ EVENT_ID_HEADER: exports.EVENT_ID_HEADER,
136
+ };
137
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/webhooks.ts"],"names":[],"mappings":";;;AA6CA,4CAcC;AAOD,gDAOC;AAGD,oDAeC;AAGD,0CAOC;AAqBD,sCAoCC;AA9JD,2CAA+C;AAG/C;;;;;;;;;;;;;;GAcG;AAEU,QAAA,gBAAgB,GAAG,iBAAiB,CAAA;AACpC,QAAA,eAAe,GAAG,gBAAgB,CAAA;AAClC,QAAA,yBAAyB,GAAG,GAAG,CAAA;AAE5C,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAA;AAEjC,SAAS,MAAM;IACb,MAAM,KAAK,GAAI,UAAkC,CAAC,MAAM,EAAE,MAAM,CAAA;IAChE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,6BAAiB,CACzB,8GAA8G,EAC9G,EAAE,IAAI,EAAE,UAAU,EAAE,CACrB,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,KAAK,CAAC,MAAmB;IAChC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAClG,CAAC;AAED,SAAS,QAAQ,CAAC,IAAyB;IACzC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AACzE,CAAC;AAED,6EAA6E;AACtE,KAAK,UA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MAAM,EAAE,aAAa;IACrB,IAAI,EAAE,kBAAkB;IACxB,gBAAgB;IAChB,WAAW,EAAE,oBAAoB;IACjC,gBAAgB,EAAhB,wBAAgB;IAChB,eAAe,EAAf,uBAAe;CACP,CAAA"}
@@ -0,0 +1,131 @@
1
+ import type { AppleReceiptParams, Balance, Entitlement, GoogleReceiptParams, StoreSubscription, StoreSubscriptionListParams, Subscriber, Checkout, CheckoutCreateParams, Customer, CustomerListParams, List, ListParams, ManageUrl, Mode, Payout, Price, PriceCreateParams, PriceListParams, PriceUpdateParams, Product, ProductCreateParams, ProductUpdateParams, RefundParams, Subscription, SubscriptionCancelParams, SubscriptionListParams, Transaction, TransactionListParams } from './types.js';
2
+ export declare const LIVE_BASE_URL = "https://billing-api.munimtech.com";
3
+ export declare const TEST_BASE_URL = "https://billing-sandbox-api.munimtech.com";
4
+ /** `'test'` for `mb_test_…` keys, `'live'` for `mb_live_…`, `null` otherwise. */
5
+ export declare function modeForKey(secretKey: string): Mode | null;
6
+ /** The API base for a key: the sandbox for `mb_test_…`, live for `mb_live_…`. */
7
+ export declare function baseUrlForKey(secretKey: string): string;
8
+ type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
9
+ export type MunimBillingOptions = {
10
+ /** Overrides the API base picked from the key, e.g. a `https://<name>.convex.site` URL. */
11
+ baseUrl?: string;
12
+ /** A `fetch` to use instead of the global one. */
13
+ fetch?: FetchLike;
14
+ /** Per-request timeout. Default 30 000 ms. */
15
+ timeoutMs?: number;
16
+ /**
17
+ * The secret key must never ship in a browser or app. The client refuses
18
+ * to start there unless this is `true` (e.g. for a local tool).
19
+ */
20
+ dangerouslyAllowBrowser?: boolean;
21
+ };
22
+ type Query = Record<string, string | number | boolean | null | undefined>;
23
+ type RequestOptions = {
24
+ query?: Query;
25
+ body?: unknown;
26
+ };
27
+ /** A list call that can also walk every page: `await list(params)` or `for await (const x of list.all(params))`. */
28
+ export type ListMethod<T, P extends ListParams> = ((params?: P) => Promise<List<T>>) & {
29
+ all: (params?: P) => AsyncIterableIterator<T>;
30
+ };
31
+ /**
32
+ * Walks every page of a list, starting from `params.cursor` (if any).
33
+ *
34
+ * ```ts
35
+ * for await (const txn of paginate((p) => munim.transactions.list(p), { limit: 100 })) { … }
36
+ * ```
37
+ */
38
+ export declare function paginate<T, P extends ListParams>(fetchPage: (params: P) => Promise<List<T>>, params?: P): AsyncIterableIterator<T>;
39
+ /**
40
+ * The Munim Billing server client.
41
+ *
42
+ * ```ts
43
+ * const munim = new MunimBilling(process.env.MUNIM_BILLING_SECRET_KEY!)
44
+ * const checkout = await munim.checkouts.create({ price_id: 'pri_…' })
45
+ * ```
46
+ */
47
+ export declare class MunimBilling {
48
+ #private;
49
+ /** Webhook helpers, also available as `munim.webhooks`. */
50
+ static readonly webhooks: {
51
+ readonly verify: typeof import("./webhooks.js").verifyWebhook;
52
+ readonly sign: typeof import("./webhooks.js").signWebhookPayload;
53
+ readonly computeSignature: typeof import("./webhooks.js").computeSignature;
54
+ readonly parseHeader: typeof import("./webhooks.js").parseSignatureHeader;
55
+ readonly SIGNATURE_HEADER: "Munim-Signature";
56
+ readonly EVENT_ID_HEADER: "Munim-Event-Id";
57
+ };
58
+ readonly webhooks: {
59
+ readonly verify: typeof import("./webhooks.js").verifyWebhook;
60
+ readonly sign: typeof import("./webhooks.js").signWebhookPayload;
61
+ readonly computeSignature: typeof import("./webhooks.js").computeSignature;
62
+ readonly parseHeader: typeof import("./webhooks.js").parseSignatureHeader;
63
+ readonly SIGNATURE_HEADER: "Munim-Signature";
64
+ readonly EVENT_ID_HEADER: "Munim-Event-Id";
65
+ };
66
+ /** `'test'` or `'live'`, from the key prefix (`null` for other keys with a custom `baseUrl`). */
67
+ readonly mode: Mode | null;
68
+ readonly baseUrl: string;
69
+ constructor(secretKey: string, options?: MunimBillingOptions);
70
+ /** Sends one request to the API. The resource methods below are built on it. */
71
+ request<T>(method: 'GET' | 'POST', path: string, options?: RequestOptions): Promise<T>;
72
+ readonly products: {
73
+ create: (params: ProductCreateParams) => Promise<Product>;
74
+ list: ListMethod<Product, ListParams>;
75
+ retrieve: (productId: string) => Promise<Product>;
76
+ update: (productId: string, params: ProductUpdateParams) => Promise<Product>;
77
+ };
78
+ readonly prices: {
79
+ create: (params: PriceCreateParams) => Promise<Price>;
80
+ list: ListMethod<Price, PriceListParams>;
81
+ retrieve: (priceId: string) => Promise<Price>;
82
+ /** A price's amount can't change; make a new price instead. */
83
+ update: (priceId: string, params: PriceUpdateParams) => Promise<Price>;
84
+ };
85
+ readonly checkouts: {
86
+ /** Creates a checkout. Send the customer to its `url`. */
87
+ create: (params: CheckoutCreateParams) => Promise<Checkout>;
88
+ retrieve: (checkoutId: string) => Promise<Checkout>;
89
+ };
90
+ readonly customers: {
91
+ list: ListMethod<Customer, CustomerListParams>;
92
+ retrieve: (customerId: string) => Promise<Customer>;
93
+ };
94
+ readonly transactions: {
95
+ list: ListMethod<Transaction, TransactionListParams>;
96
+ retrieve: (transactionId: string) => Promise<Transaction>;
97
+ /** Refunds `amount` cents, or everything not yet refunded. */
98
+ refund: (transactionId: string, params?: RefundParams) => Promise<Transaction>;
99
+ };
100
+ readonly subscriptions: {
101
+ list: ListMethod<Subscription, SubscriptionListParams>;
102
+ retrieve: (subscriptionId: string) => Promise<Subscription>;
103
+ /** Cancels at the end of the paid period by default; `{ at_period_end: false }` cancels now. */
104
+ cancel: (subscriptionId: string, params?: SubscriptionCancelParams) => Promise<Subscription>;
105
+ /** A Munim-hosted page where the customer can see and cancel the subscription. */
106
+ manageUrl: (subscriptionId: string) => Promise<ManageUrl>;
107
+ };
108
+ readonly balance: {
109
+ retrieve: () => Promise<Balance>;
110
+ };
111
+ readonly payouts: {
112
+ list: ListMethod<Payout, ListParams>;
113
+ };
114
+ /** Everything one of your users is entitled to, across web, App Store and Google Play. */
115
+ readonly subscribers: {
116
+ retrieve: (appUserId: string) => Promise<Subscriber>;
117
+ };
118
+ /** Verify a store purchase with Apple / Google and attach it to your user. */
119
+ readonly receipts: {
120
+ apple: (params: AppleReceiptParams) => Promise<StoreSubscription>;
121
+ google: (params: GoogleReceiptParams) => Promise<StoreSubscription>;
122
+ };
123
+ readonly storeSubscriptions: {
124
+ list: ListMethod<StoreSubscription, StoreSubscriptionListParams>;
125
+ };
126
+ readonly entitlements: {
127
+ list: () => Promise<List<Entitlement>>;
128
+ };
129
+ }
130
+ export {};
131
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,OAAO,EACP,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,2BAA2B,EAC3B,UAAU,EACV,QAAQ,EACR,oBAAoB,EACpB,QAAQ,EACR,kBAAkB,EAClB,IAAI,EACJ,UAAU,EACV,SAAS,EACT,IAAI,EACJ,MAAM,EACN,KAAK,EACL,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,OAAO,EACP,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,wBAAwB,EACxB,sBAAsB,EACtB,WAAW,EACX,qBAAqB,EACtB,MAAM,YAAY,CAAA;AAInB,eAAO,MAAM,aAAa,sCAAsC,CAAA;AAChE,eAAO,MAAM,aAAa,8CAA8C,CAAA;AAExE,iFAAiF;AACjF,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAIzD;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAQvD;AAED,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEzE,MAAM,MAAM,mBAAmB,GAAG;IAChC,2FAA2F;IAC3F,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,kDAAkD;IAClD,KAAK,CAAC,EA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