@beampay/checkout 1.0.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.
- package/README.md +29 -0
- package/dist/chains.d.ts +12 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/checkout.es.js +53869 -0
- package/dist/checkout.es.js.map +1 -0
- package/dist/checkout.iife.js +5051 -0
- package/dist/checkout.iife.js.map +1 -0
- package/dist/controllers/pay-controller.d.ts +18 -0
- package/dist/controllers/pay-controller.d.ts.map +1 -0
- package/dist/controllers/wagmi-config.d.ts +9 -0
- package/dist/controllers/wagmi-config.d.ts.map +1 -0
- package/dist/elements/pay-button.d.ts +9 -0
- package/dist/elements/pay-button.d.ts.map +1 -0
- package/dist/elements/pay-modal.d.ts +25 -0
- package/dist/elements/pay-modal.d.ts.map +1 -0
- package/dist/elements/status-screen.d.ts +12 -0
- package/dist/elements/status-screen.d.ts.map +1 -0
- package/dist/elements/wallet-picker.d.ts +17 -0
- package/dist/elements/wallet-picker.d.ts.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/api.d.ts +11 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/router.d.ts +93 -0
- package/dist/lib/router.d.ts.map +1 -0
- package/dist/lib/router.test.d.ts +2 -0
- package/dist/lib/router.test.d.ts.map +1 -0
- package/dist/lib/styles.d.ts +2 -0
- package/dist/lib/styles.d.ts.map +1 -0
- package/dist/types.d.ts +59 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Config } from '@wagmi/core';
|
|
2
|
+
import type { CheckoutOptions, OrderStatus } from '../types';
|
|
3
|
+
export type PayStep = 'switching' | 'approving' | 'confirming' | 'pending';
|
|
4
|
+
/**
|
|
5
|
+
* Drive a full signed-order payment to completion:
|
|
6
|
+
* ensure-connected → switch chain → (approve if ERC-20) → pay → wait receipt →
|
|
7
|
+
* poll getOrder() until payer is set. Returns the confirmed OrderStatus.
|
|
8
|
+
*/
|
|
9
|
+
export declare function runPayment(config: Config, opts: CheckoutOptions, onStep: (step: PayStep) => void): Promise<OrderStatus>;
|
|
10
|
+
export declare class BeamPayCheckout {
|
|
11
|
+
private opts;
|
|
12
|
+
private root;
|
|
13
|
+
readonly config: Config;
|
|
14
|
+
constructor(opts: CheckoutOptions);
|
|
15
|
+
mount(selector: string | HTMLElement): this;
|
|
16
|
+
private openModal;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=pay-controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pay-controller.d.ts","sourceRoot":"","sources":["../../src/controllers/pay-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAKZ,MAAM,aAAa,CAAA;AAUpB,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAG5D,MAAM,MAAM,OAAO,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,SAAS,CAAA;AAY1E;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,eAAe,EACrB,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAC9B,OAAO,CAAC,WAAW,CAAC,CAyDtB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,IAAI,CAAiB;IAC7B,OAAO,CAAC,IAAI,CAA2B;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;gBAEX,IAAI,EAAE,eAAe;IAKjC,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAoB3C,OAAO,CAAC,SAAS;CAkBlB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Config } from '@wagmi/core';
|
|
2
|
+
export declare function createWagmiConfig(wcProjectId?: string): Config;
|
|
3
|
+
export type WagmiConfig = Config;
|
|
4
|
+
/**
|
|
5
|
+
* Single shared wagmi Config per widget instance. Re-created only when the
|
|
6
|
+
* WalletConnect project id changes (multiple mounts on a page share one config).
|
|
7
|
+
*/
|
|
8
|
+
export declare function getWagmiConfig(wcProjectId?: string): Config;
|
|
9
|
+
//# sourceMappingURL=wagmi-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wagmi-config.d.ts","sourceRoot":"","sources":["../../src/controllers/wagmi-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,MAAM,EAA0B,MAAM,aAAa,CAAA;AAGvE,wBAAgB,iBAAiB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAe9D;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,CAAA;AAKhC;;;GAGG;AACH,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAO3D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import type { CheckoutOptions } from '../types';
|
|
3
|
+
export declare class PayButton extends LitElement {
|
|
4
|
+
opts?: CheckoutOptions;
|
|
5
|
+
static styles: import("lit").CSSResult;
|
|
6
|
+
private handleClick;
|
|
7
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=pay-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pay-button.d.ts","sourceRoot":"","sources":["../../src/elements/pay-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAA;AAE3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,qBACa,SAAU,SAAQ,UAAU;IACP,IAAI,CAAC,EAAE,eAAe,CAAA;IAEtD,OAAgB,MAAM,0BAerB;IAED,OAAO,CAAC,WAAW;IAIV,MAAM;CAGhB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Config } from '@wagmi/core';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
import './wallet-picker';
|
|
4
|
+
import './status-screen';
|
|
5
|
+
import type { CheckoutOptions } from '../types';
|
|
6
|
+
export declare class PayModal extends LitElement {
|
|
7
|
+
opts?: CheckoutOptions;
|
|
8
|
+
config?: Config;
|
|
9
|
+
private step;
|
|
10
|
+
private progress;
|
|
11
|
+
private errorMsg;
|
|
12
|
+
private order?;
|
|
13
|
+
static styles: import("lit").CSSResult;
|
|
14
|
+
private close;
|
|
15
|
+
private get amountLabel();
|
|
16
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
17
|
+
private renderConnect;
|
|
18
|
+
private renderConfirm;
|
|
19
|
+
private renderPending;
|
|
20
|
+
private renderSuccess;
|
|
21
|
+
private renderError;
|
|
22
|
+
private renderTxLink;
|
|
23
|
+
private submitPayment;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=pay-modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pay-modal.d.ts","sourceRoot":"","sources":["../../src/elements/pay-modal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAA;AAK3C,OAAO,iBAAiB,CAAA;AACxB,OAAO,iBAAiB,CAAA;AACxB,OAAO,KAAK,EAAE,eAAe,EAAe,MAAM,UAAU,CAAA;AAW5D,qBACa,QAAS,SAAQ,UAAU;IACN,IAAI,CAAC,EAAE,eAAe,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACtC,OAAO,CAAC,IAAI,CAAkB;IAC9B,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,KAAK,CAAC,CAAa;IAEpC,OAAgB,MAAM,0BAyBrB;IAED,OAAO,CAAC,KAAK;IAIb,OAAO,KAAK,WAAW,GAKtB;IAEQ,MAAM;IAkBf,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,aAAa;IASrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,YAAY;IAYpB,OAAO,CAAC,aAAa,CA4BpB;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
type StatusState = 'pending' | 'success' | 'error' | 'expired';
|
|
3
|
+
export declare class StatusScreen extends LitElement {
|
|
4
|
+
state: StatusState;
|
|
5
|
+
message: string;
|
|
6
|
+
static styles: import("lit").CSSResult;
|
|
7
|
+
private get icon();
|
|
8
|
+
private get label();
|
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=status-screen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-screen.d.ts","sourceRoot":"","sources":["../../src/elements/status-screen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAA;AAG3C,KAAK,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;AAE9D,qBACa,YAAa,SAAQ,UAAU;IAC9B,KAAK,EAAE,WAAW,CAAY;IAC9B,OAAO,SAAK;IAExB,OAAgB,MAAM,0BAWrB;IAED,OAAO,KAAK,IAAI,GAEf;IAED,OAAO,KAAK,KAAK,GAOhB;IAEQ,MAAM;CAOhB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Config } from '@wagmi/core';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
export declare class WalletPicker extends LitElement {
|
|
4
|
+
/** Shared wagmi config from the checkout instance. */
|
|
5
|
+
config?: Config;
|
|
6
|
+
private providers;
|
|
7
|
+
private connecting;
|
|
8
|
+
private errorMsg;
|
|
9
|
+
static styles: import("lit").CSSResult;
|
|
10
|
+
connectedCallback(): void;
|
|
11
|
+
disconnectedCallback(): void;
|
|
12
|
+
private handleAnnounce;
|
|
13
|
+
private get wcConnector();
|
|
14
|
+
private connectWith;
|
|
15
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=wallet-picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-picker.d.ts","sourceRoot":"","sources":["../../src/elements/wallet-picker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAW,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAA;AAc3C,qBACa,YAAa,SAAQ,UAAU;IAC1C,sDAAsD;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACtC,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,UAAU,CAAQ;IAC1B,OAAO,CAAC,QAAQ,CAAK;IAE9B,OAAgB,MAAM,0BAerB;IAEQ,iBAAiB;IAMjB,oBAAoB;IAK7B,OAAO,CAAC,cAAc,CAKrB;IAED,OAAO,KAAK,WAAW,GAEtB;YAEa,WAAW;IAqBhB,MAAM;CAkChB"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { BeamPayCheckout } from './controllers/pay-controller';
|
|
2
|
+
import { BeamPayCheckout } from './controllers/pay-controller';
|
|
3
|
+
export declare const BeamPay: {
|
|
4
|
+
init(opts: ConstructorParameters<typeof BeamPayCheckout>[0]): BeamPayCheckout;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAG9D,eAAO,MAAM,OAAO;eACP,qBAAqB,CAAC,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;CAG5D,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* Thin API wrapper around @beam/sdk.
|
|
4
|
+
*
|
|
5
|
+
* TODO: replace typed-fetch stub with full @beam/sdk client once workspace is
|
|
6
|
+
* set up and @beam/sdk is published. For v1, we call beam-api directly via
|
|
7
|
+
* fetch to query order status.
|
|
8
|
+
*/
|
|
9
|
+
import type { OrderStatus } from '../types.js';
|
|
10
|
+
export declare function fetchOrderStatus(apiUrl: string, chain: string, orderKey: Hex): Promise<OrderStatus | null>;
|
|
11
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B;;;;;;GAMG;AACH,OAAO,KAAK,EAAc,WAAW,EAAE,MAAM,aAAa,CAAA;AA6B1D,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,GAAG,GACZ,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAqB7B"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { Config } from '@wagmi/core';
|
|
2
|
+
import type { Address, Hex } from 'viem';
|
|
3
|
+
import { type ChainKey } from '../chains';
|
|
4
|
+
import type { BeamPayCheckoutOptions } from '../types';
|
|
5
|
+
export declare function getRouterAddress(chain: ChainKey): Address;
|
|
6
|
+
/** Minimal ERC-20 surface the widget needs (allowance + approve). */
|
|
7
|
+
export declare const erc20Abi: readonly [{
|
|
8
|
+
readonly type: "function";
|
|
9
|
+
readonly name: "approve";
|
|
10
|
+
readonly stateMutability: "nonpayable";
|
|
11
|
+
readonly inputs: readonly [{
|
|
12
|
+
readonly name: "spender";
|
|
13
|
+
readonly type: "address";
|
|
14
|
+
}, {
|
|
15
|
+
readonly name: "value";
|
|
16
|
+
readonly type: "uint256";
|
|
17
|
+
}];
|
|
18
|
+
readonly outputs: readonly [{
|
|
19
|
+
readonly name: "";
|
|
20
|
+
readonly type: "bool";
|
|
21
|
+
}];
|
|
22
|
+
}, {
|
|
23
|
+
readonly type: "function";
|
|
24
|
+
readonly name: "allowance";
|
|
25
|
+
readonly stateMutability: "view";
|
|
26
|
+
readonly inputs: readonly [{
|
|
27
|
+
readonly name: "owner";
|
|
28
|
+
readonly type: "address";
|
|
29
|
+
}, {
|
|
30
|
+
readonly name: "spender";
|
|
31
|
+
readonly type: "address";
|
|
32
|
+
}];
|
|
33
|
+
readonly outputs: readonly [{
|
|
34
|
+
readonly name: "";
|
|
35
|
+
readonly type: "uint256";
|
|
36
|
+
}];
|
|
37
|
+
}];
|
|
38
|
+
/**
|
|
39
|
+
* Build the `pay()` write request from a signed-order envelope. Mirrors the
|
|
40
|
+
* deployed signature: pay(merchant, receiver, token, amount, orderId, signer,
|
|
41
|
+
* createdAt, expiresAt, signature). Native path attaches msg.value = amount.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildPayRequest(chain: ChainKey, opts: BeamPayCheckoutOptions): {
|
|
44
|
+
address: `0x${string}`;
|
|
45
|
+
abi: import("viem").Abi;
|
|
46
|
+
functionName: "pay";
|
|
47
|
+
args: readonly [`0x${string}`, `0x${string}`, `0x${string}`, bigint, `0x${string}`, `0x${string}`, bigint, bigint, `0x${string}`];
|
|
48
|
+
value: bigint;
|
|
49
|
+
};
|
|
50
|
+
export declare function buildApproveRequest(chain: ChainKey, token: Address, amount: bigint): {
|
|
51
|
+
address: `0x${string}`;
|
|
52
|
+
abi: readonly [{
|
|
53
|
+
readonly type: "function";
|
|
54
|
+
readonly name: "approve";
|
|
55
|
+
readonly stateMutability: "nonpayable";
|
|
56
|
+
readonly inputs: readonly [{
|
|
57
|
+
readonly name: "spender";
|
|
58
|
+
readonly type: "address";
|
|
59
|
+
}, {
|
|
60
|
+
readonly name: "value";
|
|
61
|
+
readonly type: "uint256";
|
|
62
|
+
}];
|
|
63
|
+
readonly outputs: readonly [{
|
|
64
|
+
readonly name: "";
|
|
65
|
+
readonly type: "bool";
|
|
66
|
+
}];
|
|
67
|
+
}, {
|
|
68
|
+
readonly type: "function";
|
|
69
|
+
readonly name: "allowance";
|
|
70
|
+
readonly stateMutability: "view";
|
|
71
|
+
readonly inputs: readonly [{
|
|
72
|
+
readonly name: "owner";
|
|
73
|
+
readonly type: "address";
|
|
74
|
+
}, {
|
|
75
|
+
readonly name: "spender";
|
|
76
|
+
readonly type: "address";
|
|
77
|
+
}];
|
|
78
|
+
readonly outputs: readonly [{
|
|
79
|
+
readonly name: "";
|
|
80
|
+
readonly type: "uint256";
|
|
81
|
+
}];
|
|
82
|
+
}];
|
|
83
|
+
functionName: "approve";
|
|
84
|
+
args: readonly [`0x${string}`, bigint];
|
|
85
|
+
};
|
|
86
|
+
export declare function readAllowance(config: Config, chain: ChainKey, token: Address, owner: Address): Promise<bigint>;
|
|
87
|
+
/**
|
|
88
|
+
* Read the on-chain order record. `payer != 0x0` means the order has been paid
|
|
89
|
+
* — the widget polls this after submitting `pay()` rather than calling a backend.
|
|
90
|
+
*/
|
|
91
|
+
export declare function readOrderPayer(config: Config, chain: ChainKey, merchant: Address, orderId: Hex): Promise<Address>;
|
|
92
|
+
export declare function isPaid(payer: Address): boolean;
|
|
93
|
+
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/lib/router.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AACxC,OAAO,EAAE,KAAK,QAAQ,EAAmB,MAAM,WAAW,CAAA;AAC1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAItD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAMzD;AAED,qEAAqE;AACrE,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBX,CAAA;AAEV;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,sBAAsB;;;;;;EAoB5E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOlF;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,QAAQ,EACf,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,MAAM,CAAC,CAOjB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,GAAG,GACX,OAAO,CAAC,OAAO,CAAC,CAQlB;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.test.d.ts","sourceRoot":"","sources":["../../src/lib/router.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/lib/styles.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,YAAY,yBAExB,CAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* Options passed to BeamPay.init() / new BeamPayCheckout().
|
|
4
|
+
*
|
|
5
|
+
* Carries a full v1.4 signed order — the merchant (or a delegate) signs the
|
|
6
|
+
* EIP-712 Order off-chain (e.g. via beampay-web /create) and the resulting
|
|
7
|
+
* envelope is handed to the widget. The widget never signs; it only submits
|
|
8
|
+
* the user's `pay()` transaction.
|
|
9
|
+
*/
|
|
10
|
+
export interface BeamPayCheckoutOptions {
|
|
11
|
+
/** Chain key: 'bsc' | 'ethereum' | 'bsc-testnet'. */
|
|
12
|
+
chain: string;
|
|
13
|
+
/** Order owner — order-key namespace, event index, refund caller. */
|
|
14
|
+
merchant: Address;
|
|
15
|
+
/** v1.4 signed payout destination — may differ from `merchant`. */
|
|
16
|
+
receiver: Address;
|
|
17
|
+
/** Token contract address, or NATIVE_TOKEN sentinel for BNB/ETH. */
|
|
18
|
+
token: Address;
|
|
19
|
+
/** Amount in token base units (wei), as a decimal string. */
|
|
20
|
+
amount: string;
|
|
21
|
+
/** Merchant-scoped unique 32-byte order id (hex). */
|
|
22
|
+
orderId: Hex;
|
|
23
|
+
/** EIP-712 signer recovered on-chain (merchant or merchant's delegate). */
|
|
24
|
+
signer: Address;
|
|
25
|
+
/** Order creation timestamp, unix seconds (uint64). */
|
|
26
|
+
createdAt: number;
|
|
27
|
+
/** Order expiry timestamp, unix seconds (uint64). */
|
|
28
|
+
expiresAt: number;
|
|
29
|
+
/** 65-byte EIP-712 signature, hex-encoded. */
|
|
30
|
+
signature: Hex;
|
|
31
|
+
/** Token decimals — display only (amount stays in wei). Defaults to 18. */
|
|
32
|
+
decimals?: number;
|
|
33
|
+
/** Token symbol — display only (e.g. 'tUSDT'). */
|
|
34
|
+
symbol?: string;
|
|
35
|
+
/** WalletConnect project ID (optional — enables the WalletConnect connector). */
|
|
36
|
+
wcProjectId?: string;
|
|
37
|
+
/** Called when payment is confirmed on-chain. */
|
|
38
|
+
onSuccess?: (order: OrderStatus) => void;
|
|
39
|
+
/** Called on any error (wallet rejection, tx failure, poll timeout). */
|
|
40
|
+
onError?: (err: Error) => void;
|
|
41
|
+
}
|
|
42
|
+
/** Back-compat alias — elements import `CheckoutOptions`. */
|
|
43
|
+
export type CheckoutOptions = BeamPayCheckoutOptions;
|
|
44
|
+
/** On-chain / API order status */
|
|
45
|
+
export type OrderState = 'pending' | 'paid' | 'failed' | 'expired' | 'refunded';
|
|
46
|
+
export interface OrderStatus {
|
|
47
|
+
/** Derived order key (keccak256 of chain+merchant+token+amount+payer) */
|
|
48
|
+
orderKey: Hex;
|
|
49
|
+
chain: string;
|
|
50
|
+
merchant: Address;
|
|
51
|
+
token: Address;
|
|
52
|
+
amount: string;
|
|
53
|
+
payer?: Address;
|
|
54
|
+
state: OrderState;
|
|
55
|
+
txHash?: Hex;
|
|
56
|
+
/** Unix ms timestamp when status was last updated */
|
|
57
|
+
updatedAt: number;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAExC;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAA;IACb,qEAAqE;IACrE,QAAQ,EAAE,OAAO,CAAA;IACjB,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAA;IACjB,oEAAoE;IACpE,KAAK,EAAE,OAAO,CAAA;IACd,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAA;IACd,qDAAqD;IACrD,OAAO,EAAE,GAAG,CAAA;IACZ,2EAA2E;IAC3E,MAAM,EAAE,OAAO,CAAA;IACf,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAA;IACjB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAA;IACjB,8CAA8C;IAC9C,SAAS,EAAE,GAAG,CAAA;IACd,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iFAAiF;IACjF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,iDAAiD;IACjD,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,CAAA;IACxC,wEAAwE;IACxE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAA;CAC/B;AAED,6DAA6D;AAC7D,MAAM,MAAM,eAAe,GAAG,sBAAsB,CAAA;AAEpD,kCAAkC;AAClC,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,CAAA;AAE/E,MAAM,WAAW,WAAW;IAC1B,yEAAyE;IACzE,QAAQ,EAAE,GAAG,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,KAAK,EAAE,UAAU,CAAA;IACjB,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAA;CAClB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@beampay/checkout",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Framework-agnostic embeddable checkout widget for BeamPay",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/checkout.iife.js",
|
|
7
|
+
"module": "./dist/checkout.es.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/checkout.es.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "vite",
|
|
20
|
+
"build": "vite build && tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
21
|
+
"preview": "vite preview",
|
|
22
|
+
"lint": "biome check src e2e",
|
|
23
|
+
"fix": "biome check --write src e2e",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"e2e": "playwright test",
|
|
27
|
+
"release:bundle": "echo 'TODO: upload dist/checkout.iife.js to Cloudflare R2 beam-cdn/checkout/v1.js'",
|
|
28
|
+
"release:npm": "echo 'TODO: npm publish --access public'"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@beampay/contracts-abi": "^0.2.1",
|
|
32
|
+
"@wagmi/connectors": "^5.1",
|
|
33
|
+
"@wagmi/core": "^2.16",
|
|
34
|
+
"@walletconnect/ethereum-provider": "^2.17",
|
|
35
|
+
"lit": "^3",
|
|
36
|
+
"viem": "^2.21",
|
|
37
|
+
"zod": "^3.23"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@biomejs/biome": "^1.9",
|
|
41
|
+
"@playwright/test": "^1.48",
|
|
42
|
+
"@tailwindcss/vite": "^4",
|
|
43
|
+
"jsdom": "^29.1.1",
|
|
44
|
+
"tailwindcss": "^4",
|
|
45
|
+
"typescript": "^5.7",
|
|
46
|
+
"vite": "^6",
|
|
47
|
+
"vite-plugin-dts": "^4",
|
|
48
|
+
"vitest": "^2"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=20"
|
|
52
|
+
},
|
|
53
|
+
"license": "Apache-2.0",
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "https://github.com/BeamPayFun/beampay-checkout"
|
|
57
|
+
}
|
|
58
|
+
}
|