@paydock/client-sdk 1.136.0 → 1.138.1-beta

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.
@@ -817,7 +817,7 @@
817
817
  }, {
818
818
  key: "isSupportPopUp",
819
819
  value: function isSupportPopUp() {
820
- return !this.isFacebook() && !this.isInstagram();
820
+ return !Browser.isFacebook() && !Browser.isInstagram();
821
821
  }
822
822
  }, {
823
823
  key: "getLanguage",
@@ -873,18 +873,18 @@
873
873
  var M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
874
874
  var tem;
875
875
  if (/trident/i.test(M[1])) {
876
- tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
876
+ tem = /\brv[ :](\d+)/.exec(ua) || [];
877
877
  return {
878
878
  name: 'IE',
879
879
  version: tem[1] || ''
880
880
  };
881
881
  }
882
882
  if (M[1] === 'Chrome') {
883
- tem = ua.match(/\bOPR|Edge\/(\d+)/);
883
+ tem = ua.match(/\b(OPR|Edge)\/(\d+)/);
884
884
  if (tem != null) {
885
885
  return {
886
- name: 'Opera',
887
- version: tem[1]
886
+ name: tem[1] === 'OPR' ? 'Opera' : 'Edge',
887
+ version: tem[2]
888
888
  };
889
889
  }
890
890
  }
@@ -1193,7 +1193,7 @@
1193
1193
  version: 'x-sdk-version',
1194
1194
  type: 'x-sdk-type'
1195
1195
  });
1196
- SDK._version = 'v1.136.0';
1196
+ SDK._version = 'v1.138.1-beta';
1197
1197
 
1198
1198
  function isFunction(value) {
1199
1199
  return typeof value === 'function';
@@ -4417,7 +4417,7 @@
4417
4417
  _classCallCheck(this, InstrumentationAgent);
4418
4418
  _this = _callSuper(this, InstrumentationAgent, [config]);
4419
4419
  _this.call = function (method) {
4420
- if (_this.isAvailable()) {
4420
+ if (_this.isAvailable() && InstrumentationAgent.agent) {
4421
4421
  var _InstrumentationAgent;
4422
4422
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
4423
4423
  args[_key - 1] = arguments[_key];
@@ -4436,21 +4436,28 @@
4436
4436
  }], [{
4437
4437
  key: "instance",
4438
4438
  get: function get() {
4439
+ var _a;
4439
4440
  if (!InstrumentationAgent.initialized) {
4440
4441
  var _getConfig = getConfig(),
4441
4442
  available = _getConfig.available,
4442
4443
  options = _getConfig.options;
4443
4444
  InstrumentationAgent.available = available;
4445
+ InstrumentationAgent.agent = undefined;
4444
4446
  if (available) {
4445
4447
  InstrumentationAgent.agent = new InstrumentationAgent(options);
4446
4448
  InstrumentationAgent.agent.start([Instrument$2.featureName, Instrument.featureName, Instrument$1.featureName]);
4447
4449
  }
4448
4450
  InstrumentationAgent.initialized = true;
4449
4451
  }
4450
- return InstrumentationAgent.agent;
4452
+ return (_a = InstrumentationAgent.agent) !== null && _a !== void 0 ? _a : InstrumentationAgent.noopClient;
4451
4453
  }
4452
4454
  }]);
4453
4455
  }(MicroAgent);
4456
+ InstrumentationAgent.noopClient = {
4457
+ call: function call() {
4458
+ // no-op: instrumentation unavailable (missing/invalid config)
4459
+ }
4460
+ };
4454
4461
 
4455
4462
  var ActionRepository = /*#__PURE__*/function () {
4456
4463
  function ActionRepository() {
@@ -10166,7 +10173,7 @@
10166
10173
  });
10167
10174
  };
