@alien_org/contract 0.1.0 → 0.1.2
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/dist/index.cjs +6 -1
- package/dist/index.d.cts +150 -38
- package/dist/index.d.mts +150 -38
- package/dist/index.mjs +6 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9,7 +9,12 @@ const PLATFORMS = ["ios", "android"];
|
|
|
9
9
|
//#region src/methods/versions/releases.ts
|
|
10
10
|
const releases = {
|
|
11
11
|
"0.0.9": ["app:ready"],
|
|
12
|
-
"0.0.14": ["miniapp:close.ack", "host.back.button:toggle"]
|
|
12
|
+
"0.0.14": ["miniapp:close.ack", "host.back.button:toggle"],
|
|
13
|
+
"0.1.1": [
|
|
14
|
+
"payment:request",
|
|
15
|
+
"clipboard:write",
|
|
16
|
+
"clipboard:read"
|
|
17
|
+
]
|
|
13
18
|
};
|
|
14
19
|
|
|
15
20
|
//#endregion
|
package/dist/index.d.cts
CHANGED
|
@@ -44,6 +44,49 @@ type If<Cond extends boolean, True, False> = Cond extends true ? True : False;
|
|
|
44
44
|
* // Empty = {}
|
|
45
45
|
*/
|
|
46
46
|
type Empty = Record<string, never>;
|
|
47
|
+
/**
|
|
48
|
+
* Client-side payment error codes (pre-broadcast failures).
|
|
49
|
+
* Returned when `status` is `'failed'` in `payment:response`.
|
|
50
|
+
* These errors occur before transaction broadcast, so no webhook is sent.
|
|
51
|
+
* @since 0.1.1
|
|
52
|
+
* @schema
|
|
53
|
+
*/
|
|
54
|
+
type PaymentErrorCode = 'insufficient_balance' | 'network_error' | 'pre_checkout_rejected' | 'pre_checkout_timeout' | 'unknown';
|
|
55
|
+
/**
|
|
56
|
+
* Webhook status for payment results (on-chain truth).
|
|
57
|
+
* - `'finalized'`: Transaction confirmed on-chain
|
|
58
|
+
* - `'failed'`: Transaction failed on-chain
|
|
59
|
+
* @since 0.1.2
|
|
60
|
+
* @schema
|
|
61
|
+
*/
|
|
62
|
+
type PaymentWebhookStatus = 'finalized' | 'failed';
|
|
63
|
+
/**
|
|
64
|
+
* Payment test scenarios for simulating different payment outcomes.
|
|
65
|
+
*
|
|
66
|
+
* | Scenario | Client sees | Webhook |
|
|
67
|
+
* |----------|-------------|---------|
|
|
68
|
+
* | `'paid'` | `paid` | `{ status: 'finalized' }` |
|
|
69
|
+
* | `'paid:failed'` | `paid` | `{ status: 'failed' }` |
|
|
70
|
+
* | `'cancelled'` | `cancelled` | none |
|
|
71
|
+
* | `'error:*'` | `failed` | none (pre-broadcast) |
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* // Happy path: client paid, tx finalized
|
|
75
|
+
* test: 'paid'
|
|
76
|
+
*
|
|
77
|
+
* // On-chain failure: client paid, tx failed
|
|
78
|
+
* test: 'paid:failed'
|
|
79
|
+
*
|
|
80
|
+
* // User cancelled before confirming
|
|
81
|
+
* test: 'cancelled'
|
|
82
|
+
*
|
|
83
|
+
* // Pre-broadcast error (no tx, no webhook)
|
|
84
|
+
* test: 'error:insufficient_balance'
|
|
85
|
+
*
|
|
86
|
+
* @since 0.1.2
|
|
87
|
+
* @schema
|
|
88
|
+
*/
|
|
89
|
+
type PaymentTestScenario = 'paid' | 'paid:failed' | 'cancelled' | `error:${PaymentErrorCode}`;
|
|
47
90
|
//#endregion
|
|
48
91
|
//#region src/events/types/payload.d.ts
|
|
49
92
|
/**
|
|
@@ -83,7 +126,7 @@ interface Events {
|
|
|
83
126
|
* For instant fulfillment, your backend should fulfill on webhook receipt
|
|
84
127
|
* using the `invoice` from the request.
|
|
85
128
|
*
|
|
86
|
-
* @since 0.
|
|
129
|
+
* @since 0.1.1
|
|
87
130
|
* @schema
|
|
88
131
|
*/
|
|
89
132
|
'payment:response': CreateEventPayload<WithReqId<{
|
|
@@ -91,14 +134,14 @@ interface Events {
|
|
|
91
134
|
* Payment status.
|
|
92
135
|
* - `paid`: Success
|
|
93
136
|
* - `cancelled`: User rejected
|
|
94
|
-
* - `
|
|
95
|
-
* @since 0.
|
|
137
|
+
* - `error`: Error (check `errorCode`)
|
|
138
|
+
* @since 0.1.1
|
|
96
139
|
* @schema
|
|
97
140
|
*/
|
|
98
|
-
status: 'paid' | 'cancelled' | '
|
|
141
|
+
status: 'paid' | 'cancelled' | 'error';
|
|
99
142
|
/**
|
|
100
143
|
* Transaction hash (present when status is 'paid').
|
|
101
|
-
* @since 0.
|
|
144
|
+
* @since 0.1.1
|
|
102
145
|
* @schema
|
|
103
146
|
*/
|
|
104
147
|
txHash?: string;
|
|
@@ -109,10 +152,35 @@ interface Events {
|
|
|
109
152
|
* - `pre_checkout_rejected`: Backend rejected the payment in pre-checkout
|
|
110
153
|
* - `pre_checkout_timeout`: Backend didn't respond to pre-checkout in time
|
|
111
154
|
* - `unknown`: Unexpected error
|
|
112
|
-
* @since 0.
|
|
155
|
+
* @since 0.1.1
|
|
156
|
+
* @schema
|
|
157
|
+
*/
|
|
158
|
+
errorCode?: PaymentErrorCode;
|
|
159
|
+
}>>;
|
|
160
|
+
/**
|
|
161
|
+
* Clipboard read response.
|
|
162
|
+
*
|
|
163
|
+
* On success: `text` contains the clipboard content (may be empty string).
|
|
164
|
+
* On failure: `text` is null and `errorCode` indicates the reason.
|
|
165
|
+
*
|
|
166
|
+
* @since 0.1.1
|
|
167
|
+
* @schema
|
|
168
|
+
*/
|
|
169
|
+
'clipboard:response': CreateEventPayload<WithReqId<{
|
|
170
|
+
/**
|
|
171
|
+
* Text from clipboard. Null if read failed.
|
|
172
|
+
* @since 0.1.1
|
|
113
173
|
* @schema
|
|
114
174
|
*/
|
|
115
|
-
|
|
175
|
+
text: string | null;
|
|
176
|
+
/**
|
|
177
|
+
* Error code if clipboard read failed.
|
|
178
|
+
* - `permission_denied`: User denied clipboard access
|
|
179
|
+
* - `unavailable`: Clipboard is not available
|
|
180
|
+
* @since 0.1.1
|
|
181
|
+
* @schema
|
|
182
|
+
*/
|
|
183
|
+
errorCode?: 'permission_denied' | 'unavailable';
|
|
116
184
|
}>>;
|
|
117
185
|
}
|
|
118
186
|
//#endregion
|
|
@@ -204,73 +272,117 @@ interface Methods {
|
|
|
204
272
|
* Set `test: true` for test mode - no real payment is made, but webhooks
|
|
205
273
|
* are fired with `test: true` flag. Use for development and testing.
|
|
206
274
|
*
|
|
207
|
-
* @since 0.
|
|
275
|
+
* @since 0.1.1
|
|
208
276
|
* @schema
|
|
209
277
|
*/
|
|
210
278
|
'payment:request': CreateMethodPayload<WithReqId<{
|
|
211
279
|
/**
|
|
212
280
|
* The recipient's wallet address.
|
|
213
|
-
* @since 0.
|
|
281
|
+
* @since 0.1.1
|
|
214
282
|
* @schema
|
|
215
283
|
*/
|
|
216
284
|
recipient: string;
|
|
217
285
|
/**
|
|
218
286
|
* The amount to pay (in token's smallest unit, as string for precision).
|
|
219
|
-
* @since 0.
|
|
287
|
+
* @since 0.1.1
|
|
220
288
|
* @schema
|
|
221
289
|
*/
|
|
222
290
|
amount: string;
|
|
223
291
|
/**
|
|
224
292
|
* The token identifier (e.g., 'SOL', 'ALIEN', or contract address).
|
|
225
|
-
* @since 0.
|
|
293
|
+
* @since 0.1.1
|
|
226
294
|
* @schema
|
|
227
295
|
*/
|
|
228
296
|
token: string;
|
|
229
297
|
/**
|
|
230
298
|
* The network for the payment ('solana' or 'alien').
|
|
231
|
-
* @since 0.
|
|
299
|
+
* @since 0.1.1
|
|
232
300
|
* @schema
|
|
233
301
|
*/
|
|
234
302
|
network: string;
|
|
235
303
|
/**
|
|
236
304
|
* Your order/invoice ID for backend correlation and instant fulfillment.
|
|
237
|
-
* @since 0.
|
|
305
|
+
* @since 0.1.1
|
|
238
306
|
* @schema
|
|
239
307
|
*/
|
|
240
308
|
invoice: string;
|
|
241
309
|
/**
|
|
242
|
-
*
|
|
243
|
-
* @since 0.
|
|
310
|
+
* Optional item details shown on the approval screen.
|
|
311
|
+
* @since 0.1.1
|
|
244
312
|
* @schema
|
|
245
313
|
*/
|
|
246
|
-
|
|
314
|
+
item?: {
|
|
315
|
+
/**
|
|
316
|
+
* Item title shown on the approval screen.
|
|
317
|
+
* @since 0.1.1
|
|
318
|
+
* @schema
|
|
319
|
+
*/
|
|
320
|
+
title: string;
|
|
321
|
+
/**
|
|
322
|
+
* Item icon URL shown on the approval screen.
|
|
323
|
+
* @since 0.1.1
|
|
324
|
+
* @schema
|
|
325
|
+
*/
|
|
326
|
+
iconUrl: string;
|
|
327
|
+
/**
|
|
328
|
+
* Quantity of items being purchased.
|
|
329
|
+
* @since 0.1.1
|
|
330
|
+
* @schema
|
|
331
|
+
*/
|
|
332
|
+
quantity: number;
|
|
333
|
+
};
|
|
247
334
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
*
|
|
255
|
-
*
|
|
335
|
+
* Test mode. Simulates payment outcomes without real transactions.
|
|
336
|
+
*
|
|
337
|
+
* | Scenario | Client | Webhook |
|
|
338
|
+
* |----------|--------|---------|
|
|
339
|
+
* | `true` / `'paid'` | `paid` | `finalized` |
|
|
340
|
+
* | `'paid:failed'` | `paid` | `failed` |
|
|
341
|
+
* | `'cancelled'` | `cancelled` | none |
|
|
342
|
+
* | `'error:*'` | `failed` | none |
|
|
343
|
+
*
|
|
344
|
+
* **Pre-broadcast errors** (no webhook):
|
|
345
|
+
* `'error:insufficient_balance'`, `'error:network_error'`,
|
|
346
|
+
* `'error:pre_checkout_rejected'`, `'error:pre_checkout_timeout'`,
|
|
347
|
+
* `'error:unknown'`
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* // Happy path
|
|
351
|
+
* test: 'paid'
|
|
352
|
+
*
|
|
353
|
+
* // Client shows success, but tx failed on-chain
|
|
354
|
+
* test: 'paid:failed'
|
|
355
|
+
*
|
|
356
|
+
* // User cancelled
|
|
357
|
+
* test: 'cancelled'
|
|
358
|
+
*
|
|
359
|
+
* // Pre-broadcast failure
|
|
360
|
+
* test: 'error:insufficient_balance'
|
|
361
|
+
*
|
|
362
|
+
* @since 0.1.1
|
|
256
363
|
* @schema
|
|
257
364
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
365
|
+
test?: boolean | PaymentTestScenario;
|
|
366
|
+
}>>;
|
|
367
|
+
/**
|
|
368
|
+
* Write text to the system clipboard.
|
|
369
|
+
* @since 0.1.1
|
|
370
|
+
* @schema
|
|
371
|
+
*/
|
|
372
|
+
'clipboard:write': CreateMethodPayload<{
|
|
265
373
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* include `test: true`. Use for development and testing.
|
|
269
|
-
* @since 0.0.14
|
|
374
|
+
* Text to copy to clipboard.
|
|
375
|
+
* @since 0.1.1
|
|
270
376
|
* @schema
|
|
271
377
|
*/
|
|
272
|
-
|
|
273
|
-
}
|
|
378
|
+
text: string;
|
|
379
|
+
}>;
|
|
380
|
+
/**
|
|
381
|
+
* Read text from the system clipboard.
|
|
382
|
+
* @since 0.1.1
|
|
383
|
+
* @schema
|
|
384
|
+
*/
|
|
385
|
+
'clipboard:read': CreateMethodPayload<WithReqId<Empty>>;
|
|
274
386
|
}
|
|
275
387
|
//#endregion
|
|
276
388
|
//#region src/methods/types/method-types.d.ts
|
|
@@ -320,4 +432,4 @@ declare function isMethodSupported(method: MethodName, version: Version): boolea
|
|
|
320
432
|
*/
|
|
321
433
|
declare function getMethodMinVersion(method: MethodName): Version | undefined;
|
|
322
434
|
//#endregion
|
|
323
|
-
export { type CreateEventPayload, type CreateMethodPayload, type EventName, type EventPayload, type Events, type LaunchParams, type MethodName, type MethodNameWithVersionedPayload, type MethodPayload, type MethodVersionedPayload, type Methods, PLATFORMS, type Platform, type Version, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|
|
435
|
+
export { type CreateEventPayload, type CreateMethodPayload, type EventName, type EventPayload, type Events, type LaunchParams, type MethodName, type MethodNameWithVersionedPayload, type MethodPayload, type MethodVersionedPayload, type Methods, PLATFORMS, type PaymentErrorCode, type PaymentTestScenario, type PaymentWebhookStatus, type Platform, type Version, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|
package/dist/index.d.mts
CHANGED
|
@@ -44,6 +44,49 @@ type If<Cond extends boolean, True, False> = Cond extends true ? True : False;
|
|
|
44
44
|
* // Empty = {}
|
|
45
45
|
*/
|
|
46
46
|
type Empty = Record<string, never>;
|
|
47
|
+
/**
|
|
48
|
+
* Client-side payment error codes (pre-broadcast failures).
|
|
49
|
+
* Returned when `status` is `'failed'` in `payment:response`.
|
|
50
|
+
* These errors occur before transaction broadcast, so no webhook is sent.
|
|
51
|
+
* @since 0.1.1
|
|
52
|
+
* @schema
|
|
53
|
+
*/
|
|
54
|
+
type PaymentErrorCode = 'insufficient_balance' | 'network_error' | 'pre_checkout_rejected' | 'pre_checkout_timeout' | 'unknown';
|
|
55
|
+
/**
|
|
56
|
+
* Webhook status for payment results (on-chain truth).
|
|
57
|
+
* - `'finalized'`: Transaction confirmed on-chain
|
|
58
|
+
* - `'failed'`: Transaction failed on-chain
|
|
59
|
+
* @since 0.1.2
|
|
60
|
+
* @schema
|
|
61
|
+
*/
|
|
62
|
+
type PaymentWebhookStatus = 'finalized' | 'failed';
|
|
63
|
+
/**
|
|
64
|
+
* Payment test scenarios for simulating different payment outcomes.
|
|
65
|
+
*
|
|
66
|
+
* | Scenario | Client sees | Webhook |
|
|
67
|
+
* |----------|-------------|---------|
|
|
68
|
+
* | `'paid'` | `paid` | `{ status: 'finalized' }` |
|
|
69
|
+
* | `'paid:failed'` | `paid` | `{ status: 'failed' }` |
|
|
70
|
+
* | `'cancelled'` | `cancelled` | none |
|
|
71
|
+
* | `'error:*'` | `failed` | none (pre-broadcast) |
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* // Happy path: client paid, tx finalized
|
|
75
|
+
* test: 'paid'
|
|
76
|
+
*
|
|
77
|
+
* // On-chain failure: client paid, tx failed
|
|
78
|
+
* test: 'paid:failed'
|
|
79
|
+
*
|
|
80
|
+
* // User cancelled before confirming
|
|
81
|
+
* test: 'cancelled'
|
|
82
|
+
*
|
|
83
|
+
* // Pre-broadcast error (no tx, no webhook)
|
|
84
|
+
* test: 'error:insufficient_balance'
|
|
85
|
+
*
|
|
86
|
+
* @since 0.1.2
|
|
87
|
+
* @schema
|
|
88
|
+
*/
|
|
89
|
+
type PaymentTestScenario = 'paid' | 'paid:failed' | 'cancelled' | `error:${PaymentErrorCode}`;
|
|
47
90
|
//#endregion
|
|
48
91
|
//#region src/events/types/payload.d.ts
|
|
49
92
|
/**
|
|
@@ -83,7 +126,7 @@ interface Events {
|
|
|
83
126
|
* For instant fulfillment, your backend should fulfill on webhook receipt
|
|
84
127
|
* using the `invoice` from the request.
|
|
85
128
|
*
|
|
86
|
-
* @since 0.
|
|
129
|
+
* @since 0.1.1
|
|
87
130
|
* @schema
|
|
88
131
|
*/
|
|
89
132
|
'payment:response': CreateEventPayload<WithReqId<{
|
|
@@ -91,14 +134,14 @@ interface Events {
|
|
|
91
134
|
* Payment status.
|
|
92
135
|
* - `paid`: Success
|
|
93
136
|
* - `cancelled`: User rejected
|
|
94
|
-
* - `
|
|
95
|
-
* @since 0.
|
|
137
|
+
* - `error`: Error (check `errorCode`)
|
|
138
|
+
* @since 0.1.1
|
|
96
139
|
* @schema
|
|
97
140
|
*/
|
|
98
|
-
status: 'paid' | 'cancelled' | '
|
|
141
|
+
status: 'paid' | 'cancelled' | 'error';
|
|
99
142
|
/**
|
|
100
143
|
* Transaction hash (present when status is 'paid').
|
|
101
|
-
* @since 0.
|
|
144
|
+
* @since 0.1.1
|
|
102
145
|
* @schema
|
|
103
146
|
*/
|
|
104
147
|
txHash?: string;
|
|
@@ -109,10 +152,35 @@ interface Events {
|
|
|
109
152
|
* - `pre_checkout_rejected`: Backend rejected the payment in pre-checkout
|
|
110
153
|
* - `pre_checkout_timeout`: Backend didn't respond to pre-checkout in time
|
|
111
154
|
* - `unknown`: Unexpected error
|
|
112
|
-
* @since 0.
|
|
155
|
+
* @since 0.1.1
|
|
156
|
+
* @schema
|
|
157
|
+
*/
|
|
158
|
+
errorCode?: PaymentErrorCode;
|
|
159
|
+
}>>;
|
|
160
|
+
/**
|
|
161
|
+
* Clipboard read response.
|
|
162
|
+
*
|
|
163
|
+
* On success: `text` contains the clipboard content (may be empty string).
|
|
164
|
+
* On failure: `text` is null and `errorCode` indicates the reason.
|
|
165
|
+
*
|
|
166
|
+
* @since 0.1.1
|
|
167
|
+
* @schema
|
|
168
|
+
*/
|
|
169
|
+
'clipboard:response': CreateEventPayload<WithReqId<{
|
|
170
|
+
/**
|
|
171
|
+
* Text from clipboard. Null if read failed.
|
|
172
|
+
* @since 0.1.1
|
|
113
173
|
* @schema
|
|
114
174
|
*/
|
|
115
|
-
|
|
175
|
+
text: string | null;
|
|
176
|
+
/**
|
|
177
|
+
* Error code if clipboard read failed.
|
|
178
|
+
* - `permission_denied`: User denied clipboard access
|
|
179
|
+
* - `unavailable`: Clipboard is not available
|
|
180
|
+
* @since 0.1.1
|
|
181
|
+
* @schema
|
|
182
|
+
*/
|
|
183
|
+
errorCode?: 'permission_denied' | 'unavailable';
|
|
116
184
|
}>>;
|
|
117
185
|
}
|
|
118
186
|
//#endregion
|
|
@@ -204,73 +272,117 @@ interface Methods {
|
|
|
204
272
|
* Set `test: true` for test mode - no real payment is made, but webhooks
|
|
205
273
|
* are fired with `test: true` flag. Use for development and testing.
|
|
206
274
|
*
|
|
207
|
-
* @since 0.
|
|
275
|
+
* @since 0.1.1
|
|
208
276
|
* @schema
|
|
209
277
|
*/
|
|
210
278
|
'payment:request': CreateMethodPayload<WithReqId<{
|
|
211
279
|
/**
|
|
212
280
|
* The recipient's wallet address.
|
|
213
|
-
* @since 0.
|
|
281
|
+
* @since 0.1.1
|
|
214
282
|
* @schema
|
|
215
283
|
*/
|
|
216
284
|
recipient: string;
|
|
217
285
|
/**
|
|
218
286
|
* The amount to pay (in token's smallest unit, as string for precision).
|
|
219
|
-
* @since 0.
|
|
287
|
+
* @since 0.1.1
|
|
220
288
|
* @schema
|
|
221
289
|
*/
|
|
222
290
|
amount: string;
|
|
223
291
|
/**
|
|
224
292
|
* The token identifier (e.g., 'SOL', 'ALIEN', or contract address).
|
|
225
|
-
* @since 0.
|
|
293
|
+
* @since 0.1.1
|
|
226
294
|
* @schema
|
|
227
295
|
*/
|
|
228
296
|
token: string;
|
|
229
297
|
/**
|
|
230
298
|
* The network for the payment ('solana' or 'alien').
|
|
231
|
-
* @since 0.
|
|
299
|
+
* @since 0.1.1
|
|
232
300
|
* @schema
|
|
233
301
|
*/
|
|
234
302
|
network: string;
|
|
235
303
|
/**
|
|
236
304
|
* Your order/invoice ID for backend correlation and instant fulfillment.
|
|
237
|
-
* @since 0.
|
|
305
|
+
* @since 0.1.1
|
|
238
306
|
* @schema
|
|
239
307
|
*/
|
|
240
308
|
invoice: string;
|
|
241
309
|
/**
|
|
242
|
-
*
|
|
243
|
-
* @since 0.
|
|
310
|
+
* Optional item details shown on the approval screen.
|
|
311
|
+
* @since 0.1.1
|
|
244
312
|
* @schema
|
|
245
313
|
*/
|
|
246
|
-
|
|
314
|
+
item?: {
|
|
315
|
+
/**
|
|
316
|
+
* Item title shown on the approval screen.
|
|
317
|
+
* @since 0.1.1
|
|
318
|
+
* @schema
|
|
319
|
+
*/
|
|
320
|
+
title: string;
|
|
321
|
+
/**
|
|
322
|
+
* Item icon URL shown on the approval screen.
|
|
323
|
+
* @since 0.1.1
|
|
324
|
+
* @schema
|
|
325
|
+
*/
|
|
326
|
+
iconUrl: string;
|
|
327
|
+
/**
|
|
328
|
+
* Quantity of items being purchased.
|
|
329
|
+
* @since 0.1.1
|
|
330
|
+
* @schema
|
|
331
|
+
*/
|
|
332
|
+
quantity: number;
|
|
333
|
+
};
|
|
247
334
|
/**
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
*
|
|
255
|
-
*
|
|
335
|
+
* Test mode. Simulates payment outcomes without real transactions.
|
|
336
|
+
*
|
|
337
|
+
* | Scenario | Client | Webhook |
|
|
338
|
+
* |----------|--------|---------|
|
|
339
|
+
* | `true` / `'paid'` | `paid` | `finalized` |
|
|
340
|
+
* | `'paid:failed'` | `paid` | `failed` |
|
|
341
|
+
* | `'cancelled'` | `cancelled` | none |
|
|
342
|
+
* | `'error:*'` | `failed` | none |
|
|
343
|
+
*
|
|
344
|
+
* **Pre-broadcast errors** (no webhook):
|
|
345
|
+
* `'error:insufficient_balance'`, `'error:network_error'`,
|
|
346
|
+
* `'error:pre_checkout_rejected'`, `'error:pre_checkout_timeout'`,
|
|
347
|
+
* `'error:unknown'`
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* // Happy path
|
|
351
|
+
* test: 'paid'
|
|
352
|
+
*
|
|
353
|
+
* // Client shows success, but tx failed on-chain
|
|
354
|
+
* test: 'paid:failed'
|
|
355
|
+
*
|
|
356
|
+
* // User cancelled
|
|
357
|
+
* test: 'cancelled'
|
|
358
|
+
*
|
|
359
|
+
* // Pre-broadcast failure
|
|
360
|
+
* test: 'error:insufficient_balance'
|
|
361
|
+
*
|
|
362
|
+
* @since 0.1.1
|
|
256
363
|
* @schema
|
|
257
364
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
365
|
+
test?: boolean | PaymentTestScenario;
|
|
366
|
+
}>>;
|
|
367
|
+
/**
|
|
368
|
+
* Write text to the system clipboard.
|
|
369
|
+
* @since 0.1.1
|
|
370
|
+
* @schema
|
|
371
|
+
*/
|
|
372
|
+
'clipboard:write': CreateMethodPayload<{
|
|
265
373
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
* include `test: true`. Use for development and testing.
|
|
269
|
-
* @since 0.0.14
|
|
374
|
+
* Text to copy to clipboard.
|
|
375
|
+
* @since 0.1.1
|
|
270
376
|
* @schema
|
|
271
377
|
*/
|
|
272
|
-
|
|
273
|
-
}
|
|
378
|
+
text: string;
|
|
379
|
+
}>;
|
|
380
|
+
/**
|
|
381
|
+
* Read text from the system clipboard.
|
|
382
|
+
* @since 0.1.1
|
|
383
|
+
* @schema
|
|
384
|
+
*/
|
|
385
|
+
'clipboard:read': CreateMethodPayload<WithReqId<Empty>>;
|
|
274
386
|
}
|
|
275
387
|
//#endregion
|
|
276
388
|
//#region src/methods/types/method-types.d.ts
|
|
@@ -320,4 +432,4 @@ declare function isMethodSupported(method: MethodName, version: Version): boolea
|
|
|
320
432
|
*/
|
|
321
433
|
declare function getMethodMinVersion(method: MethodName): Version | undefined;
|
|
322
434
|
//#endregion
|
|
323
|
-
export { type CreateEventPayload, type CreateMethodPayload, type EventName, type EventPayload, type Events, type LaunchParams, type MethodName, type MethodNameWithVersionedPayload, type MethodPayload, type MethodVersionedPayload, type Methods, PLATFORMS, type Platform, type Version, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|
|
435
|
+
export { type CreateEventPayload, type CreateMethodPayload, type EventName, type EventPayload, type Events, type LaunchParams, type MethodName, type MethodNameWithVersionedPayload, type MethodPayload, type MethodVersionedPayload, type Methods, PLATFORMS, type PaymentErrorCode, type PaymentTestScenario, type PaymentWebhookStatus, type Platform, type Version, getMethodMinVersion, getReleaseVersion, isMethodSupported, releases };
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,12 @@ const PLATFORMS = ["ios", "android"];
|
|
|
8
8
|
//#region src/methods/versions/releases.ts
|
|
9
9
|
const releases = {
|
|
10
10
|
"0.0.9": ["app:ready"],
|
|
11
|
-
"0.0.14": ["miniapp:close.ack", "host.back.button:toggle"]
|
|
11
|
+
"0.0.14": ["miniapp:close.ack", "host.back.button:toggle"],
|
|
12
|
+
"0.1.1": [
|
|
13
|
+
"payment:request",
|
|
14
|
+
"clipboard:write",
|
|
15
|
+
"clipboard:read"
|
|
16
|
+
]
|
|
12
17
|
};
|
|
13
18
|
|
|
14
19
|
//#endregion
|