@xsolla/payment-client-core 0.2.7 → 0.2.9

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.
Files changed (64) hide show
  1. package/esm2020/lib/core/agreementsGroup.const.mjs +14 -0
  2. package/esm2020/lib/core/extended-window.interface.mjs +1 -1
  3. package/esm2020/lib/core/payment/actions/next-action.interface.mjs +1 -1
  4. package/esm2020/lib/core/payment/actions/next-actions.mjs +3 -1
  5. package/esm2020/lib/core/payment/actions/redirect/ps4-pages/pages-payment-methods-id.const.mjs +2 -2
  6. package/esm2020/lib/core/payment/actions/redirect/ps4-pages/pages-routes.const.mjs +3 -3
  7. package/esm2020/lib/core/payment/actions/show-qr-code/show-qr-code.action.class.mjs +22 -0
  8. package/esm2020/lib/core/payment/actions/show-qr-code/show-qr-code.action.type.mjs +2 -0
  9. package/esm2020/lib/core/payment/field-names.enum.mjs +2 -1
  10. package/esm2020/lib/core/payment/form-response.interface.mjs +2 -0
  11. package/esm2020/lib/core/payment/initialize/initialize-request-params.interface.mjs +1 -1
  12. package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
  13. package/esm2020/lib/core/payment/payment.service.mjs +62 -2
  14. package/esm2020/lib/core/payment/xps-api/xps-api.service.mjs +4 -1
  15. package/esm2020/lib/core/sdk-payment-systems/apple-pay/apple-pay-integration.type.mjs +2 -0
  16. package/esm2020/lib/core/sdk-payment-systems/apple-pay/apple-pay-params.interface.mjs +2 -0
  17. package/esm2020/lib/core/sdk-payment-systems/apple-pay/apple-pay.const.mjs +2 -0
  18. package/esm2020/lib/core/sdk-payment-systems/apple-pay/apple-pay.errors.enum.mjs +6 -0
  19. package/esm2020/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.mjs +265 -0
  20. package/esm2020/lib/core/sdk-payment-systems/apple-pay/checkout-params.interface.mjs +2 -0
  21. package/esm2020/lib/core/settings/configuration.interface.mjs +1 -1
  22. package/esm2020/lib/core/settings/settings.service.mjs +6 -1
  23. package/esm2020/lib/core/user-agent/browserInfo.interface.mjs +2 -0
  24. package/esm2020/lib/core/user-agent/browsers.mjs +44 -0
  25. package/esm2020/lib/core/user-agent/device.enum.mjs +6 -0
  26. package/esm2020/lib/core/user-agent/os.mjs +255 -0
  27. package/esm2020/lib/core/user-agent/user-agent-data.interface.mjs +2 -0
  28. package/esm2020/lib/core/user-agent/user-agent.service.mjs +200 -0
  29. package/esm2020/lib/core-library.service.mjs +17 -1
  30. package/esm2020/public-api.mjs +3 -1
  31. package/fesm2015/xsolla-payment-client-core.mjs +891 -4
  32. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  33. package/fesm2020/xsolla-payment-client-core.mjs +883 -4
  34. package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
  35. package/lib/core/agreementsGroup.const.d.ts +2 -0
  36. package/lib/core/extended-window.interface.d.ts +11 -0
  37. package/lib/core/payment/actions/next-action.interface.d.ts +2 -1
  38. package/lib/core/payment/actions/redirect/ps4-pages/pages-payment-methods-id.const.d.ts +1 -1
  39. package/lib/core/payment/actions/show-qr-code/show-qr-code.action.class.d.ts +11 -0
  40. package/lib/core/payment/actions/show-qr-code/show-qr-code.action.type.d.ts +3 -0
  41. package/lib/core/payment/field-names.enum.d.ts +2 -1
  42. package/lib/core/payment/form-response.interface.d.ts +8 -0
  43. package/lib/core/payment/initialize/initialize-request-params.interface.d.ts +1 -0
  44. package/lib/core/payment/payment.interface.d.ts +1 -0
  45. package/lib/core/payment/payment.service.d.ts +10 -1
  46. package/lib/core/sdk-payment-systems/apple-pay/apple-pay-integration.type.d.ts +1 -0
  47. package/lib/core/sdk-payment-systems/apple-pay/apple-pay-params.interface.d.ts +4 -0
  48. package/lib/core/sdk-payment-systems/apple-pay/apple-pay.const.d.ts +1 -0
  49. package/lib/core/sdk-payment-systems/apple-pay/apple-pay.errors.enum.d.ts +4 -0
  50. package/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.d.ts +46 -0
  51. package/lib/core/sdk-payment-systems/apple-pay/checkout-params.interface.d.ts +9 -0
  52. package/lib/core/settings/configuration.interface.d.ts +1 -0
  53. package/lib/core/settings/settings.service.d.ts +2 -0
  54. package/lib/core/user-agent/browserInfo.interface.d.ts +13 -0
  55. package/lib/core/user-agent/browsers.d.ts +9 -0
  56. package/lib/core/user-agent/device.enum.d.ts +4 -0
  57. package/lib/core/user-agent/os.d.ts +7 -0
  58. package/lib/core/user-agent/user-agent-data.interface.d.ts +10 -0
  59. package/lib/core/user-agent/user-agent.service.d.ts +36 -0
  60. package/lib/core-library.service.d.ts +9 -0
  61. package/package.json +4 -2
  62. package/public-api.d.ts +2 -0
  63. package/xsolla-payment-client-core-0.2.9.tgz +0 -0
  64. package/xsolla-payment-client-core-0.2.7.tgz +0 -0
@@ -127,6 +127,9 @@ class SettingsService {
127
127
  get token() {
128
128
  return this._token;
129
129
  }
130
+ get isMobile() {
131
+ return this._isMobile;
132
+ }
130
133
  get hasResponse() {
131
134
  return !!this.response;
132
135
  }
@@ -135,6 +138,7 @@ class SettingsService {
135
138
  this.isInitialized = false;
136
139
  this._token = '';
137
140
  this.sandboxMode = false;
141
+ this._isMobile = false;
138
142
  }
139
143
  init(configuration) {
140
144
  return __awaiter(this, void 0, void 0, function* () {
@@ -143,6 +147,7 @@ class SettingsService {
143
147
  }
144
148
  this._token = configuration.token;
145
149
  this.sandboxMode = !!configuration.sandbox;
150
+ this._isMobile = configuration.isMobile;
146
151
  yield this.sendRequest(this.token);
147
152
  this.isInitialized = true;
148
153
  });
@@ -590,6 +595,7 @@ var FieldNames;
590
595
  FieldNames["sum"] = "sum";
591
596
  FieldNames["out"] = "out";
592
597
  FieldNames["tinkoffDisclaimer"] = "ps.tinkoff.disclaimer";
598
+ FieldNames["omnibusDirective"] = "omnibus_directive";
593
599
  })(FieldNames || (FieldNames = {}));