10168
10175
  _this.onPaymentAuthorized = function (event) {
10169
- var _a;
10176
+ var _a, _b, _c, _d, _e;
10170
10177
  var _event$payment = event.payment,
10171
10178
  token = _event$payment.token,
10172
10179
  billingContact = _event$payment.billingContact,
@@ -10184,8 +10191,8 @@
10184
10191
  }), {
10185
10192
  type: token.paymentMethod.type,
10186
10193
  card_scheme: token.paymentMethod.network,
10187
- address_line1: billingContact === null || billingContact === void 0 ? void 0 : billingContact.addressLines[0],
10188
- address_line2: billingContact === null || billingContact === void 0 ? void 0 : billingContact.addressLines[1],
10194
+ address_line1: (_b = billingContact === null || billingContact === void 0 ? void 0 : billingContact.addressLines) === null || _b === void 0 ? void 0 : _b[0],
10195
+ address_line2: (_c = billingContact === null || billingContact === void 0 ? void 0 : billingContact.addressLines) === null || _c === void 0 ? void 0 : _c[1],
10189
10196
  address_country: billingContact === null || billingContact === void 0 ? void 0 : billingContact.countryCode,
10190
10197
  address_city: billingContact === null || billingContact === void 0 ? void 0 : billingContact.locality,
10191
10198
  address_postcode: billingContact === null || billingContact === void 0 ? void 0 : billingContact.postalCode,
@@ -10199,8 +10206,8 @@
10199
10206
  }), _this.hasShippingOptions() && {
10200
10207
  options: _this.meta.shipping_options
10201
10208
  }), {
10202
- address_line1: shippingContact.addressLines[0],
10203
- address_line2: shippingContact.addressLines[1],
10209
+ address_line1: (_d = shippingContact.addressLines) === null || _d === void 0 ? void 0 : _d[0],
10210
+ address_line2: (_e = shippingContact.addressLines) === null || _e === void 0 ? void 0 : _e[1],
10204
10211
  address_country: shippingContact.countryCode,
10205
10212
  address_city: shippingContact.locality,
10206
10213
  address_postcode: shippingContact.postalCode,
@@ -22656,49 +22663,75 @@
22656
22663
  });
22657
22664
  };
