@xpayeg/sdk 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/README.md +3 -22
- package/dist/index.d.cts +29 -43
- package/dist/index.d.mts +29 -43
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @xpayeg/sdk
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
### Major Changes
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
- [#331](https://github.com/xpayeg/xpay/pull/331) [`bdc6a48`](https://github.com/xpayeg/xpay/commit/bdc6a4865f8c0326a4c0eb3dd20808e1207d682a) Thanks [@Elmosh](https://github.com/Elmosh)! - **Breaking:** `returnUrl` is removed from `confirmPayment()` options. The return destination is always the checkout session's `afterCompletion.redirect.url`, set server-side at session creation.
|
|
9
|
+
|
|
10
|
+
The URL is sent to the bank during authentication, before the browser leaves your page, so a value passed at confirm time could only ever conflict with what the bank already received. Delete `returnUrl` from `confirmPayment()` and set `afterCompletion.redirect.url` on `createSession`. `redirect: "always"` now follows that destination.
|
|
11
|
+
|
|
12
|
+
**Breaking:** `afterCompletion` is now required for `uiMode: "embedded"` and `uiMode: "custom"`, and must be `type: "redirect"`. That URL is where the bank returns when authentication takes over the full page, which happens in in-app browsers where an embedded challenge cannot run. `hosted_confirmation` is rejected for these modes since those integrations run on your own site and there is no XPay page to return to.
|
|
13
|
+
|
|
14
|
+
Also fixed: the 3DS challenge now renders at the size declared to the issuer (previously cropped or oversized), the overlay waits for the issuer's page to paint instead of showing an empty frame, and a challenge that cannot run in an iframe takes over the full tab instead of failing silently.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
- [#333](https://github.com/xpayeg/xpay/pull/333) [`3dcea81`](https://github.com/xpayeg/xpay/commit/3dcea81b3e3f67267624105560c38f2615c35d96) Thanks [@Elmosh](https://github.com/Elmosh)! - Documentation: the `redirect: "always"` tables and examples now state that the destination is the checkout session's `afterCompletion.redirect.url`, set server-side at session creation.
|
|
21
|
+
|
|
22
|
+
## 1.0.1
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
- [#103](https://github.com/xpayeg/xpay/pull/103) [`7402e27`](https://github.com/xpayeg/xpay/commit/7402e27cde482148f126b2073694ef38386ea87a) Thanks [@Elmosh](https://github.com/Elmosh)! - Remove `CardElement` from both SDKs — `PaymentElement` is the only supported element going forward. It handles every payment method (Card, ValU, Fawry, etc.) through one unified UI and renders the appropriate fields based on the customer's choice.
|
|
28
|
+
|
|
29
|
+
This release also republishes both packages through the proper `pnpm publish` flow, which fixes the `workspace:*` protocol leak in 1.0.0's `devDependencies` and `peerDependencies`. `npm install @xpayeg/sdk` and `npm install @xpayeg/react` now work cleanly.
|
|
30
|
+
|
|
31
|
+
**Migration:** replace `elements.create("card")` with `elements.create("payment")`. If you previously rendered `<CardElement>` only when the user selected "Card" from your own picker, switch to `<PaymentElement>` which provides both the picker and the card form together.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// Before
|
|
35
|
+
const cardElement = elements.create("card");
|
|
36
|
+
cardElement.mount("#card");
|
|
37
|
+
|
|
38
|
+
// After
|
|
39
|
+
const paymentElement = elements.create("payment");
|
|
40
|
+
paymentElement.mount("#payment");
|
|
41
|
+
```
|
|
42
|
+
|
|
3
43
|
## 1.0.0
|
|
4
44
|
### Major Changes
|
|
5
45
|
|
package/README.md
CHANGED
|
@@ -189,17 +189,6 @@ paymentElement.on('change', (event) => {
|
|
|
189
189
|
});
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
-
### Card Element (card form only -- you handle method selection)
|
|
193
|
-
|
|
194
|
-
```javascript
|
|
195
|
-
const cardElement = elements.create('card');
|
|
196
|
-
cardElement.mount('#card-form');
|
|
197
|
-
|
|
198
|
-
cardElement.on('change', (event) => {
|
|
199
|
-
console.log(event.complete, event.value.brand);
|
|
200
|
-
});
|
|
201
|
-
```
|
|
202
|
-
|
|
203
192
|
## Step 4: Confirm the Payment
|
|
204
193
|
|
|
205
194
|
`confirm()` returns a tagged union -- check `type` to determine the outcome.
|
|
@@ -242,18 +231,10 @@ await checkout.confirm({
|
|
|
242
231
|
| `redirect` | Behavior |
|
|
243
232
|
|---|---|
|
|
244
233
|
| Not set (default) | `"if_required"` — returns result to your code |
|
|
245
|
-
| `"always"` | Redirects to
|
|
234
|
+
| `"always"` | Redirects to the session's `afterCompletion.redirect.url` |
|
|
246
235
|
| `"if_required"` | Returns result to your code — no redirect |
|
|
247
236
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
```javascript
|
|
251
|
-
await checkout.confirm({
|
|
252
|
-
customerDetails: { email, name },
|
|
253
|
-
redirect: 'always',
|
|
254
|
-
returnUrl: 'https://mysite.com/custom-success', // Overrides server URL
|
|
255
|
-
});
|
|
256
|
-
```
|
|
237
|
+
Your server sets that URL when it creates the session. XPay navigates there unchanged, appending nothing.
|
|
257
238
|
|
|
258
239
|
### Pre-validation with `submit()`
|
|
259
240
|
|
|
@@ -477,7 +458,7 @@ elements.changeAppearance({ colorMode: 'light' });
|
|
|
477
458
|
|
|
478
459
|
## API Reference
|
|
479
460
|
|
|
480
|
-
### `loadXPay(publishableKey
|
|
461
|
+
### `loadXPay(publishableKey)`
|
|
481
462
|
|
|
482
463
|
Loads the XPay SDK from CDN. Returns a Promise. Call at module level, not inside components.
|
|
483
464
|
|
package/dist/index.d.cts
CHANGED
|
@@ -749,7 +749,11 @@ interface ChargeCardDetailsDto {
|
|
|
749
749
|
expYear: number;
|
|
750
750
|
funding: string;
|
|
751
751
|
last4: string;
|
|
752
|
-
|
|
752
|
+
/**
|
|
753
|
+
* Payment rails the transaction rode (e.g. mastercard for a Meeza card). Null until the charge is processed by the gateway.
|
|
754
|
+
* @nullable
|
|
755
|
+
*/
|
|
756
|
+
network: string | null;
|
|
753
757
|
/** Card fingerprint for identifying the same card across customers */
|
|
754
758
|
fingerprint: string;
|
|
755
759
|
threeDSecure: ThreeDSecureDto;
|
|
@@ -1347,6 +1351,16 @@ interface ChargeResponseDto {
|
|
|
1347
1351
|
config: ChargeConfigDto;
|
|
1348
1352
|
geocoding?: ChargeGeocodingDto;
|
|
1349
1353
|
session?: ChargeSessionDto;
|
|
1354
|
+
/**
|
|
1355
|
+
* Origin of the page where this checkout ran — the merchant's site for embedded integrations (SDK Elements / drop-in), or our hosted checkout domain for hosted checkout and payment links. Null for merchant-initiated charges (recurring / MOTO).
|
|
1356
|
+
* @nullable
|
|
1357
|
+
*/
|
|
1358
|
+
merchantOrigin?: string | null;
|
|
1359
|
+
/**
|
|
1360
|
+
* Registrable domain (eTLD+1) derived from merchantOrigin.
|
|
1361
|
+
* @nullable
|
|
1362
|
+
*/
|
|
1363
|
+
merchantDomain?: string | null;
|
|
1350
1364
|
processorCapabilities?: ProcessorCapabilitiesDto;
|
|
1351
1365
|
/**
|
|
1352
1366
|
* ID of the currently-active risk hold on this charge, if any
|
|
@@ -3158,6 +3172,8 @@ interface CheckoutSessionResponseDto {
|
|
|
3158
3172
|
clientSecret?: string;
|
|
3159
3173
|
/** Expiration timestamp (ISO 8601) */
|
|
3160
3174
|
expiresAt?: string;
|
|
3175
|
+
/** Whether this session can no longer be paid because it has expired (either swept/expired by status, or past `expiresAt`). Clients MUST render from this flag and MUST NOT re-derive expiry by comparing `expiresAt` against the local clock — a customer device running fast reads a live session as dead. */
|
|
3176
|
+
isExpired: boolean;
|
|
3161
3177
|
/** Customer ID (when existing customer linked) */
|
|
3162
3178
|
customerId?: string;
|
|
3163
3179
|
/** Customer object (when customerId is provided). Contains existing customer data for prefill. */
|
|
@@ -3406,7 +3422,7 @@ interface XPayError {
|
|
|
3406
3422
|
interface XPayInstance {
|
|
3407
3423
|
/**
|
|
3408
3424
|
* Create an Elements instance for custom checkout UI.
|
|
3409
|
-
* Use with `PaymentElement`
|
|
3425
|
+
* Use with `PaymentElement` to render the payment form.
|
|
3410
3426
|
*
|
|
3411
3427
|
* @param options - Must include `clientSecret` from a checkout session
|
|
3412
3428
|
* @returns An Elements instance for creating and managing payment elements
|
|
@@ -3456,7 +3472,7 @@ interface ElementsOptions {
|
|
|
3456
3472
|
locale?: "en" | "ar";
|
|
3457
3473
|
}
|
|
3458
3474
|
/**
|
|
3459
|
-
* Manages the lifecycle of
|
|
3475
|
+
* Manages the lifecycle of the PaymentElement.
|
|
3460
3476
|
*
|
|
3461
3477
|
* A single Elements instance manages one embed iframe shared by all elements.
|
|
3462
3478
|
* Provides session management methods (promo codes, quantities, etc.) and
|
|
@@ -3465,12 +3481,8 @@ interface ElementsOptions {
|
|
|
3465
3481
|
interface Elements {
|
|
3466
3482
|
/** Create a PaymentElement (full payment method selector + card form) */
|
|
3467
3483
|
create(type: "payment", options?: PaymentElementOptions): PaymentElement;
|
|
3468
|
-
/** Create a CardElement (card form only — merchant handles method selection) */
|
|
3469
|
-
create(type: "card", options?: CardElementOptions): CardElement;
|
|
3470
3484
|
/** Get an existing element by type, or null if not created */
|
|
3471
3485
|
getElement(type: "payment"): PaymentElement | null;
|
|
3472
|
-
/** Get an existing element by type, or null if not created */
|
|
3473
|
-
getElement(type: "card"): CardElement | null;
|
|
3474
3486
|
/** Fetch available payment methods for this session */
|
|
3475
3487
|
fetchPaymentMethods(): Promise<PaymentMethodInfo[]>;
|
|
3476
3488
|
/**
|
|
@@ -3536,11 +3548,6 @@ interface PaymentElementOptions {
|
|
|
3536
3548
|
/** Custom ordering of payment methods by type */
|
|
3537
3549
|
paymentMethodOrder?: string[];
|
|
3538
3550
|
}
|
|
3539
|
-
/** Options for creating a CardElement */
|
|
3540
|
-
interface CardElementOptions {
|
|
3541
|
-
/** Whether to show the cardholder name input */
|
|
3542
|
-
showCardholderName?: boolean;
|
|
3543
|
-
}
|
|
3544
3551
|
/**
|
|
3545
3552
|
* Change event from a PaymentElement.
|
|
3546
3553
|
* Fires on payment method selection, card field changes, and session updates.
|
|
@@ -3570,22 +3577,6 @@ interface PaymentElementChangeEvent {
|
|
|
3570
3577
|
/** Full session data including updated amounts, fees, and discounts */
|
|
3571
3578
|
session: CheckoutSession;
|
|
3572
3579
|
}
|
|
3573
|
-
/**
|
|
3574
|
-
* Change event from a CardElement.
|
|
3575
|
-
* Fires when card fields change (input, validation, completion).
|
|
3576
|
-
*/
|
|
3577
|
-
interface CardElementChangeEvent {
|
|
3578
|
-
elementType: "card";
|
|
3579
|
-
/** Whether all card fields are empty */
|
|
3580
|
-
empty: boolean;
|
|
3581
|
-
/** Whether all card fields are filled and valid */
|
|
3582
|
-
complete: boolean;
|
|
3583
|
-
/** Detected card details (available as user types) */
|
|
3584
|
-
value: {
|
|
3585
|
-
/** Card brand (e.g., "visa", "mastercard") — null until detected */
|
|
3586
|
-
brand: string | null;
|
|
3587
|
-
};
|
|
3588
|
-
}
|
|
3589
3580
|
/** Base interface shared by all element types */
|
|
3590
3581
|
interface BaseElement {
|
|
3591
3582
|
/** Mount the element into a DOM container (CSS selector or HTMLElement) */
|
|
@@ -3614,17 +3605,17 @@ interface PaymentElement extends BaseElement {
|
|
|
3614
3605
|
/** Update element options at runtime */
|
|
3615
3606
|
update(options: Partial<PaymentElementOptions>): void;
|
|
3616
3607
|
}
|
|
3617
|
-
/** CardElement — card-only form (merchant handles payment method selection) */
|
|
3618
|
-
interface CardElement extends BaseElement {
|
|
3619
|
-
/** Update element options at runtime */
|
|
3620
|
-
update(options: Partial<CardElementOptions>): void;
|
|
3621
|
-
}
|
|
3622
3608
|
/**
|
|
3623
3609
|
* Options for `confirmPayment()` or `checkout.confirm()`.
|
|
3624
3610
|
*
|
|
3625
3611
|
* The `redirect` option controls what happens after a successful payment:
|
|
3626
3612
|
* - `"if_required"` (default) — returns the result to your code
|
|
3627
|
-
* - `"always"` — always redirects to
|
|
3613
|
+
* - `"always"` — always redirects to the session's own destination after payment
|
|
3614
|
+
*
|
|
3615
|
+
* The destination is never set here. It is the `afterCompletion.redirect.url` you gave
|
|
3616
|
+
* when creating the checkout session, because the same address is handed to the
|
|
3617
|
+
* customer's bank during verification — before the browser leaves your page. A value
|
|
3618
|
+
* supplied from the page could only ever disagree with what the bank was already told.
|
|
3628
3619
|
*
|
|
3629
3620
|
* @example
|
|
3630
3621
|
* ```ts
|
|
@@ -3633,11 +3624,8 @@ interface CardElement extends BaseElement {
|
|
|
3633
3624
|
* customerDetails: { email: "user@example.com" },
|
|
3634
3625
|
* });
|
|
3635
3626
|
*
|
|
3636
|
-
* // Always redirect after payment
|
|
3637
|
-
* await checkout.confirm({
|
|
3638
|
-
* redirect: "always",
|
|
3639
|
-
* returnUrl: "https://merchant.com/success",
|
|
3640
|
-
* });
|
|
3627
|
+
* // Always redirect to the session's own destination after payment
|
|
3628
|
+
* await checkout.confirm({ redirect: "always" });
|
|
3641
3629
|
* ```
|
|
3642
3630
|
*/
|
|
3643
3631
|
interface ConfirmPaymentOptions {
|
|
@@ -3657,11 +3645,9 @@ interface ConfirmPaymentOptions {
|
|
|
3657
3645
|
/**
|
|
3658
3646
|
* Redirect behavior after payment.
|
|
3659
3647
|
* - `"if_required"` (default) — returns the result to your code; only redirects if the payment method requires it
|
|
3660
|
-
* - `"always"` — always redirects to `
|
|
3648
|
+
* - `"always"` — always redirects to the session's `afterCompletion.redirect.url` after payment. The page navigates away and the function never returns on success.
|
|
3661
3649
|
*/
|
|
3662
3650
|
redirect?: "if_required" | "always";
|
|
3663
|
-
/** URL to redirect to after payment. Overrides the session's `afterCompletion.redirect.url`. Only needed if you want a different URL than the one set server-side. */
|
|
3664
|
-
returnUrl?: string;
|
|
3665
3651
|
}
|
|
3666
3652
|
/**
|
|
3667
3653
|
* Options for creating a drop-in checkout instance.
|
|
@@ -3871,4 +3857,4 @@ declare global {
|
|
|
3871
3857
|
declare function loadXPay(publishableKey: string): Promise<XPayInstance | null>;
|
|
3872
3858
|
|
|
3873
3859
|
export { loadXPay };
|
|
3874
|
-
export type { ActionResult, Address, Appearance, BaseElement,
|
|
3860
|
+
export type { ActionResult, Address, Appearance, BaseElement, CheckoutActions, CheckoutCompleteResult, DiscountResponseDto as CheckoutDiscount, CheckoutError, FeesResponseDto as CheckoutFees, CheckoutInstance, LineItemDto as CheckoutLineItem, CheckoutOptions, CheckoutSession, TotalDetailsResponseDto as CheckoutTotalDetails, ConfirmPaymentOptions, CustomerDetails, Elements, ElementsLoadErrorEvent, ElementsOptions, ElementsReadyEvent, InitCheckoutOptions, InitCheckoutResult, PaymentElement, PaymentElementChangeEvent, PaymentElementOptions, PaymentMethodInfo, SessionStatus, XPayError, XPayInstance };
|
package/dist/index.d.mts
CHANGED
|
@@ -749,7 +749,11 @@ interface ChargeCardDetailsDto {
|
|
|
749
749
|
expYear: number;
|
|
750
750
|
funding: string;
|
|
751
751
|
last4: string;
|
|
752
|
-
|
|
752
|
+
/**
|
|
753
|
+
* Payment rails the transaction rode (e.g. mastercard for a Meeza card). Null until the charge is processed by the gateway.
|
|
754
|
+
* @nullable
|
|
755
|
+
*/
|
|
756
|
+
network: string | null;
|
|
753
757
|
/** Card fingerprint for identifying the same card across customers */
|
|
754
758
|
fingerprint: string;
|
|
755
759
|
threeDSecure: ThreeDSecureDto;
|
|
@@ -1347,6 +1351,16 @@ interface ChargeResponseDto {
|
|
|
1347
1351
|
config: ChargeConfigDto;
|
|
1348
1352
|
geocoding?: ChargeGeocodingDto;
|
|
1349
1353
|
session?: ChargeSessionDto;
|
|
1354
|
+
/**
|
|
1355
|
+
* Origin of the page where this checkout ran — the merchant's site for embedded integrations (SDK Elements / drop-in), or our hosted checkout domain for hosted checkout and payment links. Null for merchant-initiated charges (recurring / MOTO).
|
|
1356
|
+
* @nullable
|
|
1357
|
+
*/
|
|
1358
|
+
merchantOrigin?: string | null;
|
|
1359
|
+
/**
|
|
1360
|
+
* Registrable domain (eTLD+1) derived from merchantOrigin.
|
|
1361
|
+
* @nullable
|
|
1362
|
+
*/
|
|
1363
|
+
merchantDomain?: string | null;
|
|
1350
1364
|
processorCapabilities?: ProcessorCapabilitiesDto;
|
|
1351
1365
|
/**
|
|
1352
1366
|
* ID of the currently-active risk hold on this charge, if any
|
|
@@ -3158,6 +3172,8 @@ interface CheckoutSessionResponseDto {
|
|
|
3158
3172
|
clientSecret?: string;
|
|
3159
3173
|
/** Expiration timestamp (ISO 8601) */
|
|
3160
3174
|
expiresAt?: string;
|
|
3175
|
+
/** Whether this session can no longer be paid because it has expired (either swept/expired by status, or past `expiresAt`). Clients MUST render from this flag and MUST NOT re-derive expiry by comparing `expiresAt` against the local clock — a customer device running fast reads a live session as dead. */
|
|
3176
|
+
isExpired: boolean;
|
|
3161
3177
|
/** Customer ID (when existing customer linked) */
|
|
3162
3178
|
customerId?: string;
|
|
3163
3179
|
/** Customer object (when customerId is provided). Contains existing customer data for prefill. */
|
|
@@ -3406,7 +3422,7 @@ interface XPayError {
|
|
|
3406
3422
|
interface XPayInstance {
|
|
3407
3423
|
/**
|
|
3408
3424
|
* Create an Elements instance for custom checkout UI.
|
|
3409
|
-
* Use with `PaymentElement`
|
|
3425
|
+
* Use with `PaymentElement` to render the payment form.
|
|
3410
3426
|
*
|
|
3411
3427
|
* @param options - Must include `clientSecret` from a checkout session
|
|
3412
3428
|
* @returns An Elements instance for creating and managing payment elements
|
|
@@ -3456,7 +3472,7 @@ interface ElementsOptions {
|
|
|
3456
3472
|
locale?: "en" | "ar";
|
|
3457
3473
|
}
|
|
3458
3474
|
/**
|
|
3459
|
-
* Manages the lifecycle of
|
|
3475
|
+
* Manages the lifecycle of the PaymentElement.
|
|
3460
3476
|
*
|
|
3461
3477
|
* A single Elements instance manages one embed iframe shared by all elements.
|
|
3462
3478
|
* Provides session management methods (promo codes, quantities, etc.) and
|
|
@@ -3465,12 +3481,8 @@ interface ElementsOptions {
|
|
|
3465
3481
|
interface Elements {
|
|
3466
3482
|
/** Create a PaymentElement (full payment method selector + card form) */
|
|
3467
3483
|
create(type: "payment", options?: PaymentElementOptions): PaymentElement;
|
|
3468
|
-
/** Create a CardElement (card form only — merchant handles method selection) */
|
|
3469
|
-
create(type: "card", options?: CardElementOptions): CardElement;
|
|
3470
3484
|
/** Get an existing element by type, or null if not created */
|
|
3471
3485
|
getElement(type: "payment"): PaymentElement | null;
|
|
3472
|
-
/** Get an existing element by type, or null if not created */
|
|
3473
|
-
getElement(type: "card"): CardElement | null;
|
|
3474
3486
|
/** Fetch available payment methods for this session */
|
|
3475
3487
|
fetchPaymentMethods(): Promise<PaymentMethodInfo[]>;
|
|
3476
3488
|
/**
|
|
@@ -3536,11 +3548,6 @@ interface PaymentElementOptions {
|
|
|
3536
3548
|
/** Custom ordering of payment methods by type */
|
|
3537
3549
|
paymentMethodOrder?: string[];
|
|
3538
3550
|
}
|
|
3539
|
-
/** Options for creating a CardElement */
|
|
3540
|
-
interface CardElementOptions {
|
|
3541
|
-
/** Whether to show the cardholder name input */
|
|
3542
|
-
showCardholderName?: boolean;
|
|
3543
|
-
}
|
|
3544
3551
|
/**
|
|
3545
3552
|
* Change event from a PaymentElement.
|
|
3546
3553
|
* Fires on payment method selection, card field changes, and session updates.
|
|
@@ -3570,22 +3577,6 @@ interface PaymentElementChangeEvent {
|
|
|
3570
3577
|
/** Full session data including updated amounts, fees, and discounts */
|
|
3571
3578
|
session: CheckoutSession;
|
|
3572
3579
|
}
|
|
3573
|
-
/**
|
|
3574
|
-
* Change event from a CardElement.
|
|
3575
|
-
* Fires when card fields change (input, validation, completion).
|
|
3576
|
-
*/
|
|
3577
|
-
interface CardElementChangeEvent {
|
|
3578
|
-
elementType: "card";
|
|
3579
|
-
/** Whether all card fields are empty */
|
|
3580
|
-
empty: boolean;
|
|
3581
|
-
/** Whether all card fields are filled and valid */
|
|
3582
|
-
complete: boolean;
|
|
3583
|
-
/** Detected card details (available as user types) */
|
|
3584
|
-
value: {
|
|
3585
|
-
/** Card brand (e.g., "visa", "mastercard") — null until detected */
|
|
3586
|
-
brand: string | null;
|
|
3587
|
-
};
|
|
3588
|
-
}
|
|
3589
3580
|
/** Base interface shared by all element types */
|
|
3590
3581
|
interface BaseElement {
|
|
3591
3582
|
/** Mount the element into a DOM container (CSS selector or HTMLElement) */
|
|
@@ -3614,17 +3605,17 @@ interface PaymentElement extends BaseElement {
|
|
|
3614
3605
|
/** Update element options at runtime */
|
|
3615
3606
|
update(options: Partial<PaymentElementOptions>): void;
|
|
3616
3607
|
}
|
|
3617
|
-
/** CardElement — card-only form (merchant handles payment method selection) */
|
|
3618
|
-
interface CardElement extends BaseElement {
|
|
3619
|
-
/** Update element options at runtime */
|
|
3620
|
-
update(options: Partial<CardElementOptions>): void;
|
|
3621
|
-
}
|
|
3622
3608
|
/**
|
|
3623
3609
|
* Options for `confirmPayment()` or `checkout.confirm()`.
|
|
3624
3610
|
*
|
|
3625
3611
|
* The `redirect` option controls what happens after a successful payment:
|
|
3626
3612
|
* - `"if_required"` (default) — returns the result to your code
|
|
3627
|
-
* - `"always"` — always redirects to
|
|
3613
|
+
* - `"always"` — always redirects to the session's own destination after payment
|
|
3614
|
+
*
|
|
3615
|
+
* The destination is never set here. It is the `afterCompletion.redirect.url` you gave
|
|
3616
|
+
* when creating the checkout session, because the same address is handed to the
|
|
3617
|
+
* customer's bank during verification — before the browser leaves your page. A value
|
|
3618
|
+
* supplied from the page could only ever disagree with what the bank was already told.
|
|
3628
3619
|
*
|
|
3629
3620
|
* @example
|
|
3630
3621
|
* ```ts
|
|
@@ -3633,11 +3624,8 @@ interface CardElement extends BaseElement {
|
|
|
3633
3624
|
* customerDetails: { email: "user@example.com" },
|
|
3634
3625
|
* });
|
|
3635
3626
|
*
|
|
3636
|
-
* // Always redirect after payment
|
|
3637
|
-
* await checkout.confirm({
|
|
3638
|
-
* redirect: "always",
|
|
3639
|
-
* returnUrl: "https://merchant.com/success",
|
|
3640
|
-
* });
|
|
3627
|
+
* // Always redirect to the session's own destination after payment
|
|
3628
|
+
* await checkout.confirm({ redirect: "always" });
|
|
3641
3629
|
* ```
|
|
3642
3630
|
*/
|
|
3643
3631
|
interface ConfirmPaymentOptions {
|
|
@@ -3657,11 +3645,9 @@ interface ConfirmPaymentOptions {
|
|
|
3657
3645
|
/**
|
|
3658
3646
|
* Redirect behavior after payment.
|
|
3659
3647
|
* - `"if_required"` (default) — returns the result to your code; only redirects if the payment method requires it
|
|
3660
|
-
* - `"always"` — always redirects to `
|
|
3648
|
+
* - `"always"` — always redirects to the session's `afterCompletion.redirect.url` after payment. The page navigates away and the function never returns on success.
|
|
3661
3649
|
*/
|
|
3662
3650
|
redirect?: "if_required" | "always";
|
|
3663
|
-
/** URL to redirect to after payment. Overrides the session's `afterCompletion.redirect.url`. Only needed if you want a different URL than the one set server-side. */
|
|
3664
|
-
returnUrl?: string;
|
|
3665
3651
|
}
|
|
3666
3652
|
/**
|
|
3667
3653
|
* Options for creating a drop-in checkout instance.
|
|
@@ -3871,4 +3857,4 @@ declare global {
|
|
|
3871
3857
|
declare function loadXPay(publishableKey: string): Promise<XPayInstance | null>;
|
|
3872
3858
|
|
|
3873
3859
|
export { loadXPay };
|
|
3874
|
-
export type { ActionResult, Address, Appearance, BaseElement,
|
|
3860
|
+
export type { ActionResult, Address, Appearance, BaseElement, CheckoutActions, CheckoutCompleteResult, DiscountResponseDto as CheckoutDiscount, CheckoutError, FeesResponseDto as CheckoutFees, CheckoutInstance, LineItemDto as CheckoutLineItem, CheckoutOptions, CheckoutSession, TotalDetailsResponseDto as CheckoutTotalDetails, ConfirmPaymentOptions, CustomerDetails, Elements, ElementsLoadErrorEvent, ElementsOptions, ElementsReadyEvent, InitCheckoutOptions, InitCheckoutResult, PaymentElement, PaymentElementChangeEvent, PaymentElementOptions, PaymentMethodInfo, SessionStatus, XPayError, XPayInstance };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xpayeg/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "XPay JavaScript SDK — loader and TypeScript types for embedding XPay payments",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,21 +32,16 @@
|
|
|
32
32
|
"CHANGELOG.md",
|
|
33
33
|
"LICENSE"
|
|
34
34
|
],
|
|
35
|
-
"scripts": {
|
|
36
|
-
"build": "tsdown && rollup -c rollup.dts.config.mjs",
|
|
37
|
-
"lint:pkg": "publint && attw --pack .",
|
|
38
|
-
"typecheck": "tsc --noEmit"
|
|
39
|
-
},
|
|
40
35
|
"devDependencies": {
|
|
41
36
|
"@arethetypeswrong/cli": "^0.18.2",
|
|
42
37
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
43
|
-
"@xpay/checkout-api": "workspace:*",
|
|
44
|
-
"@xpay/tsconfig": "workspace:*",
|
|
45
38
|
"publint": "^0.3.21",
|
|
46
39
|
"rollup": "^4.60.4",
|
|
47
40
|
"rollup-plugin-dts": "^6.4.1",
|
|
48
41
|
"tsdown": "^0.22.0",
|
|
49
|
-
"typescript": "
|
|
42
|
+
"typescript": "5.9.3",
|
|
43
|
+
"@xpay/checkout-api": "0.0.0",
|
|
44
|
+
"@xpay/tsconfig": "0.0.0"
|
|
50
45
|
},
|
|
51
46
|
"repository": {
|
|
52
47
|
"type": "git",
|
|
@@ -62,5 +57,10 @@
|
|
|
62
57
|
"egypt",
|
|
63
58
|
"checkout",
|
|
64
59
|
"sdk"
|
|
65
|
-
]
|
|
66
|
-
|
|
60
|
+
],
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsdown && rollup -c rollup.dts.config.mjs",
|
|
63
|
+
"lint:pkg": "publint && attw --pack .",
|
|
64
|
+
"typecheck": "tsc --noEmit"
|
|
65
|
+
}
|
|
66
|
+
}
|