594
600
 
595
601
  class SubmitResponse {
@@ -711,6 +717,9 @@ class XpsApiService {
711
717
  const pid = (_c = (_b = (_a = parameters.pid) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : parameters.xps_fix_pid) !== null && _c !== void 0 ? _c : '';
712
718
  const paymentWithSavedMethod = (_e = (_d = parameters.paymentWithSavedMethod) !== null && _d !== void 0 ? _d : parameters.xps_paymentWithSavedMethod) !== null && _e !== void 0 ? _e : '';
713
719
  const requestParams = Object.assign(Object.assign(Object.assign(Object.assign({}, this.collectAnalyticsParameters(pid, paymentWithSavedMethod)), this.collectUserSessionId()), { country: this.countryService.getCountry() }), parameters);
720
+ if (this.settingsService.isMobile) {
721
+ requestParams.mobile = "1" /* XpsBoolean.true */;
722
+ }
714
723
  return lastValueFrom(this.secureApiClient.post(this.directPaymentApiRoute, new URLSearchParams(Object.assign({}, requestParams)), {
715
724
  headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
716
725
  responseType: 'json',
@@ -766,14 +775,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
766
775
 
767
776
  const vkPay = 3496;
768
777
  const googlePay = 3431;
769
- const applePay = 3175;
778
+ const applePayId = 3175;
770
779
  const barzahlenPay = 1679;
771
780
  const naverPay = 3563;
772
781
  const venmoPay = 3636;
773
782
 
774
783
  const pagesRoutes = new Map([
775
784
  [vkPay, '/payment/external-pages/vk-pay'],
776
- [applePay, '/payment/external-pages/apple-pay'],
785
+ [applePayId, '/payment/external-pages/apple-pay'],
777
786
  [barzahlenPay, '/payment/external-pages/barzahlen-pay'],
778
787
  [naverPay, '/payment/external-pages/naver-pay'],
779
788
  [venmoPay, '/payment/external-pages/venmo-pay'],
@@ -1125,11 +1134,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
1125
1134
  type: Injectable
1126
1135
  }] });
1127
1136
 
1137
+ class ShowQrCodeActionCreator {
1138
+ constructor() {
1139
+ this.type = 'show_qr_code';
1140
+ }
1141
+ getActionData() {
1142
+ return {
1143
+ type: this.type,
1144
+ data: null,
1145
+ };
1146
+ }
1147
+ isSuitable(response) {
1148
+ var _a, _b;
1149
+ return Boolean((_b = (_a = response.parameters) === null || _a === void 0 ? void 0 : _a.form) === null || _b === void 0 ? void 0 : _b.qr);
1150
+ }
1151
+ }
1152
+ ShowQrCodeActionCreator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowQrCodeActionCreator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1153
+ ShowQrCodeActionCreator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowQrCodeActionCreator });
1154
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowQrCodeActionCreator, decorators: [{
1155
+ type: Injectable
1156
+ }] });
1157
+
1128
1158
  const nextActionsToken = new InjectionToken('Action');
1129
1159
  const nextActions = [
1130
1160
  ShowFieldsActionCreator,
1131
1161
  CheckStatusActionCreator,
1132
1162
  SpecialButtonActionCreator,
1163
+ ShowQrCodeActionCreator,
1133
1164
  RedirectActionCreator,
1134
1165
  ];
