@sunbay/checkout-sdk-js 0.0.9 → 0.1.1

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.mjs CHANGED
@@ -440,6 +440,7 @@ var CheckoutElement = class _CheckoutElement {
440
440
  this.options = opts.initialOptions;
441
441
  this.colorScheme = opts.colorScheme;
442
442
  this.appearance = opts.appearance;
443
+ this.locale = opts.locale;
443
444
  this.mode = opts.initialOptions?.mode;
444
445
  this.onDestroy = opts.onDestroy;
445
446
  this.installInputActions();
@@ -817,7 +818,8 @@ var CheckoutElement = class _CheckoutElement {
817
818
  * (no flash on the first frame); if the initial appearance contains variables or rules, append
818
819
  * `&appearance=<encodeURIComponent(JSON.stringify(appearance))>` (takes effect on the first
819
820
  * frame, no flash). An appearance containing only colorScheme (no variables/rules) is not
820
- * appended, to avoid an empty appearance string. For expressCheckout, additionally append the
821
+ * appended, to avoid an empty appearance string. If an initial locale is provided, append
822
+ * `&locale=<value>` (first frame renders in that language). For expressCheckout, additionally append the
821
823
  * wallet toggles / per-wallet buttonType / global buttonHeight (see {@link resolveExpressQuery}).
822
824
  *
823
825
  * elementId is sent with the src so the hosted child echoes it verbatim in iframe-resize
@@ -829,14 +831,20 @@ var CheckoutElement = class _CheckoutElement {
829
831
  let query = `?checkoutId=${encodeURIComponent(this.checkoutId)}`;
830
832
  query += `&elementId=${encodeURIComponent(this.elementId)}`;
831
833
  if (this.type === "address") {
832
- const mode = this.options?.mode;
834
+ const { mode, style } = this.options ?? {};
833
835
  if (mode) {
834
836
  query += `&mode=${encodeURIComponent(mode)}`;
835
837
  }
838
+ if (style === "simple" || style === "full") {
839
+ query += `&style=${style}`;
840
+ }
836
841
  }
837
842
  if (this.colorScheme) {
838
843
  query += `&colorScheme=${encodeURIComponent(this.colorScheme)}`;
839
844
  }
845
+ if (this.locale) {
846
+ query += `&locale=${encodeURIComponent(this.locale)}`;
847
+ }
840
848
  const effectiveAppearance = this.perElementAppearance() ?? this.appearance;
841
849
  if (effectiveAppearance && (effectiveAppearance.variables || effectiveAppearance.rules)) {
842
850
  query += `&appearance=${encodeURIComponent(JSON.stringify(effectiveAppearance))}`;
@@ -992,6 +1000,7 @@ var CheckoutInstance = class {
992
1000
  this.transport = opts.transport;
993
1001
  this.session = opts.session;
994
1002
  this.appearance = opts.appearance;
1003
+ this.locale = opts.locale;
995
1004
  this.paymentResultHandler = (payload) => {
996
1005
  this.handlePaymentResult(payload);
997
1006
  };
@@ -1023,6 +1032,7 @@ var CheckoutInstance = class {
1023
1032
  initialOptions: options,
1024
1033
  colorScheme: this.appearance?.colorScheme,
1025
1034
  appearance: this.appearance,
1035
+ locale: this.locale,
1026
1036
  onDestroy: (id) => this.releaseElement(id)
1027
1037
  };
1028
1038
  const element = CheckoutElement.create(elementOpts);
@@ -1154,7 +1164,7 @@ var CheckoutInstance = class {
1154
1164
  /**
1155
1165
  * Query the payment status (returns TxnStatus as-is, no transformation).
1156
1166
  *
1157
- * @returns txnStatus (may include txnId).
1167
+ * @returns txnStatus (may be absent when the session is expired), sessionStatus and txnId.
1158
1168
  * @throws rejects INSTANCE_DESTROYED when destroyed.
1159
1169
  */
1160
1170
  async getPaymentStatus() {
@@ -1411,7 +1421,8 @@ async function createCheckout(opts) {
1411
1421
  capabilities: initResp.capabilities,
1412
1422
  session: initResp.session,
1413
1423
  initialWarnings: initResp.warnings,
1414
- appearance: opts.appearance
1424
+ appearance: opts.appearance,
1425
+ locale: opts.locale
1415
1426
  });
1416
1427
  }
1417
1428
  function waitForHello(transport) {
@@ -1444,7 +1455,7 @@ if (typeof window !== "undefined") {
1444
1455
  const w = window;
1445
1456
  w.SunbayCheckout = { ...w.SunbayCheckout ?? {}, createCheckout };
1446
1457
  }
1447
- var version = true ? "0.0.9" : "0.0.0";
1458
+ var version = true ? "0.1.1" : "0.0.0";
1448
1459
  export {
1449
1460
  CheckoutElement,
1450
1461
  CheckoutInstance,