22658
22665
  _this.onPaymentAuthorized = function (event) {
22659
- var _event$payment = event.payment,
22660
- token = _event$payment.token,
22661
- billingContact = _event$payment.billingContact,
22662
- shippingContact = _event$payment.shippingContact;
22663
- _this.executeWalletCapture(_extends(_extends({}, shippingContact && {
22664
- shipping: {
22665
- address_line1: shippingContact.addressLines[0],
22666
- address_line2: shippingContact.addressLines[1],
22667
- address_line3: shippingContact.addressLines[2],
22668
- address_country: shippingContact.countryCode,
22669
- address_city: shippingContact.locality,
22670
- address_postcode: shippingContact.postalCode,
22671
- address_state: shippingContact.administrativeArea,
22672
- contact: {
22673
- phone: shippingContact.phoneNumber,
22674
- email: shippingContact.emailAddress,
22675
- first_name: shippingContact.givenName,
22676
- last_name: shippingContact.familyName
22677
- }
22678
- }
22679
- }), {
22680
- customer: {
22681
- first_name: billingContact === null || billingContact === void 0 ? void 0 : billingContact.givenName,
22682
- last_name: billingContact === null || billingContact === void 0 ? void 0 : billingContact.familyName,
22683
- email: (billingContact === null || billingContact === void 0 ? void 0 : billingContact.emailAddress) || (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.emailAddress),
22684
- phone: (billingContact === null || billingContact === void 0 ? void 0 : billingContact.phoneNumber) || (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.phoneNumber),
22685
- payment_source: {
22686
- wallet_type: WALLET_TYPE.APPLE,
22687
- address_line1: billingContact === null || billingContact === void 0 ? void 0 : billingContact.addressLines[0],
22688
- address_line2: billingContact === null || billingContact === void 0 ? void 0 : billingContact.addressLines[1],
22689
- address_country: billingContact === null || billingContact === void 0 ? void 0 : billingContact.countryCode,
22690
- address_city: billingContact === null || billingContact === void 0 ? void 0 : billingContact.locality,
22691
- address_postcode: billingContact === null || billingContact === void 0 ? void 0 : billingContact.postalCode,
22692
- address_state: billingContact === null || billingContact === void 0 ? void 0 : billingContact.administrativeArea,
22693
- ref_token: token.paymentData ? JSON.stringify(token.paymentData) : '',
22694
- wallet_express: true
22666
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
22667
+ try {
22668
+ var _event$payment = event.payment,
22669
+ token = _event$payment.token,
22670
+ billingContact = _event$payment.billingContact,
22671
+ shippingContact = _event$payment.shippingContact;
22672
+ var hasShippingFields = !!(((_a = shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.addressLines) === null || _a === void 0 ? void 0 : _a.length) || (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.countryCode) || (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.postalCode) || (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.locality) || (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.administrativeArea));
22673
+ var hasContactFields = !!((shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.phoneNumber) || (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.emailAddress) || (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.givenName) || (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.familyName));
22674
+ _this.executeWalletCapture(_extends(_extends({}, (hasShippingFields || hasContactFields) && {
22675
+ shipping: _extends(_extends(_extends(_extends(_extends(_extends(_extends(_extends({}, ((_b = shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.addressLines) === null || _b === void 0 ? void 0 : _b[0]) && {
22676
+ address_line1: (_c = shippingContact.addressLines) === null || _c === void 0 ? void 0 : _c[0]
22677
+ }), ((_d = shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.addressLines) === null || _d === void 0 ? void 0 : _d[1]) && {
22678
+ address_line2: (_e = shippingContact.addressLines) === null || _e === void 0 ? void 0 : _e[1]
22679
+ }), ((_f = shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.addressLines) === null || _f === void 0 ? void 0 : _f[2]) && {
22680
+ address_line3: (_g = shippingContact.addressLines) === null || _g === void 0 ? void 0 : _g[2]
22681
+ }), (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.countryCode) && {
22682
+ address_country: shippingContact.countryCode
22683
+ }), (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.locality) && {
22684
+ address_city: shippingContact.locality
22685
+ }), (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.postalCode) && {
22686
+ address_postcode: shippingContact.postalCode
22687
+ }), (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.administrativeArea) && {
22688
+ address_state: shippingContact.administrativeArea
22689
+ }), hasContactFields && {
22690
+ contact: _extends(_extends(_extends(_extends({}, (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.phoneNumber) && {
22691
+ phone: shippingContact.phoneNumber
22692
+ }), (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.emailAddress) && {
22693
+ email: shippingContact.emailAddress
22694
+ }), (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.givenName) && {
22695
+ first_name: shippingContact.givenName
22696
+ }), (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.familyName) && {
22697
+ last_name: shippingContact.familyName
22698
+ })
22699
+ })
22700
+ }), {
22701
+ customer: {
22702
+ first_name: billingContact === null || billingContact === void 0 ? void 0 : billingContact.givenName,
22703
+ last_name: billingContact === null || billingContact === void 0 ? void 0 : billingContact.familyName,
22704
+ email: (billingContact === null || billingContact === void 0 ? void 0 : billingContact.emailAddress) || (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.emailAddress),
22705
+ phone: (billingContact === null || billingContact === void 0 ? void 0 : billingContact.phoneNumber) || (shippingContact === null || shippingContact === void 0 ? void 0 : shippingContact.phoneNumber),
22706
+ payment_source: {
22707
+ wallet_type: WALLET_TYPE.APPLE,
22708
+ address_line1: (_h = billingContact === null || billingContact === void 0 ? void 0 : billingContact.addressLines) === null || _h === void 0 ? void 0 : _h[0],
22709
+ address_line2: (_j = billingContact === null || billingContact === void 0 ? void 0 : billingContact.addressLines) === null || _j === void 0 ? void 0 : _j[1],
22710
+ address_country: billingContact === null || billingContact === void 0 ? void 0 : billingContact.countryCode,
22711
+ address_city: billingContact === null || billingContact === void 0 ? void 0 : billingContact.locality,
22712
+ address_postcode: billingContact === null || billingContact === void 0 ? void 0 : billingContact.postalCode,
22713
+ address_state: billingContact === null || billingContact === void 0 ? void 0 : billingContact.administrativeArea,
22714
+ ref_token: token.paymentData ? JSON.stringify(token.paymentData) : '',
22715
+ wallet_express: true
22716
+ }
22695
22717
  }
22696
- }
22697
- })).then(function () {
22698
- _this.paymentSession.completePayment(ApplePaySession.STATUS_SUCCESS);
22699
- })["catch"](function () {
22718
+ })).then(function () {
22719
+ _this.paymentSession.completePayment(ApplePaySession.STATUS_SUCCESS);
22720
+ })["catch"](function () {
22721
+ _this.paymentSession.completePayment(ApplePaySession.STATUS_FAILURE);
22722
+ });
22723
+ } catch (error) {
22724
+ // this ensures thatwe always call completePayment and emit error callback even if there's an uncaught exception
22700
22725
  _this.paymentSession.completePayment(ApplePaySession.STATUS_FAILURE);
22701
- });
22726
+ _this.eventEmitter.emit(EVENT.PAYMENT_ERROR, {
22727
+ event: EVENT.PAYMENT_ERROR,
22728
+ chargeId: (_k = _this.chargeWalletTokenMeta) === null || _k === void 0 ? void 0 : _k.charge.id,
22729
+ data: {
22730
+ message: error instanceof Error ? error.message : 'Payment processing failed',
22731
+ code: 'PAYMENT_AUTHORIZATION_ERROR'
22732
+ }
22733
+ });
22734
+ }
22702
22735
  };
22703
22736
  _this.onCancelPayment = function () {
22704
22737
  return _this.handleCheckoutClose();
@@ -22925,24 +22958,30 @@
22925
22958
  }, {
22926
22959
  key: "parseShippingContact",
22927
22960
  value: function parseShippingContact() {
22928
- var _a, _b, _c, _d;
22961
+ var _a, _b, _c, _d, _e, _f, _g, _h;
22929
22962
  if (!((_b = (_a = this.chargeWalletTokenMeta) === null || _a === void 0 ? void 0 : _a.charge) === null || _b === void 0 ? void 0 : _b.shipping) && !this.meta.shipping) {
22930
22963
  return {};
22931
22964
  }
22932
22965
  var shipping = ((_d = (_c = this.chargeWalletTokenMeta) === null || _c === void 0 ? void 0 : _c.charge) === null || _d === void 0 ? void 0 : _d.shipping) || this.meta.shipping;
22933
- return _extends(_extends({}, (shipping === null || shipping === void 0 ? void 0 : shipping.contact) && {
22966
+ var shippingFromCharge = !!((_f = (_e = this.chargeWalletTokenMeta) === null || _e === void 0 ? void 0 : _e.charge) === null || _f === void 0 ? void 0 : _f.shipping);
22967
+ var requiresPostalAddress = (_h = (_g = this.meta.required_shipping_contact_fields) === null || _g === void 0 ? void 0 : _g.includes('postalAddress')) !== null && _h !== void 0 ? _h : false;
22968
+ var contact = _extends({}, (shipping === null || shipping === void 0 ? void 0 : shipping.contact) && {
22934
22969
  phoneNumber: shipping.contact.phone,
22935
22970
  emailAddress: shipping.contact.email,
22936
22971
  givenName: shipping.contact.first_name,
22937
22972
  familyName: shipping.contact.last_name
22938
- }), {
22939
- addressLines: [shipping.address_line1, shipping.address_line2, shipping.address_line3].filter(Boolean),
22940
- locality: shipping.address_city,
22941
- postalCode: shipping.address_postcode,
22942
- administrativeArea: shipping.address_state,
22943
- country: shipping.address_country,
22944
- countryCode: shipping.address_country_code ? shipping.address_country_code : shipping.address_country
22945
22973
  });
22974
+ if (requiresPostalAddress || shippingFromCharge) {
22975
+ return _extends(_extends({}, contact), {
22976
+ addressLines: [shipping.address_line1, shipping.address_line2, shipping.address_line3].filter(Boolean),
22977
+ locality: shipping.address_city,
22978
+ postalCode: shipping.address_postcode,
22979
+ administrativeArea: shipping.address_state,
22980
+ country: shipping.address_country,
22981
+ countryCode: shipping.address_country_code ? shipping.address_country_code : shipping.address_country
22982
+ });
22983
+ }
22984
+ return contact;
22946
22985
  }
22947
22986
  }, {
22948
22987
  key: "parseShippingMethod",
@@ -22970,7 +23009,7 @@
22970
23009
  }, {
22971
23010
  key: "parseShippingContactUpdateEvent",
22972
23011
  value: function parseShippingContactUpdateEvent(data) {
22973
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
23012
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
22974
23013
  return _extends(_extends(_extends({
22975
23014
  contact: {
22976
23015
  phone: (_e = (_d = (_c = (_b = (_a = this.chargeWalletTokenMeta) === null || _a === void 0 ? void 0 : _a.charge) === null || _b === void 0 ? void 0 : _b.shipping) === null || _c === void 0 ? void 0 : _c.contact) === null || _d === void 0 ? void 0 : _d.phone) !== null && _e !== void 0 ? _e : data.shippingContact.phoneNumber,
@@ -22979,9 +23018,9 @@
22979
23018
  last_name: (_v = (_u = (_t = (_s = (_r = this.chargeWalletTokenMeta) === null || _r === void 0 ? void 0 : _r.charge) === null || _s === void 0 ? void 0 : _s.shipping) === null || _t === void 0 ? void 0 : _t.contact) === null || _u === void 0 ? void 0 : _u.last_name) !== null && _v !== void 0 ? _v : data.shippingContact.familyName
22980
23019
  }
22981
23020
  }, ((_w = data.shippingContact.addressLines) === null || _w === void 0 ? void 0 : _w[0]) && {
22982
- address_line1: data.shippingContact.addressLines[0]
22983
- }), ((_x = data.shippingContact.addressLines) === null || _x === void 0 ? void 0 : _x[1]) && {
22984
- address_line2: data.shippingContact.addressLines[1]
23021
+ address_line1: (_x = data.shippingContact.addressLines) === null || _x === void 0 ? void 0 : _x[0]
23022
+ }), ((_y = data.shippingContact.addressLines) === null || _y === void 0 ? void 0 : _y[1]) && {
23023
+ address_line2: (_z = data.shippingContact.addressLines) === null || _z === void 0 ? void 0 : _z[1]
22985
23024
  }), {
22986
23025
  address_city: data.shippingContact.locality,
22987
23026
  address_postcode: data.shippingContact.postalCode,
@@ -139,12 +139,16 @@ type HttpRequestUrl = string | URL;
139
139
  type AgentPrototype = Pick<(typeof MicroAgent)['prototype'], 'addPageAction' | 'noticeError'>;
140
140
  type AgentMethodNames = keyof AgentPrototype;
141
141
  type AgentMethodParameters<T extends AgentMethodNames> = Parameters<AgentPrototype[T]>;
142
+ type InstrumentationClient = {
143
+ call<T extends AgentMethodNames>(method: T, ...args: AgentMethodParameters<T>): void;
144
+ };
142
145
  declare class InstrumentationAgent extends MicroAgent {
143
146
  private static agent;
144
147
  private static available;
145
148
  private static initialized;
149
+ private static readonly noopClient;
146
150
  private constructor();
147
- static get instance(): InstrumentationAgent;
151
+ static get instance(): InstrumentationClient;
148
152
  isAvailable(): boolean;
149
153
  call: <T extends "addPageAction" | "noticeError">(method: T, ...args: AgentMethodParameters<T>) => void;
150
154
  }
@@ -5014,7 +5018,7 @@ interface ApplePayWalletMeta extends BaseWalletMeta {
5014
5018
  merchant_capabilities?: Array<'supports3DS' | 'supportsEMV' | 'supportsCredit' | 'supportsDebit'>;
5015
5019
  supported_networks?: Array<'visa' | 'masterCard' | 'amex' | 'chinaUnionPay' | 'discover' | 'interac' | 'jcb' | 'privateLabel'>;
5016
5020
  required_billing_contact_fields?: Array<'email' | 'name' | 'phone' | 'postalAddress'>;
5017
- required_shipping_contact_fields?: Array<'email' | 'phone'>;
5021
+ required_shipping_contact_fields?: Array<'email' | 'phone' | 'postalAddress'>;
5018
5022
  apple_pay_capabilities?: Array<'credentials_available' | 'credentials_status_unknown' | 'credentials_unavailable'>;
5019
5023
  supported_countries?: string[];
5020
5024
  style?: {
@@ -139,12 +139,16 @@ type HttpRequestUrl = string | URL;
139
139
  type AgentPrototype = Pick<(typeof MicroAgent)['prototype'], 'addPageAction' | 'noticeError'>;
140
140
  type AgentMethodNames = keyof AgentPrototype;
141
141
  type AgentMethodParameters<T extends AgentMethodNames> = Parameters<AgentPrototype[T]>;
142
+ type InstrumentationClient = {
143
+ call<T extends AgentMethodNames>(method: T, ...args: AgentMethodParameters<T>): void;
144
+ };
142
145
  declare class InstrumentationAgent extends MicroAgent {
143
146
  private static agent;
144
147
  private static available;
145
148
  private static initialized;
149
+ private static readonly noopClient;
146
150
  private constructor();
147
- static get instance(): InstrumentationAgent;
151
+ static get instance(): InstrumentationClient;
148
152
  isAvailable(): boolean;
149
153
  call: <T extends "addPageAction" | "noticeError">(method: T, ...args: AgentMethodParameters<T>) => void;
150
154
  }
@@ -5014,7 +5018,7 @@ interface ApplePayWalletMeta extends BaseWalletMeta {
5014
5018
  merchant_capabilities?: Array<'supports3DS' | 'supportsEMV' | 'supportsCredit' | 'supportsDebit'>;
5015
5019
  supported_networks?: Array<'visa' | 'masterCard' | 'amex' | 'chinaUnionPay' | 'discover' | 'interac' | 'jcb' | 'privateLabel'>;
5016
5020
  required_billing_contact_fields?: Array<'email' | 'name' | 'phone' | 'postalAddress'>;
5017
- required_shipping_contact_fields?: Array<'email' | 'phone'>;
5021
+ required_shipping_contact_fields?: Array<'email' | 'phone' | 'postalAddress'>;
5018
5022
  apple_pay_capabilities?: Array<'credentials_available' | 'credentials_status_unknown' | 'credentials_unavailable'>;
5019
5023
  supported_countries?: string[];
5020
5024
  style?: {