@sunbay/checkout-sdk-js 0.1.0 → 0.2.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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { ElementType, CommandName, EventName, ElementOptions, Appearance, ElementStatus, AvailableWallets, EventPayloadMap, PublicSessionView, WarningEvent, ConfirmReq, PaymentOutcome, GetPaymentStatusResp, AddressInfo, PaymentMethodFilter } from '@sunbay/checkout-sdk-protocol';
2
- export { AddressElementOptions, AddressFormStyle, AddressInfo, Appearance, AppearanceRuleStyle, AppearanceRuleTarget, AppearanceVariables, ApplePayButtonTheme, ApplePayButtonType, ApplePayOptions, AvailableWallets, BlurEvent, CardElementOptions, CardFieldElementOptions, ChangeEvent, CheckoutError, CheckoutErrorCategory, ElementOptions, ElementReadyEvent, ElementStatus, ElementType, ErrorCode, ErrorCodeValue, ErrorEvent, EventName, EventPayloadMap, ExpressAvailabilityChangeEvent, ExpressCheckoutElementOptions, FocusEvent, GooglePayButtonTheme, GooglePayButtonType, GooglePayOptions, LoadErrorEvent, PaymentAction, PaymentMethod, PaymentMethodFilter, PaymentOutcome, PaymentResultEvent, PaymentStateChangeEvent, PublicPaymentMethod, PublicProductLine, PublicSessionView, ReadyEvent, SessionStatus, TxnStatus, WARNING_CODES, WalletErrorStage, WarningCode, WarningEvent } from '@sunbay/checkout-sdk-protocol';
1
+ import { ElementType, CommandName, EventName, ElementOptions, Appearance, ElementStatus, AvailableWallets, ElementState, EventPayloadMap, PublicSessionView, WarningEvent, ConfirmReq, PaymentOutcome, PaymentMethodsView, GetPaymentStatusResp, AddressInfo, PaymentMethodFilter } from '@sunbay/checkout-sdk-protocol';
2
+ export { AddressElementOptions, AddressFormStyle, AddressInfo, Appearance, AppearanceRuleStyle, AppearanceRuleTarget, AppearanceVariables, ApplePayButtonTheme, ApplePayButtonType, ApplePayOptions, AvailableWallets, BlurEvent, CardElementOptions, CardFieldElementOptions, ChangeEvent, CheckoutError, CheckoutErrorCategory, ElementOptions, ElementReadyEvent, ElementState, ElementStatus, ElementType, ErrorCode, ErrorCodeValue, ErrorEvent, EventName, EventPayloadMap, ExpressAvailabilityChangeEvent, ExpressCheckoutElementOptions, ExpressMethodView, FocusEvent, GooglePayButtonTheme, GooglePayButtonType, GooglePayOptions, LoadErrorEvent, PaymentAction, PaymentMethod, PaymentMethodFilter, PaymentMethodsView, PaymentOutcome, PaymentResultEvent, PaymentStateChangeEvent, PublicPaymentMethod, PublicProductLine, PublicSessionView, ReadyEvent, SessionStatus, TxnStatus, WARNING_CODES, WalletErrorStage, WarningCode, WarningEvent } from '@sunbay/checkout-sdk-protocol';
3
3
 
4
4
  /**
5
5
  * CheckoutElement — the merchant-side Element handle (spec 6).
@@ -73,6 +73,13 @@ interface CheckoutElementOptions {
73
73
  * `&colorScheme=`. Runtime switching goes through the updateCheckout command, not here.
74
74
  */
75
75
  appearance?: Appearance;
76
+ /**
77
+ * Initial locale (from createCheckout's `locale`). When provided and non-empty it is appended
78
+ * to the iframe src as `&locale=<value>`, so the hosted iframe renders in that language on the
79
+ * first frame (no flash). The hosted side resolves it to a supported language and ignores
80
+ * unknown values. Runtime switching goes through the updateCheckout command, not here.
81
+ */
82
+ locale?: string;
76
83
  }
77
84
  /** Options for {@link CheckoutElement.mount}. */
