@xsolla/payment-client-core 0.2.7 → 0.2.8
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/esm2020/lib/core/agreementsGroup.const.mjs +14 -0
- package/esm2020/lib/core/extended-window.interface.mjs +1 -1
- package/esm2020/lib/core/payment/actions/redirect/ps4-pages/pages-payment-methods-id.const.mjs +2 -2
- package/esm2020/lib/core/payment/actions/redirect/ps4-pages/pages-routes.const.mjs +3 -3
- package/esm2020/lib/core/payment/field-names.enum.mjs +2 -1
- package/esm2020/lib/core/payment/form-response.interface.mjs +2 -0
- package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.service.mjs +56 -2
- package/esm2020/lib/core/sdk-payment-systems/apple-pay/apple-pay-integration.type.mjs +2 -0
- package/esm2020/lib/core/sdk-payment-systems/apple-pay/apple-pay-params.interface.mjs +2 -0
- package/esm2020/lib/core/sdk-payment-systems/apple-pay/apple-pay.const.mjs +2 -0
- package/esm2020/lib/core/sdk-payment-systems/apple-pay/apple-pay.errors.enum.mjs +6 -0
- package/esm2020/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.mjs +265 -0
- package/esm2020/lib/core/sdk-payment-systems/apple-pay/checkout-params.interface.mjs +2 -0
- package/esm2020/lib/core/user-agent/browserInfo.interface.mjs +2 -0
- package/esm2020/lib/core/user-agent/browsers.mjs +44 -0
- package/esm2020/lib/core/user-agent/device.enum.mjs +6 -0
- package/esm2020/lib/core/user-agent/os.mjs +255 -0
- package/esm2020/lib/core/user-agent/user-agent-data.interface.mjs +2 -0
- package/esm2020/lib/core/user-agent/user-agent.service.mjs +200 -0
- package/esm2020/lib/core-library.service.mjs +11 -1
- package/esm2020/public-api.mjs +3 -1
- package/fesm2015/xsolla-payment-client-core.mjs +849 -4
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +842 -4
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/agreementsGroup.const.d.ts +2 -0
- package/lib/core/extended-window.interface.d.ts +11 -0
- package/lib/core/payment/actions/redirect/ps4-pages/pages-payment-methods-id.const.d.ts +1 -1
- package/lib/core/payment/field-names.enum.d.ts +2 -1
- package/lib/core/payment/form-response.interface.d.ts +8 -0
- package/lib/core/payment/payment.interface.d.ts +1 -0
- package/lib/core/payment/payment.service.d.ts +9 -1
- package/lib/core/sdk-payment-systems/apple-pay/apple-pay-integration.type.d.ts +1 -0
- package/lib/core/sdk-payment-systems/apple-pay/apple-pay-params.interface.d.ts +4 -0
- package/lib/core/sdk-payment-systems/apple-pay/apple-pay.const.d.ts +1 -0
- package/lib/core/sdk-payment-systems/apple-pay/apple-pay.errors.enum.d.ts +4 -0
- package/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.d.ts +46 -0
- package/lib/core/sdk-payment-systems/apple-pay/checkout-params.interface.d.ts +9 -0
- package/lib/core/user-agent/browserInfo.interface.d.ts +13 -0
- package/lib/core/user-agent/browsers.d.ts +9 -0
- package/lib/core/user-agent/device.enum.d.ts +4 -0
- package/lib/core/user-agent/os.d.ts +7 -0
- package/lib/core/user-agent/user-agent-data.interface.d.ts +10 -0
- package/lib/core/user-agent/user-agent.service.d.ts +36 -0
- package/lib/core-library.service.d.ts +5 -0
- package/package.json +4 -2
- package/public-api.d.ts +2 -0
- package/xsolla-payment-client-core-0.2.8.tgz +0 -0
- package/xsolla-payment-client-core-0.2.7.tgz +0 -0
|
@@ -590,6 +590,7 @@ var FieldNames;
|
|
|
590
590
|
FieldNames["sum"] = "sum";
|
|
591
591
|
FieldNames["out"] = "out";
|
|
592
592
|
FieldNames["tinkoffDisclaimer"] = "ps.tinkoff.disclaimer";
|
|
593
|
+
FieldNames["omnibusDirective"] = "omnibus_directive";
|
|
593
594
|
})(FieldNames || (FieldNames = {}));
|
|
594
595
|
|
|
595
596
|
class SubmitResponse {
|
|
@@ -766,14 +767,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
766
767
|
|
|
767
768
|
const vkPay = 3496;
|
|
768
769
|
const googlePay = 3431;
|
|
769
|
-
const
|
|
770
|
+
const applePayId = 3175;
|
|
770
771
|
const barzahlenPay = 1679;
|
|
771
772
|
const naverPay = 3563;
|
|
772
773
|
const venmoPay = 3636;
|
|
773
774
|
|
|
774
775
|
const pagesRoutes = new Map([
|
|
775
776
|
[vkPay, '/payment/external-pages/vk-pay'],
|
|
776
|
-
[
|
|
777
|
+
[applePayId, '/payment/external-pages/apple-pay'],
|
|
777
778
|
[barzahlenPay, '/payment/external-pages/barzahlen-pay'],
|
|
778
779
|
[naverPay, '/payment/external-pages/naver-pay'],
|
|
779
780
|
[venmoPay, '/payment/external-pages/venmo-pay'],
|
|
@@ -5509,6 +5510,15 @@ class PaymentService {
|
|
|
5509
5510
|
get formFieldsStatus$() {
|
|
5510
5511
|
return this.formFieldsStatusSubject.asObservable().pipe(filter$1(Boolean));
|
|
5511
5512
|
}
|
|
5513
|
+
get paymentForm$() {
|
|
5514
|
+
return this._paymentForm$.asObservable();
|
|
5515
|
+
}
|
|
5516
|
+
get formResponse$() {
|
|
5517
|
+
return this._formResponse$.asObservable();
|
|
5518
|
+
}
|
|
5519
|
+
get formResponseValue() {
|
|
5520
|
+
return this._formResponse$.getValue();
|
|
5521
|
+
}
|
|
5512
5522
|
constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService, formMessagesService, settingsService, countryService) {
|
|
5513
5523
|
this.initializeService = initializeService;
|
|
5514
5524
|
this.submitService = submitService;
|
|
@@ -5530,7 +5540,9 @@ class PaymentService {
|
|
|
5530
5540
|
this.fields = [];
|
|
5531
5541
|
this.destroy$ = new Subject();
|
|
5532
5542
|
this.formDestroy$ = new Subject();
|
|
5543
|
+
this._paymentForm$ = new BehaviorSubject(null);
|
|
5533
5544
|
this.formFieldsStatusSubject = new BehaviorSubject(null);
|
|
5545
|
+
this._formResponse$ = new BehaviorSubject(null);
|
|
5534
5546
|
this.isSavingMethodMode = false;
|
|
5535
5547
|
}
|
|
5536
5548
|
initialize(config) {
|
|
@@ -5541,6 +5553,7 @@ class PaymentService {
|
|
|
5541
5553
|
this.listenFinanceDetails();
|
|
5542
5554
|
this.config = config;
|
|
5543
5555
|
this.data = yield this.initializeService.request(config);
|
|
5556
|
+
this.emitFormResponse(this.data);
|
|
5544
5557
|
this.fields = this.getFields();
|
|
5545
5558
|
this.form = this.formService.createForm(this.fields);
|
|
5546
5559
|
this.updatePidConfig();
|
|
@@ -5565,6 +5578,7 @@ class PaymentService {
|
|
|
5565
5578
|
this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
|
|
5566
5579
|
const submitResponse = yield this.submitService.request(this.fields, this.form);
|
|
5567
5580
|
this.data = submitResponse;
|
|
5581
|
+
this.emitFormResponse(this.data);
|
|
5568
5582
|
if (!this.isSavingMethodMode) {
|
|
5569
5583
|
this.emitFinanceDetails(submitResponse.summary);
|
|
5570
5584
|
}
|
|
@@ -5678,6 +5692,30 @@ class PaymentService {
|
|
|
5678
5692
|
}
|
|
5679
5693
|
this.emitFormFieldsStatus(this.form);
|
|
5680
5694
|
}
|
|
5695
|
+
addExtraField(name, value) {
|
|
5696
|
+
const isHaveField = this.fields.find((field) => {
|
|
5697
|
+
return field.name === name;
|
|
5698
|
+
});
|
|
5699
|
+
if (isHaveField) {
|
|
5700
|
+
this.fields = this.fields.map((field) => {
|
|
5701
|
+
if (field.name === name) {
|
|
5702
|
+
field.value = value;
|
|
5703
|
+
}
|
|
5704
|
+
return field;
|
|
5705
|
+
});
|
|
5706
|
+
return;
|
|
5707
|
+
}
|
|
5708
|
+
const field = {
|
|
5709
|
+
name: name,
|
|
5710
|
+
value: value,
|
|
5711
|
+
title: '',
|
|
5712
|
+
type: 'text',
|
|
5713
|
+
example: '',
|
|
5714
|
+
isMandatory: "1" /* XpsBoolean.true */,
|
|
5715
|
+
isVisible: "0" /* XpsBoolean.false */,
|
|
5716
|
+
};
|
|
5717
|
+
this.fields.push(field);
|
|
5718
|
+
}
|
|
5681
5719
|
destroy() {
|
|
5682
5720
|
this.data = null;
|
|
5683
5721
|
this.financeDetails = null;
|
|
@@ -5717,6 +5755,7 @@ class PaymentService {
|
|
|
5717
5755
|
.subscribe((response) => {
|
|
5718
5756
|
this.emitFinanceDetails(response.summary);
|
|
5719
5757
|
this.emitFormMessages(response.messages);
|
|
5758
|
+
this.emitFormResponse(response);
|
|
5720
5759
|
});
|
|
5721
5760
|
this.syncService.fieldAsyncValidation$
|
|
5722
5761
|
.pipe(takeUntil(this.destroy$))
|
|
@@ -5735,7 +5774,10 @@ class PaymentService {
|
|
|
5735
5774
|
listenFormStatusChanges(form) {
|
|
5736
5775
|
form.statusChanges
|
|
5737
5776
|
.pipe(takeUntil(this.formDestroy$))
|
|
5738
|
-
.subscribe(() =>
|
|
5777
|
+
.subscribe((status) => {
|
|
5778
|
+
this.emitFormFieldsStatus(form);
|
|
5779
|
+
this._paymentForm$.next(status);
|
|
5780
|
+
});
|
|
5739
5781
|
}
|
|
5740
5782
|
/*
|
|
5741
5783
|
* in case the form pid changes despite the one passed during initialization
|
|
@@ -5746,6 +5788,19 @@ class PaymentService {
|
|
|
5746
5788
|
this.config.paymentMethodId = currentPid;
|
|
5747
5789
|
}
|
|
5748
5790
|
}
|
|
5791
|
+
emitFormResponse(data) {
|
|
5792
|
+
let type;
|
|
5793
|
+
if (data instanceof InitializeResponse) {
|
|
5794
|
+
type = 'initialize';
|
|
5795
|
+
}
|
|
5796
|
+
else if (data instanceof SubmitResponse) {
|
|
5797
|
+
type = 'submit';
|
|
5798
|
+
}
|
|
5799
|
+
else {
|
|
5800
|
+
type = 'sync';
|
|
5801
|
+
}
|
|
5802
|
+
this._formResponse$.next({ type, data, token: this.settingsService.token });
|
|
5803
|
+
}
|
|
5749
5804
|
}
|
|
5750
5805
|
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
5806
|
PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
|
|
@@ -6236,6 +6291,7 @@ class CoreLibraryService {
|
|
|
6236
6291
|
formMessages$: this.formMessagesService.data$,
|
|
6237
6292
|
getFormStatus: () => { var _a; return (_a = this.paymentService.form) === null || _a === void 0 ? void 0 : _a.status; },
|
|
6238
6293
|
},
|
|
6294
|
+
addExtraField: (name, value) => this.paymentService.addExtraField(name, value),
|
|
6239
6295
|
};
|
|
6240
6296
|
}
|
|
6241
6297
|
getCreditCardService() {
|
|
@@ -6264,6 +6320,15 @@ class CoreLibraryService {
|
|
|
6264
6320
|
getUserBalanceValue() {
|
|
6265
6321
|
return this.userBalanceService.getUserBalanceValue();
|
|
6266
6322
|
}
|
|
6323
|
+
get paymentForm$() {
|
|
6324
|
+
return this.paymentService.paymentForm$;
|
|
6325
|
+
}
|
|
6326
|
+
get formResponse$() {
|
|
6327
|
+
return this.paymentService.formResponse$;
|
|
6328
|
+
}
|
|
6329
|
+
get formResponseValue() {
|
|
6330
|
+
return this.paymentService.formResponseValue;
|
|
6331
|
+
}
|
|
6267
6332
|
}
|
|
6268
6333
|
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
6334
|
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|
|
@@ -6493,6 +6558,786 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
6493
6558
|
}]
|
|
6494
6559
|
}] });
|
|
6495
6560
|
|
|
6561
|
+
const applePayVersion = 3;
|
|
6562
|
+
|
|
6563
|
+
const agreementsGroup = [
|
|
6564
|
+
FieldNames.termsAndConditions,
|
|
6565
|
+
FieldNames.termsAndConditionsHtcEula,
|
|
6566
|
+
FieldNames.termsAndConditionsAtariTc,
|
|
6567
|
+
FieldNames.termsAndConditionsAtariPp,
|
|
6568
|
+
FieldNames.termsAndConditionsRolandEula,
|
|
6569
|
+
FieldNames.termsAndConditionsRobloxEula,
|
|
6570
|
+
FieldNames.termsAndConditionsOnzenga,
|
|
6571
|
+
FieldNames.take2Taxes,
|
|
6572
|
+
FieldNames.rockstarTaxes,
|
|
6573
|
+
FieldNames.omnibusDirective,
|
|
6574
|
+
];
|
|
6575
|
+
|
|
6576
|
+
var ApplePayErrors;
|
|
6577
|
+
(function (ApplePayErrors) {
|
|
6578
|
+
ApplePayErrors["paymentError"] = "paymentError";
|
|
6579
|
+
ApplePayErrors["deviceIsNotCapableError"] = "deviceIsNotCapableError";
|
|
6580
|
+
})(ApplePayErrors || (ApplePayErrors = {}));
|
|
6581
|
+
|
|
6582
|
+
const unknownValue = 'unknown';
|
|
6583
|
+
const browsers = [
|
|
6584
|
+
{
|
|
6585
|
+
sentName: 'Mozilla Firefox',
|
|
6586
|
+
shortName: 'Firefox',
|
|
6587
|
+
regexpBrowserNameWithVersion: '(Firefox)\\/(.+)',
|
|
6588
|
+
},
|
|
6589
|
+
{
|
|
6590
|
+
sentName: 'Samsung Internet',
|
|
6591
|
+
shortName: 'SamsungBrowser',
|
|
6592
|
+
regexpBrowserNameWithVersion: '(SamsungBrowser)\\/(.+)\\s',
|
|
6593
|
+
},
|
|
6594
|
+
{
|
|
6595
|
+
sentName: 'Opera',
|
|
6596
|
+
shortName: 'Opera',
|
|
6597
|
+
regexpBrowserNameWithVersion: '(Opera)\\/(.+)',
|
|
6598
|
+
},
|
|
6599
|
+
{
|
|
6600
|
+
sentName: 'Opera',
|
|
6601
|
+
shortName: 'Opera',
|
|
6602
|
+
regexpBrowserNameWithVersion: '(OPR)\\/(.+)',
|
|
6603
|
+
},
|
|
6604
|
+
{
|
|
6605
|
+
sentName: 'Microsoft Edge (Legacy)',
|
|
6606
|
+
shortName: 'MSEdge-legacy',
|
|
6607
|
+
regexpBrowserNameWithVersion: '(Edge)\\/(.+)',
|
|
6608
|
+
},
|
|
6609
|
+
{
|
|
6610
|
+
sentName: 'Microsoft Edge (Chromium)',
|
|
6611
|
+
shortName: 'MSEdge',
|
|
6612
|
+
regexpBrowserNameWithVersion: '(Edg)\\/(.+)',
|
|
6613
|
+
},
|
|
6614
|
+
{
|
|
6615
|
+
sentName: 'Google Chrome or Chromium',
|
|
6616
|
+
shortName: 'Chrome',
|
|
6617
|
+
regexpBrowserNameWithVersion: '(Chrome)\\/(.+)\\s',
|
|
6618
|
+
},
|
|
6619
|
+
{
|
|
6620
|
+
sentName: 'Apple Safari',
|
|
6621
|
+
shortName: 'Safari',
|
|
6622
|
+
regexpBrowserNameWithVersion: '(Safari)\\/(.+)',
|
|
6623
|
+
},
|
|
6624
|
+
];
|
|
6625
|
+
|
|
6626
|
+
var Device;
|
|
6627
|
+
(function (Device) {
|
|
6628
|
+
Device["mobile"] = "mobile";
|
|
6629
|
+
Device["desktop"] = "desktop";
|
|
6630
|
+
})(Device || (Device = {}));
|
|
6631
|
+
|
|
6632
|
+
const osList = [
|
|
6633
|
+
{
|
|
6634
|
+
name: 'Windows XP',
|
|
6635
|
+
regExp: 'Windows XP',
|
|
6636
|
+
},
|
|
6637
|
+
{
|
|
6638
|
+
name: 'Windows XP',
|
|
6639
|
+
regExp: 'Windows NT 5.1|Windows NT5.1',
|
|
6640
|
+
},
|
|
6641
|
+
{
|
|
6642
|
+
name: 'Windows Vista',
|
|
6643
|
+
regExp: 'Windows NT 6.0',
|
|
6644
|
+
},
|
|
6645
|
+
{
|
|
6646
|
+
name: 'Windows 7',
|
|
6647
|
+
regExp: 'Windows NT 6.1',
|
|
6648
|
+
},
|
|
6649
|
+
{
|
|
6650
|
+
name: 'Windows 8',
|
|
6651
|
+
regExp: 'Windows NT 6.2',
|
|
6652
|
+
},
|
|
6653
|
+
{
|
|
6654
|
+
name: 'Windows 8.1',
|
|
6655
|
+
regExp: 'Windows NT 6.3',
|
|
6656
|
+
},
|
|
6657
|
+
{
|
|
6658
|
+
name: 'Windows 10',
|
|
6659
|
+
regExp: 'Windows NT 10.0',
|
|
6660
|
+
},
|
|
6661
|
+
{
|
|
6662
|
+
name: 'Windows CE',
|
|
6663
|
+
regExp: 'Windows CE',
|
|
6664
|
+
},
|
|
6665
|
+
{
|
|
6666
|
+
name: 'iPhone',
|
|
6667
|
+
regExp: 'iphone',
|
|
6668
|
+
},
|
|
6669
|
+
{
|
|
6670
|
+
name: 'iPod',
|
|
6671
|
+
regExp: 'ipod',
|
|
6672
|
+
},
|
|
6673
|
+
{
|
|
6674
|
+
name: 'iPad',
|
|
6675
|
+
regExp: 'ipad',
|
|
6676
|
+
},
|
|
6677
|
+
{
|
|
6678
|
+
name: 'Android',
|
|
6679
|
+
regExp: 'Android ([0-9]{1,2}.[0-9]{1,2}.?[0-9]{0,3})',
|
|
6680
|
+
},
|
|
6681
|
+
{
|
|
6682
|
+
name: 'Android',
|
|
6683
|
+
regExp: 'Android',
|
|
6684
|
+
},
|
|
6685
|
+
{
|
|
6686
|
+
name: 'Android',
|
|
6687
|
+
regExp: 'android',
|
|
6688
|
+
},
|
|
6689
|
+
{
|
|
6690
|
+
name: 'BlackBerry',
|
|
6691
|
+
regExp: 'blackberry',
|
|
6692
|
+
},
|
|
6693
|
+
{
|
|
6694
|
+
name: 'Mobile',
|
|
6695
|
+
regExp: 'webos',
|
|
6696
|
+
},
|
|
6697
|
+
{
|
|
6698
|
+
name: 'Nintendo WiiU',
|
|
6699
|
+
regExp: 'Nintendo WiiU',
|
|
6700
|
+
},
|
|
6701
|
+
{
|
|
6702
|
+
name: 'Xbox One S',
|
|
6703
|
+
regExp: 'XBOX_ONE_ED',
|
|
6704
|
+
},
|
|
6705
|
+
{
|
|
6706
|
+
name: 'Xbox One',
|
|
6707
|
+
regExp: 'Xbox; Xbox One',
|
|
6708
|
+
},
|
|
6709
|
+
{
|
|
6710
|
+
name: 'PlayStation',
|
|
6711
|
+
regExp: 'PlayStation',
|
|
6712
|
+
},
|
|
6713
|
+
{
|
|
6714
|
+
name: 'Windows',
|
|
6715
|
+
regExp: '(win)([0-9]{1,2}\\.[0-9x]{1,2})',
|
|
6716
|
+
},
|
|
6717
|
+
{
|
|
6718
|
+
name: 'Windows',
|
|
6719
|
+
regExp: '(windows)([0-9x]{2})',
|
|
6720
|
+
},
|
|
6721
|
+
{
|
|
6722
|
+
name: 'Windows',
|
|
6723
|
+
regExp: '(windows)([0-9]{1,2}\\.[0-9]{1,2})',
|
|
6724
|
+
},
|
|
6725
|
+
{
|
|
6726
|
+
name: 'Windows',
|
|
6727
|
+
regExp: 'win32',
|
|
6728
|
+
},
|
|
6729
|
+
{
|
|
6730
|
+
name: 'Java',
|
|
6731
|
+
regExp: '(java)([0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,2})',
|
|
6732
|
+
},
|
|
6733
|
+
{
|
|
6734
|
+
name: 'Solaris',
|
|
6735
|
+
regExp: '(Solaris)([0-9]{1,2}\\.[0-9x]{1,2}){0,1}',
|
|
6736
|
+
},
|
|
6737
|
+
{
|
|
6738
|
+
name: 'Unix',
|
|
6739
|
+
regExp: 'unix',
|
|
6740
|
+
},
|
|
6741
|
+
{
|
|
6742
|
+
name: 'Mac OS X',
|
|
6743
|
+
regExp: 'Mac OS X',
|
|
6744
|
+
},
|
|
6745
|
+
{
|
|
6746
|
+
name: 'Mac OS',
|
|
6747
|
+
regExp: '(mac|Macintosh)',
|
|
6748
|
+
},
|
|
6749
|
+
{
|
|
6750
|
+
name: 'SunOS',
|
|
6751
|
+
regExp: '(sunos)([0-9]{1,2}\\.[0-9]{1,2}){0,1}',
|
|
6752
|
+
},
|
|
6753
|
+
{
|
|
6754
|
+
name: 'BeOS',
|
|
6755
|
+
regExp: '(beos)([0-9]{1,2}\\.[0-9]{1,2}){0,1}',
|
|
6756
|
+
},
|
|
6757
|
+
{
|
|
6758
|
+
name: 'RISC OS',
|
|
6759
|
+
regExp: '(risc os)([0-9]{1,2}\\.[0-9]{1,2})',
|
|
6760
|
+
},
|
|
6761
|
+
{
|
|
6762
|
+
name: 'FreeBSD',
|
|
6763
|
+
regExp: 'freebsd',
|
|
6764
|
+
},
|
|
6765
|
+
{
|
|
6766
|
+
name: 'OpenBSD',
|
|
6767
|
+
regExp: 'openbsd',
|
|
6768
|
+
},
|
|
6769
|
+
{
|
|
6770
|
+
name: 'NetBSD',
|
|
6771
|
+
regExp: 'netbsd',
|
|
6772
|
+
},
|
|
6773
|
+
{
|
|
6774
|
+
name: 'IRIX',
|
|
6775
|
+
regExp: 'irix',
|
|
6776
|
+
},
|
|
6777
|
+
{
|
|
6778
|
+
name: 'Plan9',
|
|
6779
|
+
regExp: 'plan9',
|
|
6780
|
+
},
|
|
6781
|
+
{
|
|
6782
|
+
name: 'OSF',
|
|
6783
|
+
regExp: 'osf',
|
|
6784
|
+
},
|
|
6785
|
+
{
|
|
6786
|
+
name: 'AIX',
|
|
6787
|
+
regExp: 'aix',
|
|
6788
|
+
},
|
|
6789
|
+
{
|
|
6790
|
+
name: 'GNU Hurd',
|
|
6791
|
+
regExp: 'GNU Hurd',
|
|
6792
|
+
},
|
|
6793
|
+
{
|
|
6794
|
+
name: 'Linux - Fedora',
|
|
6795
|
+
regExp: '(fedora)',
|
|
6796
|
+
},
|
|
6797
|
+
{
|
|
6798
|
+
name: 'Linux - Kubuntu',
|
|
6799
|
+
regExp: '(kubuntu)',
|
|
6800
|
+
},
|
|
6801
|
+
{
|
|
6802
|
+
name: 'Linux - Ubuntu',
|
|
6803
|
+
regExp: '(ubuntu)',
|
|
6804
|
+
},
|
|
6805
|
+
{
|
|
6806
|
+
name: 'Linux - Debian',
|
|
6807
|
+
regExp: '(debian)',
|
|
6808
|
+
},
|
|
6809
|
+
{
|
|
6810
|
+
name: 'Linux - CentOS',
|
|
6811
|
+
regExp: '(CentOS)',
|
|
6812
|
+
},
|
|
6813
|
+
{
|
|
6814
|
+
name: 'Linux - Mandriva',
|
|
6815
|
+
regExp: '(Mandriva).([0-9]{1,3}(\\.[0-9]{1,3})?(\\.[0-9]{1,3})?)',
|
|
6816
|
+
},
|
|
6817
|
+
{
|
|
6818
|
+
name: 'Linux - SUSE',
|
|
6819
|
+
regExp: '(SUSE).([0-9]{1,3}(\\.[0-9]{1,3})?(\\.[0-9]{1,3})?)',
|
|
6820
|
+
},
|
|
6821
|
+
{
|
|
6822
|
+
name: 'Linux - Slackware (Dropline GNOME)',
|
|
6823
|
+
regExp: '(Dropline)',
|
|
6824
|
+
},
|
|
6825
|
+
{
|
|
6826
|
+
name: 'Linux - ASPLinux',
|
|
6827
|
+
regExp: '(ASPLinux)',
|
|
6828
|
+
},
|
|
6829
|
+
{
|
|
6830
|
+
name: 'Linux - Red Hat',
|
|
6831
|
+
regExp: '(Red Hat)',
|
|
6832
|
+
},
|
|
6833
|
+
{
|
|
6834
|
+
name: 'Linux',
|
|
6835
|
+
regExp: '(linux)',
|
|
6836
|
+
},
|
|
6837
|
+
{
|
|
6838
|
+
name: 'AmigaOS',
|
|
6839
|
+
regExp: '(amigaos)([0-9]{1,2}\\.[0-9]{1,2})',
|
|
6840
|
+
},
|
|
6841
|
+
{
|
|
6842
|
+
name: 'AmigaOS',
|
|
6843
|
+
regExp: 'amiga-aweb',
|
|
6844
|
+
},
|
|
6845
|
+
{
|
|
6846
|
+
name: 'Amiga',
|
|
6847
|
+
regExp: 'amiga',
|
|
6848
|
+
},
|
|
6849
|
+
{
|
|
6850
|
+
name: 'PalmOS',
|
|
6851
|
+
regExp: 'AvantGo',
|
|
6852
|
+
},
|
|
6853
|
+
{
|
|
6854
|
+
name: 'WebTV',
|
|
6855
|
+
regExp: '(webtv)/([0-9]{1,2}\\.[0-9]{1,2})',
|
|
6856
|
+
},
|
|
6857
|
+
{
|
|
6858
|
+
name: 'Dreamcast OS',
|
|
6859
|
+
regExp: 'Dreamcast',
|
|
6860
|
+
},
|
|
6861
|
+
{
|
|
6862
|
+
name: 'Windows',
|
|
6863
|
+
regExp: 'wget',
|
|
6864
|
+
},
|
|
6865
|
+
{
|
|
6866
|
+
name: 'Unknown',
|
|
6867
|
+
regExp: 'Java',
|
|
6868
|
+
},
|
|
6869
|
+
{
|
|
6870
|
+
name: 'Windows',
|
|
6871
|
+
regExp: '(msie)([0-9]{1,2}.[0-9]{1,2})',
|
|
6872
|
+
},
|
|
6873
|
+
{
|
|
6874
|
+
name: 'Unix',
|
|
6875
|
+
regExp: 'libwww-perl',
|
|
6876
|
+
},
|
|
6877
|
+
{
|
|
6878
|
+
name: 'Windows CE',
|
|
6879
|
+
regExp: 'UP.Browser',
|
|
6880
|
+
},
|
|
6881
|
+
{
|
|
6882
|
+
name: 'Windows',
|
|
6883
|
+
regExp: 'NetAnts',
|
|
6884
|
+
},
|
|
6885
|
+
];
|
|
6886
|
+
|
|
6887
|
+
class UserAgentService {
|
|
6888
|
+
constructor(window) {
|
|
6889
|
+
this.window = window;
|
|
6890
|
+
this._browserName = null;
|
|
6891
|
+
this._browserVersion = null;
|
|
6892
|
+
this._browserApp = null;
|
|
6893
|
+
this._platform = null;
|
|
6894
|
+
this._os = null;
|
|
6895
|
+
this.getUserPlatform();
|
|
6896
|
+
this.getBrowserInformation();
|
|
6897
|
+
this.getOsInformation();
|
|
6898
|
+
}
|
|
6899
|
+
get browserVersion() {
|
|
6900
|
+
return this._browserVersion;
|
|
6901
|
+
}
|
|
6902
|
+
get browserApp() {
|
|
6903
|
+
return this._browserApp;
|
|
6904
|
+
}
|
|
6905
|
+
get platform() {
|
|
6906
|
+
if (this._platform === unknownValue) {
|
|
6907
|
+
return this.osType;
|
|
6908
|
+
}
|
|
6909
|
+
return this._platform;
|
|
6910
|
+
}
|
|
6911
|
+
get userAgent() {
|
|
6912
|
+
return this.window.navigator.userAgent;
|
|
6913
|
+
}
|
|
6914
|
+
get browserDescription() {
|
|
6915
|
+
if (this.browserName === unknownValue || this.browserName === null) {
|
|
6916
|
+
return this.userAgent;
|
|
6917
|
+
}
|
|
6918
|
+
return this.browserName;
|
|
6919
|
+
}
|
|
6920
|
+
get isSafari() {
|
|
6921
|
+
return this._browserName === 'Apple Safari';
|
|
6922
|
+
}
|
|
6923
|
+
get iOsVersion() {
|
|
6924
|
+
var _a;
|
|
6925
|
+
if (this.osType !== 'ios') {
|
|
6926
|
+
return null;
|
|
6927
|
+
}
|
|
6928
|
+
const version = /OS (\d+)_(\d+)_?(\d+)?/.exec(this.window.navigator.appVersion);
|
|
6929
|
+
return version ? `${version[1]}.${version[2]}.${(_a = version[3]) !== null && _a !== void 0 ? _a : 0}` : null;
|
|
6930
|
+
}
|
|
6931
|
+
get browserInfo() {
|
|
6932
|
+
var _a, _b, _c, _d, _e;
|
|
6933
|
+
const browserInfo = {
|
|
6934
|
+
name: this.browserDescription,
|
|
6935
|
+
[(_b = (_a = this.browserApp) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== null && _b !== void 0 ? _b : unknownValue]: true,
|
|
6936
|
+
version: this.browserVersion,
|
|
6937
|
+
[this.browserEngine.toLowerCase()]: true,
|
|
6938
|
+
ui_version: this.isMobileDevice ? Device.mobile : Device.desktop,
|
|
6939
|
+
os: this.os,
|
|
6940
|
+
};
|
|
6941
|
+
if (this.isMobileDevice) {
|
|
6942
|
+
browserInfo.mobile = true;
|
|
6943
|
+
}
|
|
6944
|
+
if (this.osType) {
|
|
6945
|
+
// @ts-expect-error index is string
|
|
6946
|
+
browserInfo[this.osType.toLowerCase()] = true;
|
|
6947
|
+
}
|
|
6948
|
+
if ((_c = this.window.navigator.platform) === null || _c === void 0 ? void 0 : _c.includes('iPhone')) {
|
|
6949
|
+
browserInfo.iphone = true;
|
|
6950
|
+
}
|
|
6951
|
+
if ((_d = this.window.navigator.platform) === null || _d === void 0 ? void 0 : _d.includes('iPod')) {
|
|
6952
|
+
browserInfo.ipod = true;
|
|
6953
|
+
}
|
|
6954
|
+
if ((_e = this.window.navigator.platform) === null || _e === void 0 ? void 0 : _e.includes('iPad')) {
|
|
6955
|
+
browserInfo.ipad = true;
|
|
6956
|
+
browserInfo.tablet = true;
|
|
6957
|
+
}
|
|
6958
|
+
if (this.isAndroid) {
|
|
6959
|
+
browserInfo.android = true;
|
|
6960
|
+
}
|
|
6961
|
+
return browserInfo;
|
|
6962
|
+
}
|
|
6963
|
+
get isMobileDevice() {
|
|
6964
|
+
const deviceAgents = [
|
|
6965
|
+
'Android',
|
|
6966
|
+
'webOS',
|
|
6967
|
+
'iPhone',
|
|
6968
|
+
'iPad',
|
|
6969
|
+
'iPod',
|
|
6970
|
+
'BlackBerry',
|
|
6971
|
+
'IEMobile',
|
|
6972
|
+
'Opera Mini',
|
|
6973
|
+
'Mobile',
|
|
6974
|
+
'Tablet',
|
|
6975
|
+
'Kindle',
|
|
6976
|
+
'Playbook',
|
|
6977
|
+
'Silk',
|
|
6978
|
+
'Puffin',
|
|
6979
|
+
'CriOS',
|
|
6980
|
+
];
|
|
6981
|
+
return new RegExp(deviceAgents.join('|'), 'i').test(this.userAgent);
|
|
6982
|
+
}
|
|
6983
|
+
get isIosAndNotIpad() {
|
|
6984
|
+
return ['iPhone', 'iPod'].includes(this.window.navigator.platform);
|
|
6985
|
+
}
|
|
6986
|
+
getUserPlatform() {
|
|
6987
|
+
var _a, _b, _c, _d, _e;
|
|
6988
|
+
const experimentalPlatformApi = (_a = this.window.navigator) === null || _a === void 0 ? void 0 : _a.userAgentData;
|
|
6989
|
+
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;
|
|
6990
|
+
this._platform = platform.toLowerCase();
|
|
6991
|
+
}
|
|
6992
|
+
getBrowserInformation() {
|
|
6993
|
+
for (const browser of browsers) {
|
|
6994
|
+
const browserRegExp = new RegExp(browser.regexpBrowserNameWithVersion);
|
|
6995
|
+
const browserNameWithVersion = browserRegExp.exec(this.userAgent);
|
|
6996
|
+
if (browserNameWithVersion !== null) {
|
|
6997
|
+
this._browserName = browser.sentName;
|
|
6998
|
+
this._browserApp = browser.shortName;
|
|
6999
|
+
this._browserVersion = browserNameWithVersion[2];
|
|
7000
|
+
break;
|
|
7001
|
+
}
|
|
7002
|
+
this._browserName = unknownValue;
|
|
7003
|
+
this._browserApp = unknownValue;
|
|
7004
|
+
this._browserVersion = unknownValue;
|
|
7005
|
+
}
|
|
7006
|
+
}
|
|
7007
|
+
getOsInformation() {
|
|
7008
|
+
for (const os of osList) {
|
|
7009
|
+
const osRegExp = new RegExp(os.regExp);
|
|
7010
|
+
const osName = osRegExp.exec(this.userAgent);
|
|
7011
|
+
if (osName !== null) {
|
|
7012
|
+
this._os = os.name;
|
|
7013
|
+
break;
|
|
7014
|
+
}
|
|
7015
|
+
this._os = unknownValue;
|
|
7016
|
+
}
|
|
7017
|
+
}
|
|
7018
|
+
get browserName() {
|
|
7019
|
+
return this._browserName;
|
|
7020
|
+
}
|
|
7021
|
+
get isAndroid() {
|
|
7022
|
+
return /Android\s+([\d.]+)/.test(this.userAgent);
|
|
7023
|
+
}
|
|
7024
|
+
get isXbox() {
|
|
7025
|
+
return /xbox/i.test(this.userAgent);
|
|
7026
|
+
}
|
|
7027
|
+
get isLinux() {
|
|
7028
|
+
return /linux/i.test(this.userAgent);
|
|
7029
|
+
}
|
|
7030
|
+
get isWindows() {
|
|
7031
|
+
return /windows/i.test(this.userAgent);
|
|
7032
|
+
}
|
|
7033
|
+
get browserEngine() {
|
|
7034
|
+
var _a;
|
|
7035
|
+
const engines = new Map([
|
|
7036
|
+
['Firefox', 'Gecko'],
|
|
7037
|
+
['Safari', 'Webkit'],
|
|
7038
|
+
['MSEdge-legacy', 'EdgeHTML'],
|
|
7039
|
+
['Chrome', 'Blink'],
|
|
7040
|
+
['Opera', 'Blink'],
|
|
7041
|
+
['MSEdge', 'Blink'],
|
|
7042
|
+
['SamsungBrowser', 'Blink'],
|
|
7043
|
+
]);
|
|
7044
|
+
return (_a = engines.get(this.browserApp)) !== null && _a !== void 0 ? _a : unknownValue;
|
|
7045
|
+
}
|
|
7046
|
+
get os() {
|
|
7047
|
+
return this._os;
|
|
7048
|
+
}
|
|
7049
|
+
get osType() {
|
|
7050
|
+
var _a;
|
|
7051
|
+
if (['iPhone', 'iPod', 'iPad'].includes(this.window.navigator.platform)) {
|
|
7052
|
+
return 'ios';
|
|
7053
|
+
}
|
|
7054
|
+
if ((_a = this.window.navigator.platform) === null || _a === void 0 ? void 0 : _a.includes('MacIntel')) {
|
|
7055
|
+
return 'mac';
|
|
7056
|
+
}
|
|
7057
|
+
if (this.isXbox) {
|
|
7058
|
+
return 'xbox';
|
|
7059
|
+
}
|
|
7060
|
+
if (this.isWindows) {
|
|
7061
|
+
return 'windows';
|
|
7062
|
+
}
|
|
7063
|
+
if (this.isAndroid) {
|
|
7064
|
+
return 'android';
|
|
7065
|
+
}
|
|
7066
|
+
if (this.isLinux) {
|
|
7067
|
+
return 'linux';
|
|
7068
|
+
}
|
|
7069
|
+
return null;
|
|
7070
|
+
}
|
|
7071
|
+
}
|
|
7072
|
+
UserAgentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UserAgentService, deps: [{ token: windowToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
7073
|
+
UserAgentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UserAgentService, providedIn: 'root' });
|
|
7074
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UserAgentService, decorators: [{
|
|
7075
|
+
type: Injectable,
|
|
7076
|
+
args: [{
|
|
7077
|
+
providedIn: 'root',
|
|
7078
|
+
}]
|
|
7079
|
+
}], ctorParameters: function () {
|
|
7080
|
+
return [{ type: undefined, decorators: [{
|
|
7081
|
+
type: Inject,
|
|
7082
|
+
args: [windowToken]
|
|
7083
|
+
}] }];
|
|
7084
|
+
} });
|
|
7085
|
+
|
|
7086
|
+
class ApplePayService {
|
|
7087
|
+
get paymentParameters() {
|
|
7088
|
+
return this.applePayParams;
|
|
7089
|
+
}
|
|
7090
|
+
get payment$() {
|
|
7091
|
+
return this.payment.asObservable();
|
|
7092
|
+
}
|
|
7093
|
+
get error$() {
|
|
7094
|
+
return this.error.asObservable();
|
|
7095
|
+
}
|
|
7096
|
+
get integrationType$() {
|
|
7097
|
+
return this.integrationType.asObservable();
|
|
7098
|
+
}
|
|
7099
|
+
constructor(window, userAgentService, summaryFinanceDetailsAdapterService) {
|
|
7100
|
+
this.window = window;
|
|
7101
|
+
this.userAgentService = userAgentService;
|
|
7102
|
+
this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
|
|
7103
|
+
this.agreementFieldsNames = agreementsGroup;
|
|
7104
|
+
this.payment = new Subject();
|
|
7105
|
+
this.error = new Subject();
|
|
7106
|
+
this.integrationType = new Subject();
|
|
7107
|
+
this.paymentClient = null;
|
|
7108
|
+
this.applePayParams = null;
|
|
7109
|
+
this.order = null;
|
|
7110
|
+
this.api = this.loadBraintree();
|
|
7111
|
+
}
|
|
7112
|
+
setApplePayParams(data) {
|
|
7113
|
+
var _a, _b, _c, _d;
|
|
7114
|
+
const formFields = (_a = data === null || data === void 0 ? void 0 : data.paymentForm) === null || _a === void 0 ? void 0 : _a.fields;
|
|
7115
|
+
const summary = (_b = data === null || data === void 0 ? void 0 : data.paymentForm) === null || _b === void 0 ? void 0 : _b.summary;
|
|
7116
|
+
if (!formFields || !summary) {
|
|
7117
|
+
return;
|
|
7118
|
+
}
|
|
7119
|
+
const fields = formFields.reduce((acc, field) => {
|
|
7120
|
+
if (this.agreementFieldsNames.includes(field.name) &&
|
|
7121
|
+
field.isVisible === '1') {
|
|
7122
|
+
acc[field.name] = field.title;
|
|
7123
|
+
}
|
|
7124
|
+
else {
|
|
7125
|
+
acc[field.name] = field.value;
|
|
7126
|
+
}
|
|
7127
|
+
return acc;
|
|
7128
|
+
}, {});
|
|
7129
|
+
const agreements = this.agreementFieldsNames
|
|
7130
|
+
.map((fieldName) => fields[fieldName])
|
|
7131
|
+
.filter(Boolean);
|
|
7132
|
+
this.applePayParams = {
|
|
7133
|
+
tokenKey: this.getAppleToken(formFields),
|
|
7134
|
+
totalLabel: (_c = fields['label_applePay']) !== null && _c !== void 0 ? _c : '',
|
|
7135
|
+
totalAmount: this.getTotalAmount(summary),
|
|
7136
|
+
currencyCode: this.getTotalCurrency(summary),
|
|
7137
|
+
countryCode: (_d = fields['countryCode']) !== null && _d !== void 0 ? _d : '',
|
|
7138
|
+
merchantCapabilities: this.getJsonValueFromField(fields, 'merchantCapabilities'),
|
|
7139
|
+
supportedNetworks: this.getJsonValueFromField(fields, 'supportedNetworks'),
|
|
7140
|
+
agreements: agreements,
|
|
7141
|
+
};
|
|
7142
|
+
}
|
|
7143
|
+
initLibrary(tokenKey) {
|
|
7144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7145
|
+
try {
|
|
7146
|
+
const api = yield this.api;
|
|
7147
|
+
const clientInstance = yield api.client.create({
|
|
7148
|
+
authorization: tokenKey,
|
|
7149
|
+
});
|
|
7150
|
+
this.paymentClient = yield api.applePay.create({
|
|
7151
|
+
client: clientInstance,
|
|
7152
|
+
});
|
|
7153
|
+
}
|
|
7154
|
+
catch (error) {
|
|
7155
|
+
console.error('apple pay: initialize failed', error);
|
|
7156
|
+
}
|
|
7157
|
+
this.emitIntegrationType();
|
|
7158
|
+
if (!this.paymentClient ||
|
|
7159
|
+
(!this.isDeviceCapable() && !this.userAgentService.isSafari)) {
|
|
7160
|
+
this.emitError(ApplePayErrors.deviceIsNotCapableError);
|
|
7161
|
+
}
|
|
7162
|
+
});
|
|
7163
|
+
}
|
|
7164
|
+
redirectToPaymentPage(parameters, token) {
|
|
7165
|
+
const route = pagesRoutes.get(applePayId);
|
|
7166
|
+
if (!route) {
|
|
7167
|
+
return;
|
|
7168
|
+
}
|
|
7169
|
+
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) }));
|
|
7170
|
+
if (this.order) {
|
|
7171
|
+
query.append('order', this.order);
|
|
7172
|
+
}
|
|
7173
|
+
const url = `${route}?${query.toString()}`;
|
|
7174
|
+
return url;
|
|
7175
|
+
}
|
|
7176
|
+
setOrder(data) {
|
|
7177
|
+
var _a;
|
|
7178
|
+
const summary = (_a = data === null || data === void 0 ? void 0 : data.paymentForm) === null || _a === void 0 ? void 0 : _a.summary;
|
|
7179
|
+
if (!summary) {
|
|
7180
|
+
return;
|
|
7181
|
+
}
|
|
7182
|
+
const financeDetails = this.summaryFinanceDetailsAdapterService.getFinanceDetails(summary);
|
|
7183
|
+
if ((financeDetails === null || financeDetails === void 0 ? void 0 : financeDetails.purchase) && (financeDetails === null || financeDetails === void 0 ? void 0 : financeDetails.finance)) {
|
|
7184
|
+
const cartItems = financeDetails.cartItems;
|
|
7185
|
+
this.order = cartItems === null || cartItems === void 0 ? void 0 : cartItems.reduce((curr, item) => {
|
|
7186
|
+
if (curr) {
|
|
7187
|
+
return curr + `; ${item.title}`;
|
|
7188
|
+
}
|
|
7189
|
+
return curr + item.title;
|
|
7190
|
+
}, '');
|
|
7191
|
+
}
|
|
7192
|
+
}
|
|
7193
|
+
proceedCheckout(parameters) {
|
|
7194
|
+
if (!parameters) {
|
|
7195
|
+
return;
|
|
7196
|
+
}
|
|
7197
|
+
if (!this.paymentClient || !this.isDeviceCapable()) {
|
|
7198
|
+
console.warn('apple pay: device is not capable', this.paymentClient);
|
|
7199
|
+
this.emitError(ApplePayErrors.deviceIsNotCapableError);
|
|
7200
|
+
return;
|
|
7201
|
+
}
|
|
7202
|
+
try {
|
|
7203
|
+
const paymentRequest = this.paymentClient.createPaymentRequest({
|
|
7204
|
+
total: {
|
|
7205
|
+
label: parameters.totalLabel,
|
|
7206
|
+
amount: parameters.totalAmount,
|
|
7207
|
+
},
|
|
7208
|
+
currencyCode: parameters.currencyCode,
|
|
7209
|
+
countryCode: parameters.countryCode,
|
|
7210
|
+
merchantCapabilities: parameters.merchantCapabilities,
|
|
7211
|
+
supportedNetworks: parameters.supportedNetworks,
|
|
7212
|
+
});
|
|
7213
|
+
const session = new this.window.ApplePaySession(applePayVersion, paymentRequest);
|
|
7214
|
+
session.onvalidatemerchant = (event) => {
|
|
7215
|
+
var _a;
|
|
7216
|
+
console.info('apple pay: merchant validation', event);
|
|
7217
|
+
(_a = this.paymentClient) === null || _a === void 0 ? void 0 : _a.performValidation({
|
|
7218
|
+
validationURL: event.validationURL,
|
|
7219
|
+
displayName: parameters === null || parameters === void 0 ? void 0 : parameters.totalLabel,
|
|
7220
|
+
}).then((merchantSession) => {
|
|
7221
|
+
session.completeMerchantValidation(merchantSession);
|
|
7222
|
+
}).catch((error) => {
|
|
7223
|
+
console.error('apple pay: merchant validation error', error);
|
|
7224
|
+
session.abort();
|
|
7225
|
+
});
|
|
7226
|
+
};
|
|
7227
|
+
session.onpaymentauthorized = (event) => {
|
|
7228
|
+
var _a;
|
|
7229
|
+
console.info('apple pay: payment authorization', event);
|
|
7230
|
+
(_a = this.paymentClient) === null || _a === void 0 ? void 0 : _a.tokenize({
|
|
7231
|
+
token: event.payment.token,
|
|
7232
|
+
}).then((authorizationResponse) => {
|
|
7233
|
+
var _a;
|
|
7234
|
+
this.payment.next((_a = authorizationResponse === null || authorizationResponse === void 0 ? void 0 : authorizationResponse.nonce) !== null && _a !== void 0 ? _a : '');
|
|
7235
|
+
session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
|
|
7236
|
+
}).catch((error) => {
|
|
7237
|
+
console.error('apple pay: payment authorization error', error);
|
|
7238
|
+
session.completePayment(this.window.ApplePaySession.STATUS_FAILURE);
|
|
7239
|
+
});
|
|
7240
|
+
};
|
|
7241
|
+
session.oncancel = (event) => {
|
|
7242
|
+
this.emitError(ApplePayErrors.paymentError);
|
|
7243
|
+
console.error('apple pay: user cancel payment', event);
|
|
7244
|
+
};
|
|
7245
|
+
session.begin();
|
|
7246
|
+
}
|
|
7247
|
+
catch (error) {
|
|
7248
|
+
console.error('apple pay: checkout error', error);
|
|
7249
|
+
this.emitError(ApplePayErrors.paymentError);
|
|
7250
|
+
}
|
|
7251
|
+
}
|
|
7252
|
+
isDeviceCapable() {
|
|
7253
|
+
var _a, _b;
|
|
7254
|
+
try {
|
|
7255
|
+
return Boolean(((_a = this.window.ApplePaySession) === null || _a === void 0 ? void 0 : _a.supportsVersion(applePayVersion)) &&
|
|
7256
|
+
((_b = this.window.ApplePaySession) === null || _b === void 0 ? void 0 : _b.canMakePayments()));
|
|
7257
|
+
}
|
|
7258
|
+
catch (error) {
|
|
7259
|
+
return false;
|
|
7260
|
+
}
|
|
7261
|
+
}
|
|
7262
|
+
getTokenNonceFieldData(tokenNonce) {
|
|
7263
|
+
const name = FieldNames.tokenApplePay;
|
|
7264
|
+
const value = btoa(tokenNonce);
|
|
7265
|
+
return { name, value };
|
|
7266
|
+
}
|
|
7267
|
+
updateApplePayParams(data) {
|
|
7268
|
+
const summary = data === null || data === void 0 ? void 0 : data.summary;
|
|
7269
|
+
if (!this.applePayParams || !summary) {
|
|
7270
|
+
return;
|
|
7271
|
+
}
|
|
7272
|
+
this.applePayParams.totalAmount = this.getTotalAmount(summary);
|
|
7273
|
+
this.applePayParams.currencyCode = this.getTotalCurrency(summary);
|
|
7274
|
+
}
|
|
7275
|
+
loadBraintree() {
|
|
7276
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7277
|
+
const api = yield import('braintree-web');
|
|
7278
|
+
return api;
|
|
7279
|
+
});
|
|
7280
|
+
}
|
|
7281
|
+
getAppleToken(formFields) {
|
|
7282
|
+
const appleTokenField = formFields.find((field) => {
|
|
7283
|
+
return field.name === 'token_key';
|
|
7284
|
+
});
|
|
7285
|
+
if (!appleTokenField) {
|
|
7286
|
+
return '';
|
|
7287
|
+
}
|
|
7288
|
+
return appleTokenField.value;
|
|
7289
|
+
}
|
|
7290
|
+
getTotalAmount(summary) {
|
|
7291
|
+
var _a, _b, _c;
|
|
7292
|
+
const finance = summary === null || summary === void 0 ? void 0 : summary.finance;
|
|
7293
|
+
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;
|
|
7294
|
+
return (_c = total === null || total === void 0 ? void 0 : total.toString()) !== null && _c !== void 0 ? _c : '';
|
|
7295
|
+
}
|
|
7296
|
+
getTotalCurrency(summary) {
|
|
7297
|
+
var _a, _b, _c, _d;
|
|
7298
|
+
const finance = summary === null || summary === void 0 ? void 0 : summary.finance;
|
|
7299
|
+
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 : '';
|
|
7300
|
+
}
|
|
7301
|
+
getJsonValueFromField(fields, fieldName) {
|
|
7302
|
+
const field = fields[fieldName];
|
|
7303
|
+
try {
|
|
7304
|
+
return field ? JSON.parse(field) : undefined;
|
|
7305
|
+
}
|
|
7306
|
+
catch (error) {
|
|
7307
|
+
return undefined;
|
|
7308
|
+
}
|
|
7309
|
+
}
|
|
7310
|
+
emitError(error) {
|
|
7311
|
+
this.error.next(error);
|
|
7312
|
+
}
|
|
7313
|
+
emitIntegrationType() {
|
|
7314
|
+
let integrationType;
|
|
7315
|
+
if (this.paymentClient && this.isDeviceCapable()) {
|
|
7316
|
+
integrationType = 'sdk';
|
|
7317
|
+
}
|
|
7318
|
+
else if (this.userAgentService.isSafari) {
|
|
7319
|
+
integrationType = 'redirect';
|
|
7320
|
+
}
|
|
7321
|
+
else {
|
|
7322
|
+
integrationType = 'none';
|
|
7323
|
+
}
|
|
7324
|
+
this.integrationType.next(integrationType);
|
|
7325
|
+
}
|
|
7326
|
+
}
|
|
7327
|
+
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 });
|
|
7328
|
+
ApplePayService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ApplePayService, providedIn: 'root' });
|
|
7329
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ApplePayService, decorators: [{
|
|
7330
|
+
type: Injectable,
|
|
7331
|
+
args: [{
|
|
7332
|
+
providedIn: 'root',
|
|
7333
|
+
}]
|
|
7334
|
+
}], ctorParameters: function () {
|
|
7335
|
+
return [{ type: undefined, decorators: [{
|
|
7336
|
+
type: Inject,
|
|
7337
|
+
args: [windowToken]
|
|
7338
|
+
}] }, { type: UserAgentService }, { type: SummaryFinanceDetailsAdapterService }];
|
|
7339
|
+
} });
|
|
7340
|
+
|
|
6496
7341
|
/*
|
|
6497
7342
|
* Public API Surface of core-library
|
|
6498
7343
|
*/
|
|
@@ -6501,5 +7346,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
6501
7346
|
* Generated bundle index. Do not edit.
|
|
6502
7347
|
*/
|
|
6503
7348
|
|
|
6504
|
-
export { CoreLibraryModule, CoreLibraryService };
|
|
7349
|
+
export { ApplePayService, CoreLibraryModule, CoreLibraryService };
|
|
6505
7350
|
//# sourceMappingURL=xsolla-payment-client-core.mjs.map
|