swell-js 5.9.4 → 5.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swell-js",
3
- "version": "5.9.4",
3
+ "version": "5.10.0",
4
4
  "description": "Swell JS library for client-side stores",
5
5
  "engines": {
6
6
  "node": ">=16"
package/types/index.d.cts CHANGED
@@ -147,12 +147,14 @@ declare namespace swell {
147
147
  export type OrderShippingCamel = import('./index.js', { with: { 'resolution-mode': 'import' } }).OrderShippingCamel;
148
148
  export type PaymentCase = import('./index.js', { with: { 'resolution-mode': 'import' } }).PaymentCase;
149
149
  export type InputPaymentElementBase = import('./index.js', { with: { 'resolution-mode': 'import' } }).InputPaymentElementBase;
150
+ export type InputPaymentStripePaymentElement = import('./index.js', { with: { 'resolution-mode': 'import' } }).InputPaymentStripePaymentElement;
150
151
  export type InputPaymentElementCard = import('./index.js', { with: { 'resolution-mode': 'import' } }).InputPaymentElementCard;
151
152
  export type InputPaymentElementIdeal = import('./index.js', { with: { 'resolution-mode': 'import' } }).InputPaymentElementIdeal;
152
153
  export type InputPaymentElementPaypal = import('./index.js', { with: { 'resolution-mode': 'import' } }).InputPaymentElementPaypal;
153
154
  export type InputPaymentElementApple = import('./index.js', { with: { 'resolution-mode': 'import' } }).InputPaymentElementApple;
154
155
  export type InputPaymentElementGoogle = import('./index.js', { with: { 'resolution-mode': 'import' } }).InputPaymentElementGoogle;
155
156
  export type InputPaymentElementSezzle = import('./index.js', { with: { 'resolution-mode': 'import' } }).InputPaymentElementSezzle;
157
+ export type InputPaymentTokenizeCard = import('./index.js', { with: { 'resolution-mode': 'import' } }).InputPaymentTokenizeCard;
156
158
  export type InputPaymentRedirect = import('./index.js', { with: { 'resolution-mode': 'import' } }).InputPaymentRedirect;
157
159
  export type Payment = import('./index.js', { with: { 'resolution-mode': 'import' } }).Payment;
158
160
  export type PaymentCamel = import('./index.js', { with: { 'resolution-mode': 'import' } }).PaymentCamel;
package/types/index.d.ts CHANGED
@@ -41,6 +41,7 @@ import type {
41
41
  InputPaymentElementApple,
42
42
  InputPaymentElementSezzle,
43
43
  InputPaymentRedirect,
44
+ InputPaymentTokenizeCard,
44
45
  PaymentCase,
45
46
  } from './payment/index.js';
46
47
 
@@ -376,24 +377,36 @@ export interface SwellClient<C extends 'snake' | 'camel' = 'snake'> {
376
377
  }): Promise<void>;
377
378
 
378
379
  tokenize(input?: {
379
- card?: object;
380
+ card?: InputPaymentTokenizeCard;
381
+ /** Without `createElements` iDEAL needs no element: the shopper picks the bank on the iDEAL page */
380
382
  ideal?: object;
381
383
  klarna?: object;
382
384
  bancontact?: object;
383
385
  paysafecard?: object;
384
386
  amazon?: object;
387
+ /** Saferpay payment page; has no element, `tokenize` redirects */
388
+ twint?: InputPaymentRedirect;
385
389
  }): Promise<void>;
386
390
 
387
391
  handleRedirect(input?: {
388
392
  card?: InputPaymentRedirect;
393
+ ideal?: InputPaymentRedirect;
389
394
  paysafecard?: InputPaymentRedirect;
390
395
  klarna?: InputPaymentRedirect;
391
396
  bancontact?: InputPaymentRedirect;
397
+ amazon?: InputPaymentRedirect;
398
+ twint?: InputPaymentRedirect;
392
399
  }): Promise<void>;
393
400
 
394
401
  authenticate(id: string): Promise<object | { error: Error }>;
395
402
  resetAsyncPayment(id: string): Promise<object>;
396
403
 
404
+ /**
405
+ * Redirects to the gateway when a submitted order waits for an
406
+ * asynchronous payment; resolves `true` after starting the redirect
407
+ */
408
+ handleAsyncRedirect(order: object): Promise<boolean>;
409
+
397
410
  createIntent(input: { gateway: string; intent: object }): Promise<object>;
398
411
 
399
412
  updateIntent(input: { gateway: string; intent: object }): Promise<object>;
@@ -27,8 +27,28 @@ export interface InputPaymentElementBase {
27
27
  onError?: (error: Error) => void;
28
28
  }
29
29
 
30
- export interface InputPaymentElementCard extends InputPaymentElementBase {
31
- /** @see {@link https://docs.stripe.com/js/elements_object/create_element?type=card#elements_create-options} */
30
+ /**
31
+ * Stripe: draw the form with the Payment Element instead of the split elements.
32
+ * The element mounts into `#payment-element` unless `elementId` is set.
33
+ */
34
+ export interface InputPaymentStripePaymentElement {
35
+ paymentElement?: boolean;
36
+ /**
37
+ * Payment Element only: Stripe Appearance API object (`theme`, `variables`, `rules`, `labels`).
38
+ *
39
+ * @see {@link https://docs.stripe.com/elements/appearance-api}
40
+ */
41
+ appearance?: Record<string, unknown>;
42
+ }
43
+
44
+ export interface InputPaymentElementCard
45
+ extends InputPaymentElementBase,
46
+ InputPaymentStripePaymentElement {
47
+ /**
48
+ * Split elements: {@link https://docs.stripe.com/js/elements_object/create_element?type=card#elements_create-options}.
49
+ * Payment Element: {@link https://docs.stripe.com/js/elements_object/create_payment_element#payment_element_create-options},
50
+ * merged over `{ layout: 'tabs', fields: { billingDetails: 'never' }, wallets: { applePay: 'never', googlePay: 'never' } }`.
51
+ */
32
52
  options?: object;
33
53
  separateElements?: boolean;
34
54
  cardNumber?: {
@@ -47,9 +67,13 @@ export interface InputPaymentElementCard extends InputPaymentElementBase {
47
67
  };
48
68
  }
49
69
 
50
- export interface InputPaymentElementIdeal extends InputPaymentElementBase {
70
+ export interface InputPaymentElementIdeal
71
+ extends InputPaymentElementBase,
72
+ InputPaymentStripePaymentElement {
73
+ /** Payment Element: the same options and defaults as the card one */
51
74
  options?: {
52
75
  style?: unknown;
76
+ [key: string]: unknown;
53
77
  };
54
78
  }
55
79
 
@@ -127,6 +151,21 @@ export interface InputPaymentElementSezzle extends InputPaymentElementBase {
127
151
  };
128
152
  }
129
153
 
154
+ export interface InputPaymentTokenizeCard
155
+ extends InputPaymentRedirect,
156
+ Pick<InputPaymentStripePaymentElement, 'paymentElement'> {
157
+ /** Stripe: `false` stores the card without a payment intent (default `true`) */
158
+ createIntent?: boolean;
159
+ /**
160
+ * Stripe: the `pm_` id of a card the shopper already has (a saved card, a
161
+ * wallet's payment method), authorized with an intent and 3-D Secure instead
162
+ * of an element's card
163
+ */
164
+ paymentMethod?: string;
165
+ /** Saferpay: register a new card even when the cart already has one */
166
+ replace?: boolean;
167
+ }
168
+
130
169
  export interface InputPaymentRedirect {
131
170
  /** @optional called on card payment success */
132
171
  onSuccess?: (event: unknown) => void;