78
85
  interface MountOptions {
@@ -98,6 +105,8 @@ declare class CheckoutElement {
98
105
  private readonly colorScheme;
99
106
  /** Initial appearance customization (appended to the iframe src when it contains variables/rules; not appended when absent or colorScheme-only). */
100
107
  private readonly appearance;
108
+ /** Initial locale (appended to the iframe src; not appended when absent or empty). */
109
+ private readonly locale;
101
110
  /** Destruction callback (injected by the instance): called at the end of destroy() so the instance removes itself from the mutual-exclusion registry to free the slot. */
102
111
  private readonly onDestroy;
103
112
  private status;
@@ -118,6 +127,10 @@ declare class CheckoutElement {
118
127
  private availableWallets;
119
128
  /** expressCheckout only: the persistently subscribed expressAvailabilityChange handler (unbound on destroy). */
120
129
  private availabilityHandler;
130
+ /** Input Elements only: the last `change` snapshot, tracked from construction (never replayed to `on`). */
131
+ private state;
132
+ /** Input Elements only: the persistently subscribed `change` handler (unbound on destroy). */
133
+ private stateHandler;
121
134
  /** Merchant listeners registered via `on`: event → (original handler → transport wrapper). Cleared on destroy. */
122
135
  private readonly userListeners;
123
136
  /**
@@ -141,6 +154,16 @@ declare class CheckoutElement {
141
154
  * @returns The availability snapshot; undefined when not yet ready or non-express.
142
155
  */
143
156
  getAvailableWallets(): AvailableWallets | undefined;
157
+ /**
158
+ * Input Elements only: the last known `change` state (`empty`, `complete`, `brand?`, `error?`).
159
+ *
160
+ * `change` events are not replayed, so a handler registered after `mount()` resolves can miss
161
+ * changes (e.g. browser autofill). Read this to get the current value instead; it is tracked from
162
+ * construction. Starts as `{ empty: true, complete: false }`. Never contains values.
163
+ *
164
+ * @returns A copy of the snapshot; undefined for `expressCheckout`. Still readable after destroy.
165
+ */
166
+ getState(): ElementState | undefined;
144
167
  /**
145
168
  * Mount at the merchant DOM target: insert a visible iframe, send createElement, await elementReady.
146
169
  *
@@ -209,6 +232,8 @@ declare class CheckoutElement {
209
232
  * so there is no need to filter by elementId. Non-express types do not subscribe.
210
233
  */
211
234
  private installExpressAvailability;
235
+ /** Input Elements only: keep the `change` snapshot current so `getState()` works without a listener. */
236
+ private installInputState;
212
237
  /** Send one input-class action command (synchronously throws INSTANCE_DESTROYED after destruction). */
213
238
  private sendAction;
214
239
  /** Throw INSTANCE_DESTROYED if already destroyed. */
@@ -221,7 +246,8 @@ declare class CheckoutElement {
221
246
  * (no flash on the first frame); if the initial appearance contains variables or rules, append
222
247
  * `&appearance=<encodeURIComponent(JSON.stringify(appearance))>` (takes effect on the first
223
248
  * frame, no flash). An appearance containing only colorScheme (no variables/rules) is not
224
- * appended, to avoid an empty appearance string. For expressCheckout, additionally append the
249
+ * appended, to avoid an empty appearance string. If an initial locale is provided, append
250
+ * `&locale=<value>` (first frame renders in that language). For expressCheckout, additionally append the
225
251
  * wallet toggles / per-wallet buttonType / global buttonHeight (see {@link resolveExpressQuery}).
226
252
  *
227
253
  * elementId is sent with the src so the hosted child echoes it verbatim in iframe-resize
@@ -332,6 +358,11 @@ interface CheckoutInstanceOptions {
332
358
  * Not appended when absent. Runtime switching goes through the updateCheckout command.
333
359
  */
334
360
  appearance?: Appearance;
361
+ /**
362
+ * Initial locale (from createCheckout's `locale`). Passed through to every created Element and
363
+ * appended to its iframe src as `&locale=`, so the first frame renders in that language.
364
+ */
365
+ locale?: string;
335
366
  }
336
367
  /**
337
368
  * Optional confirm parameters (aligned with ConfirmReq, minus the instance-generated operationId,
@@ -362,6 +393,8 @@ declare class CheckoutInstance {
362
393
  private session;
363
394
  /** Initial appearance customization (passed through to each created Element's iframe src). */
364
395
  private readonly appearance;
396
+ /** Initial locale (passed through to each created Element's iframe src). */
397
+ private readonly locale;
365
398
  /** Created Elements (indexed by elementId). */
366
399
  /**
367
400
  * The **single source of truth** for the mutual-exclusion registry: elementId → the created
@@ -434,6 +467,17 @@ declare class CheckoutInstance {
434
467
  * @throws rejects INSTANCE_DESTROYED when destroyed.
435
468
  */
436
469
  getSession(): Promise<PublicSessionView>;
470
+ /**
471
+ * The session's payment methods split into quick wallets (`express`) and everything else
472
+ * (`regular`), from the local session snapshot (already filtered by `paymentMethods`).
473
+ *
474
+ * Each express entry carries `available` from the `expressCheckout` Element's availability
475
+ * snapshot; it is `undefined` while no such Element exists or it has not reported yet.
476
+ *
477
+ * @returns The split view.
478
+ * @throws INSTANCE_DESTROYED when destroyed.
479
+ */
480
+ getPaymentMethods(): PaymentMethodsView;
437
481
  /**
438
482
  * Refresh the session (passes through the refresh command and writes back the local snapshot).
439
483
  *
@@ -546,7 +590,11 @@ interface CreateCheckoutOptions {
546
590
  env?: Env;
547
591
  /** Override the hosted origin (takes precedence over env). */
548
592
  hostOrigin?: string;
549
- /** Locale. */
593
+ /**
594
+ * Initial locale, e.g. `'en-US'` or `'zh-CN'`. Sent to the runtime and appended to every
595
+ * Element iframe src, so the first frame renders in that language. Unknown values fall back to
596
+ * the browser language. Change it later with `updateCheckout({ locale })`.
597
+ */
550
598
  locale?: string;
551
599
  /** Appearance customization. */
552
600
  appearance?: Appearance;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ElementType, CommandName, EventName, ElementOptions, Appearance, ElementStatus, AvailableWallets, EventPayloadMap, PublicSessionView, WarningEvent, ConfirmReq, PaymentOutcome, GetPaymentStatusResp, AddressInfo, PaymentMethodFilter } from '@sunbay/checkout-sdk-protocol';
2
- export { AddressElementOptions, AddressFormStyle, AddressInfo, Appearance, AppearanceRuleStyle, AppearanceRuleTarget, AppearanceVariables, ApplePayButtonTheme, ApplePayButtonType, ApplePayOptions, AvailableWallets, BlurEvent, CardElementOptions, CardFieldElementOptions, ChangeEvent, CheckoutError, CheckoutErrorCategory, ElementOptions, ElementReadyEvent, ElementStatus, ElementType, ErrorCode, ErrorCodeValue, ErrorEvent, EventName, EventPayloadMap, ExpressAvailabilityChangeEvent, ExpressCheckoutElementOptions, FocusEvent, GooglePayButtonTheme, GooglePayButtonType, GooglePayOptions, LoadErrorEvent, PaymentAction, PaymentMethod, PaymentMethodFilter, PaymentOutcome, PaymentResultEvent, PaymentStateChangeEvent, PublicPaymentMethod, PublicProductLine, PublicSessionView, ReadyEvent, SessionStatus, TxnStatus, WARNING_CODES, WalletErrorStage, WarningCode, WarningEvent } from '@sunbay/checkout-sdk-protocol';
1
+ import { ElementType, CommandName, EventName, ElementOptions, Appearance, ElementStatus, AvailableWallets, ElementState, EventPayloadMap, PublicSessionView, WarningEvent, ConfirmReq, PaymentOutcome, PaymentMethodsView, GetPaymentStatusResp, AddressInfo, PaymentMethodFilter } from '@sunbay/checkout-sdk-protocol';
2
+ export { AddressElementOptions, AddressFormStyle, AddressInfo, Appearance, AppearanceRuleStyle, AppearanceRuleTarget, AppearanceVariables, ApplePayButtonTheme, ApplePayButtonType, ApplePayOptions, AvailableWallets, BlurEvent, CardElementOptions, CardFieldElementOptions, ChangeEvent, CheckoutError, CheckoutErrorCategory, ElementOptions, ElementReadyEvent, ElementState, ElementStatus, ElementType, ErrorCode, ErrorCodeValue, ErrorEvent, EventName, EventPayloadMap, ExpressAvailabilityChangeEvent, ExpressCheckoutElementOptions, ExpressMethodView, FocusEvent, GooglePayButtonTheme, GooglePayButtonType, GooglePayOptions, LoadErrorEvent, PaymentAction, PaymentMethod, PaymentMethodFilter, PaymentMethodsView, PaymentOutcome, PaymentResultEvent, PaymentStateChangeEvent, PublicPaymentMethod, PublicProductLine, PublicSessionView, ReadyEvent, SessionStatus, TxnStatus, WARNING_CODES, WalletErrorStage, WarningCode, WarningEvent } from '@sunbay/checkout-sdk-protocol';
3
3
 
4
4
  /**
5
5
  * CheckoutElement — the merchant-side Element handle (spec 6).
@@ -73,6 +73,13 @@ interface CheckoutElementOptions {
73
73
  * `&colorScheme=`. Runtime switching goes through the updateCheckout command, not here.
74
74
  */
75
75
  appearance?: Appearance;
76
+ /**
77
+ * Initial locale (from createCheckout's `locale`). When provided and non-empty it is appended
78
+ * to the iframe src as `&locale=<value>`, so the hosted iframe renders in that language on the
79
+ * first frame (no flash). The hosted side resolves it to a supported language and ignores
80
+ * unknown values. Runtime switching goes through the updateCheckout command, not here.
81
+ */
82
+ locale?: string;
76
83
  }
77
84
  /** Options for {@link CheckoutElement.mount}. */
78
85
  interface MountOptions {
@@ -98,6 +105,8 @@ declare class CheckoutElement {
98
105
  private readonly colorScheme;
99
106
  /** Initial appearance customization (appended to the iframe src when it contains variables/rules; not appended when absent or colorScheme-only). */
100
107
  private readonly appearance;
108
+ /** Initial locale (appended to the iframe src; not appended when absent or empty). */
109
+ private readonly locale;
101
110
  /** Destruction callback (injected by the instance): called at the end of destroy() so the instance removes itself from the mutual-exclusion registry to free the slot. */
102
111
  private readonly onDestroy;
103
112
  private status;
@@ -118,6 +127,10 @@ declare class CheckoutElement {
118
127
  private availableWallets;
119
128
  /** expressCheckout only: the persistently subscribed expressAvailabilityChange handler (unbound on destroy). */
120
129
  private availabilityHandler;
130
+ /** Input Elements only: the last `change` snapshot, tracked from construction (never replayed to `on`). */
131
+ private state;
132
+ /** Input Elements only: the persistently subscribed `change` handler (unbound on destroy). */
133
+ private stateHandler;
121
134
  /** Merchant listeners registered via `on`: event → (original handler → transport wrapper). Cleared on destroy. */
122
135
  private readonly userListeners;
123
136
  /**
@@ -141,6 +154,16 @@ declare class CheckoutElement {
141
154
  * @returns The availability snapshot; undefined when not yet ready or non-express.
142
155
  */
143
156
  getAvailableWallets(): AvailableWallets | undefined;
157
+ /**
158
+ * Input Elements only: the last known `change` state (`empty`, `complete`, `brand?`, `error?`).
159
+ *
160
+ * `change` events are not replayed, so a handler registered after `mount()` resolves can miss
161
+ * changes (e.g. browser autofill). Read this to get the current value instead; it is tracked from
162
+ * construction. Starts as `{ empty: true, complete: false }`. Never contains values.
163
+ *
164
+ * @returns A copy of the snapshot; undefined for `expressCheckout`. Still readable after destroy.
165
+ */
166
+ getState(): ElementState | undefined;
144
167
  /**
145
168
  * Mount at the merchant DOM target: insert a visible iframe, send createElement, await elementReady.
146
169
  *
@@ -209,6 +232,8 @@ declare class CheckoutElement {
209
232
  * so there is no need to filter by elementId. Non-express types do not subscribe.
210
233
  */
211
234
  private installExpressAvailability;
235
+ /** Input Elements only: keep the `change` snapshot current so `getState()` works without a listener. */
236
+ private installInputState;
212
237
  /** Send one input-class action command (synchronously throws INSTANCE_DESTROYED after destruction). */
213
238
  private sendAction;
214
239
  /** Throw INSTANCE_DESTROYED if already destroyed. */
@@ -221,7 +246,8 @@ declare class CheckoutElement {
221
246
  * (no flash on the first frame); if the initial appearance contains variables or rules, append
222
247
  * `&appearance=<encodeURIComponent(JSON.stringify(appearance))>` (takes effect on the first
223
248
  * frame, no flash). An appearance containing only colorScheme (no variables/rules) is not
224
- * appended, to avoid an empty appearance string. For expressCheckout, additionally append the
249
+ * appended, to avoid an empty appearance string. If an initial locale is provided, append
250
+ * `&locale=<value>` (first frame renders in that language). For expressCheckout, additionally append the
225
251
  * wallet toggles / per-wallet buttonType / global buttonHeight (see {@link resolveExpressQuery}).
226
252
  *
227
253
  * elementId is sent with the src so the hosted child echoes it verbatim in iframe-resize
@@ -332,6 +358,11 @@ interface CheckoutInstanceOptions {
332
358
  * Not appended when absent. Runtime switching goes through the updateCheckout command.
333
359
  */
334
360
  appearance?: Appearance;
361
+ /**
362
+ * Initial locale (from createCheckout's `locale`). Passed through to every created Element and
363
+ * appended to its iframe src as `&locale=`, so the first frame renders in that language.
364
+ */
365
+ locale?: string;
335
366
  }
336
367
  /**
337
368
  * Optional confirm parameters (aligned with ConfirmReq, minus the instance-generated operationId,
@@ -362,6 +393,8 @@ declare class CheckoutInstance {
362
393
  private session;
363
394
  /** Initial appearance customization (passed through to each created Element's iframe src). */
364
395
  private readonly appearance;
396
+ /** Initial locale (passed through to each created Element's iframe src). */
397
+ private readonly locale;
365
398
  /** Created Elements (indexed by elementId). */
366
399
  /**
367
400
  * The **single source of truth** for the mutual-exclusion registry: elementId → the created
@@ -434,6 +467,17 @@ declare class CheckoutInstance {
434
467
  * @throws rejects INSTANCE_DESTROYED when destroyed.
435
468
  */
436
469
  getSession(): Promise<PublicSessionView>;
470
+ /**
471
+ * The session's payment methods split into quick wallets (`express`) and everything else
472
+ * (`regular`), from the local session snapshot (already filtered by `paymentMethods`).
473
+ *
474
+ * Each express entry carries `available` from the `expressCheckout` Element's availability
475
+ * snapshot; it is `undefined` while no such Element exists or it has not reported yet.
476
+ *
477
+ * @returns The split view.
478
+ * @throws INSTANCE_DESTROYED when destroyed.
479
+ */
480
+ getPaymentMethods(): PaymentMethodsView;
437
481
  /**
438
482
  * Refresh the session (passes through the refresh command and writes back the local snapshot).
439
483
  *
@@ -546,7 +590,11 @@ interface CreateCheckoutOptions {
546
590
  env?: Env;
547
591
  /** Override the hosted origin (takes precedence over env). */
548
592
  hostOrigin?: string;
549
- /** Locale. */
593
+ /**
594
+ * Initial locale, e.g. `'en-US'` or `'zh-CN'`. Sent to the runtime and appended to every
595
+ * Element iframe src, so the first frame renders in that language. Unknown values fall back to
596
+ * the browser language. Change it later with `updateCheckout({ locale })`.
597
+ */
550
598
  locale?: string;
551
599
  /** Appearance customization. */
552
600
  appearance?: Appearance;
@@ -564,6 +564,10 @@ var SunbayCheckout = (() => {
564
564
  this.abortMount = null;
565
565
  /** expressCheckout only: the persistently subscribed expressAvailabilityChange handler (unbound on destroy). */
566
566
  this.availabilityHandler = null;
567
+ /** Input Elements only: the last `change` snapshot, tracked from construction (never replayed to `on`). */
568
+ this.state = { empty: true, complete: false };
569
+ /** Input Elements only: the persistently subscribed `change` handler (unbound on destroy). */
570
+ this.stateHandler = null;
567
571
  /** Merchant listeners registered via `on`: event → (original handler → transport wrapper). Cleared on destroy. */
568
572
  this.userListeners = /* @__PURE__ */ new Map();
569
573
  /**
@@ -582,10 +586,12 @@ var SunbayCheckout = (() => {
582
586
  this.options = opts.initialOptions;
583
587
  this.colorScheme = opts.colorScheme;
584
588
  this.appearance = opts.appearance;
589
+ this.locale = opts.locale;
585
590
  this.mode = opts.initialOptions?.mode;
586
591
  this.onDestroy = opts.onDestroy;
587
592
  this.installInputActions();
588
593
  this.installExpressAvailability();
594
+ this.installInputState();
589
595
  }
590
596
  /** The current status (read-only snapshot, for external/test observation). */
591
597
  getStatus() {
@@ -603,6 +609,21 @@ var SunbayCheckout = (() => {
603
609
  getAvailableWallets() {
604
610
  return this.availableWallets;
605
611
  }
612
+ /**
613
+ * Input Elements only: the last known `change` state (`empty`, `complete`, `brand?`, `error?`).
614
+ *
615
+ * `change` events are not replayed, so a handler registered after `mount()` resolves can miss
616
+ * changes (e.g. browser autofill). Read this to get the current value instead; it is tracked from
617
+ * construction. Starts as `{ empty: true, complete: false }`. Never contains values.
618
+ *
619
+ * @returns A copy of the snapshot; undefined for `expressCheckout`. Still readable after destroy.
620
+ */
621
+ getState() {
622
+ if (!INPUT_TYPES.includes(this.type)) {
623
+ return void 0;
624
+ }
625
+ return { ...this.state };
626
+ }
606
627
  /**
607
628
  * Mount at the merchant DOM target: insert a visible iframe, send createElement, await elementReady.
608
629
  *
@@ -819,6 +840,10 @@ var SunbayCheckout = (() => {
819
840
  this.transport.off("expressAvailabilityChange", this.availabilityHandler);
820
841
  this.availabilityHandler = null;
821
842
  }
843
+ if (this.stateHandler) {
844
+ this.transport.off("change", this.stateHandler);
845
+ this.stateHandler = null;
846
+ }
822
847
  for (const [event, wrappers] of this.userListeners) {
823
848
  for (const wrapper of wrappers.values()) {
824
849
  this.transport.off(event, wrapper);
@@ -930,6 +955,31 @@ var SunbayCheckout = (() => {
930
955
  this.availabilityHandler = handler;
931
956
  this.transport.on("expressAvailabilityChange", handler);
932
957
  }
958
+ /** Input Elements only: keep the `change` snapshot current so `getState()` works without a listener. */
959
+ installInputState() {
960
+ if (!INPUT_TYPES.includes(this.type)) {
961
+ return;
962
+ }
963
+ const handler = (payload) => {
964
+ const change = payload;
965
+ if (!change || change.elementId !== this.elementId) {
966
+ return;
967
+ }
968
+ const next = {
969
+ empty: change.empty === true,
970
+ complete: change.complete === true
971
+ };
972
+ if (change.brand !== void 0) {
973
+ next.brand = change.brand;
974
+ }
975
+ if (change.error !== void 0) {
976
+ next.error = change.error;
977
+ }
978
+ this.state = next;
979
+ };
980
+ this.stateHandler = handler;
981
+ this.transport.on("change", handler);
982
+ }
933
983
  /** Send one input-class action command (synchronously throws INSTANCE_DESTROYED after destruction). */
934
984
  sendAction(name) {
935
985
  this.assertAlive();
@@ -959,7 +1009,8 @@ var SunbayCheckout = (() => {
959
1009
  * (no flash on the first frame); if the initial appearance contains variables or rules, append
960
1010
  * `&appearance=<encodeURIComponent(JSON.stringify(appearance))>` (takes effect on the first
961
1011
  * frame, no flash). An appearance containing only colorScheme (no variables/rules) is not
962
- * appended, to avoid an empty appearance string. For expressCheckout, additionally append the
1012
+ * appended, to avoid an empty appearance string. If an initial locale is provided, append
1013
+ * `&locale=<value>` (first frame renders in that language). For expressCheckout, additionally append the
963
1014
  * wallet toggles / per-wallet buttonType / global buttonHeight (see {@link resolveExpressQuery}).
964
1015
  *
965
1016
  * elementId is sent with the src so the hosted child echoes it verbatim in iframe-resize
@@ -982,6 +1033,9 @@ var SunbayCheckout = (() => {
982
1033
  if (this.colorScheme) {
983
1034
  query += `&colorScheme=${encodeURIComponent(this.colorScheme)}`;
984
1035
  }
1036
+ if (this.locale) {
1037
+ query += `&locale=${encodeURIComponent(this.locale)}`;
1038
+ }
985
1039
  const effectiveAppearance = this.perElementAppearance() ?? this.appearance;
986
1040
  if (effectiveAppearance && (effectiveAppearance.variables || effectiveAppearance.rules)) {
987
1041
  query += `&appearance=${encodeURIComponent(JSON.stringify(effectiveAppearance))}`;
@@ -1134,6 +1188,7 @@ var SunbayCheckout = (() => {
1134
1188
  this.transport = opts.transport;
1135
1189
  this.session = opts.session;
1136
1190
  this.appearance = opts.appearance;
1191
+ this.locale = opts.locale;
1137
1192
  this.paymentResultHandler = (payload) => {
1138
1193
  this.handlePaymentResult(payload);
1139
1194
  };
@@ -1165,6 +1220,7 @@ var SunbayCheckout = (() => {
1165
1220
  initialOptions: options,
1166
1221
  colorScheme: this.appearance?.colorScheme,
1167
1222
  appearance: this.appearance,
1223
+ locale: this.locale,
1168
1224
  onDestroy: (id) => this.releaseElement(id)
1169
1225
  };
1170
1226
  const element = CheckoutElement.create(elementOpts);
@@ -1281,6 +1337,35 @@ var SunbayCheckout = (() => {
1281
1337
  this.session = resp;
1282
1338
  return resp;
1283
1339
  }
1340
+ /**
1341
+ * The session's payment methods split into quick wallets (`express`) and everything else
1342
+ * (`regular`), from the local session snapshot (already filtered by `paymentMethods`).
1343
+ *
1344
+ * Each express entry carries `available` from the `expressCheckout` Element's availability
1345
+ * snapshot; it is `undefined` while no such Element exists or it has not reported yet.
1346
+ *
1347
+ * @returns The split view.
1348
+ * @throws INSTANCE_DESTROYED when destroyed.
1349
+ */
1350
+ getPaymentMethods() {
1351
+ this.assertAlive();
1352
+ let wallets;
1353
+ for (const element of this.elements.values()) {
1354
+ if (element.type === "expressCheckout") {
1355
+ wallets = element.getAvailableWallets();
1356
+ }
1357
+ }
1358
+ const view = { express: [], regular: [] };
1359
+ for (const method of this.session.paymentMethods) {
1360
+ if (method.method === "APPLE_PAY" || method.method === "GOOGLE_PAY") {
1361
+ const available = wallets === void 0 ? void 0 : method.method === "APPLE_PAY" ? wallets.applePay : wallets.googlePay;
1362
+ view.express.push({ ...method, available });
1363
+ } else {
1364
+ view.regular.push({ ...method });
1365
+ }
1366
+ }
1367
+ return view;
1368
+ }
1284
1369
  /**
1285
1370
  * Refresh the session (passes through the refresh command and writes back the local snapshot).
1286
1371
  *
@@ -1549,7 +1634,8 @@ var SunbayCheckout = (() => {
1549
1634
  capabilities: initResp.capabilities,
1550
1635
  session: initResp.session,
1551
1636
  initialWarnings: initResp.warnings,
1552
- appearance: opts.appearance
1637
+ appearance: opts.appearance,
1638
+ locale: opts.locale
1553
1639
  });
1554
1640
  }
1555
1641
  function waitForHello(transport) {
@@ -1578,7 +1664,7 @@ var SunbayCheckout = (() => {
1578
1664
  const w = window;
1579
1665
  w.SunbayCheckout = { ...w.SunbayCheckout ?? {}, createCheckout };
1580
1666
  }
1581
- var version = true ? "0.1.0" : "0.0.0";
1667
+ var version = true ? "0.2.0" : "0.0.0";
1582
1668
  return __toCommonJS(index_exports);
1583
1669
  })();
1584
1670
  //# sourceMappingURL=index.global.js.map