@xpayeg/sdk 2.2.0 → 2.4.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @xpayeg/sdk
2
2
 
3
+ ## 2.4.0
4
+ ### Minor Changes
5
+
6
+
7
+
8
+ - [#474](https://github.com/xpayeg/xpay/pull/474) [`c45243c`](https://github.com/xpayeg/xpay/commit/c45243c970b71944482352baea8e8047ba746d8b) Thanks [@Elmosh](https://github.com/Elmosh)! - The Payment Element's `layout` option now works: `elements.create("payment", { layout })`, or the `options` prop on `<PaymentElement />`. `"accordion"` (default) is the vertical list; `"tabs"` is a wrapping tile grid with the selected method's form below it. With exactly one payment method the chooser chrome collapses: the accordion shows a static logo-and-name header above the content (card keeps its bare form), and tabs render the content alone with no logo or title, for pages whose own UI already shows the method's identity, such as a per-gateway row paired with `paymentMethodTypes: ["<type>"]`. Layout is updatable after creation via `element.update({ layout })`, and every method's form stays mounted across switches so typed card details survive.
9
+
10
+ ## 2.3.0
11
+ ### Minor Changes
12
+
13
+
14
+
15
+ - [#471](https://github.com/xpayeg/xpay/pull/471) [`e76a6c3`](https://github.com/xpayeg/xpay/commit/e76a6c3e5f73f4dcf1f108b6be0e1a63dce5d1b9) Thanks [@Elmosh](https://github.com/Elmosh)! - Deferred Elements accept `paymentMethodTypes` (e.g. `["card"]`) to restrict which payment methods the element renders. Narrow-only: the list is intersected with the methods enabled for your account, so a type you have not enabled is never rendered, and an empty intersection fails with `loaderror` instead of rendering an empty frame. Fixed for the element's lifetime; pass the same values when your server creates the session so display and acceptance match. One method per element is the pattern for per-method rows in your own selector.
16
+
3
17
  ## 2.2.0
4
18
  ### Minor Changes
5
19
 
package/dist/index.d.cts CHANGED
@@ -3611,6 +3611,8 @@ interface ElementsOptionsClientSecret {
3611
3611
  amount?: never;
3612
3612
  /** Currency is only applicable in deferred mode (`mode: "payment"`). */
3613
3613
  currency?: never;
3614
+ /** Only applicable in deferred mode. Session-first elements render the session's own payment method types, set when the session is created. */
3615
+ paymentMethodTypes?: never;
3614
3616
  /** Appearance overrides for the checkout UI */
3615
3617
  appearance?: Appearance;
3616
3618
  /** Locale for the payment form — `"en"` (default) or `"ar"` */
@@ -3643,6 +3645,16 @@ interface ElementsOptionsMode {
3643
3645
  amount: number;
3644
3646
  /** Three-letter currency code (e.g. `"EGP"`). */
3645
3647
  currency: string;
3648
+ /**
3649
+ * Restrict which payment method types the element renders (e.g. `["card"]`).
3650
+ * Narrow-only: the list is intersected with the payment methods enabled for
3651
+ * your account, so a type that is not enabled is never rendered. If nothing
3652
+ * survives the intersection the element fails to load with a `loaderror`.
3653
+ * Fixed for the element's lifetime. Omit to render every enabled method.
3654
+ * The same values are passed as `paymentMethodTypes` when your server
3655
+ * creates the session at pay time, so display and acceptance match.
3656
+ */
3657
+ paymentMethodTypes?: string[];
3646
3658
  /** Either use mode or clientSecret when creating an Elements group. */
3647
3659
  clientSecret?: never;
3648
3660
  /** Appearance overrides for the checkout UI */
@@ -3739,7 +3751,23 @@ interface ElementsLoadErrorEvent {
3739
3751
  }
3740
3752
  /** Options for creating a PaymentElement */
3741
3753
  interface PaymentElementOptions {
3742
- /** Layout style for the payment method selector — `"accordion"` (default) or `"tabs"` */
3754
+ /**
3755
+ * How the element presents the payment method chooser.
3756
+ *
3757
+ * - `"accordion"` (default): a vertical list, one row per method, the
3758
+ * selected method's content expanding beneath its row. With exactly one
3759
+ * method the chooser disappears: a single non-card method shows a static
3760
+ * identity header (logo and name, no radio) above its content, while a
3761
+ * single card method renders the bare card form, since its fields
3762
+ * already identify it.
3763
+ * - `"tabs"`: a grid of tiles that fills the row and wraps when the
3764
+ * methods no longer fit, with the selected method's content below it.
3765
+ * With exactly one method the tile grid disappears and
3766
+ * only the content renders, for pages whose own UI already shows the
3767
+ * method's logo and name (e.g. a per-gateway plugin row).
3768
+ *
3769
+ * Updatable after creation via `element.update({ layout })`.
3770
+ */
3743
3771
  layout?: "accordion" | "tabs";
3744
3772
  /** Pre-select a specific payment method by type */
3745
3773
  defaultPaymentMethod?: string;
@@ -3796,12 +3824,19 @@ interface BaseElement {
3796
3824
  on(event: string, handler: (...args: unknown[]) => void): void;
3797
3825
  off(event: string, handler: (...args: unknown[]) => void): void;
3798
3826
  }
3827
+ /**
3828
+ * The subset of `PaymentElementOptions` that can be updated after creation
3829
+ * (Stripe's `StripePaymentElementUpdateOptions` pattern). Only `layout` is
3830
+ * updatable; `defaultPaymentMethod` and `paymentMethodOrder` are set at
3831
+ * creation.
3832
+ */
3833
+ type PaymentElementUpdateOptions = Pick<PaymentElementOptions, "layout">;
3799
3834
  /** PaymentElement — full payment method selector with card form */
3800
3835
  interface PaymentElement extends BaseElement {
3801
3836
  /** Collapse the payment method selector (deselect all methods) */
3802
3837
  collapse(): void;
3803
- /** Update element options at runtime */
3804
- update(options: Partial<PaymentElementOptions>): void;
3838
+ /** Update element options at runtime — see {@link PaymentElementUpdateOptions} */
3839
+ update(options: PaymentElementUpdateOptions): void;
3805
3840
  }
3806
3841
  /**
3807
3842
  * Options for `confirmPayment()` or `checkout.confirm()`.
package/dist/index.d.mts CHANGED
@@ -3611,6 +3611,8 @@ interface ElementsOptionsClientSecret {
3611
3611
  amount?: never;
3612
3612
  /** Currency is only applicable in deferred mode (`mode: "payment"`). */
3613
3613
  currency?: never;
3614
+ /** Only applicable in deferred mode. Session-first elements render the session's own payment method types, set when the session is created. */
3615
+ paymentMethodTypes?: never;
3614
3616
  /** Appearance overrides for the checkout UI */
3615
3617
  appearance?: Appearance;
3616
3618
  /** Locale for the payment form — `"en"` (default) or `"ar"` */
@@ -3643,6 +3645,16 @@ interface ElementsOptionsMode {
3643
3645
  amount: number;
3644
3646
  /** Three-letter currency code (e.g. `"EGP"`). */
3645
3647
  currency: string;
3648
+ /**
3649
+ * Restrict which payment method types the element renders (e.g. `["card"]`).
3650
+ * Narrow-only: the list is intersected with the payment methods enabled for
3651
+ * your account, so a type that is not enabled is never rendered. If nothing
3652
+ * survives the intersection the element fails to load with a `loaderror`.
3653
+ * Fixed for the element's lifetime. Omit to render every enabled method.
3654
+ * The same values are passed as `paymentMethodTypes` when your server
3655
+ * creates the session at pay time, so display and acceptance match.
3656
+ */
3657
+ paymentMethodTypes?: string[];
3646
3658
  /** Either use mode or clientSecret when creating an Elements group. */
3647
3659
  clientSecret?: never;
3648
3660
  /** Appearance overrides for the checkout UI */
@@ -3739,7 +3751,23 @@ interface ElementsLoadErrorEvent {
3739
3751
  }
3740
3752
  /** Options for creating a PaymentElement */
3741
3753
  interface PaymentElementOptions {
3742
- /** Layout style for the payment method selector — `"accordion"` (default) or `"tabs"` */
3754
+ /**
3755
+ * How the element presents the payment method chooser.
3756
+ *
3757
+ * - `"accordion"` (default): a vertical list, one row per method, the
3758
+ * selected method's content expanding beneath its row. With exactly one
3759
+ * method the chooser disappears: a single non-card method shows a static
3760
+ * identity header (logo and name, no radio) above its content, while a
3761
+ * single card method renders the bare card form, since its fields
3762
+ * already identify it.
3763
+ * - `"tabs"`: a grid of tiles that fills the row and wraps when the
3764
+ * methods no longer fit, with the selected method's content below it.
3765
+ * With exactly one method the tile grid disappears and
3766
+ * only the content renders, for pages whose own UI already shows the
3767
+ * method's logo and name (e.g. a per-gateway plugin row).
3768
+ *
3769
+ * Updatable after creation via `element.update({ layout })`.
3770
+ */
3743
3771
  layout?: "accordion" | "tabs";
3744
3772
  /** Pre-select a specific payment method by type */
3745
3773
  defaultPaymentMethod?: string;
@@ -3796,12 +3824,19 @@ interface BaseElement {
3796
3824
  on(event: string, handler: (...args: unknown[]) => void): void;
3797
3825
  off(event: string, handler: (...args: unknown[]) => void): void;
3798
3826
  }
3827
+ /**
3828
+ * The subset of `PaymentElementOptions` that can be updated after creation
3829
+ * (Stripe's `StripePaymentElementUpdateOptions` pattern). Only `layout` is
3830
+ * updatable; `defaultPaymentMethod` and `paymentMethodOrder` are set at
3831
+ * creation.
3832
+ */
3833
+ type PaymentElementUpdateOptions = Pick<PaymentElementOptions, "layout">;
3799
3834
  /** PaymentElement — full payment method selector with card form */
3800
3835
  interface PaymentElement extends BaseElement {
3801
3836
  /** Collapse the payment method selector (deselect all methods) */
3802
3837
  collapse(): void;
3803
- /** Update element options at runtime */
3804
- update(options: Partial<PaymentElementOptions>): void;
3838
+ /** Update element options at runtime — see {@link PaymentElementUpdateOptions} */
3839
+ update(options: PaymentElementUpdateOptions): void;
3805
3840
  }
3806
3841
  /**
3807
3842
  * Options for `confirmPayment()` or `checkout.confirm()`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpayeg/sdk",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "XPay JavaScript SDK — loader and TypeScript types for embedding XPay payments",
5
5
  "license": "MIT",
6
6
  "type": "module",