@odus/checkout 0.27.1 → 0.28.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.
@@ -5248,6 +5248,35 @@ class Pl {
5248
5248
  const o = i ? e.shippingAddress : t ? e.billingAddress : void 0;
5249
5249
  return o && this.hasAddressData(o) && (n.shippingAddress = this.mapAddressToApiFormat(o)), n;
5250
5250
  }
5251
+ getAttributionParams() {
5252
+ const e = new URLSearchParams(globalThis.location?.search ?? ""), t = [
5253
+ "utm_source",
5254
+ "utm_medium",
5255
+ "utm_campaign",
5256
+ "utm_term",
5257
+ "utm_content",
5258
+ "utm_id",
5259
+ "utm_contentid",
5260
+ "fbclid",
5261
+ "ref_id",
5262
+ "cmpid",
5263
+ "sub1",
5264
+ "sub2",
5265
+ "sub3",
5266
+ "sub4",
5267
+ "sub5",
5268
+ "sub6",
5269
+ "sub7",
5270
+ "sub8",
5271
+ "sub9",
5272
+ "sub10"
5273
+ ], i = {};
5274
+ for (const n of t) {
5275
+ const a = e.get(n);
5276
+ a && (i[n] = a.slice(0, 255));
5277
+ }
5278
+ return Object.keys(i).length > 0 ? i : void 0;
5279
+ }
5251
5280
  async fetchApi({
5252
5281
  endpoint: e,
5253
5282
  method: t = "POST",
@@ -5296,18 +5325,19 @@ class Pl {
5296
5325
  applePayData: a,
5297
5326
  customCustomerData: o
5298
5327
  }) {
5299
- let s = {};
5328
+ const s = this.getAttributionParams();
5329
+ let d = {};
5300
5330
  if (a) {
5301
- const d = this.hasAddressData(a.billingAddress), l = this.hasAddressData(a.shippingAddress), u = {}, h = d ? a.billingAddress : l ? a.shippingAddress : void 0;
5302
- h && this.hasAddressData(h) && (u.billingAddress = this.mapAddressToApiFormat(h));
5303
- const f = l ? a.shippingAddress : d ? a.billingAddress : void 0;
5304
- f && this.hasAddressData(f) && (u.shippingAddress = this.mapAddressToApiFormat(f));
5305
- const m = {
5331
+ const l = this.hasAddressData(a.billingAddress), u = this.hasAddressData(a.shippingAddress), h = {}, f = l ? a.billingAddress : u ? a.shippingAddress : void 0;
5332
+ f && this.hasAddressData(f) && (h.billingAddress = this.mapAddressToApiFormat(f));
5333
+ const m = u ? a.shippingAddress : l ? a.billingAddress : void 0;
5334
+ m && this.hasAddressData(m) && (h.shippingAddress = this.mapAddressToApiFormat(m));
5335
+ const p = {
5306
5336
  email: a.email,
5307
5337
  name: a.name,
5308
- ...u
5338
+ ...h
5309
5339
  };
5310
- a.phone && (m.phoneNumber = a.phone), s = {
5340
+ a.phone && (p.phoneNumber = a.phone), d = {
5311
5341
  paymentMethodData: {
5312
5342
  type: "applePay",
5313
5343
  applePay: {
@@ -5315,35 +5345,36 @@ class Pl {
5315
5345
  displayName: a.displayName
5316
5346
  }
5317
5347
  },
5318
- customerData: m,
5348
+ customerData: p,
5319
5349
  context: {
5320
5350
  returnUrl: n,
5321
- userAgent: globalThis.navigator.userAgent
5351
+ userAgent: globalThis.navigator.userAgent,
5352
+ ...s && { attribution: s }
5322
5353
  }
5323
5354
  };
5324
5355
  } else if (i) {
5325
- const d = i.cardExpiry.replace(/\s+/g, "").split("/"), l = d[0];
5326
- let u = d[1];
5327
- u && u.length === 2 && (u = `20${u}`);
5328
- const h = new Ii();
5329
- h.setPublicKey(this.publicKey);
5330
- const f = h.encrypt(
5356
+ const l = i.cardExpiry.replace(/\s+/g, "").split("/"), u = l[0];
5357
+ let h = l[1];
5358
+ h && h.length === 2 && (h = `20${h}`);
5359
+ const f = new Ii();
5360
+ f.setPublicKey(this.publicKey);
5361
+ const m = f.encrypt(
5331
5362
  i.cardNumber.replace(/\s+/g, "")
5332
- ), m = h.encrypt(i.cardCvv), p = i.billingAddress || i.shippingAddress, $ = p?.firstName && p?.lastName ? `${p.firstName} ${p.lastName}`.trim() : i.name;
5333
- s = {
5363
+ ), p = f.encrypt(i.cardCvv), $ = i.billingAddress || i.shippingAddress, g = $?.firstName && $?.lastName ? `${$.firstName} ${$.lastName}`.trim() : i.name;
5364
+ d = {
5334
5365
  paymentMethodData: {
5335
5366
  type: "card",
5336
5367
  card: {
5337
- expMonth: l,
5338
- expYear: u,
5339
- cardholderName: $,
5340
- encryptedCardNumber: f,
5341
- encryptedCvv: m
5368
+ expMonth: u,
5369
+ expYear: h,
5370
+ cardholderName: g,
5371
+ encryptedCardNumber: m,
5372
+ encryptedCvv: p
5342
5373
  }
5343
5374
  },
5344
5375
  customerData: {
5345
5376
  email: i.email,
5346
- name: $,
5377
+ name: g,
5347
5378
  ...i.phoneNumber && {
5348
5379
  phoneNumber: i.phoneCountryCode != null || i.phoneNumber.startsWith("+") ? Vr(
5349
5380
  i.phoneNumber,
@@ -5355,18 +5386,20 @@ class Pl {
5355
5386
  },
5356
5387
  context: {
5357
5388
  returnUrl: n,
5358
- browserInfo: this.browserInfo
5389
+ browserInfo: this.browserInfo,
5390
+ ...s && { attribution: s }
5359
5391
  }
5360
5392
  };
5361
5393
  } else
5362
- s = {
5394
+ d = {
5363
5395
  paymentMethodData: {
5364
5396
  type: "paypal"
5365
5397
  },
5366
5398
  ...o && { customerData: o },
5367
5399
  context: {
5368
5400
  returnUrl: n,
5369
- browserInfo: this.browserInfo
5401
+ browserInfo: this.browserInfo,
5402
+ ...s && { attribution: s }
5370
5403
  }
5371
5404
  };
5372
5405
  return await this.fetchApi({
@@ -5375,7 +5408,7 @@ class Pl {
5375
5408
  Authorization: `Bearer ${t}`,
5376
5409
  "X-Idempotency-Key": e
5377
5410
  },
5378
- body: s
5411
+ body: d
5379
5412
  });
5380
5413
  }
5381
5414
  }
@@ -1,5 +1,5 @@
1
- import { c as en, a as Hn, f as Tt, d as qn, C as he, I as tn, g as Kn, S as Ft, b as gi, e as be, A as $n, P as Wn, E as Gn, h as Yn, i as Xn, j as Zn, k as Jn, l as Qn, F as es, m as ts, n as is } from "./Alert-xum-l8Uv.js";
2
- import { o as Co, p as Ao, q as Mo, r as _o, s as ko, t as No, u as Io, v as Oo } from "./Alert-xum-l8Uv.js";
1
+ import { c as en, a as Hn, f as Tt, d as qn, C as he, I as tn, g as Kn, S as Ft, b as gi, e as be, A as $n, P as Wn, E as Gn, h as Yn, i as Xn, j as Zn, k as Jn, l as Qn, F as es, m as ts, n as is } from "./Alert-B4nrSL91.js";
2
+ import { o as Co, p as Ao, q as Mo, r as _o, s as ko, t as No, u as Io, v as Oo } from "./Alert-B4nrSL91.js";
3
3
  const V = {
4
4
  // Checkout lifecycle events
5
5
  CHECKOUT_INITIALIZED: "checkout.initialized",
@@ -1,4 +1,4 @@
1
- import { l as a, I as m, S as y, g as C, b as g, A as E, F as k, i as z, a as c, f as N, J as S, E as P, k as x, P as F, h as R, w as A, m as V, n as M, j as B } from "./Alert-xum-l8Uv.js";
1
+ import { l as a, I as m, S as y, g as C, b as g, A as E, F as k, i as z, a as c, f as N, J as S, E as P, k as x, P as F, h as R, w as A, m as V, n as M, j as B } from "./Alert-B4nrSL91.js";
2
2
  const l = ".form-helper-text{color:#dc2727;font-family:var(--odus-font-family, inherit);font-size:12px;font-weight:500;margin-top:4px;display:block;overflow:hidden;max-height:100px;transition:max-height .3s ease-in-out,opacity .3s ease-in-out,margin .3s ease-in-out}.form-helper-text-hidden{max-height:0;opacity:0;margin-top:0;overflow:hidden}", h = ".input-wrapper{display:flex;flex-direction:column;width:100%;min-width:0;box-sizing:border-box;align-items:stretch}.input-wrapper *{box-sizing:border-box}.form-input{opacity:1;font-size:var(--odus-input-font-size, 16px);font-weight:var(--odus-input-font-weight, 400);letter-spacing:var(--odus-input-letter-spacing, .02em);transition:box-shadow .1s ease-in,border-radius .2s ease-in;box-shadow:0 0 0 1px var(--odus-border-color, #e0e0e0),0 2px 4px #00000012,0 1px 1.5px #0000000d;background:var(--odus-color-background, #fff);padding:var(--odus-input-padding, 8px 12px);border:none;outline:none;line-height:var(--odus-input-line-height, 1.5);z-index:0;box-sizing:border-box;min-height:0;flex:1;width:100%}.form-input[name=cardNumber]{padding-right:100px}.form-input-error{color:#dc2727}.form-input::placeholder{color:var(--odus-input-placeholder-color, #717173);opacity:var(--odus-input-placeholder-opacity, .3)}.form-input:focus{box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d;position:relative;z-index:2}", u = ".input-label{font-family:var(--odus-font-family, inherit);font-size:var(--odus-label-font-size, 14px);font-weight:var(--odus-label-font-weight, 400);color:var(--odus-label-color, var(--odus-color-text, #1a1a1a));letter-spacing:var(--odus-label-letter-spacing, normal);line-height:var(--odus-label-line-height, 1.4);margin-bottom:var(--odus-label-margin-bottom, 6px)}", I = ":host{--odus-font-family: system-ui, sans-serif;--odus-font-size: 16px;--odus-color-error: #dc2727;--odus-color-text: #1a1a1a;--odus-color-background: #ffffff;--odus-border-color: #e0e0e0;--odus-border-radius: 6px;--odus-spacing-sm: 8px;--odus-spacing-md: 16px;--odus-spacing-lg: 24px;--odus-input-height: 44px;--odus-input-padding: 8px 12px;--odus-input-font-size: var(--odus-font-size);--odus-input-font-weight: 400;--odus-input-letter-spacing: .02em;--odus-input-line-height: 1.5;--odus-input-placeholder-color: #717173;--odus-input-placeholder-opacity: .3;--odus-input-focus-shadow: 0 0 0 1px rgba(50, 151, 211, .7), 0 1px 1px 0 rgba(0, 0, 0, .07), 0 0 0 4px rgba(50, 151, 211, .3);--odus-label-font-size: 14px;--odus-label-font-weight: 400;--odus-label-color: var(--odus-color-text);--odus-label-letter-spacing: normal;--odus-label-line-height: 1.4;--odus-label-margin-bottom: 6px;--odus-card-gap: 12px;--odus-button-height: 48px;--odus-button-border-radius: var(--odus-border-radius)}.form-input{opacity:1;font-weight:var(--odus-input-font-weight, 400);letter-spacing:var(--odus-input-letter-spacing, .02em);transition:box-shadow .1s ease-in,border-radius .2s ease-in;box-shadow:0 0 0 1px var(--odus-border-color, #e0e0e0),0 2px 4px #00000012,0 1px 1.5px #0000000d;background:var(--odus-color-background, #fff);padding:var(--odus-input-padding, 8px 12px);border:none;outline:none;line-height:var(--odus-input-line-height, 1.5);z-index:0;box-sizing:border-box;min-height:0;flex:1;width:100%}.form-input::placeholder{color:var(--odus-input-placeholder-color, #717173);opacity:var(--odus-input-placeholder-opacity, .3)}.form-input:focus{box-shadow:var( --odus-input-focus-shadow, 0 0 0 1px rgba(50, 151, 211, .7), 0 1px 1px 0 rgba(0, 0, 0, .07), 0 0 0 4px rgba(50, 151, 211, .3) );position:relative;z-index:2}.input-label{font-family:var(--odus-font-family, inherit)!important;font-size:var(--odus-label-font-size, 14px)!important;font-weight:var(--odus-label-font-weight, 400)!important;color:var(--odus-label-color, var(--odus-color-text, #1a1a1a))!important;letter-spacing:var(--odus-label-letter-spacing, normal)!important;line-height:var(--odus-label-line-height, 1.4)!important;margin-bottom:var(--odus-label-margin-bottom, 6px)!important}.form-helper-text{font-family:var(--odus-font-family, inherit)!important}";
3
3
  class d {
4
4
  shadowRoot = null;
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odus/checkout",
3
- "version": "0.27.1",
3
+ "version": "0.28.0",
4
4
  "displayName": "Odus Checkout SDK",
5
5
  "keywords": [
6
6
  "odus",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odus/checkout",
3
- "version": "0.27.1",
3
+ "version": "0.28.0",
4
4
  "displayName": "Odus Checkout SDK",
5
5
  "keywords": [
6
6
  "odus",