@sunbay/checkout-sdk-js 0.0.8 → 0.1.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.mjs CHANGED
@@ -829,10 +829,13 @@ var CheckoutElement = class _CheckoutElement {
829
829
  let query = `?checkoutId=${encodeURIComponent(this.checkoutId)}`;
830
830
  query += `&elementId=${encodeURIComponent(this.elementId)}`;
831
831
  if (this.type === "address") {
832
- const mode = this.options?.mode;
832
+ const { mode, style } = this.options ?? {};
833
833
  if (mode) {
834
834
  query += `&mode=${encodeURIComponent(mode)}`;
835
835
  }
836
+ if (style === "simple" || style === "full") {
837
+ query += `&style=${style}`;
838
+ }
836
839
  }
837
840
  if (this.colorScheme) {
838
841
  query += `&colorScheme=${encodeURIComponent(this.colorScheme)}`;
@@ -984,6 +987,7 @@ var CheckoutInstance = class {
984
987
  /** The current pending confirm (at most one at a time). */
985
988
  this.pendingConfirm = null;
986
989
  this.destroyed = false;
990
+ this.pendingWarnings = opts.initialWarnings ? [...opts.initialWarnings] : [];
987
991
  this.checkoutId = opts.checkoutId;
988
992
  this.runtimeId = opts.runtimeId;
989
993
  this.capabilities = opts.capabilities;
@@ -1153,7 +1157,7 @@ var CheckoutInstance = class {
1153
1157
  /**
1154
1158
  * Query the payment status (returns TxnStatus as-is, no transformation).
1155
1159
  *
1156
- * @returns txnStatus (may include txnId).
1160
+ * @returns txnStatus (may be absent when the session is expired), sessionStatus and txnId.
1157
1161
  * @throws rejects INSTANCE_DESTROYED when destroyed.
1158
1162
  */
1159
1163
  async getPaymentStatus() {
@@ -1181,6 +1185,18 @@ var CheckoutInstance = class {
1181
1185
  on(event, handler) {
1182
1186
  this.assertAlive();
1183
1187
  this.transport.on(event, handler);
1188
+ if (event === "warning" && this.pendingWarnings.length > 0) {
1189
+ const pending = this.pendingWarnings;
1190
+ this.pendingWarnings = [];
1191
+ queueMicrotask(() => {
1192
+ if (this.destroyed) {
1193
+ return;
1194
+ }
1195
+ for (const w of pending) {
1196
+ handler(w);
1197
+ }
1198
+ });
1199
+ }
1184
1200
  }
1185
1201
  /**
1186
1202
  * Unregister an event handler (safe to call after destruction).
@@ -1379,7 +1395,9 @@ async function createCheckout(opts) {
1379
1395
  checkoutClientSecret: opts.checkoutClientSecret,
1380
1396
  locale: opts.locale,
1381
1397
  appearance: opts.appearance,
1382
- paymentMethods: opts.paymentMethods
1398
+ paymentMethods: opts.paymentMethods,
1399
+ billingAddress: opts.billingAddress,
1400
+ shippingAddress: opts.shippingAddress
1383
1401
  };
1384
1402
  let initResp;
1385
1403
  try {
@@ -1395,6 +1413,7 @@ async function createCheckout(opts) {
1395
1413
  transport,
1396
1414
  capabilities: initResp.capabilities,
1397
1415
  session: initResp.session,
1416
+ initialWarnings: initResp.warnings,
1398
1417
  appearance: opts.appearance
1399
1418
  });
1400
1419
  }
@@ -1421,17 +1440,19 @@ function waitForHello(transport) {
1421
1440
 
1422
1441
  // src/index.ts
1423
1442
  import {
1424
- ErrorCode as ErrorCode5
1443
+ ErrorCode as ErrorCode5,
1444
+ WARNING_CODES
1425
1445
  } from "@sunbay/checkout-sdk-protocol";
1426
1446
  if (typeof window !== "undefined") {
1427
1447
  const w = window;
1428
1448
  w.SunbayCheckout = { ...w.SunbayCheckout ?? {}, createCheckout };
1429
1449
  }
1430
- var version = true ? "0.0.8" : "0.0.0";
1450
+ var version = true ? "0.1.0" : "0.0.0";
1431
1451
  export {
1432
1452
  CheckoutElement,
1433
1453
  CheckoutInstance,
1434
1454
  ErrorCode5 as ErrorCode,
1455
+ WARNING_CODES,
1435
1456
  createCheckout,
1436
1457
  version
1437
1458
  };