@xpayeg/sdk 2.4.0 → 3.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/.types/index.d.cts +1654 -0
- package/.types/index.d.mts +1654 -0
- package/CHANGELOG.md +38 -29
- package/README.md +155 -131
- package/dist/index.cjs +0 -2
- package/dist/index.mjs +0 -2
- package/package.json +10 -23
- package/dist/index.d.cts +0 -4108
- package/dist/index.d.mts +0 -4108
|
@@ -0,0 +1,1654 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by orval 🍺
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
* XPay Checkout API
|
|
5
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
6
|
+
* OpenAPI spec version: 1.0
|
|
7
|
+
*/
|
|
8
|
+
interface AdjustableQuantityDto {
|
|
9
|
+
/** Whether adjustable quantity is enabled */
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Minimum quantity allowed
|
|
13
|
+
* @nullable
|
|
14
|
+
*/
|
|
15
|
+
minimum?: number | null;
|
|
16
|
+
/**
|
|
17
|
+
* Maximum quantity allowed
|
|
18
|
+
* @nullable
|
|
19
|
+
*/
|
|
20
|
+
maximum?: number | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Generated by orval 🍺
|
|
24
|
+
* Do not edit manually.
|
|
25
|
+
* XPay Checkout API
|
|
26
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
27
|
+
* OpenAPI spec version: 1.0
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Border style for inputs, buttons, cards
|
|
31
|
+
* @nullable
|
|
32
|
+
*/
|
|
33
|
+
type BrandingSettingsResponseDtoBorderStyle = (typeof BrandingSettingsResponseDtoBorderStyle)[keyof typeof BrandingSettingsResponseDtoBorderStyle] | null;
|
|
34
|
+
declare const BrandingSettingsResponseDtoBorderStyle: {
|
|
35
|
+
readonly rounded: "rounded";
|
|
36
|
+
readonly sharp: "sharp";
|
|
37
|
+
readonly pill: "pill";
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Generated by orval 🍺
|
|
41
|
+
* Do not edit manually.
|
|
42
|
+
* XPay Checkout API
|
|
43
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
44
|
+
* OpenAPI spec version: 1.0
|
|
45
|
+
*/
|
|
46
|
+
/**
|
|
47
|
+
* Dark mode preference
|
|
48
|
+
* @nullable
|
|
49
|
+
*/
|
|
50
|
+
type BrandingSettingsResponseDtoColorMode = (typeof BrandingSettingsResponseDtoColorMode)[keyof typeof BrandingSettingsResponseDtoColorMode] | null;
|
|
51
|
+
declare const BrandingSettingsResponseDtoColorMode: {
|
|
52
|
+
readonly light: "light";
|
|
53
|
+
readonly dark: "dark";
|
|
54
|
+
readonly system: "system";
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Generated by orval 🍺
|
|
58
|
+
* Do not edit manually.
|
|
59
|
+
* XPay Checkout API
|
|
60
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
61
|
+
* OpenAPI spec version: 1.0
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* Form layout density
|
|
65
|
+
* @nullable
|
|
66
|
+
*/
|
|
67
|
+
type BrandingSettingsResponseDtoFormLayout = (typeof BrandingSettingsResponseDtoFormLayout)[keyof typeof BrandingSettingsResponseDtoFormLayout] | null;
|
|
68
|
+
declare const BrandingSettingsResponseDtoFormLayout: {
|
|
69
|
+
readonly compact: "compact";
|
|
70
|
+
readonly spacious: "spacious";
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Generated by orval 🍺
|
|
74
|
+
* Do not edit manually.
|
|
75
|
+
* XPay Checkout API
|
|
76
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
77
|
+
* OpenAPI spec version: 1.0
|
|
78
|
+
*/
|
|
79
|
+
/**
|
|
80
|
+
* Input field size
|
|
81
|
+
* @nullable
|
|
82
|
+
*/
|
|
83
|
+
type BrandingSettingsResponseDtoInputSize = (typeof BrandingSettingsResponseDtoInputSize)[keyof typeof BrandingSettingsResponseDtoInputSize] | null;
|
|
84
|
+
declare const BrandingSettingsResponseDtoInputSize: {
|
|
85
|
+
readonly small: "small";
|
|
86
|
+
readonly medium: "medium";
|
|
87
|
+
readonly large: "large";
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Generated by orval 🍺
|
|
91
|
+
* Do not edit manually.
|
|
92
|
+
* XPay Checkout API
|
|
93
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
94
|
+
* OpenAPI spec version: 1.0
|
|
95
|
+
*/
|
|
96
|
+
/**
|
|
97
|
+
* Input field style
|
|
98
|
+
* @nullable
|
|
99
|
+
*/
|
|
100
|
+
type BrandingSettingsResponseDtoInputStyle = (typeof BrandingSettingsResponseDtoInputStyle)[keyof typeof BrandingSettingsResponseDtoInputStyle] | null;
|
|
101
|
+
declare const BrandingSettingsResponseDtoInputStyle: {
|
|
102
|
+
readonly flat: "flat";
|
|
103
|
+
readonly outlined: "outlined";
|
|
104
|
+
readonly filled: "filled";
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Generated by orval 🍺
|
|
108
|
+
* Do not edit manually.
|
|
109
|
+
* XPay Checkout API
|
|
110
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
111
|
+
* OpenAPI spec version: 1.0
|
|
112
|
+
*/
|
|
113
|
+
/**
|
|
114
|
+
* Spacing density
|
|
115
|
+
* @nullable
|
|
116
|
+
*/
|
|
117
|
+
type BrandingSettingsResponseDtoSpacing = (typeof BrandingSettingsResponseDtoSpacing)[keyof typeof BrandingSettingsResponseDtoSpacing] | null;
|
|
118
|
+
declare const BrandingSettingsResponseDtoSpacing: {
|
|
119
|
+
readonly condensed: "condensed";
|
|
120
|
+
readonly normal: "normal";
|
|
121
|
+
readonly spacious: "spacious";
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Generated by orval 🍺
|
|
125
|
+
* Do not edit manually.
|
|
126
|
+
* XPay Checkout API
|
|
127
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
128
|
+
* OpenAPI spec version: 1.0
|
|
129
|
+
*/
|
|
130
|
+
interface ColorCustomizationResponseDto {
|
|
131
|
+
/**
|
|
132
|
+
* Primary brand color (buttons, links, accents). Hex only.
|
|
133
|
+
* @nullable
|
|
134
|
+
*/
|
|
135
|
+
primary?: string | null;
|
|
136
|
+
/**
|
|
137
|
+
* Primary foreground (text on primary background). Hex only.
|
|
138
|
+
* @nullable
|
|
139
|
+
*/
|
|
140
|
+
primaryForeground?: string | null;
|
|
141
|
+
/**
|
|
142
|
+
* Page background color. Hex only.
|
|
143
|
+
* @nullable
|
|
144
|
+
*/
|
|
145
|
+
background?: string | null;
|
|
146
|
+
/**
|
|
147
|
+
* Main text color. Hex only.
|
|
148
|
+
* @nullable
|
|
149
|
+
*/
|
|
150
|
+
foreground?: string | null;
|
|
151
|
+
/**
|
|
152
|
+
* Border color. Hex only.
|
|
153
|
+
* @nullable
|
|
154
|
+
*/
|
|
155
|
+
border?: string | null;
|
|
156
|
+
/**
|
|
157
|
+
* Input, button, and dropdown border color. Hex only.
|
|
158
|
+
* @nullable
|
|
159
|
+
*/
|
|
160
|
+
input?: string | null;
|
|
161
|
+
/**
|
|
162
|
+
* Focus ring color. Hex only.
|
|
163
|
+
* @nullable
|
|
164
|
+
*/
|
|
165
|
+
ring?: string | null;
|
|
166
|
+
/**
|
|
167
|
+
* Muted/secondary background. Hex only.
|
|
168
|
+
* @nullable
|
|
169
|
+
*/
|
|
170
|
+
muted?: string | null;
|
|
171
|
+
/**
|
|
172
|
+
* Muted text color. Hex only.
|
|
173
|
+
* @nullable
|
|
174
|
+
*/
|
|
175
|
+
mutedForeground?: string | null;
|
|
176
|
+
/**
|
|
177
|
+
* Accent background. Hex only.
|
|
178
|
+
* @nullable
|
|
179
|
+
*/
|
|
180
|
+
accent?: string | null;
|
|
181
|
+
/**
|
|
182
|
+
* Accent text color. Hex only.
|
|
183
|
+
* @nullable
|
|
184
|
+
*/
|
|
185
|
+
accentForeground?: string | null;
|
|
186
|
+
/**
|
|
187
|
+
* Destructive/error color. Hex only.
|
|
188
|
+
* @nullable
|
|
189
|
+
*/
|
|
190
|
+
destructive?: string | null;
|
|
191
|
+
}
|
|
192
|
+
interface BrandingSettingsResponseDto {
|
|
193
|
+
/**
|
|
194
|
+
* Dark mode preference
|
|
195
|
+
* @nullable
|
|
196
|
+
*/
|
|
197
|
+
colorMode?: BrandingSettingsResponseDtoColorMode;
|
|
198
|
+
/**
|
|
199
|
+
* Border style for inputs, buttons, cards
|
|
200
|
+
* @nullable
|
|
201
|
+
*/
|
|
202
|
+
borderStyle?: BrandingSettingsResponseDtoBorderStyle;
|
|
203
|
+
/**
|
|
204
|
+
* Spacing density
|
|
205
|
+
* @nullable
|
|
206
|
+
*/
|
|
207
|
+
spacing?: BrandingSettingsResponseDtoSpacing;
|
|
208
|
+
/**
|
|
209
|
+
* Input field size
|
|
210
|
+
* @nullable
|
|
211
|
+
*/
|
|
212
|
+
inputSize?: BrandingSettingsResponseDtoInputSize;
|
|
213
|
+
/**
|
|
214
|
+
* Input field style
|
|
215
|
+
* @nullable
|
|
216
|
+
*/
|
|
217
|
+
inputStyle?: BrandingSettingsResponseDtoInputStyle;
|
|
218
|
+
/**
|
|
219
|
+
* Form layout density
|
|
220
|
+
* @nullable
|
|
221
|
+
*/
|
|
222
|
+
formLayout?: BrandingSettingsResponseDtoFormLayout;
|
|
223
|
+
/** Color customization options */
|
|
224
|
+
colors?: ColorCustomizationResponseDto | null;
|
|
225
|
+
/**
|
|
226
|
+
* Font family override
|
|
227
|
+
* @nullable
|
|
228
|
+
*/
|
|
229
|
+
fontFamily?: string | null;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Generated by orval 🍺
|
|
233
|
+
* Do not edit manually.
|
|
234
|
+
* XPay Checkout API
|
|
235
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
236
|
+
* OpenAPI spec version: 1.0
|
|
237
|
+
*/
|
|
238
|
+
interface CardInfoResponseDto {
|
|
239
|
+
brand: string;
|
|
240
|
+
isOnUs: boolean;
|
|
241
|
+
isInternational: boolean;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Generated by orval 🍺
|
|
245
|
+
* Do not edit manually.
|
|
246
|
+
* XPay Checkout API
|
|
247
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
248
|
+
* OpenAPI spec version: 1.0
|
|
249
|
+
*/
|
|
250
|
+
/**
|
|
251
|
+
* @nullable
|
|
252
|
+
*/
|
|
253
|
+
type CatalogRecurringDtoInterval = (typeof CatalogRecurringDtoInterval)[keyof typeof CatalogRecurringDtoInterval] | null;
|
|
254
|
+
declare const CatalogRecurringDtoInterval: {
|
|
255
|
+
readonly DAY: "DAY";
|
|
256
|
+
readonly WEEK: "WEEK";
|
|
257
|
+
readonly MONTH: "MONTH";
|
|
258
|
+
readonly YEAR: "YEAR";
|
|
259
|
+
readonly CUSTOM: "CUSTOM";
|
|
260
|
+
};
|
|
261
|
+
interface CatalogRecurringDto {
|
|
262
|
+
/** @nullable */
|
|
263
|
+
interval?: CatalogRecurringDtoInterval;
|
|
264
|
+
/** @nullable */
|
|
265
|
+
intervalCount?: number | null;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Generated by orval 🍺
|
|
269
|
+
* Do not edit manually.
|
|
270
|
+
* XPay Checkout API
|
|
271
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
272
|
+
* OpenAPI spec version: 1.0
|
|
273
|
+
*/
|
|
274
|
+
type CouponResponseDtoCurrency = (typeof CouponResponseDtoCurrency)[keyof typeof CouponResponseDtoCurrency];
|
|
275
|
+
declare const CouponResponseDtoCurrency: {
|
|
276
|
+
readonly EGP: "EGP";
|
|
277
|
+
readonly USD: "USD";
|
|
278
|
+
readonly EUR: "EUR";
|
|
279
|
+
readonly GBP: "GBP";
|
|
280
|
+
readonly SAR: "SAR";
|
|
281
|
+
readonly AED: "AED";
|
|
282
|
+
readonly QAR: "QAR";
|
|
283
|
+
readonly KWD: "KWD";
|
|
284
|
+
readonly JOD: "JOD";
|
|
285
|
+
readonly OMR: "OMR";
|
|
286
|
+
readonly BHD: "BHD";
|
|
287
|
+
readonly LYD: "LYD";
|
|
288
|
+
readonly AUD: "AUD";
|
|
289
|
+
readonly CAD: "CAD";
|
|
290
|
+
readonly CNY: "CNY";
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* Generated by orval 🍺
|
|
294
|
+
* Do not edit manually.
|
|
295
|
+
* XPay Checkout API
|
|
296
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
297
|
+
* OpenAPI spec version: 1.0
|
|
298
|
+
*/
|
|
299
|
+
/**
|
|
300
|
+
* Discount type
|
|
301
|
+
*/
|
|
302
|
+
type CouponResponseDtoDiscountType = (typeof CouponResponseDtoDiscountType)[keyof typeof CouponResponseDtoDiscountType];
|
|
303
|
+
declare const CouponResponseDtoDiscountType: {
|
|
304
|
+
readonly percentage: "percentage";
|
|
305
|
+
readonly fixed_amount: "fixed_amount";
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* Generated by orval 🍺
|
|
309
|
+
* Do not edit manually.
|
|
310
|
+
* XPay Checkout API
|
|
311
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
312
|
+
* OpenAPI spec version: 1.0
|
|
313
|
+
*/
|
|
314
|
+
/**
|
|
315
|
+
* Duration
|
|
316
|
+
*/
|
|
317
|
+
type CouponResponseDtoDuration = (typeof CouponResponseDtoDuration)[keyof typeof CouponResponseDtoDuration];
|
|
318
|
+
declare const CouponResponseDtoDuration: {
|
|
319
|
+
readonly once: "once";
|
|
320
|
+
readonly repeating: "repeating";
|
|
321
|
+
readonly forever: "forever";
|
|
322
|
+
};
|
|
323
|
+
/**
|
|
324
|
+
* Generated by orval 🍺
|
|
325
|
+
* Do not edit manually.
|
|
326
|
+
* XPay Checkout API
|
|
327
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
328
|
+
* OpenAPI spec version: 1.0
|
|
329
|
+
*/
|
|
330
|
+
/**
|
|
331
|
+
* Custom metadata
|
|
332
|
+
*/
|
|
333
|
+
type CouponResponseDtoMetadata = {
|
|
334
|
+
[key: string]: unknown;
|
|
335
|
+
};
|
|
336
|
+
/**
|
|
337
|
+
* Generated by orval 🍺
|
|
338
|
+
* Do not edit manually.
|
|
339
|
+
* XPay Checkout API
|
|
340
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
341
|
+
* OpenAPI spec version: 1.0
|
|
342
|
+
*/
|
|
343
|
+
/**
|
|
344
|
+
* Object type
|
|
345
|
+
*/
|
|
346
|
+
type CouponResponseDtoObject = (typeof CouponResponseDtoObject)[keyof typeof CouponResponseDtoObject];
|
|
347
|
+
declare const CouponResponseDtoObject: {
|
|
348
|
+
readonly coupon: "coupon";
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* A Coupon defines a reusable discount you can apply to Checkout Sessions and PaymentIntents. Coupons can grant either a percentage off (`percentOff`) or a fixed amount off (`amountOff`), and can apply once, forever, or repeating for a number of billing cycles. You can also cap how many times a Coupon may be redeemed and when it expires.
|
|
352
|
+
*
|
|
353
|
+
* Coupons are the reusable template. Each concrete application of a Coupon to a customer's purchase is recorded as a Discount. To give customers a redeemable code (e.g. `SUMMER25`) instead of applying the Coupon directly, create one or more Promotion Codes that map to this Coupon — a single Coupon can have many Promotion Codes, each with its own per-code restrictions. You receive `coupon.*` and `promotion_code.*` webhook events for each as they are created or changed.
|
|
354
|
+
*/
|
|
355
|
+
interface CouponResponseDto {
|
|
356
|
+
/** Coupon ID */
|
|
357
|
+
id: string;
|
|
358
|
+
/** Object type */
|
|
359
|
+
object: CouponResponseDtoObject;
|
|
360
|
+
/** Created timestamp (ISO 8601) */
|
|
361
|
+
createdAt: string;
|
|
362
|
+
/** Discount type */
|
|
363
|
+
discountType: CouponResponseDtoDiscountType;
|
|
364
|
+
/** Percentage off (0.01-100) */
|
|
365
|
+
percentOff?: number;
|
|
366
|
+
/** Fixed amount off in smallest currency unit */
|
|
367
|
+
amountOff?: number;
|
|
368
|
+
currency?: CouponResponseDtoCurrency;
|
|
369
|
+
/** Duration */
|
|
370
|
+
duration: CouponResponseDtoDuration;
|
|
371
|
+
/** Number of months for repeating duration */
|
|
372
|
+
durationInMonths?: number;
|
|
373
|
+
/** Display name */
|
|
374
|
+
name?: string;
|
|
375
|
+
/** Maximum discount amount for percentage coupons (caps the discount) */
|
|
376
|
+
maxDiscountAmount?: number;
|
|
377
|
+
/** Minimum order subtotal required to use this coupon */
|
|
378
|
+
minValue?: number;
|
|
379
|
+
/** Maximum total redemptions */
|
|
380
|
+
maxRedemptions?: number;
|
|
381
|
+
/** Maximum times a single customer can redeem */
|
|
382
|
+
customerMaxRedemptions?: number;
|
|
383
|
+
/** Number of times redeemed */
|
|
384
|
+
timesRedeemed: number;
|
|
385
|
+
/** Redemption deadline (ISO 8601) */
|
|
386
|
+
redeemBy?: string;
|
|
387
|
+
/** Whether the coupon is currently valid (computed) */
|
|
388
|
+
valid: boolean;
|
|
389
|
+
/** Whether the coupon is active */
|
|
390
|
+
active: boolean;
|
|
391
|
+
/** Product IDs this coupon applies to */
|
|
392
|
+
appliesToProductIds?: string[];
|
|
393
|
+
/** Custom metadata */
|
|
394
|
+
metadata?: CouponResponseDtoMetadata;
|
|
395
|
+
/** Merchant ID */
|
|
396
|
+
merchantId: string;
|
|
397
|
+
/** Whether this is live mode */
|
|
398
|
+
livemode: boolean;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Generated by orval 🍺
|
|
402
|
+
* Do not edit manually.
|
|
403
|
+
* XPay Checkout API
|
|
404
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
405
|
+
* OpenAPI spec version: 1.0
|
|
406
|
+
*/
|
|
407
|
+
/**
|
|
408
|
+
* Object type
|
|
409
|
+
*/
|
|
410
|
+
type DiscountResponseDtoObject = (typeof DiscountResponseDtoObject)[keyof typeof DiscountResponseDtoObject];
|
|
411
|
+
declare const DiscountResponseDtoObject: {
|
|
412
|
+
readonly discount: "discount";
|
|
413
|
+
};
|
|
414
|
+
/**
|
|
415
|
+
* A Discount records a single application of a Coupon to a specific Checkout Session, PaymentIntent, or Customer. Where a Coupon is the reusable template, a Discount captures the concrete redemption: which Coupon was applied, when it became active, when it expires, and (when applicable) which Promotion Code the customer entered to claim it.
|
|
416
|
+
*/
|
|
417
|
+
interface DiscountResponseDto {
|
|
418
|
+
/** Discount ID */
|
|
419
|
+
id: string;
|
|
420
|
+
/** Object type */
|
|
421
|
+
object: DiscountResponseDtoObject;
|
|
422
|
+
/** The coupon that was applied */
|
|
423
|
+
coupon: CouponResponseDto;
|
|
424
|
+
/** Promotion code ID used (null if direct coupon application) */
|
|
425
|
+
promotionCodeId?: string;
|
|
426
|
+
/** Customer-facing promotion code string (e.g. SUMMER25) */
|
|
427
|
+
promotionCodeCode?: string;
|
|
428
|
+
/** Checkout session this discount was applied to */
|
|
429
|
+
checkoutSessionId: string;
|
|
430
|
+
/** Customer who received the discount */
|
|
431
|
+
customerId?: string;
|
|
432
|
+
/** When the discount became active (ISO 8601) */
|
|
433
|
+
start: string;
|
|
434
|
+
/** When the discount ends (ISO 8601) */
|
|
435
|
+
end?: string;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Generated by orval 🍺
|
|
439
|
+
* Do not edit manually.
|
|
440
|
+
* XPay Checkout API
|
|
441
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
442
|
+
* OpenAPI spec version: 1.0
|
|
443
|
+
*/
|
|
444
|
+
type PendingCouponResponseDtoObject = (typeof PendingCouponResponseDtoObject)[keyof typeof PendingCouponResponseDtoObject];
|
|
445
|
+
declare const PendingCouponResponseDtoObject: {
|
|
446
|
+
readonly coupon: "coupon";
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* The Coupon selected for a Checkout Session before payment completes. It contains the discount terms used to calculate the session total; the Coupon has not yet been redeemed.
|
|
450
|
+
*/
|
|
451
|
+
interface PendingCouponResponseDto {
|
|
452
|
+
id: string;
|
|
453
|
+
object: PendingCouponResponseDtoObject;
|
|
454
|
+
/** @nullable */
|
|
455
|
+
name?: string | null;
|
|
456
|
+
discountType: string;
|
|
457
|
+
/** @nullable */
|
|
458
|
+
percentOff?: number | null;
|
|
459
|
+
/** @nullable */
|
|
460
|
+
amountOff?: string | null;
|
|
461
|
+
/** @nullable */
|
|
462
|
+
currency?: string | null;
|
|
463
|
+
valid: true;
|
|
464
|
+
livemode: boolean;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Generated by orval 🍺
|
|
468
|
+
* Do not edit manually.
|
|
469
|
+
* XPay Checkout API
|
|
470
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
471
|
+
* OpenAPI spec version: 1.0
|
|
472
|
+
*/
|
|
473
|
+
type PendingDiscountResponseDtoId = (typeof PendingDiscountResponseDtoId)[keyof typeof PendingDiscountResponseDtoId];
|
|
474
|
+
declare const PendingDiscountResponseDtoId: {
|
|
475
|
+
readonly pending: "pending";
|
|
476
|
+
};
|
|
477
|
+
/**
|
|
478
|
+
* Generated by orval 🍺
|
|
479
|
+
* Do not edit manually.
|
|
480
|
+
* XPay Checkout API
|
|
481
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
482
|
+
* OpenAPI spec version: 1.0
|
|
483
|
+
*/
|
|
484
|
+
/**
|
|
485
|
+
* Object type
|
|
486
|
+
*/
|
|
487
|
+
type PendingDiscountResponseDtoObject = (typeof PendingDiscountResponseDtoObject)[keyof typeof PendingDiscountResponseDtoObject];
|
|
488
|
+
declare const PendingDiscountResponseDtoObject: {
|
|
489
|
+
readonly discount: "discount";
|
|
490
|
+
};
|
|
491
|
+
/**
|
|
492
|
+
* A Discount selected for a Checkout Session before payment completes. Its ID is pending until the discount is redeemed, and it includes the selected Coupon and any Promotion Code used.
|
|
493
|
+
*/
|
|
494
|
+
interface PendingDiscountResponseDto {
|
|
495
|
+
id: PendingDiscountResponseDtoId;
|
|
496
|
+
/** Object type */
|
|
497
|
+
object: PendingDiscountResponseDtoObject;
|
|
498
|
+
coupon: PendingCouponResponseDto;
|
|
499
|
+
/** @nullable */
|
|
500
|
+
promotionCodeId?: string | null;
|
|
501
|
+
/** @nullable */
|
|
502
|
+
promotionCodeCode?: string | null;
|
|
503
|
+
/** Checkout session this discount was applied to */
|
|
504
|
+
checkoutSessionId: string;
|
|
505
|
+
/** Customer who received the discount */
|
|
506
|
+
customerId?: string;
|
|
507
|
+
/** When the discount became active (ISO 8601) */
|
|
508
|
+
start: string;
|
|
509
|
+
/** When the discount ends (ISO 8601) */
|
|
510
|
+
end?: string;
|
|
511
|
+
}
|
|
512
|
+
type CheckoutDiscountResponseDto = DiscountResponseDto | PendingDiscountResponseDto;
|
|
513
|
+
/**
|
|
514
|
+
* Generated by orval 🍺
|
|
515
|
+
* Do not edit manually.
|
|
516
|
+
* XPay Checkout API
|
|
517
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
518
|
+
* OpenAPI spec version: 1.0
|
|
519
|
+
*/
|
|
520
|
+
/**
|
|
521
|
+
* Currency of this line's amount fields
|
|
522
|
+
* @nullable
|
|
523
|
+
*/
|
|
524
|
+
type CheckoutLineItemDtoCurrency = (typeof CheckoutLineItemDtoCurrency)[keyof typeof CheckoutLineItemDtoCurrency] | null;
|
|
525
|
+
declare const CheckoutLineItemDtoCurrency: {
|
|
526
|
+
readonly EGP: "EGP";
|
|
527
|
+
readonly USD: "USD";
|
|
528
|
+
readonly EUR: "EUR";
|
|
529
|
+
readonly GBP: "GBP";
|
|
530
|
+
readonly SAR: "SAR";
|
|
531
|
+
readonly AED: "AED";
|
|
532
|
+
readonly QAR: "QAR";
|
|
533
|
+
readonly KWD: "KWD";
|
|
534
|
+
readonly JOD: "JOD";
|
|
535
|
+
readonly OMR: "OMR";
|
|
536
|
+
readonly BHD: "BHD";
|
|
537
|
+
readonly LYD: "LYD";
|
|
538
|
+
readonly AUD: "AUD";
|
|
539
|
+
readonly CAD: "CAD";
|
|
540
|
+
readonly CNY: "CNY";
|
|
541
|
+
};
|
|
542
|
+
/**
|
|
543
|
+
* Generated by orval 🍺
|
|
544
|
+
* Do not edit manually.
|
|
545
|
+
* XPay Checkout API
|
|
546
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
547
|
+
* OpenAPI spec version: 1.0
|
|
548
|
+
*/
|
|
549
|
+
/**
|
|
550
|
+
* Presentment currency matching the session
|
|
551
|
+
*/
|
|
552
|
+
type LineItemPresentmentDetailsDtoCurrency = (typeof LineItemPresentmentDetailsDtoCurrency)[keyof typeof LineItemPresentmentDetailsDtoCurrency];
|
|
553
|
+
declare const LineItemPresentmentDetailsDtoCurrency: {
|
|
554
|
+
readonly EGP: "EGP";
|
|
555
|
+
readonly USD: "USD";
|
|
556
|
+
readonly EUR: "EUR";
|
|
557
|
+
readonly GBP: "GBP";
|
|
558
|
+
readonly SAR: "SAR";
|
|
559
|
+
readonly AED: "AED";
|
|
560
|
+
readonly QAR: "QAR";
|
|
561
|
+
readonly KWD: "KWD";
|
|
562
|
+
readonly JOD: "JOD";
|
|
563
|
+
readonly OMR: "OMR";
|
|
564
|
+
readonly BHD: "BHD";
|
|
565
|
+
readonly LYD: "LYD";
|
|
566
|
+
readonly AUD: "AUD";
|
|
567
|
+
readonly CAD: "CAD";
|
|
568
|
+
readonly CNY: "CNY";
|
|
569
|
+
};
|
|
570
|
+
interface LineItemPresentmentDetailsDto {
|
|
571
|
+
/** Unit amount in presentment smallest units */
|
|
572
|
+
unitAmount: number;
|
|
573
|
+
/** Line subtotal in presentment smallest units */
|
|
574
|
+
amountSubtotal: number;
|
|
575
|
+
/** Allocated line discount in presentment smallest units */
|
|
576
|
+
amountDiscount: number;
|
|
577
|
+
/** Line total after discount and tax, in presentment smallest units */
|
|
578
|
+
amountTotal: number;
|
|
579
|
+
/** Presentment currency matching the session */
|
|
580
|
+
currency: LineItemPresentmentDetailsDtoCurrency;
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Generated by orval 🍺
|
|
584
|
+
* Do not edit manually.
|
|
585
|
+
* XPay Checkout API
|
|
586
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
587
|
+
* OpenAPI spec version: 1.0
|
|
588
|
+
*/
|
|
589
|
+
type PriceAvailability = (typeof PriceAvailability)[keyof typeof PriceAvailability];
|
|
590
|
+
declare const PriceAvailability: {
|
|
591
|
+
readonly available: "available";
|
|
592
|
+
readonly archived: "archived";
|
|
593
|
+
readonly scheduled: "scheduled";
|
|
594
|
+
readonly expired: "expired";
|
|
595
|
+
readonly sold_out: "sold_out";
|
|
596
|
+
readonly oversold: "oversold";
|
|
597
|
+
readonly recurring_unsupported: "recurring_unsupported";
|
|
598
|
+
};
|
|
599
|
+
/**
|
|
600
|
+
* Generated by orval 🍺
|
|
601
|
+
* Do not edit manually.
|
|
602
|
+
* XPay Checkout API
|
|
603
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
604
|
+
* OpenAPI spec version: 1.0
|
|
605
|
+
*/
|
|
606
|
+
interface CustomUnitAmountResponseDto {
|
|
607
|
+
/**
|
|
608
|
+
* Minimum amount the customer may enter (minor units).
|
|
609
|
+
* @nullable
|
|
610
|
+
*/
|
|
611
|
+
minimum?: number | null;
|
|
612
|
+
/**
|
|
613
|
+
* Maximum amount the customer may enter (minor units).
|
|
614
|
+
* @nullable
|
|
615
|
+
*/
|
|
616
|
+
maximum?: number | null;
|
|
617
|
+
/**
|
|
618
|
+
* Suggested amount pre-filled for the customer (minor units).
|
|
619
|
+
* @nullable
|
|
620
|
+
*/
|
|
621
|
+
preset?: number | null;
|
|
622
|
+
}
|
|
623
|
+
type CustomUnitAmountDto = CustomUnitAmountResponseDto;
|
|
624
|
+
/**
|
|
625
|
+
* Generated by orval 🍺
|
|
626
|
+
* Do not edit manually.
|
|
627
|
+
* XPay Checkout API
|
|
628
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
629
|
+
* OpenAPI spec version: 1.0
|
|
630
|
+
*/
|
|
631
|
+
/**
|
|
632
|
+
* Price currency
|
|
633
|
+
*/
|
|
634
|
+
type PriceDtoCurrency = (typeof PriceDtoCurrency)[keyof typeof PriceDtoCurrency];
|
|
635
|
+
declare const PriceDtoCurrency: {
|
|
636
|
+
readonly EGP: "EGP";
|
|
637
|
+
readonly USD: "USD";
|
|
638
|
+
readonly EUR: "EUR";
|
|
639
|
+
readonly GBP: "GBP";
|
|
640
|
+
readonly SAR: "SAR";
|
|
641
|
+
readonly AED: "AED";
|
|
642
|
+
readonly QAR: "QAR";
|
|
643
|
+
readonly KWD: "KWD";
|
|
644
|
+
readonly JOD: "JOD";
|
|
645
|
+
readonly OMR: "OMR";
|
|
646
|
+
readonly BHD: "BHD";
|
|
647
|
+
readonly LYD: "LYD";
|
|
648
|
+
readonly AUD: "AUD";
|
|
649
|
+
readonly CAD: "CAD";
|
|
650
|
+
readonly CNY: "CNY";
|
|
651
|
+
};
|
|
652
|
+
/**
|
|
653
|
+
* Generated by orval 🍺
|
|
654
|
+
* Do not edit manually.
|
|
655
|
+
* XPay Checkout API
|
|
656
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
657
|
+
* OpenAPI spec version: 1.0
|
|
658
|
+
*/
|
|
659
|
+
/**
|
|
660
|
+
* Price type
|
|
661
|
+
*/
|
|
662
|
+
type PriceDtoType = (typeof PriceDtoType)[keyof typeof PriceDtoType];
|
|
663
|
+
declare const PriceDtoType: {
|
|
664
|
+
readonly ONE_TIME: "ONE_TIME";
|
|
665
|
+
readonly RECURRING: "RECURRING";
|
|
666
|
+
readonly CUSTOM: "CUSTOM";
|
|
667
|
+
};
|
|
668
|
+
/**
|
|
669
|
+
* Generated by orval 🍺
|
|
670
|
+
* Do not edit manually.
|
|
671
|
+
* XPay Checkout API
|
|
672
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
673
|
+
* OpenAPI spec version: 1.0
|
|
674
|
+
*/
|
|
675
|
+
interface ProductDto {
|
|
676
|
+
/** Product ID */
|
|
677
|
+
id: string;
|
|
678
|
+
/** Product name */
|
|
679
|
+
name: string;
|
|
680
|
+
/**
|
|
681
|
+
* Product description
|
|
682
|
+
* @nullable
|
|
683
|
+
*/
|
|
684
|
+
description?: string | null;
|
|
685
|
+
/**
|
|
686
|
+
* Product image identifier
|
|
687
|
+
* @nullable
|
|
688
|
+
*/
|
|
689
|
+
image?: string | null;
|
|
690
|
+
/**
|
|
691
|
+
* Unit label, such as seat or license
|
|
692
|
+
* @nullable
|
|
693
|
+
*/
|
|
694
|
+
unitLabel?: string | null;
|
|
695
|
+
/** Whether the product is available; inline products surface as active */
|
|
696
|
+
active: boolean;
|
|
697
|
+
}
|
|
698
|
+
type RecurringDto = CatalogRecurringDto;
|
|
699
|
+
interface PriceDto {
|
|
700
|
+
/** Price ID */
|
|
701
|
+
id: string;
|
|
702
|
+
/** Unit amount in smallest currency units */
|
|
703
|
+
unitAmount?: number;
|
|
704
|
+
/** Price currency */
|
|
705
|
+
currency: PriceDtoCurrency;
|
|
706
|
+
/** Price type */
|
|
707
|
+
type: PriceDtoType;
|
|
708
|
+
recurring?: RecurringDto;
|
|
709
|
+
customUnitAmount?: CustomUnitAmountDto;
|
|
710
|
+
/**
|
|
711
|
+
* Creation timestamp
|
|
712
|
+
* @pattern ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
|
|
713
|
+
*/
|
|
714
|
+
createdAt: string;
|
|
715
|
+
/** Whether the price is available; inline prices surface as active */
|
|
716
|
+
active: boolean;
|
|
717
|
+
/**
|
|
718
|
+
* Remaining stock; null means unlimited and negative means oversold
|
|
719
|
+
* @nullable
|
|
720
|
+
*/
|
|
721
|
+
stock?: number | null;
|
|
722
|
+
/**
|
|
723
|
+
* Earliest checkout availability
|
|
724
|
+
* @nullable
|
|
725
|
+
* @pattern ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
|
|
726
|
+
*/
|
|
727
|
+
startDate?: string | null;
|
|
728
|
+
/**
|
|
729
|
+
* Checkout availability ends at this time
|
|
730
|
+
* @nullable
|
|
731
|
+
* @pattern ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$
|
|
732
|
+
*/
|
|
733
|
+
expirationDate?: string | null;
|
|
734
|
+
product: ProductDto;
|
|
735
|
+
}
|
|
736
|
+
interface CheckoutLineItemDto {
|
|
737
|
+
/** Line item ID */
|
|
738
|
+
id: string;
|
|
739
|
+
/** Quantity; zero represents an optional item */
|
|
740
|
+
quantity: number;
|
|
741
|
+
price: PriceDto;
|
|
742
|
+
adjustableQuantity?: AdjustableQuantityDto;
|
|
743
|
+
/** Subtotal before discounts and taxes */
|
|
744
|
+
amountSubtotal?: number;
|
|
745
|
+
/** Total after discounts and taxes */
|
|
746
|
+
amountTotal?: number;
|
|
747
|
+
/** Allocated discount */
|
|
748
|
+
amountDiscount?: number;
|
|
749
|
+
/** Allocated tax */
|
|
750
|
+
amountTax?: number;
|
|
751
|
+
/**
|
|
752
|
+
* Currency of this line's amount fields
|
|
753
|
+
* @nullable
|
|
754
|
+
*/
|
|
755
|
+
currency?: CheckoutLineItemDtoCurrency;
|
|
756
|
+
/** Line item description */
|
|
757
|
+
description?: string;
|
|
758
|
+
presentmentDetails?: LineItemPresentmentDetailsDto;
|
|
759
|
+
/** Server-calculated availability for this quantity (one unit for optional items). Never derive this from the device clock. */
|
|
760
|
+
availability: PriceAvailability;
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Generated by orval 🍺
|
|
764
|
+
* Do not edit manually.
|
|
765
|
+
* XPay Checkout API
|
|
766
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
767
|
+
* OpenAPI spec version: 1.0
|
|
768
|
+
*/
|
|
769
|
+
/**
|
|
770
|
+
* Currency code (ISO 4217)
|
|
771
|
+
* @nullable
|
|
772
|
+
*/
|
|
773
|
+
type CheckoutSessionResponseDtoCurrency = (typeof CheckoutSessionResponseDtoCurrency)[keyof typeof CheckoutSessionResponseDtoCurrency] | null;
|
|
774
|
+
declare const CheckoutSessionResponseDtoCurrency: {
|
|
775
|
+
readonly EGP: "EGP";
|
|
776
|
+
readonly USD: "USD";
|
|
777
|
+
readonly EUR: "EUR";
|
|
778
|
+
readonly GBP: "GBP";
|
|
779
|
+
readonly SAR: "SAR";
|
|
780
|
+
readonly AED: "AED";
|
|
781
|
+
readonly QAR: "QAR";
|
|
782
|
+
readonly KWD: "KWD";
|
|
783
|
+
readonly JOD: "JOD";
|
|
784
|
+
readonly OMR: "OMR";
|
|
785
|
+
readonly BHD: "BHD";
|
|
786
|
+
readonly LYD: "LYD";
|
|
787
|
+
readonly AUD: "AUD";
|
|
788
|
+
readonly CAD: "CAD";
|
|
789
|
+
readonly CNY: "CNY";
|
|
790
|
+
};
|
|
791
|
+
/**
|
|
792
|
+
* Generated by orval 🍺
|
|
793
|
+
* Do not edit manually.
|
|
794
|
+
* XPay Checkout API
|
|
795
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
796
|
+
* OpenAPI spec version: 1.0
|
|
797
|
+
*/
|
|
798
|
+
/**
|
|
799
|
+
* Whether the money has arrived. `paid` means fulfil; `unpaid` on a `complete` session means the customer still has to pay a reference. Never fulfil on `status` alone.
|
|
800
|
+
*/
|
|
801
|
+
type CheckoutSessionResponseDtoPaymentStatus = (typeof CheckoutSessionResponseDtoPaymentStatus)[keyof typeof CheckoutSessionResponseDtoPaymentStatus];
|
|
802
|
+
declare const CheckoutSessionResponseDtoPaymentStatus: {
|
|
803
|
+
readonly paid: "paid";
|
|
804
|
+
readonly unpaid: "unpaid";
|
|
805
|
+
readonly no_payment_required: "no_payment_required";
|
|
806
|
+
};
|
|
807
|
+
interface FeesResponseDto {
|
|
808
|
+
paymentMethodType: string;
|
|
809
|
+
feeAmount: number;
|
|
810
|
+
feePercentage: number;
|
|
811
|
+
vatAmount?: number;
|
|
812
|
+
totalAmount: number;
|
|
813
|
+
cardInfo?: CardInfoResponseDto;
|
|
814
|
+
}
|
|
815
|
+
/**
|
|
816
|
+
* Generated by orval 🍺
|
|
817
|
+
* Do not edit manually.
|
|
818
|
+
* XPay Checkout API
|
|
819
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
820
|
+
* OpenAPI spec version: 1.0
|
|
821
|
+
*/
|
|
822
|
+
interface PaymentMethodTypeResponseDto {
|
|
823
|
+
/** Concrete payment method type */
|
|
824
|
+
type: string;
|
|
825
|
+
/** Display name */
|
|
826
|
+
displayName: string;
|
|
827
|
+
/** UI grouping category */
|
|
828
|
+
category?: string;
|
|
829
|
+
/**
|
|
830
|
+
* Minimum transaction amount in smallest currency units
|
|
831
|
+
* @nullable
|
|
832
|
+
*/
|
|
833
|
+
minTransactionAmount?: string | null;
|
|
834
|
+
/**
|
|
835
|
+
* Maximum transaction amount in smallest currency units
|
|
836
|
+
* @nullable
|
|
837
|
+
*/
|
|
838
|
+
maxTransactionAmount?: string | null;
|
|
839
|
+
/** @nullable */
|
|
840
|
+
requiredCustomerFields?: string[] | null;
|
|
841
|
+
supportsRefund?: boolean;
|
|
842
|
+
supportsPartialRefund?: boolean;
|
|
843
|
+
supportsPartialCapture?: boolean;
|
|
844
|
+
paymentConfirmation?: string;
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Generated by orval 🍺
|
|
848
|
+
* Do not edit manually.
|
|
849
|
+
* XPay Checkout API
|
|
850
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
851
|
+
* OpenAPI spec version: 1.0
|
|
852
|
+
*/
|
|
853
|
+
/**
|
|
854
|
+
* Customer's currency code (ISO 4217)
|
|
855
|
+
*/
|
|
856
|
+
type SessionPresentmentDetailsDtoCurrency = (typeof SessionPresentmentDetailsDtoCurrency)[keyof typeof SessionPresentmentDetailsDtoCurrency];
|
|
857
|
+
declare const SessionPresentmentDetailsDtoCurrency: {
|
|
858
|
+
readonly EGP: "EGP";
|
|
859
|
+
readonly USD: "USD";
|
|
860
|
+
readonly EUR: "EUR";
|
|
861
|
+
readonly GBP: "GBP";
|
|
862
|
+
readonly SAR: "SAR";
|
|
863
|
+
readonly AED: "AED";
|
|
864
|
+
readonly QAR: "QAR";
|
|
865
|
+
readonly KWD: "KWD";
|
|
866
|
+
readonly JOD: "JOD";
|
|
867
|
+
readonly OMR: "OMR";
|
|
868
|
+
readonly BHD: "BHD";
|
|
869
|
+
readonly LYD: "LYD";
|
|
870
|
+
readonly AUD: "AUD";
|
|
871
|
+
readonly CAD: "CAD";
|
|
872
|
+
readonly CNY: "CNY";
|
|
873
|
+
};
|
|
874
|
+
interface SessionPresentmentDetailsDto {
|
|
875
|
+
/** Amount in the customer's currency, in the smallest unit */
|
|
876
|
+
amount: number;
|
|
877
|
+
/** Customer's currency code (ISO 4217) */
|
|
878
|
+
currency: SessionPresentmentDetailsDtoCurrency;
|
|
879
|
+
/** Locked rate: presentment major units × rate = processing major units */
|
|
880
|
+
exchangeRate: number;
|
|
881
|
+
/** Immutable exchange-rate record ID */
|
|
882
|
+
exchangeRateId: string;
|
|
883
|
+
/** Subtotal before discounts and fees, in presentment smallest units */
|
|
884
|
+
amountSubtotal: number;
|
|
885
|
+
/** Final total in presentment smallest units */
|
|
886
|
+
amountTotal: number;
|
|
887
|
+
/** Discount in presentment smallest units */
|
|
888
|
+
amountDiscount: number;
|
|
889
|
+
/** Collected VAT when collection is enabled */
|
|
890
|
+
amountCollectedVat?: number;
|
|
891
|
+
/** Platform fee when fees are passed through */
|
|
892
|
+
amountPlatformFee?: number;
|
|
893
|
+
/** Tax when charged */
|
|
894
|
+
amountTax?: number;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Generated by orval 🍺
|
|
898
|
+
* Do not edit manually.
|
|
899
|
+
* XPay Checkout API
|
|
900
|
+
* API for the XPay checkout flow — client endpoints and SSR
|
|
901
|
+
* OpenAPI spec version: 1.0
|
|
902
|
+
*/
|
|
903
|
+
interface TotalDetailsResponseDto {
|
|
904
|
+
/** Discount amount */
|
|
905
|
+
amountDiscount: number;
|
|
906
|
+
/** Shipping amount */
|
|
907
|
+
amountShipping?: number;
|
|
908
|
+
/** Tax amount */
|
|
909
|
+
amountTax: number;
|
|
910
|
+
/** Platform fee passed through to the customer */
|
|
911
|
+
amountPlatformFee?: number;
|
|
912
|
+
/** Collected VAT amount */
|
|
913
|
+
amountCollectedVat?: number;
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Information about an available payment method.
|
|
917
|
+
*
|
|
918
|
+
* @example
|
|
919
|
+
* ```ts
|
|
920
|
+
* checkout.paymentMethods.forEach(pm => {
|
|
921
|
+
* console.log(pm.type); // "card", "valu", "fawry"
|
|
922
|
+
* console.log(pm.displayName); // "Card", "ValU", "Fawry"
|
|
923
|
+
* console.log(pm.category); // "card", "bnpl", "kiosk", "wallet"
|
|
924
|
+
* });
|
|
925
|
+
* ```
|
|
926
|
+
*/
|
|
927
|
+
type PaymentMethodInfo = Required<Pick<PaymentMethodTypeResponseDto, "type" | "displayName">> & {
|
|
928
|
+
/** Payment method category for grouping in UI */
|
|
929
|
+
category: "card" | "bnpl" | "kiosk" | "wallet";
|
|
930
|
+
/** Icon URL for the payment method */
|
|
931
|
+
icon?: string;
|
|
932
|
+
/** Description of the next step (e.g., "You will be redirected to complete payment") */
|
|
933
|
+
nextActionText?: string;
|
|
934
|
+
};
|
|
935
|
+
/**
|
|
936
|
+
* Appearance overrides for the checkout UI.
|
|
937
|
+
* Merged with the session's server-side `brandingSettings`.
|
|
938
|
+
*
|
|
939
|
+
* @example
|
|
940
|
+
* ```ts
|
|
941
|
+
* const elements = xpay.elements({
|
|
942
|
+
* clientSecret,
|
|
943
|
+
* appearance: {
|
|
944
|
+
* colorMode: "dark",
|
|
945
|
+
* borderStyle: "rounded",
|
|
946
|
+
* inputStyle: "outlined",
|
|
947
|
+
* },
|
|
948
|
+
* });
|
|
949
|
+
* ```
|
|
950
|
+
*/
|
|
951
|
+
type Appearance = Pick<BrandingSettingsResponseDto, "colorMode" | "borderStyle" | "spacing" | "inputSize" | "inputStyle" | "formLayout" | "colors" | "fontFamily">;
|
|
952
|
+
/**
|
|
953
|
+
* Structured session status — tagged union for exhaustive checking.
|
|
954
|
+
*
|
|
955
|
+
* @example
|
|
956
|
+
* ```ts
|
|
957
|
+
* switch (checkout.status.type) {
|
|
958
|
+
* case "open": // ready for payment
|
|
959
|
+
* case "expired": // session timed out
|
|
960
|
+
* case "complete": // payment completed — check paymentStatus
|
|
961
|
+
* }
|
|
962
|
+
* ```
|
|
963
|
+
*/
|
|
964
|
+
/**
|
|
965
|
+
* `complete` means the customer is done with checkout, not that the money has
|
|
966
|
+
* arrived. Cards and other instant methods complete as `paid`; a method the customer
|
|
967
|
+
* pays afterwards (a Fawry reference) completes as `unpaid`, and the session turns
|
|
968
|
+
* `paid` later — announced by `checkout.session.async_payment_succeeded`. Fulfil on
|
|
969
|
+
* `paymentStatus === "paid"`, never on `type === "complete"` alone.
|
|
970
|
+
*/
|
|
971
|
+
type SessionStatus = {
|
|
972
|
+
type: "open";
|
|
973
|
+
} | {
|
|
974
|
+
type: "expired";
|
|
975
|
+
} | {
|
|
976
|
+
type: "complete";
|
|
977
|
+
paymentStatus: CheckoutSessionResponseDtoPaymentStatus;
|
|
978
|
+
};
|
|
979
|
+
/**
|
|
980
|
+
* Checkout session data exposed to merchants.
|
|
981
|
+
*
|
|
982
|
+
* Contains everything needed to render a checkout UI: amounts, currency,
|
|
983
|
+
* available payment methods, line items, fees, and discounts.
|
|
984
|
+
*
|
|
985
|
+
* @example
|
|
986
|
+
* ```ts
|
|
987
|
+
* const state = useCheckout();
|
|
988
|
+
* if (state.type === "success") {
|
|
989
|
+
* const { checkout } = state;
|
|
990
|
+
* console.log(checkout.amountTotal); // "10000" (in minor units)
|
|
991
|
+
* console.log(checkout.currency); // "EGP"
|
|
992
|
+
* console.log(checkout.status.type); // "open"
|
|
993
|
+
* console.log(checkout.paymentMethods); // [{type: "card", ...}, ...]
|
|
994
|
+
* }
|
|
995
|
+
* ```
|
|
996
|
+
*/
|
|
997
|
+
type CheckoutSession = {
|
|
998
|
+
id?: string;
|
|
999
|
+
amountSubtotal?: number;
|
|
1000
|
+
amountTotal?: number;
|
|
1001
|
+
currency?: CheckoutSessionResponseDtoCurrency;
|
|
1002
|
+
merchantName?: string | null;
|
|
1003
|
+
livemode: boolean;
|
|
1004
|
+
expiresAt?: string;
|
|
1005
|
+
/** Structured session status */
|
|
1006
|
+
status: SessionStatus;
|
|
1007
|
+
/** Whether the session is ready for confirmation */
|
|
1008
|
+
canConfirm: boolean;
|
|
1009
|
+
/** Available payment methods */
|
|
1010
|
+
paymentMethods: PaymentMethodInfo[];
|
|
1011
|
+
/**
|
|
1012
|
+
* Customer-facing amounts, present only when the merchant prices in a
|
|
1013
|
+
* currency other than the processing currency — read amounts
|
|
1014
|
+
* presentment-first (`presentmentDetails.amountTotal` when present,
|
|
1015
|
+
* top-level `amountTotal` otherwise).
|
|
1016
|
+
*/
|
|
1017
|
+
presentmentDetails?: SessionPresentmentDetailsDto | undefined;
|
|
1018
|
+
/** Line items in the session */
|
|
1019
|
+
lineItems?: CheckoutLineItemDto[] | undefined;
|
|
1020
|
+
/** Totals breakdown (subtotal, tax, shipping, etc.) */
|
|
1021
|
+
totalDetails?: TotalDetailsResponseDto | undefined;
|
|
1022
|
+
/** Fee breakdown (when feesPassThrough is enabled) */
|
|
1023
|
+
fees?: FeesResponseDto | undefined;
|
|
1024
|
+
/** Applied discounts / promotion codes */
|
|
1025
|
+
discounts?: CheckoutDiscountResponseDto[] | undefined;
|
|
1026
|
+
};
|
|
1027
|
+
/** Line item in a checkout session */
|
|
1028
|
+
type CheckoutLineItem = CheckoutLineItemDto;
|
|
1029
|
+
/** Totals breakdown (subtotal, tax, shipping, discount amounts) */
|
|
1030
|
+
type CheckoutTotalDetails = TotalDetailsResponseDto;
|
|
1031
|
+
/** Fee breakdown for pass-through fees */
|
|
1032
|
+
type CheckoutFees = FeesResponseDto;
|
|
1033
|
+
/** Applied discount / promotion code */
|
|
1034
|
+
type CheckoutDiscount = CheckoutDiscountResponseDto;
|
|
1035
|
+
/**
|
|
1036
|
+
* Result of an action (confirm, promo, quantity update, etc.).
|
|
1037
|
+
* Tagged union — check `result.type` to determine success or failure.
|
|
1038
|
+
*
|
|
1039
|
+
* @example
|
|
1040
|
+
* ```ts
|
|
1041
|
+
* const result = await checkout.applyPromotionCode("SAVE10");
|
|
1042
|
+
* if (result.type === "success") {
|
|
1043
|
+
* console.log(result.session.amountTotal); // updated amount
|
|
1044
|
+
* } else {
|
|
1045
|
+
* console.log(result.error.message); // "Invalid promotion code"
|
|
1046
|
+
* }
|
|
1047
|
+
* ```
|
|
1048
|
+
*/
|
|
1049
|
+
type ActionResult<E = XPayError> = {
|
|
1050
|
+
type: "success";
|
|
1051
|
+
session: CheckoutSession;
|
|
1052
|
+
} | {
|
|
1053
|
+
type: "error";
|
|
1054
|
+
error: E;
|
|
1055
|
+
};
|
|
1056
|
+
/**
|
|
1057
|
+
* Unified error type for ALL SDK operations (Stripe-style).
|
|
1058
|
+
*
|
|
1059
|
+
* Same type for `confirm()`, `applyPromotionCode()`, `updateLineItemQuantity()`, etc.
|
|
1060
|
+
* Payment-specific fields (`declineCode`, `adviceCode`, `chargeId`, `paymentMethod`) are
|
|
1061
|
+
* `null` for non-payment errors.
|
|
1062
|
+
*
|
|
1063
|
+
* @example Payment decline:
|
|
1064
|
+
* ```ts
|
|
1065
|
+
* const result = await checkout.confirm({ customerDetails: { email } });
|
|
1066
|
+
* if (result.type === "error") {
|
|
1067
|
+
* console.log(result.error.type); // "card_error"
|
|
1068
|
+
* console.log(result.error.code); // "card_declined"
|
|
1069
|
+
* console.log(result.error.declineCode); // "insufficient_funds"
|
|
1070
|
+
* console.log(result.error.adviceCode); // "try_again_later"
|
|
1071
|
+
* console.log(result.error.message); // "Your card has insufficient funds."
|
|
1072
|
+
* }
|
|
1073
|
+
* ```
|
|
1074
|
+
*
|
|
1075
|
+
* @example API error (promo code, quantity, session):
|
|
1076
|
+
* ```ts
|
|
1077
|
+
* const result = await checkout.applyPromotionCode("INVALID");
|
|
1078
|
+
* if (result.type === "error") {
|
|
1079
|
+
* console.log(result.error.type); // "invalid_request_error"
|
|
1080
|
+
* console.log(result.error.code); // "promotion_code_not_found"
|
|
1081
|
+
* console.log(result.error.param); // "promotionCode"
|
|
1082
|
+
* console.log(result.error.docUrl); // "https://docs.xpay.app/api/errors#promotion_code_not_found"
|
|
1083
|
+
* console.log(result.error.message); // "No promotion code found for 'INVALID'"
|
|
1084
|
+
* }
|
|
1085
|
+
* ```
|
|
1086
|
+
*/
|
|
1087
|
+
interface XPayError {
|
|
1088
|
+
/** Error category: "card_error" | "payment_method_error" | "invalid_request_error" | "api_error" | ... */
|
|
1089
|
+
type: string;
|
|
1090
|
+
/** Machine-readable error code: "card_declined" | "checkout_session_expired" | "promotion_code_not_found" | ... */
|
|
1091
|
+
code: string | null;
|
|
1092
|
+
/** Human-readable error message */
|
|
1093
|
+
message: string;
|
|
1094
|
+
/** Parameter that caused the error (e.g., "promotionCode", "quantity") — null for payment errors */
|
|
1095
|
+
param?: string | null;
|
|
1096
|
+
/** Documentation URL for this error code */
|
|
1097
|
+
docUrl?: string | null;
|
|
1098
|
+
/** Decline code — WHY it failed specifically ("insufficient_funds", "generic_decline") — null for non-payment errors */
|
|
1099
|
+
declineCode?: string | null;
|
|
1100
|
+
/** Retry advice ("try_again_later" | "do_not_try_again" | "confirm_card_data") — null for non-payment errors */
|
|
1101
|
+
adviceCode?: string | null;
|
|
1102
|
+
/** Failed charge ID — null for non-payment errors */
|
|
1103
|
+
chargeId?: string | null;
|
|
1104
|
+
/** Failed payment method ID — null for non-payment errors */
|
|
1105
|
+
paymentMethodId?: string | null;
|
|
1106
|
+
/** Payment method type ("card" | "valu" | "fawry") — null for non-payment errors */
|
|
1107
|
+
paymentMethodType?: string | null;
|
|
1108
|
+
/** Payment method snapshot at time of failure — null for non-payment errors */
|
|
1109
|
+
paymentMethod?: Record<string, unknown> | null;
|
|
1110
|
+
}
|
|
1111
|
+
/**
|
|
1112
|
+
* The XPay SDK instance returned by `loadXPay()`.
|
|
1113
|
+
*
|
|
1114
|
+
* @example
|
|
1115
|
+
* ```ts
|
|
1116
|
+
* import { loadXPay } from "@xpayeg/sdk";
|
|
1117
|
+
*
|
|
1118
|
+
* const xpay = await loadXPay("pk_test_xxx");
|
|
1119
|
+
* const elements = xpay.elements({ clientSecret: "cs_test_abc_secret_xyz" });
|
|
1120
|
+
* ```
|
|
1121
|
+
*/
|
|
1122
|
+
interface XPayInstance {
|
|
1123
|
+
/**
|
|
1124
|
+
* Create an Elements instance for custom checkout UI.
|
|
1125
|
+
* Use with `PaymentElement` to render the payment form.
|
|
1126
|
+
*
|
|
1127
|
+
* @param options - Must include `clientSecret` from a checkout session
|
|
1128
|
+
* @returns An Elements instance for creating and managing payment elements
|
|
1129
|
+
*/
|
|
1130
|
+
elements(options: ElementsOptions): Elements;
|
|
1131
|
+
/**
|
|
1132
|
+
* Create a drop-in checkout modal or inline embed.
|
|
1133
|
+
*
|
|
1134
|
+
* @param options - Configuration including `clientSecret` and event handlers
|
|
1135
|
+
* @returns A checkout instance with `open()`, `close()`, and `destroy()` methods
|
|
1136
|
+
*/
|
|
1137
|
+
checkout(options: CheckoutOptions): CheckoutInstance;
|
|
1138
|
+
/**
|
|
1139
|
+
* Confirm a payment using the data collected by Elements.
|
|
1140
|
+
*
|
|
1141
|
+
* @param options - Must include `elements` and optionally `customerDetails`
|
|
1142
|
+
* @returns Action result with the updated session on success, or an error
|
|
1143
|
+
*/
|
|
1144
|
+
confirmPayment(options: ConfirmPaymentOptions): Promise<ActionResult>;
|
|
1145
|
+
/**
|
|
1146
|
+
* Initialize a checkout session — combines `elements()` with session data.
|
|
1147
|
+
* Returns session data + action methods in a single call.
|
|
1148
|
+
*
|
|
1149
|
+
* @param options - Must include `clientSecret`
|
|
1150
|
+
* @returns Session data merged with checkout action methods
|
|
1151
|
+
*/
|
|
1152
|
+
initCheckout(options: InitCheckoutOptions): Promise<InitCheckoutResult>;
|
|
1153
|
+
}
|
|
1154
|
+
/**
|
|
1155
|
+
* Options for creating an Elements instance from an existing checkout session.
|
|
1156
|
+
*
|
|
1157
|
+
* @example
|
|
1158
|
+
* ```ts
|
|
1159
|
+
* const elements = xpay.elements({
|
|
1160
|
+
* clientSecret: "cs_test_abc_secret_xyz",
|
|
1161
|
+
* appearance: { colorMode: "dark" },
|
|
1162
|
+
* locale: "ar",
|
|
1163
|
+
* });
|
|
1164
|
+
* ```
|
|
1165
|
+
*/
|
|
1166
|
+
interface ElementsOptionsClientSecret {
|
|
1167
|
+
/** The client secret from a checkout session. Can be a string or a Promise. */
|
|
1168
|
+
clientSecret: string | Promise<string>;
|
|
1169
|
+
/** Either use mode or clientSecret when creating an Elements group. */
|
|
1170
|
+
mode?: never;
|
|
1171
|
+
/** Amount is only applicable in deferred mode (`mode: "payment"`). */
|
|
1172
|
+
amount?: never;
|
|
1173
|
+
/** Currency is only applicable in deferred mode (`mode: "payment"`). */
|
|
1174
|
+
currency?: never;
|
|
1175
|
+
/** Only applicable in deferred mode. Session-first elements render the session's own payment method types, set when the session is created. */
|
|
1176
|
+
paymentMethodTypes?: never;
|
|
1177
|
+
/** Appearance overrides for the checkout UI */
|
|
1178
|
+
appearance?: Appearance;
|
|
1179
|
+
/** Locale for the payment form — `"en"` (default) or `"ar"` */
|
|
1180
|
+
locale?: "en" | "ar";
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* Options for creating a DEFERRED Elements instance — no checkout session
|
|
1184
|
+
* exists yet. The Payment Element renders immediately from the amount and
|
|
1185
|
+
* currency alone; your server creates the session with the final total when
|
|
1186
|
+
* the customer clicks Pay, and its clientSecret is passed to
|
|
1187
|
+
* `confirmPayment({ elements, clientSecret })`.
|
|
1188
|
+
*
|
|
1189
|
+
* The amount shown is the amount charged: if the session your server creates
|
|
1190
|
+
* has a different total, the confirmation fails with
|
|
1191
|
+
* `amount_reconfirmation_required` and nothing is charged.
|
|
1192
|
+
*
|
|
1193
|
+
* @example
|
|
1194
|
+
* ```ts
|
|
1195
|
+
* const elements = xpay.elements({
|
|
1196
|
+
* mode: "payment",
|
|
1197
|
+
* amount: 250000, // piasters
|
|
1198
|
+
* currency: "EGP",
|
|
1199
|
+
* });
|
|
1200
|
+
* ```
|
|
1201
|
+
*/
|
|
1202
|
+
interface ElementsOptionsMode {
|
|
1203
|
+
/** Deferred mode. Only `"payment"` is supported. */
|
|
1204
|
+
mode: "payment";
|
|
1205
|
+
/** The amount to display and charge, in the currency's smallest unit (piasters). Integer, greater than zero. */
|
|
1206
|
+
amount: number;
|
|
1207
|
+
/** Three-letter currency code (e.g. `"EGP"`). */
|
|
1208
|
+
currency: string;
|
|
1209
|
+
/**
|
|
1210
|
+
* Restrict which payment method types the element renders (e.g. `["card"]`).
|
|
1211
|
+
* Narrow-only: the list is intersected with the payment methods enabled for
|
|
1212
|
+
* your account, so a type that is not enabled is never rendered. If nothing
|
|
1213
|
+
* survives the intersection the element fails to load with a `loaderror`.
|
|
1214
|
+
* Fixed for the element's lifetime. Omit to render every enabled method.
|
|
1215
|
+
* The same values are passed as `paymentMethodTypes` when your server
|
|
1216
|
+
* creates the session at pay time, so display and acceptance match.
|
|
1217
|
+
*/
|
|
1218
|
+
paymentMethodTypes?: string[];
|
|
1219
|
+
/** Either use mode or clientSecret when creating an Elements group. */
|
|
1220
|
+
clientSecret?: never;
|
|
1221
|
+
/** Appearance overrides for the checkout UI */
|
|
1222
|
+
appearance?: Appearance;
|
|
1223
|
+
/** Locale for the payment form — `"en"` (default) or `"ar"` */
|
|
1224
|
+
locale?: "en" | "ar";
|
|
1225
|
+
}
|
|
1226
|
+
/**
|
|
1227
|
+
* Options for creating an Elements instance — with a session's
|
|
1228
|
+
* `clientSecret`, or session-less with `{ mode, amount, currency }`
|
|
1229
|
+
* (deferred). The two forms are mutually exclusive.
|
|
1230
|
+
*/
|
|
1231
|
+
type ElementsOptions = ElementsOptionsClientSecret | ElementsOptionsMode;
|
|
1232
|
+
/** Options for `elements.update()` — deferred mode only. */
|
|
1233
|
+
interface ElementsUpdateOptions {
|
|
1234
|
+
/** New display amount in the currency's smallest unit. Integer, greater than zero. */
|
|
1235
|
+
amount?: number;
|
|
1236
|
+
/** New three-letter currency code. */
|
|
1237
|
+
currency?: string;
|
|
1238
|
+
}
|
|
1239
|
+
/**
|
|
1240
|
+
* Manages the lifecycle of the PaymentElement.
|
|
1241
|
+
*
|
|
1242
|
+
* A single Elements instance manages one embed iframe shared by all elements.
|
|
1243
|
+
* Provides session management methods (promo codes, quantities, etc.) and
|
|
1244
|
+
* element creation.
|
|
1245
|
+
*/
|
|
1246
|
+
interface Elements {
|
|
1247
|
+
/** Create a PaymentElement (full payment method selector + card form) */
|
|
1248
|
+
create(type: "payment", options?: PaymentElementOptions): PaymentElement;
|
|
1249
|
+
/** Get an existing element by type, or null if not created */
|
|
1250
|
+
getElement(type: "payment"): PaymentElement | null;
|
|
1251
|
+
/** Fetch available payment methods for this session */
|
|
1252
|
+
fetchPaymentMethods(): Promise<PaymentMethodInfo[]>;
|
|
1253
|
+
/**
|
|
1254
|
+
* Listen for the `ready` event — fires when the session is loaded and elements can render.
|
|
1255
|
+
* If the session is already loaded, the handler fires immediately.
|
|
1256
|
+
*/
|
|
1257
|
+
on(event: "ready", handler: (data: ElementsReadyEvent) => void): void;
|
|
1258
|
+
/** Listen for session data changes (payment method selection, promo codes, fee updates, etc.) */
|
|
1259
|
+
on(event: "change", handler: (session: CheckoutSession) => void): void;
|
|
1260
|
+
/** Listen for session load failures (network errors, invalid client secret, API errors) */
|
|
1261
|
+
on(event: "loaderror", handler: (data: ElementsLoadErrorEvent) => void): void;
|
|
1262
|
+
/** Listen for unsolicited errors not triggered by a merchant action (e.g. session expired during fee recalculation, BIN detection failure) */
|
|
1263
|
+
on(event: "error", handler: (error: XPayError) => void): void;
|
|
1264
|
+
/** Listen for a custom event */
|
|
1265
|
+
on(event: string, handler: (...args: unknown[]) => void): void;
|
|
1266
|
+
/** Remove an event handler */
|
|
1267
|
+
off(event: string, handler: (...args: unknown[]) => void): void;
|
|
1268
|
+
/** Apply a promotion code to the session */
|
|
1269
|
+
applyPromotionCode(code: string): Promise<ActionResult>;
|
|
1270
|
+
/** Remove the applied promotion code */
|
|
1271
|
+
removePromotionCode(): Promise<ActionResult>;
|
|
1272
|
+
/** Update a line item's quantity */
|
|
1273
|
+
updateLineItemQuantity(args: {
|
|
1274
|
+
lineItem: string;
|
|
1275
|
+
quantity: number;
|
|
1276
|
+
}): Promise<ActionResult>;
|
|
1277
|
+
/** Validate all element fields before confirming — returns the selected payment method on success */
|
|
1278
|
+
submit(): Promise<{
|
|
1279
|
+
error?: XPayError;
|
|
1280
|
+
selectedPaymentMethod?: string;
|
|
1281
|
+
}>;
|
|
1282
|
+
/** Re-fetch the session from the server to get the latest data */
|
|
1283
|
+
fetchUpdates(): Promise<ActionResult>;
|
|
1284
|
+
/** Update the appearance at runtime without recreating elements */
|
|
1285
|
+
changeAppearance(appearance: Appearance): void;
|
|
1286
|
+
/**
|
|
1287
|
+
* Update the displayed amount/currency of a DEFERRED Elements instance
|
|
1288
|
+
* (created with `{ mode: "payment" }`). Throws when the instance was
|
|
1289
|
+
* created with a `clientSecret` — session amounts are server-owned.
|
|
1290
|
+
*/
|
|
1291
|
+
update(options: ElementsUpdateOptions): Promise<void>;
|
|
1292
|
+
/** Destroy the Elements instance and clean up all resources */
|
|
1293
|
+
destroy(): void;
|
|
1294
|
+
}
|
|
1295
|
+
/** Fired when the session is loaded and elements are ready to render */
|
|
1296
|
+
interface ElementsReadyEvent {
|
|
1297
|
+
/** The loaded checkout session data */
|
|
1298
|
+
session: CheckoutSession;
|
|
1299
|
+
}
|
|
1300
|
+
/** Fired when the session fails to load */
|
|
1301
|
+
interface ElementsLoadErrorEvent {
|
|
1302
|
+
/** Error category */
|
|
1303
|
+
type: "invalid_request_error" | "api_error" | "network_error";
|
|
1304
|
+
/** Human-readable error message */
|
|
1305
|
+
message: string;
|
|
1306
|
+
/** Machine-readable error code */
|
|
1307
|
+
code?: string;
|
|
1308
|
+
/** The parameter that caused the error */
|
|
1309
|
+
param?: string;
|
|
1310
|
+
/** Link to documentation about this error */
|
|
1311
|
+
docUrl?: string;
|
|
1312
|
+
}
|
|
1313
|
+
/** Options for creating a PaymentElement */
|
|
1314
|
+
interface PaymentElementOptions {
|
|
1315
|
+
/**
|
|
1316
|
+
* How the element presents the payment method chooser.
|
|
1317
|
+
*
|
|
1318
|
+
* - `"accordion"` (default): a vertical list, one row per method, the
|
|
1319
|
+
* selected method's content expanding beneath its row. With exactly one
|
|
1320
|
+
* method the chooser disappears: a single non-card method shows a static
|
|
1321
|
+
* identity header (logo and name, no radio) above its content, while a
|
|
1322
|
+
* single card method renders the bare card form, since its fields
|
|
1323
|
+
* already identify it.
|
|
1324
|
+
* - `"tabs"`: a grid of tiles that fills the row and wraps when the
|
|
1325
|
+
* methods no longer fit, with the selected method's content below it.
|
|
1326
|
+
* With exactly one method the tile grid disappears and
|
|
1327
|
+
* only the content renders, for pages whose own UI already shows the
|
|
1328
|
+
* method's logo and name (e.g. a per-gateway plugin row).
|
|
1329
|
+
*
|
|
1330
|
+
* Updatable after creation via `element.update({ layout })`.
|
|
1331
|
+
*/
|
|
1332
|
+
layout?: "accordion" | "tabs";
|
|
1333
|
+
/** Pre-select a specific payment method by type */
|
|
1334
|
+
defaultPaymentMethod?: string;
|
|
1335
|
+
/** Custom ordering of payment methods by type */
|
|
1336
|
+
paymentMethodOrder?: string[];
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Change event from a PaymentElement.
|
|
1340
|
+
* Fires on payment method selection, card field changes, and session updates.
|
|
1341
|
+
*
|
|
1342
|
+
* @example
|
|
1343
|
+
* ```tsx
|
|
1344
|
+
* <PaymentElement
|
|
1345
|
+
* onChange={(event) => {
|
|
1346
|
+
* setPaymentReady(event.complete);
|
|
1347
|
+
* console.log("Selected method:", event.value.type);
|
|
1348
|
+
* }}
|
|
1349
|
+
* />
|
|
1350
|
+
* ```
|
|
1351
|
+
*/
|
|
1352
|
+
interface PaymentElementChangeEvent {
|
|
1353
|
+
elementType: "payment";
|
|
1354
|
+
/** Whether all card fields are empty (no user input yet) */
|
|
1355
|
+
empty: boolean;
|
|
1356
|
+
/** Whether the form is complete and ready for submission */
|
|
1357
|
+
complete: boolean;
|
|
1358
|
+
/** Whether the payment method selector is collapsed (no method selected) */
|
|
1359
|
+
collapsed: boolean;
|
|
1360
|
+
/** The currently selected payment method */
|
|
1361
|
+
value: {
|
|
1362
|
+
type: string;
|
|
1363
|
+
};
|
|
1364
|
+
/** Full session data including updated amounts, fees, and discounts */
|
|
1365
|
+
session: CheckoutSession;
|
|
1366
|
+
}
|
|
1367
|
+
/** Base interface shared by all element types */
|
|
1368
|
+
interface BaseElement {
|
|
1369
|
+
/** Mount the element into a DOM container (CSS selector or HTMLElement) */
|
|
1370
|
+
mount(container: string | HTMLElement): void;
|
|
1371
|
+
/** Unmount the element from the DOM (can be re-mounted later) */
|
|
1372
|
+
unmount(): void;
|
|
1373
|
+
/** Destroy the element and release all resources */
|
|
1374
|
+
destroy(): void;
|
|
1375
|
+
/** Programmatically focus the element's iframe */
|
|
1376
|
+
focus(): void;
|
|
1377
|
+
/** Programmatically blur the element's iframe */
|
|
1378
|
+
blur(): void;
|
|
1379
|
+
/** Fired when the element is mounted and the iframe content is ready */
|
|
1380
|
+
on(event: "ready", handler: () => void): void;
|
|
1381
|
+
/** Fired when the element's iframe starts loading */
|
|
1382
|
+
on(event: "loaderstart", handler: () => void): void;
|
|
1383
|
+
/** Fired when the element fails to load */
|
|
1384
|
+
on(event: "loaderror", handler: (event: ElementsLoadErrorEvent) => void): void;
|
|
1385
|
+
on(event: string, handler: (...args: unknown[]) => void): void;
|
|
1386
|
+
off(event: string, handler: (...args: unknown[]) => void): void;
|
|
1387
|
+
}
|
|
1388
|
+
/**
|
|
1389
|
+
* The subset of `PaymentElementOptions` that can be updated after creation
|
|
1390
|
+
* (Stripe's `StripePaymentElementUpdateOptions` pattern). Only `layout` is
|
|
1391
|
+
* updatable; `defaultPaymentMethod` and `paymentMethodOrder` are set at
|
|
1392
|
+
* creation.
|
|
1393
|
+
*/
|
|
1394
|
+
type PaymentElementUpdateOptions = Pick<PaymentElementOptions, "layout">;
|
|
1395
|
+
/** PaymentElement — full payment method selector with card form */
|
|
1396
|
+
interface PaymentElement extends BaseElement {
|
|
1397
|
+
/** Collapse the payment method selector (deselect all methods) */
|
|
1398
|
+
collapse(): void;
|
|
1399
|
+
/** Update element options at runtime — see {@link PaymentElementUpdateOptions} */
|
|
1400
|
+
update(options: PaymentElementUpdateOptions): void;
|
|
1401
|
+
}
|
|
1402
|
+
/**
|
|
1403
|
+
* Options for `confirmPayment()` or `checkout.confirm()`.
|
|
1404
|
+
*
|
|
1405
|
+
* The `redirect` option controls what happens after a successful payment:
|
|
1406
|
+
* - `"if_required"` (default) — returns the result to your code
|
|
1407
|
+
* - `"always"` — always redirects to the session's own destination after payment
|
|
1408
|
+
*
|
|
1409
|
+
* The destination is never set here. It is the `afterCompletion.redirect.url` you gave
|
|
1410
|
+
* when creating the checkout session, because the same address is handed to the
|
|
1411
|
+
* customer's bank during verification — before the browser leaves your page. A value
|
|
1412
|
+
* supplied from the page could only ever disagree with what the bank was already told.
|
|
1413
|
+
*
|
|
1414
|
+
* @example
|
|
1415
|
+
* ```ts
|
|
1416
|
+
* // Default: get the result back in code
|
|
1417
|
+
* const result = await checkout.confirm({
|
|
1418
|
+
* customerDetails: { email: "user@example.com" },
|
|
1419
|
+
* });
|
|
1420
|
+
*
|
|
1421
|
+
* // Always redirect to the session's own destination after payment
|
|
1422
|
+
* await checkout.confirm({ redirect: "always" });
|
|
1423
|
+
* ```
|
|
1424
|
+
*/
|
|
1425
|
+
interface ConfirmPaymentOptions {
|
|
1426
|
+
/** The Elements instance managing the payment form */
|
|
1427
|
+
elements: Elements;
|
|
1428
|
+
/**
|
|
1429
|
+
* DEFERRED mode only, and required there: the clientSecret of the checkout
|
|
1430
|
+
* session your server just created with the final total. A plain string —
|
|
1431
|
+
* await your own fetch before calling. The session's total must equal the
|
|
1432
|
+
* amount the element displays, or the confirmation fails with
|
|
1433
|
+
* `amount_reconfirmation_required` and nothing is charged. Ignored when the
|
|
1434
|
+
* elements were created with a clientSecret.
|
|
1435
|
+
*/
|
|
1436
|
+
clientSecret?: string;
|
|
1437
|
+
/** Customer details collected by the merchant's form */
|
|
1438
|
+
customerDetails?: CustomerDetails;
|
|
1439
|
+
/** Custom field values for the session */
|
|
1440
|
+
customFields?: Record<string, string | number | boolean>;
|
|
1441
|
+
/** Device fingerprint for fraud detection */
|
|
1442
|
+
deviceFingerprint?: {
|
|
1443
|
+
visitorId: string;
|
|
1444
|
+
confidence?: number;
|
|
1445
|
+
};
|
|
1446
|
+
/** Override the selected payment method type */
|
|
1447
|
+
paymentMethod?: string;
|
|
1448
|
+
/**
|
|
1449
|
+
* Redirect behavior after payment.
|
|
1450
|
+
* - `"if_required"` (default) — returns the result to your code; only redirects if the payment method requires it
|
|
1451
|
+
* - `"always"` — always redirects to the session's `afterCompletion.redirect.url` after payment. The page navigates away and the function never returns on success.
|
|
1452
|
+
*/
|
|
1453
|
+
redirect?: "if_required" | "always";
|
|
1454
|
+
}
|
|
1455
|
+
/**
|
|
1456
|
+
* Options for creating a drop-in checkout instance.
|
|
1457
|
+
*
|
|
1458
|
+
* @example
|
|
1459
|
+
* ```ts
|
|
1460
|
+
* const checkout = xpay.checkout({
|
|
1461
|
+
* clientSecret: "cs_test_abc_secret_xyz",
|
|
1462
|
+
* mode: "modal",
|
|
1463
|
+
* onComplete: (result) => console.log("Paid!", result.paymentIntentId),
|
|
1464
|
+
* });
|
|
1465
|
+
* checkout.open();
|
|
1466
|
+
* ```
|
|
1467
|
+
*/
|
|
1468
|
+
interface CheckoutOptions {
|
|
1469
|
+
/** Client secret from a checkout session */
|
|
1470
|
+
clientSecret: string;
|
|
1471
|
+
/** Display mode — `"modal"` (overlay) or `"inline"` (embedded in page) */
|
|
1472
|
+
mode?: "modal" | "inline";
|
|
1473
|
+
/** Container for inline mode (CSS selector or HTMLElement) */
|
|
1474
|
+
container?: string | HTMLElement;
|
|
1475
|
+
/** Called when the payment completes successfully */
|
|
1476
|
+
onComplete?: (result: CheckoutCompleteResult) => void;
|
|
1477
|
+
/** Called when the checkout UI is closed */
|
|
1478
|
+
onClose?: () => void;
|
|
1479
|
+
/** Called when the session is loaded and the checkout is ready */
|
|
1480
|
+
onReady?: (session: CheckoutSession) => void;
|
|
1481
|
+
/** Called when the payment is confirmed (before final result) */
|
|
1482
|
+
onConfirmed?: () => void;
|
|
1483
|
+
/** Called when an error occurs */
|
|
1484
|
+
onError?: (error: CheckoutError) => void;
|
|
1485
|
+
/** Appearance overrides */
|
|
1486
|
+
appearance?: Appearance;
|
|
1487
|
+
/** Locale for the checkout UI */
|
|
1488
|
+
locale?: "en" | "ar";
|
|
1489
|
+
}
|
|
1490
|
+
/** Drop-in checkout instance with lifecycle control */
|
|
1491
|
+
interface CheckoutInstance {
|
|
1492
|
+
/** Open the checkout modal (only for `mode: "modal"`) */
|
|
1493
|
+
open(): void;
|
|
1494
|
+
/** Close the checkout UI */
|
|
1495
|
+
close(): void;
|
|
1496
|
+
/** Destroy the checkout instance and clean up resources */
|
|
1497
|
+
destroy(): void;
|
|
1498
|
+
on(event: "complete", handler: (result: CheckoutCompleteResult) => void): void;
|
|
1499
|
+
on(event: "close", handler: () => void): void;
|
|
1500
|
+
on(event: "ready", handler: (session: CheckoutSession) => void): void;
|
|
1501
|
+
on(event: "confirmed", handler: () => void): void;
|
|
1502
|
+
on(event: "error", handler: (error: CheckoutError) => void): void;
|
|
1503
|
+
off(event: string, handler: (...args: unknown[]) => void): void;
|
|
1504
|
+
}
|
|
1505
|
+
/** Result of a successful payment via drop-in checkout */
|
|
1506
|
+
interface CheckoutCompleteResult {
|
|
1507
|
+
status: "succeeded";
|
|
1508
|
+
/**
|
|
1509
|
+
* Whether the money has arrived. `paid` for cards and other instant methods.
|
|
1510
|
+
* `unpaid` when the customer holds a reference they pay afterwards (Fawry): the
|
|
1511
|
+
* checkout is over, but fulfil only on `checkout.session.async_payment_succeeded`.
|
|
1512
|
+
*/
|
|
1513
|
+
paymentStatus: "paid" | "unpaid" | "no_payment_required";
|
|
1514
|
+
/** The payment intent ID for server-side verification */
|
|
1515
|
+
paymentIntentId: string;
|
|
1516
|
+
/** The charge ID (if available) */
|
|
1517
|
+
chargeId?: string;
|
|
1518
|
+
/** Redirect URL from the session's afterCompletion settings */
|
|
1519
|
+
redirectUrl?: string;
|
|
1520
|
+
}
|
|
1521
|
+
/** Error from the drop-in checkout */
|
|
1522
|
+
interface CheckoutError {
|
|
1523
|
+
/** Human-readable error message */
|
|
1524
|
+
message: string;
|
|
1525
|
+
/** Machine-readable error code */
|
|
1526
|
+
code?: string;
|
|
1527
|
+
}
|
|
1528
|
+
/**
|
|
1529
|
+
* Options for `initCheckout()` — the modern single-call API.
|
|
1530
|
+
*
|
|
1531
|
+
* @example
|
|
1532
|
+
* ```ts
|
|
1533
|
+
* const checkout = await xpay.initCheckout({
|
|
1534
|
+
* clientSecret: "cs_test_abc_secret_xyz",
|
|
1535
|
+
* });
|
|
1536
|
+
* console.log(checkout.amountTotal);
|
|
1537
|
+
* await checkout.confirm({ customerDetails: { email: "..." } });
|
|
1538
|
+
* ```
|
|
1539
|
+
*/
|
|
1540
|
+
interface InitCheckoutOptions {
|
|
1541
|
+
/** Client secret from a checkout session (string or Promise) */
|
|
1542
|
+
clientSecret: string | Promise<string>;
|
|
1543
|
+
/** Appearance overrides */
|
|
1544
|
+
appearance?: Appearance;
|
|
1545
|
+
/** Locale for the payment form */
|
|
1546
|
+
locale?: "en" | "ar";
|
|
1547
|
+
}
|
|
1548
|
+
/** Result of `initCheckout()` — session data merged with action methods */
|
|
1549
|
+
type InitCheckoutResult = CheckoutSession & CheckoutActions;
|
|
1550
|
+
/**
|
|
1551
|
+
* Action methods available on the checkout object.
|
|
1552
|
+
* These are merged with `CheckoutSession` to form the `Checkout` type.
|
|
1553
|
+
*/
|
|
1554
|
+
interface CheckoutActions {
|
|
1555
|
+
/**
|
|
1556
|
+
* Confirm the payment.
|
|
1557
|
+
*
|
|
1558
|
+
* @param options - Customer details and redirect behavior
|
|
1559
|
+
* @returns Action result with updated session on success, or an `XPayError`.
|
|
1560
|
+
* With `redirect: "always"`, the page navigates away on success (never returns).
|
|
1561
|
+
*
|
|
1562
|
+
* @example
|
|
1563
|
+
* ```ts
|
|
1564
|
+
* const result = await checkout.confirm({
|
|
1565
|
+
* customerDetails: { email: "user@example.com" },
|
|
1566
|
+
* });
|
|
1567
|
+
* if (result.type === "error") {
|
|
1568
|
+
* console.error(result.error.message);
|
|
1569
|
+
* }
|
|
1570
|
+
* ```
|
|
1571
|
+
*/
|
|
1572
|
+
confirm(options?: Omit<ConfirmPaymentOptions, "elements">): Promise<ActionResult>;
|
|
1573
|
+
/** Apply a promotion code to the session */
|
|
1574
|
+
applyPromotionCode(code: string): Promise<ActionResult>;
|
|
1575
|
+
/** Remove the applied promotion code */
|
|
1576
|
+
removePromotionCode(): Promise<ActionResult>;
|
|
1577
|
+
/** Update a line item's quantity */
|
|
1578
|
+
updateLineItemQuantity(args: {
|
|
1579
|
+
lineItem: string;
|
|
1580
|
+
quantity: number;
|
|
1581
|
+
}): Promise<ActionResult>;
|
|
1582
|
+
/** Validate all fields before confirming — returns the selected payment method on success */
|
|
1583
|
+
submit(): Promise<{
|
|
1584
|
+
error?: XPayError;
|
|
1585
|
+
selectedPaymentMethod?: string;
|
|
1586
|
+
}>;
|
|
1587
|
+
/** Re-fetch the session from the server */
|
|
1588
|
+
fetchUpdates(): Promise<ActionResult>;
|
|
1589
|
+
/** Update the appearance at runtime */
|
|
1590
|
+
changeAppearance(appearance: Appearance): void;
|
|
1591
|
+
/** Listen for session data changes */
|
|
1592
|
+
on(event: "change", handler: (session: CheckoutSession) => void): void;
|
|
1593
|
+
/** Listen for unsolicited errors (e.g. session expired during internal updates) */
|
|
1594
|
+
on(event: "error", handler: (error: XPayError) => void): void;
|
|
1595
|
+
/** Listen for a custom event */
|
|
1596
|
+
on(event: string, handler: (...args: unknown[]) => void): void;
|
|
1597
|
+
/** Access the underlying Elements instance for element creation */
|
|
1598
|
+
getElements(): Elements;
|
|
1599
|
+
}
|
|
1600
|
+
/** Customer details collected by the merchant's form */
|
|
1601
|
+
interface CustomerDetails {
|
|
1602
|
+
/** Customer email address */
|
|
1603
|
+
email?: string;
|
|
1604
|
+
/** Customer full name */
|
|
1605
|
+
name?: string;
|
|
1606
|
+
/** Customer phone number */
|
|
1607
|
+
phone?: string;
|
|
1608
|
+
/** Billing details for the payment */
|
|
1609
|
+
billingDetails?: {
|
|
1610
|
+
name?: string;
|
|
1611
|
+
email?: string;
|
|
1612
|
+
phone?: string;
|
|
1613
|
+
address?: Address;
|
|
1614
|
+
};
|
|
1615
|
+
/** Shipping details */
|
|
1616
|
+
shipping?: {
|
|
1617
|
+
name?: string;
|
|
1618
|
+
phone?: string;
|
|
1619
|
+
address?: Address;
|
|
1620
|
+
};
|
|
1621
|
+
}
|
|
1622
|
+
/** Physical address */
|
|
1623
|
+
interface Address {
|
|
1624
|
+
line1?: string;
|
|
1625
|
+
line2?: string;
|
|
1626
|
+
city?: string;
|
|
1627
|
+
state?: string;
|
|
1628
|
+
postalCode?: string;
|
|
1629
|
+
country?: string;
|
|
1630
|
+
}
|
|
1631
|
+
type XPayFactory = (publishableKey: string) => XPayInstance;
|
|
1632
|
+
declare global {
|
|
1633
|
+
interface Window {
|
|
1634
|
+
XPay?: XPayFactory;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
/**
|
|
1638
|
+
* Load the XPay SDK from CDN.
|
|
1639
|
+
*
|
|
1640
|
+
* Returns a promise that resolves to an XPayInstance with full TypeScript support.
|
|
1641
|
+
* The SDK script is loaded once and cached — subsequent calls return the same instance.
|
|
1642
|
+
*
|
|
1643
|
+
* @param publishableKey - Your publishable API key (pk_test_... or pk_live_...)
|
|
1644
|
+
*
|
|
1645
|
+
* @example
|
|
1646
|
+
* ```typescript
|
|
1647
|
+
* import { loadXPay } from '@xpayeg/sdk';
|
|
1648
|
+
*
|
|
1649
|
+
* const xpay = await loadXPay('pk_test_xxx');
|
|
1650
|
+
* const elements = xpay.elements({ clientSecret: 'cs_test_abc_secret_xyz' });
|
|
1651
|
+
* ```
|
|
1652
|
+
*/
|
|
1653
|
+
export declare function loadXPay(publishableKey: string): Promise<XPayInstance | null>;
|
|
1654
|
+
export type { ActionResult, Address, Appearance, BaseElement, CheckoutActions, CheckoutCompleteResult, CheckoutDiscount, CheckoutError, CheckoutFees, CheckoutInstance, CheckoutLineItem, CheckoutOptions, CheckoutSession, CheckoutTotalDetails, ConfirmPaymentOptions, CustomerDetails, Elements, ElementsLoadErrorEvent, ElementsOptions, ElementsOptionsClientSecret, ElementsOptionsMode, ElementsReadyEvent, ElementsUpdateOptions, InitCheckoutOptions, InitCheckoutResult, PaymentElement, PaymentElementChangeEvent, PaymentElementOptions, PaymentMethodInfo, SessionStatus, XPayError, XPayInstance };
|