@strimz/shared-types 0.1.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/LICENSE +21 -0
- package/README.md +69 -0
- package/dist/agents.cjs +148 -0
- package/dist/agents.cjs.map +1 -0
- package/dist/agents.d.cts +317 -0
- package/dist/agents.d.ts +317 -0
- package/dist/agents.js +137 -0
- package/dist/agents.js.map +1 -0
- package/dist/api-keys.cjs +91 -0
- package/dist/api-keys.cjs.map +1 -0
- package/dist/api-keys.d.cts +155 -0
- package/dist/api-keys.d.ts +155 -0
- package/dist/api-keys.js +84 -0
- package/dist/api-keys.js.map +1 -0
- package/dist/common.cjs +56 -0
- package/dist/common.cjs.map +1 -0
- package/dist/common.d.cts +82 -0
- package/dist/common.d.ts +82 -0
- package/dist/common.js +37 -0
- package/dist/common.js.map +1 -0
- package/dist/compliance.cjs +61 -0
- package/dist/compliance.cjs.map +1 -0
- package/dist/compliance.d.cts +59 -0
- package/dist/compliance.d.ts +59 -0
- package/dist/compliance.js +56 -0
- package/dist/compliance.js.map +1 -0
- package/dist/customers.cjs +56 -0
- package/dist/customers.cjs.map +1 -0
- package/dist/customers.d.cts +64 -0
- package/dist/customers.d.ts +64 -0
- package/dist/customers.js +53 -0
- package/dist/customers.js.map +1 -0
- package/dist/events.cjs +675 -0
- package/dist/events.cjs.map +1 -0
- package/dist/events.d.cts +7907 -0
- package/dist/events.d.ts +7907 -0
- package/dist/events.js +650 -0
- package/dist/events.js.map +1 -0
- package/dist/index.cjs +976 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +113 -0
- package/dist/index.d.ts +113 -0
- package/dist/index.js +858 -0
- package/dist/index.js.map +1 -0
- package/dist/invoices.cjs +72 -0
- package/dist/invoices.cjs.map +1 -0
- package/dist/invoices.d.cts +159 -0
- package/dist/invoices.d.ts +159 -0
- package/dist/invoices.js +67 -0
- package/dist/invoices.js.map +1 -0
- package/dist/merchants.cjs +104 -0
- package/dist/merchants.cjs.map +1 -0
- package/dist/merchants.d.cts +259 -0
- package/dist/merchants.d.ts +259 -0
- package/dist/merchants.js +93 -0
- package/dist/merchants.js.map +1 -0
- package/dist/payment-sessions.cjs +125 -0
- package/dist/payment-sessions.cjs.map +1 -0
- package/dist/payment-sessions.d.cts +180 -0
- package/dist/payment-sessions.d.ts +180 -0
- package/dist/payment-sessions.js +120 -0
- package/dist/payment-sessions.js.map +1 -0
- package/dist/refunds.cjs +81 -0
- package/dist/refunds.cjs.map +1 -0
- package/dist/refunds.d.cts +91 -0
- package/dist/refunds.d.ts +91 -0
- package/dist/refunds.js +75 -0
- package/dist/refunds.js.map +1 -0
- package/dist/storefronts.cjs +223 -0
- package/dist/storefronts.cjs.map +1 -0
- package/dist/storefronts.d.cts +177 -0
- package/dist/storefronts.d.ts +177 -0
- package/dist/storefronts.js +216 -0
- package/dist/storefronts.js.map +1 -0
- package/dist/subscriptions.cjs +175 -0
- package/dist/subscriptions.cjs.map +1 -0
- package/dist/subscriptions.d.cts +290 -0
- package/dist/subscriptions.d.ts +290 -0
- package/dist/subscriptions.js +163 -0
- package/dist/subscriptions.js.map +1 -0
- package/dist/transactions.cjs +67 -0
- package/dist/transactions.cjs.map +1 -0
- package/dist/transactions.d.cts +78 -0
- package/dist/transactions.d.ts +78 -0
- package/dist/transactions.js +63 -0
- package/dist/transactions.js.map +1 -0
- package/dist/webhooks.cjs +116 -0
- package/dist/webhooks.cjs.map +1 -0
- package/dist/webhooks.d.cts +201 -0
- package/dist/webhooks.d.ts +201 -0
- package/dist/webhooks.js +107 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +134 -0
- package/src/agents.ts +149 -0
- package/src/api-keys.ts +78 -0
- package/src/common.ts +113 -0
- package/src/compliance.ts +40 -0
- package/src/customers.ts +40 -0
- package/src/events.ts +176 -0
- package/src/index.ts +23 -0
- package/src/invoices.ts +53 -0
- package/src/merchants.ts +104 -0
- package/src/payment-sessions.ts +131 -0
- package/src/refunds.ts +68 -0
- package/src/storefronts.ts +89 -0
- package/src/subscriptions.ts +180 -0
- package/src/tokens.ts +60 -0
- package/src/transactions.ts +52 -0
- package/src/webhooks.ts +109 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Payment session — a one-shot checkout intent.
|
|
5
|
+
*
|
|
6
|
+
* State machine:
|
|
7
|
+
* created → awaiting_payment → submitted → confirmed
|
|
8
|
+
* \
|
|
9
|
+
* → failed
|
|
10
|
+
* → expired
|
|
11
|
+
* → cancelled
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
declare const paymentSessionStatusSchema: z.ZodEnum<["created", "awaiting_payment", "submitted", "confirmed", "failed", "expired", "cancelled"]>;
|
|
15
|
+
type PaymentSessionStatus = z.infer<typeof paymentSessionStatusSchema>;
|
|
16
|
+
declare const paymentSessionSchema: z.ZodObject<{
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
merchantId: z.ZodString;
|
|
19
|
+
/**
|
|
20
|
+
* On-chain StrimzRegistry merchant id (uint96) as a decimal string.
|
|
21
|
+
* Set when the merchant has been registered on-chain; null when the
|
|
22
|
+
* merchant exists in our DB but the registry transaction hasn't
|
|
23
|
+
* been broadcast yet. Hosted checkout uses this to populate the
|
|
24
|
+
* meta-tx calldata; if null, the checkout refuses to accept
|
|
25
|
+
* payments.
|
|
26
|
+
*/
|
|
27
|
+
chainMerchantId: z.ZodNullable<z.ZodString>;
|
|
28
|
+
/**
|
|
29
|
+
* ERC-20 token contract address resolved from `currency` on the
|
|
30
|
+
* active chain (Arc Testnet / Mainnet). Used as the `verifyingContract`
|
|
31
|
+
* in the EIP-712 domain for both EIP-3009 and EIP-2612 signing.
|
|
32
|
+
* Null on the (vanishingly unlikely) path where the API has no
|
|
33
|
+
* configured address for the session's currency.
|
|
34
|
+
*/
|
|
35
|
+
tokenAddress: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
|
|
36
|
+
customerId: z.ZodNullable<z.ZodString>;
|
|
37
|
+
status: z.ZodEnum<["created", "awaiting_payment", "submitted", "confirmed", "failed", "expired", "cancelled"]>;
|
|
38
|
+
amount: z.ZodEffects<z.ZodString, string, string>;
|
|
39
|
+
currency: z.ZodEnum<["USDC", "EURC"]>;
|
|
40
|
+
feeAmount: z.ZodEffects<z.ZodString, string, string>;
|
|
41
|
+
netAmount: z.ZodEffects<z.ZodString, string, string>;
|
|
42
|
+
description: z.ZodNullable<z.ZodString>;
|
|
43
|
+
payerWalletAddress: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
|
|
44
|
+
payerEmail: z.ZodNullable<z.ZodString>;
|
|
45
|
+
successUrl: z.ZodNullable<z.ZodString>;
|
|
46
|
+
cancelUrl: z.ZodNullable<z.ZodString>;
|
|
47
|
+
sourceChain: z.ZodNullable<z.ZodEnum<["arc", "ethereum", "base", "polygon", "arbitrum", "optimism", "avalanche", "solana"]>>;
|
|
48
|
+
bridgeTxHash: z.ZodNullable<z.ZodString>;
|
|
49
|
+
onchainTxHash: z.ZodNullable<z.ZodString>;
|
|
50
|
+
checkoutUrl: z.ZodString;
|
|
51
|
+
metadata: z.ZodDefault<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>;
|
|
52
|
+
expiresAt: z.ZodString;
|
|
53
|
+
createdAt: z.ZodString;
|
|
54
|
+
updatedAt: z.ZodString;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
status: "created" | "awaiting_payment" | "submitted" | "confirmed" | "failed" | "expired" | "cancelled";
|
|
57
|
+
id: string;
|
|
58
|
+
merchantId: string;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
metadata: Record<string, string | number | boolean | null>;
|
|
61
|
+
chainMerchantId: string | null;
|
|
62
|
+
tokenAddress: string | null;
|
|
63
|
+
customerId: string | null;
|
|
64
|
+
amount: string;
|
|
65
|
+
currency: "USDC" | "EURC";
|
|
66
|
+
feeAmount: string;
|
|
67
|
+
netAmount: string;
|
|
68
|
+
description: string | null;
|
|
69
|
+
payerWalletAddress: string | null;
|
|
70
|
+
payerEmail: string | null;
|
|
71
|
+
successUrl: string | null;
|
|
72
|
+
cancelUrl: string | null;
|
|
73
|
+
sourceChain: "arc" | "ethereum" | "base" | "polygon" | "arbitrum" | "optimism" | "avalanche" | "solana" | null;
|
|
74
|
+
bridgeTxHash: string | null;
|
|
75
|
+
onchainTxHash: string | null;
|
|
76
|
+
checkoutUrl: string;
|
|
77
|
+
expiresAt: string;
|
|
78
|
+
updatedAt: string;
|
|
79
|
+
}, {
|
|
80
|
+
status: "created" | "awaiting_payment" | "submitted" | "confirmed" | "failed" | "expired" | "cancelled";
|
|
81
|
+
id: string;
|
|
82
|
+
merchantId: string;
|
|
83
|
+
createdAt: string;
|
|
84
|
+
chainMerchantId: string | null;
|
|
85
|
+
tokenAddress: string | null;
|
|
86
|
+
customerId: string | null;
|
|
87
|
+
amount: string;
|
|
88
|
+
currency: "USDC" | "EURC";
|
|
89
|
+
feeAmount: string;
|
|
90
|
+
netAmount: string;
|
|
91
|
+
description: string | null;
|
|
92
|
+
payerWalletAddress: string | null;
|
|
93
|
+
payerEmail: string | null;
|
|
94
|
+
successUrl: string | null;
|
|
95
|
+
cancelUrl: string | null;
|
|
96
|
+
sourceChain: "arc" | "ethereum" | "base" | "polygon" | "arbitrum" | "optimism" | "avalanche" | "solana" | null;
|
|
97
|
+
bridgeTxHash: string | null;
|
|
98
|
+
onchainTxHash: string | null;
|
|
99
|
+
checkoutUrl: string;
|
|
100
|
+
expiresAt: string;
|
|
101
|
+
updatedAt: string;
|
|
102
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
103
|
+
}>;
|
|
104
|
+
type PaymentSession = z.infer<typeof paymentSessionSchema>;
|
|
105
|
+
declare const createPaymentSessionInputSchema: z.ZodObject<{
|
|
106
|
+
amount: z.ZodEffects<z.ZodString, string, string>;
|
|
107
|
+
currency: z.ZodEnum<["USDC", "EURC"]>;
|
|
108
|
+
description: z.ZodOptional<z.ZodString>;
|
|
109
|
+
customer: z.ZodOptional<z.ZodObject<{
|
|
110
|
+
walletAddress: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
111
|
+
email: z.ZodOptional<z.ZodString>;
|
|
112
|
+
externalRef: z.ZodOptional<z.ZodString>;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
walletAddress?: string | undefined;
|
|
115
|
+
email?: string | undefined;
|
|
116
|
+
externalRef?: string | undefined;
|
|
117
|
+
}, {
|
|
118
|
+
walletAddress?: string | undefined;
|
|
119
|
+
email?: string | undefined;
|
|
120
|
+
externalRef?: string | undefined;
|
|
121
|
+
}>>;
|
|
122
|
+
successUrl: z.ZodOptional<z.ZodString>;
|
|
123
|
+
cancelUrl: z.ZodOptional<z.ZodString>;
|
|
124
|
+
/** Minutes until the session expires. Default 30, max 60*24 (one day). */
|
|
125
|
+
expiresInMinutes: z.ZodDefault<z.ZodNumber>;
|
|
126
|
+
/**
|
|
127
|
+
* Allowed source chains a payer can bridge USDC from via CCTP. Omit to
|
|
128
|
+
* accept every CCTP-supported chain.
|
|
129
|
+
*/
|
|
130
|
+
supportedSourceChains: z.ZodOptional<z.ZodArray<z.ZodEnum<["arc", "ethereum", "base", "polygon", "arbitrum", "optimism", "avalanche", "solana"]>, "many">>;
|
|
131
|
+
metadata: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>>;
|
|
132
|
+
}, "strip", z.ZodTypeAny, {
|
|
133
|
+
amount: string;
|
|
134
|
+
currency: "USDC" | "EURC";
|
|
135
|
+
expiresInMinutes: number;
|
|
136
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
137
|
+
description?: string | undefined;
|
|
138
|
+
successUrl?: string | undefined;
|
|
139
|
+
cancelUrl?: string | undefined;
|
|
140
|
+
customer?: {
|
|
141
|
+
walletAddress?: string | undefined;
|
|
142
|
+
email?: string | undefined;
|
|
143
|
+
externalRef?: string | undefined;
|
|
144
|
+
} | undefined;
|
|
145
|
+
supportedSourceChains?: ("arc" | "ethereum" | "base" | "polygon" | "arbitrum" | "optimism" | "avalanche" | "solana")[] | undefined;
|
|
146
|
+
}, {
|
|
147
|
+
amount: string;
|
|
148
|
+
currency: "USDC" | "EURC";
|
|
149
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
150
|
+
description?: string | undefined;
|
|
151
|
+
successUrl?: string | undefined;
|
|
152
|
+
cancelUrl?: string | undefined;
|
|
153
|
+
customer?: {
|
|
154
|
+
walletAddress?: string | undefined;
|
|
155
|
+
email?: string | undefined;
|
|
156
|
+
externalRef?: string | undefined;
|
|
157
|
+
} | undefined;
|
|
158
|
+
expiresInMinutes?: number | undefined;
|
|
159
|
+
supportedSourceChains?: ("arc" | "ethereum" | "base" | "polygon" | "arbitrum" | "optimism" | "avalanche" | "solana")[] | undefined;
|
|
160
|
+
}>;
|
|
161
|
+
type CreatePaymentSessionInput = z.infer<typeof createPaymentSessionInputSchema>;
|
|
162
|
+
declare const submitPaymentSessionInputSchema: z.ZodObject<{
|
|
163
|
+
sourceChain: z.ZodEnum<["arc", "ethereum", "base", "polygon", "arbitrum", "optimism", "avalanche", "solana"]>;
|
|
164
|
+
onchainTxHash: z.ZodString;
|
|
165
|
+
bridgeTxHash: z.ZodOptional<z.ZodString>;
|
|
166
|
+
payerWalletAddress: z.ZodEffects<z.ZodString, string, string>;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
payerWalletAddress: string;
|
|
169
|
+
sourceChain: "arc" | "ethereum" | "base" | "polygon" | "arbitrum" | "optimism" | "avalanche" | "solana";
|
|
170
|
+
onchainTxHash: string;
|
|
171
|
+
bridgeTxHash?: string | undefined;
|
|
172
|
+
}, {
|
|
173
|
+
payerWalletAddress: string;
|
|
174
|
+
sourceChain: "arc" | "ethereum" | "base" | "polygon" | "arbitrum" | "optimism" | "avalanche" | "solana";
|
|
175
|
+
onchainTxHash: string;
|
|
176
|
+
bridgeTxHash?: string | undefined;
|
|
177
|
+
}>;
|
|
178
|
+
type SubmitPaymentSessionInput = z.infer<typeof submitPaymentSessionInputSchema>;
|
|
179
|
+
|
|
180
|
+
export { type CreatePaymentSessionInput, type PaymentSession, type PaymentSessionStatus, type SubmitPaymentSessionInput, createPaymentSessionInputSchema, paymentSessionSchema, paymentSessionStatusSchema, submitPaymentSessionInputSchema };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Payment session — a one-shot checkout intent.
|
|
5
|
+
*
|
|
6
|
+
* State machine:
|
|
7
|
+
* created → awaiting_payment → submitted → confirmed
|
|
8
|
+
* \
|
|
9
|
+
* → failed
|
|
10
|
+
* → expired
|
|
11
|
+
* → cancelled
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
declare const paymentSessionStatusSchema: z.ZodEnum<["created", "awaiting_payment", "submitted", "confirmed", "failed", "expired", "cancelled"]>;
|
|
15
|
+
type PaymentSessionStatus = z.infer<typeof paymentSessionStatusSchema>;
|
|
16
|
+
declare const paymentSessionSchema: z.ZodObject<{
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
merchantId: z.ZodString;
|
|
19
|
+
/**
|
|
20
|
+
* On-chain StrimzRegistry merchant id (uint96) as a decimal string.
|
|
21
|
+
* Set when the merchant has been registered on-chain; null when the
|
|
22
|
+
* merchant exists in our DB but the registry transaction hasn't
|
|
23
|
+
* been broadcast yet. Hosted checkout uses this to populate the
|
|
24
|
+
* meta-tx calldata; if null, the checkout refuses to accept
|
|
25
|
+
* payments.
|
|
26
|
+
*/
|
|
27
|
+
chainMerchantId: z.ZodNullable<z.ZodString>;
|
|
28
|
+
/**
|
|
29
|
+
* ERC-20 token contract address resolved from `currency` on the
|
|
30
|
+
* active chain (Arc Testnet / Mainnet). Used as the `verifyingContract`
|
|
31
|
+
* in the EIP-712 domain for both EIP-3009 and EIP-2612 signing.
|
|
32
|
+
* Null on the (vanishingly unlikely) path where the API has no
|
|
33
|
+
* configured address for the session's currency.
|
|
34
|
+
*/
|
|
35
|
+
tokenAddress: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
|
|
36
|
+
customerId: z.ZodNullable<z.ZodString>;
|
|
37
|
+
status: z.ZodEnum<["created", "awaiting_payment", "submitted", "confirmed", "failed", "expired", "cancelled"]>;
|
|
38
|
+
amount: z.ZodEffects<z.ZodString, string, string>;
|
|
39
|
+
currency: z.ZodEnum<["USDC", "EURC"]>;
|
|
40
|
+
feeAmount: z.ZodEffects<z.ZodString, string, string>;
|
|
41
|
+
netAmount: z.ZodEffects<z.ZodString, string, string>;
|
|
42
|
+
description: z.ZodNullable<z.ZodString>;
|
|
43
|
+
payerWalletAddress: z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>;
|
|
44
|
+
payerEmail: z.ZodNullable<z.ZodString>;
|
|
45
|
+
successUrl: z.ZodNullable<z.ZodString>;
|
|
46
|
+
cancelUrl: z.ZodNullable<z.ZodString>;
|
|
47
|
+
sourceChain: z.ZodNullable<z.ZodEnum<["arc", "ethereum", "base", "polygon", "arbitrum", "optimism", "avalanche", "solana"]>>;
|
|
48
|
+
bridgeTxHash: z.ZodNullable<z.ZodString>;
|
|
49
|
+
onchainTxHash: z.ZodNullable<z.ZodString>;
|
|
50
|
+
checkoutUrl: z.ZodString;
|
|
51
|
+
metadata: z.ZodDefault<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>;
|
|
52
|
+
expiresAt: z.ZodString;
|
|
53
|
+
createdAt: z.ZodString;
|
|
54
|
+
updatedAt: z.ZodString;
|
|
55
|
+
}, "strip", z.ZodTypeAny, {
|
|
56
|
+
status: "created" | "awaiting_payment" | "submitted" | "confirmed" | "failed" | "expired" | "cancelled";
|
|
57
|
+
id: string;
|
|
58
|
+
merchantId: string;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
metadata: Record<string, string | number | boolean | null>;
|
|
61
|
+
chainMerchantId: string | null;
|
|
62
|
+
tokenAddress: string | null;
|
|
63
|
+
customerId: string | null;
|
|
64
|
+
amount: string;
|
|
65
|
+
currency: "USDC" | "EURC";
|
|
66
|
+
feeAmount: string;
|
|
67
|
+
netAmount: string;
|
|
68
|
+
description: string | null;
|
|
69
|
+
payerWalletAddress: string | null;
|
|
70
|
+
payerEmail: string | null;
|
|
71
|
+
successUrl: string | null;
|
|
72
|
+
cancelUrl: string | null;
|
|
73
|
+
sourceChain: "arc" | "ethereum" | "base" | "polygon" | "arbitrum" | "optimism" | "avalanche" | "solana" | null;
|
|
74
|
+
bridgeTxHash: string | null;
|
|
75
|
+
onchainTxHash: string | null;
|
|
76
|
+
checkoutUrl: string;
|
|
77
|
+
expiresAt: string;
|
|
78
|
+
updatedAt: string;
|
|
79
|
+
}, {
|
|
80
|
+
status: "created" | "awaiting_payment" | "submitted" | "confirmed" | "failed" | "expired" | "cancelled";
|
|
81
|
+
id: string;
|
|
82
|
+
merchantId: string;
|
|
83
|
+
createdAt: string;
|
|
84
|
+
chainMerchantId: string | null;
|
|
85
|
+
tokenAddress: string | null;
|
|
86
|
+
customerId: string | null;
|
|
87
|
+
amount: string;
|
|
88
|
+
currency: "USDC" | "EURC";
|
|
89
|
+
feeAmount: string;
|
|
90
|
+
netAmount: string;
|
|
91
|
+
description: string | null;
|
|
92
|
+
payerWalletAddress: string | null;
|
|
93
|
+
payerEmail: string | null;
|
|
94
|
+
successUrl: string | null;
|
|
95
|
+
cancelUrl: string | null;
|
|
96
|
+
sourceChain: "arc" | "ethereum" | "base" | "polygon" | "arbitrum" | "optimism" | "avalanche" | "solana" | null;
|
|
97
|
+
bridgeTxHash: string | null;
|
|
98
|
+
onchainTxHash: string | null;
|
|
99
|
+
checkoutUrl: string;
|
|
100
|
+
expiresAt: string;
|
|
101
|
+
updatedAt: string;
|
|
102
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
103
|
+
}>;
|
|
104
|
+
type PaymentSession = z.infer<typeof paymentSessionSchema>;
|
|
105
|
+
declare const createPaymentSessionInputSchema: z.ZodObject<{
|
|
106
|
+
amount: z.ZodEffects<z.ZodString, string, string>;
|
|
107
|
+
currency: z.ZodEnum<["USDC", "EURC"]>;
|
|
108
|
+
description: z.ZodOptional<z.ZodString>;
|
|
109
|
+
customer: z.ZodOptional<z.ZodObject<{
|
|
110
|
+
walletAddress: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
111
|
+
email: z.ZodOptional<z.ZodString>;
|
|
112
|
+
externalRef: z.ZodOptional<z.ZodString>;
|
|
113
|
+
}, "strip", z.ZodTypeAny, {
|
|
114
|
+
walletAddress?: string | undefined;
|
|
115
|
+
email?: string | undefined;
|
|
116
|
+
externalRef?: string | undefined;
|
|
117
|
+
}, {
|
|
118
|
+
walletAddress?: string | undefined;
|
|
119
|
+
email?: string | undefined;
|
|
120
|
+
externalRef?: string | undefined;
|
|
121
|
+
}>>;
|
|
122
|
+
successUrl: z.ZodOptional<z.ZodString>;
|
|
123
|
+
cancelUrl: z.ZodOptional<z.ZodString>;
|
|
124
|
+
/** Minutes until the session expires. Default 30, max 60*24 (one day). */
|
|
125
|
+
expiresInMinutes: z.ZodDefault<z.ZodNumber>;
|
|
126
|
+
/**
|
|
127
|
+
* Allowed source chains a payer can bridge USDC from via CCTP. Omit to
|
|
128
|
+
* accept every CCTP-supported chain.
|
|
129
|
+
*/
|
|
130
|
+
supportedSourceChains: z.ZodOptional<z.ZodArray<z.ZodEnum<["arc", "ethereum", "base", "polygon", "arbitrum", "optimism", "avalanche", "solana"]>, "many">>;
|
|
131
|
+
metadata: z.ZodOptional<z.ZodDefault<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>, Record<string, string | number | boolean | null>, Record<string, string | number | boolean | null>>>>;
|
|
132
|
+
}, "strip", z.ZodTypeAny, {
|
|
133
|
+
amount: string;
|
|
134
|
+
currency: "USDC" | "EURC";
|
|
135
|
+
expiresInMinutes: number;
|
|
136
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
137
|
+
description?: string | undefined;
|
|
138
|
+
successUrl?: string | undefined;
|
|
139
|
+
cancelUrl?: string | undefined;
|
|
140
|
+
customer?: {
|
|
141
|
+
walletAddress?: string | undefined;
|
|
142
|
+
email?: string | undefined;
|
|
143
|
+
externalRef?: string | undefined;
|
|
144
|
+
} | undefined;
|
|
145
|
+
supportedSourceChains?: ("arc" | "ethereum" | "base" | "polygon" | "arbitrum" | "optimism" | "avalanche" | "solana")[] | undefined;
|
|
146
|
+
}, {
|
|
147
|
+
amount: string;
|
|
148
|
+
currency: "USDC" | "EURC";
|
|
149
|
+
metadata?: Record<string, string | number | boolean | null> | undefined;
|
|
150
|
+
description?: string | undefined;
|
|
151
|
+
successUrl?: string | undefined;
|
|
152
|
+
cancelUrl?: string | undefined;
|
|
153
|
+
customer?: {
|
|
154
|
+
walletAddress?: string | undefined;
|
|
155
|
+
email?: string | undefined;
|
|
156
|
+
externalRef?: string | undefined;
|
|
157
|
+
} | undefined;
|
|
158
|
+
expiresInMinutes?: number | undefined;
|
|
159
|
+
supportedSourceChains?: ("arc" | "ethereum" | "base" | "polygon" | "arbitrum" | "optimism" | "avalanche" | "solana")[] | undefined;
|
|
160
|
+
}>;
|
|
161
|
+
type CreatePaymentSessionInput = z.infer<typeof createPaymentSessionInputSchema>;
|
|
162
|
+
declare const submitPaymentSessionInputSchema: z.ZodObject<{
|
|
163
|
+
sourceChain: z.ZodEnum<["arc", "ethereum", "base", "polygon", "arbitrum", "optimism", "avalanche", "solana"]>;
|
|
164
|
+
onchainTxHash: z.ZodString;
|
|
165
|
+
bridgeTxHash: z.ZodOptional<z.ZodString>;
|
|
166
|
+
payerWalletAddress: z.ZodEffects<z.ZodString, string, string>;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
payerWalletAddress: string;
|
|
169
|
+
sourceChain: "arc" | "ethereum" | "base" | "polygon" | "arbitrum" | "optimism" | "avalanche" | "solana";
|
|
170
|
+
onchainTxHash: string;
|
|
171
|
+
bridgeTxHash?: string | undefined;
|
|
172
|
+
}, {
|
|
173
|
+
payerWalletAddress: string;
|
|
174
|
+
sourceChain: "arc" | "ethereum" | "base" | "polygon" | "arbitrum" | "optimism" | "avalanche" | "solana";
|
|
175
|
+
onchainTxHash: string;
|
|
176
|
+
bridgeTxHash?: string | undefined;
|
|
177
|
+
}>;
|
|
178
|
+
type SubmitPaymentSessionInput = z.infer<typeof submitPaymentSessionInputSchema>;
|
|
179
|
+
|
|
180
|
+
export { type CreatePaymentSessionInput, type PaymentSession, type PaymentSessionStatus, type SubmitPaymentSessionInput, createPaymentSessionInputSchema, paymentSessionSchema, paymentSessionStatusSchema, submitPaymentSessionInputSchema };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/payment-sessions.ts
|
|
4
|
+
var idSchema = z.string().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/, "id must be URL-safe");
|
|
5
|
+
var evmAddressSchema = z.string().regex(/^0x[a-fA-F0-9]{40}$/, "must be a 0x-prefixed 40-character hex EVM address").transform((v) => v.toLowerCase());
|
|
6
|
+
var evmTxHashSchema = z.string().regex(/^0x[a-fA-F0-9]{64}$/, "must be a 0x-prefixed 64-character hex EVM transaction hash");
|
|
7
|
+
z.string().email().trim().toLowerCase().max(320);
|
|
8
|
+
z.string().url().refine((v) => v.startsWith("https://"), {
|
|
9
|
+
message: "must be an https:// URL"
|
|
10
|
+
});
|
|
11
|
+
z.string().url();
|
|
12
|
+
var tokenAmountSchema = z.string().regex(/^[0-9]+$/, "must be a non-negative integer string (base-10)").refine((v) => BigInt(v) >= 0n, "must be >= 0");
|
|
13
|
+
z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
14
|
+
var isoTimestampSchema = z.string().datetime({ offset: true, message: "must be an ISO-8601 timestamp" });
|
|
15
|
+
z.string().length(2).regex(/^[A-Z]{2}$/, "must be an ISO-3166 alpha-2 country code");
|
|
16
|
+
z.object({
|
|
17
|
+
limit: z.number().int().min(1).max(100).default(25),
|
|
18
|
+
cursor: z.string().min(1).max(200).nullish()
|
|
19
|
+
});
|
|
20
|
+
var metadataSchema = z.record(
|
|
21
|
+
z.string().min(1).max(40),
|
|
22
|
+
z.union([z.string().max(500), z.number(), z.boolean(), z.null()])
|
|
23
|
+
).refine((m) => Object.keys(m).length <= 50, "at most 50 metadata keys").default({});
|
|
24
|
+
z.enum(["test", "live"]);
|
|
25
|
+
var paymentCurrencySchema = z.enum(["USDC", "EURC"]);
|
|
26
|
+
z.enum(["USDC", "EURC", "USYC"]);
|
|
27
|
+
z.enum(["free", "growth", "business", "enterprise"]);
|
|
28
|
+
z.enum(["testnet", "mainnet"]);
|
|
29
|
+
|
|
30
|
+
// src/payment-sessions.ts
|
|
31
|
+
var paymentSessionStatusSchema = z.enum([
|
|
32
|
+
"created",
|
|
33
|
+
"awaiting_payment",
|
|
34
|
+
"submitted",
|
|
35
|
+
"confirmed",
|
|
36
|
+
"failed",
|
|
37
|
+
"expired",
|
|
38
|
+
"cancelled"
|
|
39
|
+
]);
|
|
40
|
+
var paymentSessionSchema = z.object({
|
|
41
|
+
id: idSchema,
|
|
42
|
+
merchantId: idSchema,
|
|
43
|
+
/**
|
|
44
|
+
* On-chain StrimzRegistry merchant id (uint96) as a decimal string.
|
|
45
|
+
* Set when the merchant has been registered on-chain; null when the
|
|
46
|
+
* merchant exists in our DB but the registry transaction hasn't
|
|
47
|
+
* been broadcast yet. Hosted checkout uses this to populate the
|
|
48
|
+
* meta-tx calldata; if null, the checkout refuses to accept
|
|
49
|
+
* payments.
|
|
50
|
+
*/
|
|
51
|
+
chainMerchantId: z.string().regex(/^[0-9]+$/u, "must be a non-negative decimal integer string").nullable(),
|
|
52
|
+
/**
|
|
53
|
+
* ERC-20 token contract address resolved from `currency` on the
|
|
54
|
+
* active chain (Arc Testnet / Mainnet). Used as the `verifyingContract`
|
|
55
|
+
* in the EIP-712 domain for both EIP-3009 and EIP-2612 signing.
|
|
56
|
+
* Null on the (vanishingly unlikely) path where the API has no
|
|
57
|
+
* configured address for the session's currency.
|
|
58
|
+
*/
|
|
59
|
+
tokenAddress: evmAddressSchema.nullable(),
|
|
60
|
+
customerId: idSchema.nullable(),
|
|
61
|
+
status: paymentSessionStatusSchema,
|
|
62
|
+
amount: tokenAmountSchema,
|
|
63
|
+
currency: paymentCurrencySchema,
|
|
64
|
+
feeAmount: tokenAmountSchema,
|
|
65
|
+
netAmount: tokenAmountSchema,
|
|
66
|
+
description: z.string().max(500).nullable(),
|
|
67
|
+
payerWalletAddress: evmAddressSchema.nullable(),
|
|
68
|
+
payerEmail: z.string().email().nullable(),
|
|
69
|
+
successUrl: z.string().url().nullable(),
|
|
70
|
+
cancelUrl: z.string().url().nullable(),
|
|
71
|
+
sourceChain: z.enum(["arc", "ethereum", "base", "polygon", "arbitrum", "optimism", "avalanche", "solana"]).nullable(),
|
|
72
|
+
bridgeTxHash: evmTxHashSchema.nullable(),
|
|
73
|
+
onchainTxHash: evmTxHashSchema.nullable(),
|
|
74
|
+
checkoutUrl: z.string().url(),
|
|
75
|
+
metadata: metadataSchema,
|
|
76
|
+
expiresAt: isoTimestampSchema,
|
|
77
|
+
createdAt: isoTimestampSchema,
|
|
78
|
+
updatedAt: isoTimestampSchema
|
|
79
|
+
});
|
|
80
|
+
var createPaymentSessionInputSchema = z.object({
|
|
81
|
+
amount: tokenAmountSchema,
|
|
82
|
+
currency: paymentCurrencySchema,
|
|
83
|
+
description: z.string().max(500).optional(),
|
|
84
|
+
customer: z.object({
|
|
85
|
+
walletAddress: evmAddressSchema.optional(),
|
|
86
|
+
email: z.string().email().optional(),
|
|
87
|
+
externalRef: z.string().max(120).optional()
|
|
88
|
+
}).optional(),
|
|
89
|
+
successUrl: z.string().url().optional(),
|
|
90
|
+
cancelUrl: z.string().url().optional(),
|
|
91
|
+
/** Minutes until the session expires. Default 30, max 60*24 (one day). */
|
|
92
|
+
expiresInMinutes: z.number().int().min(1).max(60 * 24).default(30),
|
|
93
|
+
/**
|
|
94
|
+
* Allowed source chains a payer can bridge USDC from via CCTP. Omit to
|
|
95
|
+
* accept every CCTP-supported chain.
|
|
96
|
+
*/
|
|
97
|
+
supportedSourceChains: z.array(
|
|
98
|
+
z.enum(["arc", "ethereum", "base", "polygon", "arbitrum", "optimism", "avalanche", "solana"])
|
|
99
|
+
).optional(),
|
|
100
|
+
metadata: metadataSchema.optional()
|
|
101
|
+
});
|
|
102
|
+
var submitPaymentSessionInputSchema = z.object({
|
|
103
|
+
sourceChain: z.enum([
|
|
104
|
+
"arc",
|
|
105
|
+
"ethereum",
|
|
106
|
+
"base",
|
|
107
|
+
"polygon",
|
|
108
|
+
"arbitrum",
|
|
109
|
+
"optimism",
|
|
110
|
+
"avalanche",
|
|
111
|
+
"solana"
|
|
112
|
+
]),
|
|
113
|
+
onchainTxHash: evmTxHashSchema,
|
|
114
|
+
bridgeTxHash: evmTxHashSchema.optional(),
|
|
115
|
+
payerWalletAddress: evmAddressSchema
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
export { createPaymentSessionInputSchema, paymentSessionSchema, paymentSessionStatusSchema, submitPaymentSessionInputSchema };
|
|
119
|
+
//# sourceMappingURL=payment-sessions.js.map
|
|
120
|
+
//# sourceMappingURL=payment-sessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common.ts","../src/payment-sessions.ts"],"names":["z"],"mappings":";;;AAQO,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AO;AAAA,EACtD,WAAA,EAAaA,EAAE,IAAA,CAAK;AAAA,IAClB,KAAA;AAAA,IACA,UAAA;AAAA,IACA,MAAA;AAAA,IACA,SAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAA;AAAA,IACA,WAAA;AAAA,IACA;AAAA,GACD,CAAA;AAAA,EACD,aAAA,EAAe,eAAA;AAAA,EACf,YAAA,EAAc,gBAAgB,QAAA,EAAS;AAAA,EACvC,kBAAA,EAAoB;AACtB,CAAC","file":"payment-sessions.js","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum — mirrors `@strimz/shared-config`. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum — mirrors `@strimz/shared-config`. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Payment session — a one-shot checkout intent.\n *\n * State machine:\n * created → awaiting_payment → submitted → confirmed\n * \\\n * → failed\n * → expired\n * → cancelled\n */\n\nimport { z } from 'zod'\nimport {\n evmAddressSchema,\n evmTxHashSchema,\n idSchema,\n isoTimestampSchema,\n metadataSchema,\n paymentCurrencySchema,\n tokenAmountSchema,\n} from './common.js'\n\nexport const paymentSessionStatusSchema = z.enum([\n 'created',\n 'awaiting_payment',\n 'submitted',\n 'confirmed',\n 'failed',\n 'expired',\n 'cancelled',\n])\nexport type PaymentSessionStatus = z.infer<typeof paymentSessionStatusSchema>\n\nexport const paymentSessionSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n /**\n * On-chain StrimzRegistry merchant id (uint96) as a decimal string.\n * Set when the merchant has been registered on-chain; null when the\n * merchant exists in our DB but the registry transaction hasn't\n * been broadcast yet. Hosted checkout uses this to populate the\n * meta-tx calldata; if null, the checkout refuses to accept\n * payments.\n */\n chainMerchantId: z\n .string()\n .regex(/^[0-9]+$/u, 'must be a non-negative decimal integer string')\n .nullable(),\n /**\n * ERC-20 token contract address resolved from `currency` on the\n * active chain (Arc Testnet / Mainnet). Used as the `verifyingContract`\n * in the EIP-712 domain for both EIP-3009 and EIP-2612 signing.\n * Null on the (vanishingly unlikely) path where the API has no\n * configured address for the session's currency.\n */\n tokenAddress: evmAddressSchema.nullable(),\n customerId: idSchema.nullable(),\n status: paymentSessionStatusSchema,\n amount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n feeAmount: tokenAmountSchema,\n netAmount: tokenAmountSchema,\n description: z.string().max(500).nullable(),\n payerWalletAddress: evmAddressSchema.nullable(),\n payerEmail: z.string().email().nullable(),\n successUrl: z.string().url().nullable(),\n cancelUrl: z.string().url().nullable(),\n sourceChain: z\n .enum(['arc', 'ethereum', 'base', 'polygon', 'arbitrum', 'optimism', 'avalanche', 'solana'])\n .nullable(),\n bridgeTxHash: evmTxHashSchema.nullable(),\n onchainTxHash: evmTxHashSchema.nullable(),\n checkoutUrl: z.string().url(),\n metadata: metadataSchema,\n expiresAt: isoTimestampSchema,\n createdAt: isoTimestampSchema,\n updatedAt: isoTimestampSchema,\n})\nexport type PaymentSession = z.infer<typeof paymentSessionSchema>\n\n// ---------- DTOs ----------\n\nexport const createPaymentSessionInputSchema = z.object({\n amount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n description: z.string().max(500).optional(),\n customer: z\n .object({\n walletAddress: evmAddressSchema.optional(),\n email: z.string().email().optional(),\n externalRef: z.string().max(120).optional(),\n })\n .optional(),\n successUrl: z.string().url().optional(),\n cancelUrl: z.string().url().optional(),\n /** Minutes until the session expires. Default 30, max 60*24 (one day). */\n expiresInMinutes: z\n .number()\n .int()\n .min(1)\n .max(60 * 24)\n .default(30),\n /**\n * Allowed source chains a payer can bridge USDC from via CCTP. Omit to\n * accept every CCTP-supported chain.\n */\n supportedSourceChains: z\n .array(\n z.enum(['arc', 'ethereum', 'base', 'polygon', 'arbitrum', 'optimism', 'avalanche', 'solana']),\n )\n .optional(),\n metadata: metadataSchema.optional(),\n})\nexport type CreatePaymentSessionInput = z.infer<typeof createPaymentSessionInputSchema>\n\nexport const submitPaymentSessionInputSchema = z.object({\n sourceChain: z.enum([\n 'arc',\n 'ethereum',\n 'base',\n 'polygon',\n 'arbitrum',\n 'optimism',\n 'avalanche',\n 'solana',\n ]),\n onchainTxHash: evmTxHashSchema,\n bridgeTxHash: evmTxHashSchema.optional(),\n payerWalletAddress: evmAddressSchema,\n})\nexport type SubmitPaymentSessionInput = z.infer<typeof submitPaymentSessionInputSchema>\n"]}
|
package/dist/refunds.cjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
|
|
5
|
+
// src/refunds.ts
|
|
6
|
+
var idSchema = zod.z.string().min(1).max(64).regex(/^[a-zA-Z0-9_-]+$/, "id must be URL-safe");
|
|
7
|
+
var evmAddressSchema = zod.z.string().regex(/^0x[a-fA-F0-9]{40}$/, "must be a 0x-prefixed 40-character hex EVM address").transform((v) => v.toLowerCase());
|
|
8
|
+
var evmTxHashSchema = zod.z.string().regex(/^0x[a-fA-F0-9]{64}$/, "must be a 0x-prefixed 64-character hex EVM transaction hash");
|
|
9
|
+
zod.z.string().email().trim().toLowerCase().max(320);
|
|
10
|
+
zod.z.string().url().refine((v) => v.startsWith("https://"), {
|
|
11
|
+
message: "must be an https:// URL"
|
|
12
|
+
});
|
|
13
|
+
zod.z.string().url();
|
|
14
|
+
var tokenAmountSchema = zod.z.string().regex(/^[0-9]+$/, "must be a non-negative integer string (base-10)").refine((v) => BigInt(v) >= 0n, "must be >= 0");
|
|
15
|
+
zod.z.number().int().min(0).max(Number.MAX_SAFE_INTEGER);
|
|
16
|
+
var isoTimestampSchema = zod.z.string().datetime({ offset: true, message: "must be an ISO-8601 timestamp" });
|
|
17
|
+
zod.z.string().length(2).regex(/^[A-Z]{2}$/, "must be an ISO-3166 alpha-2 country code");
|
|
18
|
+
zod.z.object({
|
|
19
|
+
limit: zod.z.number().int().min(1).max(100).default(25),
|
|
20
|
+
cursor: zod.z.string().min(1).max(200).nullish()
|
|
21
|
+
});
|
|
22
|
+
zod.z.record(
|
|
23
|
+
zod.z.string().min(1).max(40),
|
|
24
|
+
zod.z.union([zod.z.string().max(500), zod.z.number(), zod.z.boolean(), zod.z.null()])
|
|
25
|
+
).refine((m) => Object.keys(m).length <= 50, "at most 50 metadata keys").default({});
|
|
26
|
+
zod.z.enum(["test", "live"]);
|
|
27
|
+
var paymentCurrencySchema = zod.z.enum(["USDC", "EURC"]);
|
|
28
|
+
zod.z.enum(["USDC", "EURC", "USYC"]);
|
|
29
|
+
zod.z.enum(["free", "growth", "business", "enterprise"]);
|
|
30
|
+
zod.z.enum(["testnet", "mainnet"]);
|
|
31
|
+
|
|
32
|
+
// src/refunds.ts
|
|
33
|
+
var refundReasonSchema = zod.z.enum([
|
|
34
|
+
"customer_request",
|
|
35
|
+
"product_issue",
|
|
36
|
+
"duplicate_charge",
|
|
37
|
+
"fraudulent",
|
|
38
|
+
"other"
|
|
39
|
+
]);
|
|
40
|
+
var refundStatusSchema = zod.z.enum([
|
|
41
|
+
"pending",
|
|
42
|
+
"awaiting_signature",
|
|
43
|
+
"submitted",
|
|
44
|
+
"completed",
|
|
45
|
+
"failed",
|
|
46
|
+
"cancelled"
|
|
47
|
+
]);
|
|
48
|
+
var refundSchema = zod.z.object({
|
|
49
|
+
id: idSchema,
|
|
50
|
+
merchantId: idSchema,
|
|
51
|
+
transactionId: idSchema,
|
|
52
|
+
amount: tokenAmountSchema,
|
|
53
|
+
currency: paymentCurrencySchema,
|
|
54
|
+
reason: refundReasonSchema,
|
|
55
|
+
note: zod.z.string().max(500).nullable(),
|
|
56
|
+
status: refundStatusSchema,
|
|
57
|
+
payerAddress: evmAddressSchema,
|
|
58
|
+
refundTxHash: evmTxHashSchema.nullable(),
|
|
59
|
+
failureReason: zod.z.string().max(500).nullable(),
|
|
60
|
+
initiatedBy: idSchema,
|
|
61
|
+
createdAt: isoTimestampSchema,
|
|
62
|
+
completedAt: isoTimestampSchema.nullable()
|
|
63
|
+
});
|
|
64
|
+
var createRefundInputSchema = zod.z.object({
|
|
65
|
+
transactionId: idSchema,
|
|
66
|
+
amount: tokenAmountSchema,
|
|
67
|
+
reason: refundReasonSchema,
|
|
68
|
+
note: zod.z.string().max(500).optional()
|
|
69
|
+
});
|
|
70
|
+
var submitRefundSignatureInputSchema = zod.z.object({
|
|
71
|
+
id: idSchema,
|
|
72
|
+
refundTxHash: evmTxHashSchema
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
exports.createRefundInputSchema = createRefundInputSchema;
|
|
76
|
+
exports.refundReasonSchema = refundReasonSchema;
|
|
77
|
+
exports.refundSchema = refundSchema;
|
|
78
|
+
exports.refundStatusSchema = refundStatusSchema;
|
|
79
|
+
exports.submitRefundSignatureInputSchema = submitRefundSignatureInputSchema;
|
|
80
|
+
//# sourceMappingURL=refunds.cjs.map
|
|
81
|
+
//# sourceMappingURL=refunds.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/common.ts","../src/refunds.ts"],"names":["z"],"mappings":";;;;;AAQO,IAAM,QAAA,GAAWA,KAAA,CACrB,MAAA,EAAO,CACP,GAAA,CAAI,CAAC,CAAA,CACL,GAAA,CAAI,EAAE,CAAA,CACN,KAAA,CAAM,kBAAA,EAAoB,qBAAqB,CAAA;AAG3C,IAAM,gBAAA,GAAmBA,KAAA,CAC7B,MAAA,EAAO,CACP,KAAA,CAAM,qBAAA,EAAuB,oDAAoD,CAAA,CACjF,SAAA,CAAU,CAAC,CAAA,KAAM,CAAA,CAAE,aAAa,CAAA;AAG5B,IAAM,kBAAkBA,KAAA,CAC5B,MAAA,EAAO,CACP,KAAA,CAAM,uBAAuB,6DAA6D,CAAA;AAGlEA,KAAA,CAAE,MAAA,EAAO,CAAE,KAAA,EAAM,CAAE,IAAA,EAAK,CAAE,WAAA,EAAY,CAAE,GAAA,CAAI,GAAG;AAG5CA,KAAA,CAC3B,MAAA,EAAO,CACP,GAAA,EAAI,CACJ,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,UAAA,CAAW,UAAU,CAAA,EAAG;AAAA,EACvC,OAAA,EAAS;AACX,CAAC;AAG0BA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA;AAOjC,IAAM,iBAAA,GAAoBA,KAAA,CAC9B,MAAA,EAAO,CACP,MAAM,UAAA,EAAY,iDAAiD,CAAA,CACnE,MAAA,CAAO,CAAC,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AAA,EAAe,QAAA;AAAA,EACf,MAAA,EAAQ,iBAAA;AAAA,EACR,MAAA,EAAQ,kBAAA;AAAA,EACR,MAAMA,KAAAA,CAAE,MAAA,GAAS,GAAA,CAAI,GAAG,EAAE,QAAA;AAC5B,CAAC;AAGM,IAAM,gCAAA,GAAmCA,MAAE,MAAA,CAAO;AAAA,EACvD,EAAA,EAAI,QAAA;AAAA,EACJ,YAAA,EAAc;AAChB,CAAC","file":"refunds.cjs","sourcesContent":["/**\n * Primitive schemas shared across every entity.\n * Every higher-level schema builds on these so validation is consistent.\n */\n\nimport { z } from 'zod'\n\n/** CUID2 or UUID-style opaque identifier. */\nexport const idSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(/^[a-zA-Z0-9_-]+$/, 'id must be URL-safe')\n\n/** EVM address. Hex-encoded, 0x-prefixed, 20 bytes. Normalised to lowercase. */\nexport const evmAddressSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{40}$/, 'must be a 0x-prefixed 40-character hex EVM address')\n .transform((v) => v.toLowerCase())\n\n/** EVM transaction hash. 32-byte hex. */\nexport const evmTxHashSchema = z\n .string()\n .regex(/^0x[a-fA-F0-9]{64}$/, 'must be a 0x-prefixed 64-character hex EVM transaction hash')\n\n/** Email address, trimmed and lower-cased. */\nexport const emailSchema = z.string().email().trim().toLowerCase().max(320)\n\n/** HTTPS URL. No http:// allowed outside dev. */\nexport const httpsUrlSchema = z\n .string()\n .url()\n .refine((v) => v.startsWith('https://'), {\n message: 'must be an https:// URL',\n })\n\n/** URL permitting http and https (dev + prod). */\nexport const httpUrlSchema = z.string().url()\n\n/**\n * Amount expressed in the token's smallest unit, serialised as a string to\n * preserve precision beyond `Number.MAX_SAFE_INTEGER`. For USDC (6 decimals),\n * 1 USDC is the string \"1000000\".\n */\nexport const tokenAmountSchema = z\n .string()\n .regex(/^[0-9]+$/, 'must be a non-negative integer string (base-10)')\n .refine((v) => BigInt(v) >= 0n, 'must be >= 0')\n\n/** Unsigned integer up to 2^53 - 1; validated and returned as number. */\nexport const uintSchema = z.number().int().min(0).max(Number.MAX_SAFE_INTEGER)\n\n/** ISO-8601 timestamp string (`.toISOString()`-compatible). */\nexport const isoTimestampSchema = z\n .string()\n .datetime({ offset: true, message: 'must be an ISO-8601 timestamp' })\n\n/** Two-letter ISO-3166 country code. */\nexport const countryCodeSchema = z\n .string()\n .length(2)\n .regex(/^[A-Z]{2}$/, 'must be an ISO-3166 alpha-2 country code')\n\n/** Pagination inputs used by every list endpoint. */\nexport const paginationInputSchema = z.object({\n limit: z.number().int().min(1).max(100).default(25),\n cursor: z.string().min(1).max(200).nullish(),\n})\nexport type PaginationInput = z.infer<typeof paginationInputSchema>\n\n/** Pagination envelope used by every list response. */\nexport const makePaginatedSchema = <T extends z.ZodTypeAny>(item: T) =>\n z.object({\n data: z.array(item),\n nextCursor: z.string().nullable(),\n hasMore: z.boolean(),\n })\n\n/** Free-form metadata bag the API round-trips for merchants. */\nexport const metadataSchema = z\n .record(\n z.string().min(1).max(40),\n z.union([z.string().max(500), z.number(), z.boolean(), z.null()]),\n )\n .refine((m) => Object.keys(m).length <= 50, 'at most 50 metadata keys')\n .default({})\n\n/** Environment mode carried on every mode-scoped resource. */\nexport const modeSchema = z.enum(['test', 'live'])\nexport type Mode = z.infer<typeof modeSchema>\n\n/** Payment token enum — mirrors `@strimz/shared-config`. */\nexport const paymentCurrencySchema = z.enum(['USDC', 'EURC'])\nexport type PaymentCurrency = z.infer<typeof paymentCurrencySchema>\n\n/** Every display-level currency (payment + treasury). */\nexport const tokenSymbolSchema = z.enum(['USDC', 'EURC', 'USYC'])\nexport type TokenSymbol = z.infer<typeof tokenSymbolSchema>\n\n/** Merchant tier enum — mirrors `@strimz/shared-config`. */\nexport const merchantTierSchema = z.enum(['free', 'growth', 'business', 'enterprise'])\nexport type MerchantTier = z.infer<typeof merchantTierSchema>\n\n/** Arc environment enum. */\nexport const arcEnvironmentSchema = z.enum(['testnet', 'mainnet'])\nexport type ArcEnvironment = z.infer<typeof arcEnvironmentSchema>\n\nexport type Id = z.infer<typeof idSchema>\nexport type EvmAddress = z.infer<typeof evmAddressSchema>\nexport type EvmTxHash = z.infer<typeof evmTxHashSchema>\nexport type TokenAmount = z.infer<typeof tokenAmountSchema>\nexport type IsoTimestamp = z.infer<typeof isoTimestampSchema>\nexport type Metadata = z.infer<typeof metadataSchema>\n","/**\n * Refund — a merchant-initiated return of funds to a payer.\n *\n * Refunds are executed off-chain (from the merchant's wallet to the payer's\n * wallet). Strimz records the intent, validates constraints, and reconciles\n * via the merchant-signed on-chain transfer.\n */\n\nimport { z } from 'zod'\nimport {\n evmAddressSchema,\n evmTxHashSchema,\n idSchema,\n isoTimestampSchema,\n paymentCurrencySchema,\n tokenAmountSchema,\n} from './common.js'\n\nexport const refundReasonSchema = z.enum([\n 'customer_request',\n 'product_issue',\n 'duplicate_charge',\n 'fraudulent',\n 'other',\n])\nexport type RefundReason = z.infer<typeof refundReasonSchema>\n\nexport const refundStatusSchema = z.enum([\n 'pending',\n 'awaiting_signature',\n 'submitted',\n 'completed',\n 'failed',\n 'cancelled',\n])\nexport type RefundStatus = z.infer<typeof refundStatusSchema>\n\nexport const refundSchema = z.object({\n id: idSchema,\n merchantId: idSchema,\n transactionId: idSchema,\n amount: tokenAmountSchema,\n currency: paymentCurrencySchema,\n reason: refundReasonSchema,\n note: z.string().max(500).nullable(),\n status: refundStatusSchema,\n payerAddress: evmAddressSchema,\n refundTxHash: evmTxHashSchema.nullable(),\n failureReason: z.string().max(500).nullable(),\n initiatedBy: idSchema,\n createdAt: isoTimestampSchema,\n completedAt: isoTimestampSchema.nullable(),\n})\nexport type Refund = z.infer<typeof refundSchema>\n\nexport const createRefundInputSchema = z.object({\n transactionId: idSchema,\n amount: tokenAmountSchema,\n reason: refundReasonSchema,\n note: z.string().max(500).optional(),\n})\nexport type CreateRefundInput = z.infer<typeof createRefundInputSchema>\n\nexport const submitRefundSignatureInputSchema = z.object({\n id: idSchema,\n refundTxHash: evmTxHashSchema,\n})\nexport type SubmitRefundSignatureInput = z.infer<typeof submitRefundSignatureInputSchema>\n"]}
|