1135
1166
  const flowUpdateNextActions = [
@@ -5509,6 +5540,15 @@ class PaymentService {
5509
5540
  get formFieldsStatus$() {
5510
5541
  return this.formFieldsStatusSubject.asObservable().pipe(filter$1(Boolean));
5511
5542
  }
5543
+ get paymentForm$() {
5544
+ return this._paymentForm$.asObservable();
5545
+ }
5546
+ get formResponse$() {
5547
+ return this._formResponse$.asObservable();
5548
+ }
5549
+ get formResponseValue() {
5550
+ return this._formResponse$.getValue();
5551
+ }
5512
5552
  constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService, formMessagesService, settingsService, countryService) {
5513
5553
  this.initializeService = initializeService;
5514
5554
  this.submitService = submitService;
@@ -5530,7 +5570,9 @@ class PaymentService {
5530
5570
  this.fields = [];
5531
5571
  this.destroy$ = new Subject();
5532
5572
  this.formDestroy$ = new Subject();
5573
+ this._paymentForm$ = new BehaviorSubject(null);
5533
5574
  this.formFieldsStatusSubject = new BehaviorSubject(null);
5575
+ this._formResponse$ = new BehaviorSubject(null);
5534
5576
  this.isSavingMethodMode = false;
5535
5577
  }
5536
5578
  initialize(config) {
@@ -5541,6 +5583,7 @@ class PaymentService {
5541
5583
  this.listenFinanceDetails();
5542
5584
  this.config = config;
5543
5585
  this.data = yield this.initializeService.request(config);
5586
+ this.emitFormResponse(this.data);
5544
5587
  this.fields = this.getFields();
5545
5588
  this.form = this.formService.createForm(this.fields);
5546
5589
  this.updatePidConfig();
@@ -5565,6 +5608,7 @@ class PaymentService {
5565
5608
  this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
5566
5609
  const submitResponse = yield this.submitService.request(this.fields, this.form);
5567
5610
  this.data = submitResponse;
5611
+ this.emitFormResponse(this.data);
5568
5612
  if (!this.isSavingMethodMode) {
5569
5613
  this.emitFinanceDetails(submitResponse.summary);
5570
5614
  }
@@ -5599,6 +5643,12 @@ class PaymentService {
5599
5643
  country: this.countryService.getCountry(),
5600
5644
  };
5601
5645
  }
5646
+ getQrCode() {
5647
+ if (!isSubmitResponse(this.data)) {
5648
+ throw new Error('Should submit form first');
5649
+ }
5650
+ return this.data.parameters.form.qr.title;
5651
+ }
5602
5652
  getPid() {
5603
5653
  var _a, _b, _c;
5604
5654
  if (this.data instanceof SubmitResponse) {
@@ -5678,6 +5728,30 @@ class PaymentService {
5678
5728
  }
5679
5729
  this.emitFormFieldsStatus(this.form);
5680
5730
  }
5731
+ addExtraField(name, value) {
5732
+ const isHaveField = this.fields.find((field) => {
5733
+ return field.name === name;
5734
+ });
5735
+ if (isHaveField) {
5736
+ this.fields = this.fields.map((field) => {
5737
+ if (field.name === name) {
5738
+ field.value = value;
5739
+ }
5740
+ return field;
5741
+ });
5742
+ return;
5743
+ }
5744
+ const field = {
5745
+ name: name,
5746
+ value: value,
5747
+ title: '',
5748
+ type: 'text',
5749
+ example: '',
5750
+ isMandatory: "1" /* XpsBoolean.true */,
5751
+ isVisible: "0" /* XpsBoolean.false */,
5752
+ };
5753
+ this.fields.push(field);
5754
+ }
5681
5755
  destroy() {
5682
5756
  this.data = null;
5683
5757
  this.financeDetails = null;
@@ -5717,6 +5791,7 @@ class PaymentService {
5717
5791
  .subscribe((response) => {
5718
5792
  this.emitFinanceDetails(response.summary);
5719
5793
  this.emitFormMessages(response.messages);
5794
+ this.emitFormResponse(response);
5720
5795
  });
5721
5796
  this.syncService.fieldAsyncValidation$
5722
5797
  .pipe(takeUntil(this.destroy$))
@@ -5735,7 +5810,10 @@ class PaymentService {
5735
5810
  listenFormStatusChanges(form) {
5736
5811
  form.statusChanges
5737
5812
  .pipe(takeUntil(this.formDestroy$))
5738
- .subscribe(() => this.emitFormFieldsStatus(form));
5813
+ .subscribe((status) => {
5814
+ this.emitFormFieldsStatus(form);
5815
+ this._paymentForm$.next(status);
5816
+ });
5739
5817
  }
5740
5818
  /*
5741
5819
  * in case the form pid changes despite the one passed during initialization
@@ -5746,6 +5824,19 @@ class PaymentService {
5746
5824
  this.config.paymentMethodId = currentPid;
5747
5825
  }
5748
5826
  }
5827
+ emitFormResponse(data) {
5828
+ let type;
5829
+ if (data instanceof InitializeResponse) {
5830
+ type = 'initialize';
5831
+ }
5832
+ else if (data instanceof SubmitResponse) {
5833
+ type = 'submit';
5834
+ }
5835
+ else {
5836
+ type = 'sync';
5837
+ }
5838
+ this._formResponse$.next({ type, data, token: this.settingsService.token });
5839
+ }
5749
5840
  }
5750
5841
  PaymentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, deps: [{ token: InitializeService }, { token: SubmitService }, { token: SyncService }, { token: FormService }, { token: StatusService }, { token: FinanceDetailsService }, { token: CreditCardStateService }, { token: NextActionService }, { token: ControlConfigService }, { token: ThreeDsService }, { token: FormMessagesService }, { token: SettingsService }, { token: CountryService }], target: i0.ɵɵFactoryTarget.Injectable });
5751
5842
  PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
@@ -6209,6 +6300,12 @@ class CoreLibraryService {
6209
6300
  return this.statusService.getStatusWithUrlSearchParams(url);
6210
6301
  });
6211
6302
  }
6303
+ getQrCodeInitialData() {
6304
+ return {
6305
+ qrCode: this.paymentService.getQrCode(),
6306
+ pid: this.paymentService.getPid(),
6307
+ };
6308
+ }
6212
6309
  setCountry(country) {
6213
6310
  this.countryService.setCountry(country);
6214
6311
  }
@@ -6236,6 +6333,7 @@ class CoreLibraryService {
6236
6333
  formMessages$: this.formMessagesService.data$,
6237
6334
  getFormStatus: () => { var _a; return (_a = this.paymentService.form) === null || _a === void 0 ? void 0 : _a.status; },
6238
6335
  },
6336
+ addExtraField: (name, value) => this.paymentService.addExtraField(name, value),
6239
6337
  };
6240
6338
  }
6241
6339
  getCreditCardService() {
@@ -6264,6 +6362,15 @@ class CoreLibraryService {
6264
6362
  getUserBalanceValue() {
6265
6363
  return this.userBalanceService.getUserBalanceValue();
6266
6364
  }
6365
+ get paymentForm$() {
6366
+ return this.paymentService.paymentForm$;
6367
+ }
6368
+ get formResponse$() {
6369
+ return this.paymentService.formResponse$;
6370
+ }
6371
+ get formResponseValue() {
6372
+ return this.paymentService.formResponseValue;
6373
+ }
6267
6374
  }
6268
6375
  CoreLibraryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, deps: [{ token: SettingsService }, { token: CountryService }, { token: PaymentMethodsService }, { token: SavedMethodsService }, { token: UserBalanceService }, { token: PaymentConfigService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: StatusService }, { token: NextActionService }, { token: CreditCardService }, { token: CreditCardStateService }, { token: FormMessagesService }, { token: EditSavedMethodsService }, { token: GooglePayService }, { token: PaymentSystemProcessingService }], target: i0.ɵɵFactoryTarget.Injectable });
6269
6376
  CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
@@ -6493,6 +6600,786 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
6493
6600
  }]
6494
6601
  }] });
6495
6602
 
6603
+ const applePayVersion = 3;
6604
+
6605
+ const agreementsGroup = [
6606
+ FieldNames.termsAndConditions,
6607
+ FieldNames.termsAndConditionsHtcEula,
6608
+ FieldNames.termsAndConditionsAtariTc,
6609
+ FieldNames.termsAndConditionsAtariPp,
6610
+ FieldNames.termsAndConditionsRolandEula,
6611
+ FieldNames.termsAndConditionsRobloxEula,
6612
+ FieldNames.termsAndConditionsOnzenga,
6613
+ FieldNames.take2Taxes,
6614
+ FieldNames.rockstarTaxes,
6615
+ FieldNames.omnibusDirective,
6616
+ ];
6617
+
6618
+ var ApplePayErrors;
6619
+ (function (ApplePayErrors) {
6620
+ ApplePayErrors["paymentError"] = "paymentError";
6621
+ ApplePayErrors["deviceIsNotCapableError"] = "deviceIsNotCapableError";
6622
+ })(ApplePayErrors || (ApplePayErrors = {}));
6623
+
6624
+ const unknownValue = 'unknown';
6625
+ const browsers = [
6626
+ {
6627
+ sentName: 'Mozilla Firefox',
6628
+ shortName: 'Firefox',
6629
+ regexpBrowserNameWithVersion: '(Firefox)\\/(.+)',
6630
+ },
6631
+ {
6632
+ sentName: 'Samsung Internet',
6633
+ shortName: 'SamsungBrowser',
6634
+ regexpBrowserNameWithVersion: '(SamsungBrowser)\\/(.+)\\s',
6635
+ },
6636
+ {
6637
+ sentName: 'Opera',
6638
+ shortName: 'Opera',
6639
+ regexpBrowserNameWithVersion: '(Opera)\\/(.+)',
6640
+ },
6641
+ {
6642
+ sentName: 'Opera',
6643
+ shortName: 'Opera',
6644
+ regexpBrowserNameWithVersion: '(OPR)\\/(.+)',
6645
+ },
6646
+ {
6647
+ sentName: 'Microsoft Edge (Legacy)',
6648
+ shortName: 'MSEdge-legacy',
6649
+ regexpBrowserNameWithVersion: '(Edge)\\/(.+)',
6650
+ },
6651
+ {
6652
+ sentName: 'Microsoft Edge (Chromium)',
6653
+ shortName: 'MSEdge',
6654
+ regexpBrowserNameWithVersion: '(Edg)\\/(.+)',
6655
+ },
6656
+ {
6657
+ sentName: 'Google Chrome or Chromium',
6658
+ shortName: 'Chrome',
6659
+ regexpBrowserNameWithVersion: '(Chrome)\\/(.+)\\s',
6660
+ },
6661
+ {
6662
+ sentName: 'Apple Safari',
6663
+ shortName: 'Safari',
6664
+ regexpBrowserNameWithVersion: '(Safari)\\/(.+)',
6665
+ },
6666
+ ];
6667
+
6668
+ var Device;
6669
+ (function (Device) {
6670
+ Device["mobile"] = "mobile";
6671
+ Device["desktop"] = "desktop";
6672
+ })(Device || (Device = {}));
6673
+
6674
+ const osList = [
6675
+ {
6676
+ name: 'Windows XP',
6677
+ regExp: 'Windows XP',
6678
+ },
6679
+ {
6680
+ name: 'Windows XP',
6681
+ regExp: 'Windows NT 5.1|Windows NT5.1',
6682
+ },
6683
+ {
6684
+ name: 'Windows Vista',
6685
+ regExp: 'Windows NT 6.0',
6686
+ },
6687
+ {
6688
+ name: 'Windows 7',
6689
+ regExp: 'Windows NT 6.1',
6690
+ },
6691
+ {
6692
+ name: 'Windows 8',
6693
+ regExp: 'Windows NT 6.2',
6694
+ },
6695
+ {
6696
+ name: 'Windows 8.1',
6697
+ regExp: 'Windows NT 6.3',
6698
+ },
6699
+ {
6700
+ name: 'Windows 10',
6701
+ regExp: 'Windows NT 10.0',
6702
+ },
6703
+ {
6704
+ name: 'Windows CE',
6705
+ regExp: 'Windows CE',
6706
+ },
6707
+ {
6708
+ name: 'iPhone',
6709
+ regExp: 'iphone',
6710
+ },
6711
+ {
6712
+ name: 'iPod',
6713
+ regExp: 'ipod',
6714
+ },
6715
+ {
6716
+ name: 'iPad',
6717
+ regExp: 'ipad',
6718
+ },
6719
+ {
6720
+ name: 'Android',
6721
+ regExp: 'Android ([0-9]{1,2}.[0-9]{1,2}.?[0-9]{0,3})',
6722
+ },
6723
+ {
6724
+ name: 'Android',
6725
+ regExp: 'Android',
6726
+ },
6727
+ {
6728
+ name: 'Android',
6729
+ regExp: 'android',
6730
+ },
6731
+ {
6732
+ name: 'BlackBerry',
6733
+ regExp: 'blackberry',
6734
+ },
6735
+ {
6736
+ name: 'Mobile',
6737
+ regExp: 'webos',
6738
+ },
6739
+ {
6740
+ name: 'Nintendo WiiU',
6741
+ regExp: 'Nintendo WiiU',
6742
+ },
6743
+ {
6744
+ name: 'Xbox One S',
6745
+ regExp: 'XBOX_ONE_ED',
6746
+ },
6747
+ {
6748
+ name: 'Xbox One',
6749
+ regExp: 'Xbox; Xbox One',
6750
+ },
6751
+ {
6752
+ name: 'PlayStation',
6753
+ regExp: 'PlayStation',
6754
+ },
6755
+ {
6756
+ name: 'Windows',
6757
+ regExp: '(win)([0-9]{1,2}\\.[0-9x]{1,2})',
6758
+ },
6759
+ {
6760
+ name: 'Windows',
6761
+ regExp: '(windows)([0-9x]{2})',
6762
+ },
6763
+ {
6764
+ name: 'Windows',
6765
+ regExp: '(windows)([0-9]{1,2}\\.[0-9]{1,2})',
6766
+ },
6767
+ {
6768
+ name: 'Windows',
6769
+ regExp: 'win32',
6770
+ },
6771
+ {
6772
+ name: 'Java',
6773
+ regExp: '(java)([0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,2})',
6774
+ },
6775
+ {
6776
+ name: 'Solaris',
6777
+ regExp: '(Solaris)([0-9]{1,2}\\.[0-9x]{1,2}){0,1}',
6778
+ },
6779
+ {
6780
+ name: 'Unix',
6781
+ regExp: 'unix',
6782
+ },
6783
+ {
6784
+ name: 'Mac OS X',
6785
+ regExp: 'Mac OS X',
6786
+ },
6787
+ {
6788
+ name: 'Mac OS',
6789
+ regExp: '(mac|Macintosh)',
6790
+ },
6791
+ {
6792
+ name: 'SunOS',
6793
+ regExp: '(sunos)([0-9]{1,2}\\.[0-9]{1,2}){0,1}',
6794
+ },
6795
+ {
6796
+ name: 'BeOS',
6797
+ regExp: '(beos)([0-9]{1,2}\\.[0-9]{1,2}){0,1}',
6798
+ },
6799
+ {
6800
+ name: 'RISC OS',
6801
+ regExp: '(risc os)([0-9]{1,2}\\.[0-9]{1,2})',
6802
+ },
6803
+ {
6804
+ name: 'FreeBSD',
6805
+ regExp: 'freebsd',
6806
+ },
6807
+ {
6808
+ name: 'OpenBSD',
6809
+ regExp: 'openbsd',
6810
+ },
6811
+ {
6812
+ name: 'NetBSD',
6813
+ regExp: 'netbsd',
6814
+ },
6815
+ {
6816
+ name: 'IRIX',
6817
+ regExp: 'irix',
6818
+ },
6819
+ {
6820
+ name: 'Plan9',
6821
+ regExp: 'plan9',
6822
+ },
6823
+ {
6824
+ name: 'OSF',
6825
+ regExp: 'osf',
6826
+ },
6827
+ {
6828
+ name: 'AIX',
6829
+ regExp: 'aix',
6830
+ },
6831
+ {
6832
+ name: 'GNU Hurd',
6833
+ regExp: 'GNU Hurd',
6834
+ },
6835
+ {
6836
+ name: 'Linux - Fedora',
6837
+ regExp: '(fedora)',
6838
+ },
6839
+ {
6840
+ name: 'Linux - Kubuntu',
6841
+ regExp: '(kubuntu)',
6842
+ },
6843
+ {
6844
+ name: 'Linux - Ubuntu',
6845
+ regExp: '(ubuntu)',
6846
+ },
6847
+ {
6848
+ name: 'Linux - Debian',
6849
+ regExp: '(debian)',
6850
+ },
6851
+ {
6852
+ name: 'Linux - CentOS',
6853
+ regExp: '(CentOS)',
6854
+ },
6855
+ {
6856
+ name: 'Linux - Mandriva',
6857
+ regExp: '(Mandriva).([0-9]{1,3}(\\.[0-9]{1,3})?(\\.[0-9]{1,3})?)',
6858
+ },
6859
+ {
6860
+ name: 'Linux - SUSE',
6861
+ regExp: '(SUSE).([0-9]{1,3}(\\.[0-9]{1,3})?(\\.[0-9]{1,3})?)',
6862
+ },
6863
+ {
6864
+ name: 'Linux - Slackware (Dropline GNOME)',
6865
+ regExp: '(Dropline)',
6866
+ },
6867
+ {
6868
+ name: 'Linux - ASPLinux',
6869
+ regExp: '(ASPLinux)',
6870
+ },
6871
+ {
6872
+ name: 'Linux - Red Hat',
6873
+ regExp: '(Red Hat)',
6874
+ },
6875
+ {
6876
+ name: 'Linux',
6877
+ regExp: '(linux)',
6878
+ },
6879
+ {
6880
+ name: 'AmigaOS',
6881
+ regExp: '(amigaos)([0-9]{1,2}\\.[0-9]{1,2})',
6882
+ },
6883
+ {
6884
+ name: 'AmigaOS',
6885
+ regExp: 'amiga-aweb',
6886
+ },
6887
+ {
6888
+ name: 'Amiga',
6889
+ regExp: 'amiga',
6890
+ },
6891
+ {
6892
+ name: 'PalmOS',
6893
+ regExp: 'AvantGo',
6894
+ },
6895
+ {
6896
+ name: 'WebTV',
6897
+ regExp: '(webtv)/([0-9]{1,2}\\.[0-9]{1,2})',
6898
+ },
6899
+ {
6900
+ name: 'Dreamcast OS',
6901
+ regExp: 'Dreamcast',
6902
+ },
6903
+ {
6904
+ name: 'Windows',
6905
+ regExp: 'wget',
6906
+ },
6907
+ {
6908
+ name: 'Unknown',
6909
+ regExp: 'Java',
6910
+ },
6911
+ {
6912
+ name: 'Windows',
6913
+ regExp: '(msie)([0-9]{1,2}.[0-9]{1,2})',
6914
+ },
6915
+ {
6916
+ name: 'Unix',
6917
+ regExp: 'libwww-perl',
6918
+ },
6919
+ {
6920
+ name: 'Windows CE',
6921
+ regExp: 'UP.Browser',
6922
+ },
6923
+ {
6924
+ name: 'Windows',
6925
+ regExp: 'NetAnts',
6926
+ },
6927
+ ];
6928
+
6929
+ class UserAgentService {
6930
+ constructor(window) {
6931
+ this.window = window;
6932
+ this._browserName = null;
6933
+ this._browserVersion = null;
6934
+ this._browserApp = null;
6935
+ this._platform = null;
6936
+ this._os = null;
6937
+ this.getUserPlatform();
6938
+ this.getBrowserInformation();
6939
+ this.getOsInformation();
6940
+ }
6941
+ get browserVersion() {
6942
+ return this._browserVersion;
6943
+ }
6944
+ get browserApp() {
6945
+ return this._browserApp;
6946
+ }
6947
+ get platform() {
6948
+ if (this._platform === unknownValue) {
6949
+ return this.osType;
6950
+ }
6951
+ return this._platform;
6952
+ }
6953
+ get userAgent() {
6954
+ return this.window.navigator.userAgent;
6955
+ }
6956
+ get browserDescription() {
6957
+ if (this.browserName === unknownValue || this.browserName === null) {
6958
+ return this.userAgent;
6959
+ }
6960
+ return this.browserName;
6961
+ }
6962
+ get isSafari() {
6963
+ return this._browserName === 'Apple Safari';
6964
+ }
6965
+ get iOsVersion() {
6966
+ var _a;
6967
+ if (this.osType !== 'ios') {
6968
+ return null;
6969
+ }
6970
+ const version = /OS (\d+)_(\d+)_?(\d+)?/.exec(this.window.navigator.appVersion);
6971
+ return version ? `${version[1]}.${version[2]}.${(_a = version[3]) !== null && _a !== void 0 ? _a : 0}` : null;
6972
+ }
6973
+ get browserInfo() {
6974
+ var _a, _b, _c, _d, _e;
6975
+ const browserInfo = {
6976
+ name: this.browserDescription,
6977
+ [(_b = (_a = this.browserApp) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : unknownValue]: true,
6978
+ version: this.browserVersion,
6979
+ [this.browserEngine.toLowerCase()]: true,
6980
+ ui_version: this.isMobileDevice ? Device.mobile : Device.desktop,
6981
+ os: this.os,
6982
+ };
6983
+ if (this.isMobileDevice) {
6984
+ browserInfo.mobile = true;
6985
+ }
6986
+ if (this.osType) {
6987
+ // @ts-expect-error index is string
6988
+ browserInfo[this.osType.toLowerCase()] = true;
6989
+ }
6990
+ if ((_c = this.window.navigator.platform) === null || _c === void 0 ? void 0 : _c.includes('iPhone')) {
6991
+ browserInfo.iphone = true;
6992
+ }
6993
+ if ((_d = this.window.navigator.platform) === null || _d === void 0 ? void 0 : _d.includes('iPod')) {
6994
+ browserInfo.ipod = true;
6995
+ }
6996
+ if ((_e = this.window.navigator.platform) === null || _e === void 0 ? void 0 : _e.includes('iPad')) {
6997
+ browserInfo.ipad = true;
6998
+ browserInfo.tablet = true;
6999
+ }
7000
+ if (this.isAndroid) {
7001
+ browserInfo.android = true;
7002
+ }
7003
+ return browserInfo;
7004
+ }
7005
+ get isMobileDevice() {
7006
+ const deviceAgents = [
7007
+ 'Android',
7008
+ 'webOS',
7009
+ 'iPhone',
7010
+ 'iPad',
7011
+ 'iPod',
7012
+ 'BlackBerry',
7013
+ 'IEMobile',
7014
+ 'Opera Mini',
7015
+ 'Mobile',
7016
+ 'Tablet',
7017
+ 'Kindle',
7018
+ 'Playbook',
7019
+ 'Silk',
7020
+ 'Puffin',
7021
+ 'CriOS',
7022
+ ];
7023
+ return new RegExp(deviceAgents.join('|'), 'i').test(this.userAgent);
7024
+ }
7025
+ get isIosAndNotIpad() {
7026
+ return ['iPhone', 'iPod'].includes(this.window.navigator.platform);
7027
+ }
7028
+ getUserPlatform() {
7029
+ var _a, _b, _c, _d, _e;
7030
+ const experimentalPlatformApi = (_a = this.window.navigator) === null || _a === void 0 ? void 0 : _a.userAgentData;
7031
+ const platform = (_e = (_b = experimentalPlatformApi === null || experimentalPlatformApi === void 0 ? void 0 : experimentalPlatformApi.platform) !== null && _b !== void 0 ? _b : (_d = (_c = this.window) === null || _c === void 0 ? void 0 : _c.navigator) === null || _d === void 0 ? void 0 : _d.platform) !== null && _e !== void 0 ? _e : unknownValue;
7032
+ this._platform = platform.toLowerCase();
7033
+ }
7034
+ getBrowserInformation() {
7035
+ for (const browser of browsers) {
7036
+ const browserRegExp = new RegExp(browser.regexpBrowserNameWithVersion);
7037
+ const browserNameWithVersion = browserRegExp.exec(this.userAgent);
7038
+ if (browserNameWithVersion !== null) {
7039
+ this._browserName = browser.sentName;
7040
+ this._browserApp = browser.shortName;
7041
+ this._browserVersion = browserNameWithVersion[2];
7042
+ break;
7043
+ }
7044
+ this._browserName = unknownValue;
7045
+ this._browserApp = unknownValue;
7046
+ this._browserVersion = unknownValue;
7047
+ }
7048
+ }
7049
+ getOsInformation() {
7050
+ for (const os of osList) {
7051
+ const osRegExp = new RegExp(os.regExp);
7052
+ const osName = osRegExp.exec(this.userAgent);
7053
+ if (osName !== null) {
7054
+ this._os = os.name;
7055
+ break;
7056
+ }
7057
+ this._os = unknownValue;
7058
+ }
7059
+ }
7060
+ get browserName() {
7061
+ return this._browserName;
7062
+ }
7063
+ get isAndroid() {
7064
+ return /Android\s+([\d.]+)/.test(this.userAgent);
7065
+ }
7066
+ get isXbox() {
7067
+ return /xbox/i.test(this.userAgent);
7068
+ }
7069
+ get isLinux() {
7070
+ return /linux/i.test(this.userAgent);
7071
+ }
7072
+ get isWindows() {
7073
+ return /windows/i.test(this.userAgent);
7074
+ }
7075
+ get browserEngine() {
7076
+ var _a;
7077
+ const engines = new Map([
7078
+ ['Firefox', 'Gecko'],
7079
+ ['Safari', 'Webkit'],
7080
+ ['MSEdge-legacy', 'EdgeHTML'],
7081
+ ['Chrome', 'Blink'],
7082
+ ['Opera', 'Blink'],
7083
+ ['MSEdge', 'Blink'],
7084
+ ['SamsungBrowser', 'Blink'],
7085
+ ]);
7086
+ return (_a = engines.get(this.browserApp)) !== null && _a !== void 0 ? _a : unknownValue;
7087
+ }
7088
+ get os() {
7089
+ return this._os;
7090
+ }
7091
+ get osType() {
7092
+ var _a;
7093
+ if (['iPhone', 'iPod', 'iPad'].includes(this.window.navigator.platform)) {
7094
+ return 'ios';
7095
+ }
7096
+ if ((_a = this.window.navigator.platform) === null || _a === void 0 ? void 0 : _a.includes('MacIntel')) {
7097
+ return 'mac';
7098
+ }
7099
+ if (this.isXbox) {
7100
+ return 'xbox';
7101
+ }
7102
+ if (this.isWindows) {
7103
+ return 'windows';
7104
+ }
7105
+ if (this.isAndroid) {
7106
+ return 'android';
7107
+ }
7108
+ if (this.isLinux) {
7109
+ return 'linux';
7110
+ }
7111
+ return null;
7112
+ }
7113
+ }
7114
+ UserAgentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UserAgentService, deps: [{ token: windowToken }], target: i0.ɵɵFactoryTarget.Injectable });
7115
+ UserAgentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UserAgentService, providedIn: 'root' });
7116
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UserAgentService, decorators: [{
7117
+ type: Injectable,
7118
+ args: [{
7119
+ providedIn: 'root',
7120
+ }]
7121
+ }], ctorParameters: function () {
7122
+ return [{ type: undefined, decorators: [{
7123
+ type: Inject,
7124
+ args: [windowToken]
7125
+ }] }];
7126
+ } });
7127
+
7128
+ class ApplePayService {
7129
+ get paymentParameters() {
7130
+ return this.applePayParams;
7131
+ }
7132
+ get payment$() {
7133
+ return this.payment.asObservable();
7134
+ }
7135
+ get error$() {
7136
+ return this.error.asObservable();
7137
+ }
7138
+ get integrationType$() {
7139
+ return this.integrationType.asObservable();
7140
+ }
7141
+ constructor(window, userAgentService, summaryFinanceDetailsAdapterService) {
7142
+ this.window = window;
7143
+ this.userAgentService = userAgentService;
7144
+ this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
7145
+ this.agreementFieldsNames = agreementsGroup;
7146
+ this.payment = new Subject();
7147
+ this.error = new Subject();
7148
+ this.integrationType = new Subject();
7149
+ this.paymentClient = null;
7150
+ this.applePayParams = null;
7151
+ this.order = null;
7152
+ this.api = this.loadBraintree();
7153
+ }
7154
+ setApplePayParams(data) {
7155
+ var _a, _b, _c, _d;
7156
+ const formFields = (_a = data === null || data === void 0 ? void 0 : data.paymentForm) === null || _a === void 0 ? void 0 : _a.fields;
7157
+ const summary = (_b = data === null || data === void 0 ? void 0 : data.paymentForm) === null || _b === void 0 ? void 0 : _b.summary;
7158
+ if (!formFields || !summary) {
7159
+ return;
7160
+ }
7161
+ const fields = formFields.reduce((acc, field) => {
7162
+ if (this.agreementFieldsNames.includes(field.name) &&
7163
+ field.isVisible === '1') {
7164
+ acc[field.name] = field.title;
7165
+ }
7166
+ else {
7167
+ acc[field.name] = field.value;
7168
+ }
7169
+ return acc;
7170
+ }, {});
7171
+ const agreements = this.agreementFieldsNames
7172
+ .map((fieldName) => fields[fieldName])
7173
+ .filter(Boolean);
7174
+ this.applePayParams = {
7175
+ tokenKey: this.getAppleToken(formFields),
7176
+ totalLabel: (_c = fields['label_applePay']) !== null && _c !== void 0 ? _c : '',
7177
+ totalAmount: this.getTotalAmount(summary),
7178
+ currencyCode: this.getTotalCurrency(summary),
7179
+ countryCode: (_d = fields['countryCode']) !== null && _d !== void 0 ? _d : '',
7180
+ merchantCapabilities: this.getJsonValueFromField(fields, 'merchantCapabilities'),
7181
+ supportedNetworks: this.getJsonValueFromField(fields, 'supportedNetworks'),
7182
+ agreements: agreements,
7183
+ };
7184
+ }
7185
+ initLibrary(tokenKey) {
7186
+ return __awaiter(this, void 0, void 0, function* () {
7187
+ try {
7188
+ const api = yield this.api;
7189
+ const clientInstance = yield api.client.create({
7190
+ authorization: tokenKey,
7191
+ });
7192
+ this.paymentClient = yield api.applePay.create({
7193
+ client: clientInstance,
7194
+ });
7195
+ }
7196
+ catch (error) {
7197
+ console.error('apple pay: initialize failed', error);
7198
+ }
7199
+ this.emitIntegrationType();
7200
+ if (!this.paymentClient ||
7201
+ (!this.isDeviceCapable() && !this.userAgentService.isSafari)) {
7202
+ this.emitError(ApplePayErrors.deviceIsNotCapableError);
7203
+ }
7204
+ });
7205
+ }
7206
+ redirectToPaymentPage(parameters, token) {
7207
+ const route = pagesRoutes.get(applePayId);
7208
+ if (!route) {
7209
+ return;
7210
+ }
7211
+ const query = new URLSearchParams(Object.assign(Object.assign({}, parameters), { merchantCapabilities: JSON.stringify(parameters.merchantCapabilities), supportedNetworks: JSON.stringify(parameters.supportedNetworks), token, agreements: JSON.stringify(parameters.agreements) }));
7212
+ if (this.order) {
7213
+ query.append('order', this.order);
7214
+ }
7215
+ const url = `${route}?${query.toString()}`;
7216
+ return url;
7217
+ }
7218
+ setOrder(data) {
7219
+ var _a;
7220
+ const summary = (_a = data === null || data === void 0 ? void 0 : data.paymentForm) === null || _a === void 0 ? void 0 : _a.summary;
7221
+ if (!summary) {
7222
+ return;
7223
+ }
7224
+ const financeDetails = this.summaryFinanceDetailsAdapterService.getFinanceDetails(summary);
7225
+ if ((financeDetails === null || financeDetails === void 0 ? void 0 : financeDetails.purchase) && (financeDetails === null || financeDetails === void 0 ? void 0 : financeDetails.finance)) {
7226
+ const cartItems = financeDetails.cartItems;
7227
+ this.order = cartItems === null || cartItems === void 0 ? void 0 : cartItems.reduce((curr, item) => {
7228
+ if (curr) {
7229
+ return curr + `; ${item.title}`;
7230
+ }
7231
+ return curr + item.title;
7232
+ }, '');
7233
+ }
7234
+ }
7235
+ proceedCheckout(parameters) {
7236
+ if (!parameters) {
7237
+ return;
7238
+ }
7239
+ if (!this.paymentClient || !this.isDeviceCapable()) {
7240
+ console.warn('apple pay: device is not capable', this.paymentClient);
7241
+ this.emitError(ApplePayErrors.deviceIsNotCapableError);
7242
+ return;
7243
+ }
7244
+ try {
7245
+ const paymentRequest = this.paymentClient.createPaymentRequest({
7246
+ total: {
7247
+ label: parameters.totalLabel,
7248
+ amount: parameters.totalAmount,
7249
+ },
7250
+ currencyCode: parameters.currencyCode,
7251
+ countryCode: parameters.countryCode,
7252
+ merchantCapabilities: parameters.merchantCapabilities,
7253
+ supportedNetworks: parameters.supportedNetworks,
7254
+ });
7255
+ const session = new this.window.ApplePaySession(applePayVersion, paymentRequest);
7256
+ session.onvalidatemerchant = (event) => {
7257
+ var _a;
7258
+ console.info('apple pay: merchant validation', event);
7259
+ (_a = this.paymentClient) === null || _a === void 0 ? void 0 : _a.performValidation({
7260
+ validationURL: event.validationURL,
7261
+ displayName: parameters === null || parameters === void 0 ? void 0 : parameters.totalLabel,
7262
+ }).then((merchantSession) => {
7263
+ session.completeMerchantValidation(merchantSession);
7264
+ }).catch((error) => {
7265
+ console.error('apple pay: merchant validation error', error);
7266
+ session.abort();
7267
+ });
7268
+ };
7269
+ session.onpaymentauthorized = (event) => {
7270
+ var _a;
7271
+ console.info('apple pay: payment authorization', event);
7272
+ (_a = this.paymentClient) === null || _a === void 0 ? void 0 : _a.tokenize({
7273
+ token: event.payment.token,
7274
+ }).then((authorizationResponse) => {
7275
+ var _a;
7276
+ this.payment.next((_a = authorizationResponse === null || authorizationResponse === void 0 ? void 0 : authorizationResponse.nonce) !== null && _a !== void 0 ? _a : '');
7277
+ session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
7278
+ }).catch((error) => {
7279
+ console.error('apple pay: payment authorization error', error);
7280
+ session.completePayment(this.window.ApplePaySession.STATUS_FAILURE);
7281
+ });
7282
+ };
7283
+ session.oncancel = (event) => {
7284
+ this.emitError(ApplePayErrors.paymentError);
7285
+ console.error('apple pay: user cancel payment', event);
7286
+ };
7287
+ session.begin();
7288
+ }
7289
+ catch (error) {
7290
+ console.error('apple pay: checkout error', error);
7291
+ this.emitError(ApplePayErrors.paymentError);
7292
+ }
7293
+ }
7294
+ isDeviceCapable() {
7295
+ var _a, _b;
7296
+ try {
7297
+ return Boolean(((_a = this.window.ApplePaySession) === null || _a === void 0 ? void 0 : _a.supportsVersion(applePayVersion)) &&
7298
+ ((_b = this.window.ApplePaySession) === null || _b === void 0 ? void 0 : _b.canMakePayments()));
7299
+ }
7300
+ catch (error) {
7301
+ return false;
7302
+ }
7303
+ }
7304
+ getTokenNonceFieldData(tokenNonce) {
7305
+ const name = FieldNames.tokenApplePay;
7306
+ const value = btoa(tokenNonce);
7307
+ return { name, value };
7308
+ }
7309
+ updateApplePayParams(data) {
7310
+ const summary = data === null || data === void 0 ? void 0 : data.summary;
7311
+ if (!this.applePayParams || !summary) {
7312
+ return;
7313
+ }
7314
+ this.applePayParams.totalAmount = this.getTotalAmount(summary);
7315
+ this.applePayParams.currencyCode = this.getTotalCurrency(summary);
7316
+ }
7317
+ loadBraintree() {
7318
+ return __awaiter(this, void 0, void 0, function* () {
7319
+ const api = yield import('braintree-web');
7320
+ return api;
7321
+ });
7322
+ }
7323
+ getAppleToken(formFields) {
7324
+ const appleTokenField = formFields.find((field) => {
7325
+ return field.name === 'token_key';
7326
+ });
7327
+ if (!appleTokenField) {
7328
+ return '';
7329
+ }
7330
+ return appleTokenField.value;
7331
+ }
7332
+ getTotalAmount(summary) {
7333
+ var _a, _b, _c;
7334
+ const finance = summary === null || summary === void 0 ? void 0 : summary.finance;
7335
+ const total = (_b = (_a = finance === null || finance === void 0 ? void 0 : finance.grand_total) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : finance === null || finance === void 0 ? void 0 : finance.total.amount;
7336
+ return (_c = total === null || total === void 0 ? void 0 : total.toString()) !== null && _c !== void 0 ? _c : '';
7337
+ }
7338
+ getTotalCurrency(summary) {
7339
+ var _a, _b, _c, _d;
7340
+ const finance = summary === null || summary === void 0 ? void 0 : summary.finance;
7341
+ return (_d = (_b = (_a = finance === null || finance === void 0 ? void 0 : finance.grand_total) === null || _a === void 0 ? void 0 : _a.currency) !== null && _b !== void 0 ? _b : (_c = finance === null || finance === void 0 ? void 0 : finance.total) === null || _c === void 0 ? void 0 : _c.currency) !== null && _d !== void 0 ? _d : '';
7342
+ }
7343
+ getJsonValueFromField(fields, fieldName) {
7344
+ const field = fields[fieldName];
7345
+ try {
7346
+ return field ? JSON.parse(field) : undefined;
7347
+ }
7348
+ catch (error) {
7349
+ return undefined;
7350
+ }
7351
+ }
7352
+ emitError(error) {
7353
+ this.error.next(error);
7354
+ }
7355
+ emitIntegrationType() {
7356
+ let integrationType;
7357
+ if (this.paymentClient && this.isDeviceCapable()) {
7358
+ integrationType = 'sdk';
7359
+ }
7360
+ else if (this.userAgentService.isSafari) {
7361
+ integrationType = 'redirect';
7362
+ }
7363
+ else {
7364
+ integrationType = 'none';
7365
+ }
7366
+ this.integrationType.next(integrationType);
7367
+ }
7368
+ }
7369
+ ApplePayService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ApplePayService, deps: [{ token: windowToken }, { token: UserAgentService }, { token: SummaryFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable });
7370
+ ApplePayService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ApplePayService, providedIn: 'root' });
7371
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ApplePayService, decorators: [{
7372
+ type: Injectable,
7373
+ args: [{
7374
+ providedIn: 'root',
7375
+ }]
7376
+ }], ctorParameters: function () {
7377
+ return [{ type: undefined, decorators: [{
7378
+ type: Inject,
7379
+ args: [windowToken]
7380
+ }] }, { type: UserAgentService }, { type: SummaryFinanceDetailsAdapterService }];
7381
+ } });
7382
+
6496
7383
  /*
6497
7384
  * Public API Surface of core-library
6498
7385
  */
@@ -6501,5 +7388,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
6501
7388
  * Generated bundle index. Do not edit.
6502
7389
  */
6503
7390
 
6504
- export { CoreLibraryModule, CoreLibraryService };
7391
+ export { ApplePayService, CoreLibraryModule, CoreLibraryService };
6505
7392
  //# sourceMappingURL=xsolla-payment-client-core.mjs.map