@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.
- 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/next-action.interface.mjs +1 -1
- package/esm2020/lib/core/payment/actions/next-actions.mjs +3 -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/actions/show-qr-code/show-qr-code.action.class.mjs +22 -0
- package/esm2020/lib/core/payment/actions/show-qr-code/show-qr-code.action.type.mjs +2 -0
- 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/initialize/initialize-request-params.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.service.mjs +62 -2
- package/esm2020/lib/core/payment/xps-api/xps-api.service.mjs +4 -1
- 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/settings/configuration.interface.mjs +1 -1
- package/esm2020/lib/core/settings/settings.service.mjs +6 -1
- 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 +17 -1
- package/esm2020/public-api.mjs +3 -1
- package/fesm2015/xsolla-payment-client-core.mjs +891 -4
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +883 -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/next-action.interface.d.ts +2 -1
- package/lib/core/payment/actions/redirect/ps4-pages/pages-payment-methods-id.const.d.ts +1 -1
- package/lib/core/payment/actions/show-qr-code/show-qr-code.action.class.d.ts +11 -0
- package/lib/core/payment/actions/show-qr-code/show-qr-code.action.type.d.ts +3 -0
- 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/initialize/initialize-request-params.interface.d.ts +1 -0
- package/lib/core/payment/payment.interface.d.ts +1 -0
- package/lib/core/payment/payment.service.d.ts +10 -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/settings/configuration.interface.d.ts +1 -0
- package/lib/core/settings/settings.service.d.ts +2 -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 +9 -0
- package/package.json +4 -2
- package/public-api.d.ts +2 -0
- package/xsolla-payment-client-core-0.2.9.tgz +0 -0
- package/xsolla-payment-client-core-0.2.7.tgz +0 -0
|
@@ -126,6 +126,9 @@ class SettingsService {
|
|
|
126
126
|
get token() {
|
|
127
127
|
return this._token;
|
|
128
128
|
}
|
|
129
|
+
get isMobile() {
|
|
130
|
+
return this._isMobile;
|
|
131
|
+
}
|
|
129
132
|
get hasResponse() {
|
|
130
133
|
return !!this.response;
|
|
131
134
|
}
|
|
@@ -134,6 +137,7 @@ class SettingsService {
|
|
|
134
137
|
this.isInitialized = false;
|
|
135
138
|
this._token = '';
|
|
136
139
|
this.sandboxMode = false;
|
|
140
|
+
this._isMobile = false;
|
|
137
141
|
}
|
|
138
142
|
async init(configuration) {
|
|
139
143
|
if (!configuration.token) {
|
|
@@ -141,6 +145,7 @@ class SettingsService {
|
|
|
141
145
|
}
|
|
142
146
|
this._token = configuration.token;
|
|
143
147
|
this.sandboxMode = !!configuration.sandbox;
|
|
148
|
+
this._isMobile = configuration.isMobile;
|
|
144
149
|
await this.sendRequest(this.token);
|
|
145
150
|
this.isInitialized = true;
|
|
146
151
|
}
|
|
@@ -564,6 +569,7 @@ var FieldNames;
|
|
|
564
569
|
FieldNames["sum"] = "sum";
|
|
565
570
|
FieldNames["out"] = "out";
|
|
566
571
|
FieldNames["tinkoffDisclaimer"] = "ps.tinkoff.disclaimer";
|
|
572
|
+
FieldNames["omnibusDirective"] = "omnibus_directive";
|
|
567
573
|
})(FieldNames || (FieldNames = {}));
|
|
568
574
|
|
|
569
575
|
class SubmitResponse {
|
|
@@ -690,6 +696,9 @@ class XpsApiService {
|
|
|
690
696
|
country: this.countryService.getCountry(),
|
|
691
697
|
...parameters,
|
|
692
698
|
};
|
|
699
|
+
if (this.settingsService.isMobile) {
|
|
700
|
+
requestParams.mobile = "1" /* XpsBoolean.true */;
|
|
701
|
+
}
|
|
693
702
|
return lastValueFrom(this.secureApiClient.post(this.directPaymentApiRoute, new URLSearchParams({ ...requestParams }), {
|
|
694
703
|
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
695
704
|
responseType: 'json',
|
|
@@ -741,14 +750,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
741
750
|
|
|
742
751
|
const vkPay = 3496;
|
|
743
752
|
const googlePay = 3431;
|
|
744
|
-
const
|
|
753
|
+
const applePayId = 3175;
|
|
745
754
|
const barzahlenPay = 1679;
|
|
746
755
|
const naverPay = 3563;
|
|
747
756
|
const venmoPay = 3636;
|
|
748
757
|
|
|
749
758
|
const pagesRoutes = new Map([
|
|
750
759
|
[vkPay, '/payment/external-pages/vk-pay'],
|
|
751
|
-
[
|
|
760
|
+
[applePayId, '/payment/external-pages/apple-pay'],
|
|
752
761
|
[barzahlenPay, '/payment/external-pages/barzahlen-pay'],
|
|
753
762
|
[naverPay, '/payment/external-pages/naver-pay'],
|
|
754
763
|
[venmoPay, '/payment/external-pages/venmo-pay'],
|
|
@@ -1095,11 +1104,32 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
1095
1104
|
type: Injectable
|
|
1096
1105
|
}] });
|
|
1097
1106
|
|
|
1107
|
+
class ShowQrCodeActionCreator {
|
|
1108
|
+
constructor() {
|
|
1109
|
+
this.type = 'show_qr_code';
|
|
1110
|
+
}
|
|
1111
|
+
getActionData() {
|
|
1112
|
+
return {
|
|
1113
|
+
type: this.type,
|
|
1114
|
+
data: null,
|
|
1115
|
+
};
|
|
1116
|
+
}
|
|
1117
|
+
isSuitable(response) {
|
|
1118
|
+
return Boolean(response.parameters?.form?.qr);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
ShowQrCodeActionCreator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowQrCodeActionCreator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1122
|
+
ShowQrCodeActionCreator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowQrCodeActionCreator });
|
|
1123
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowQrCodeActionCreator, decorators: [{
|
|
1124
|
+
type: Injectable
|
|
1125
|
+
}] });
|
|
1126
|
+
|
|
1098
1127
|
const nextActionsToken = new InjectionToken('Action');
|
|
1099
1128
|
const nextActions = [
|
|
1100
1129
|
ShowFieldsActionCreator,
|
|
1101
1130
|
CheckStatusActionCreator,
|
|
1102
1131
|
SpecialButtonActionCreator,
|
|
1132
|
+
ShowQrCodeActionCreator,
|
|
1103
1133
|
RedirectActionCreator,
|
|
1104
1134
|
];
|
|
1105
1135
|
const flowUpdateNextActions = [
|
|
@@ -5373,6 +5403,15 @@ class PaymentService {
|
|
|
5373
5403
|
get formFieldsStatus$() {
|
|
5374
5404
|
return this.formFieldsStatusSubject.asObservable().pipe(filter$1(Boolean));
|
|
5375
5405
|
}
|
|
5406
|
+
get paymentForm$() {
|
|
5407
|
+
return this._paymentForm$.asObservable();
|
|
5408
|
+
}
|
|
5409
|
+
get formResponse$() {
|
|
5410
|
+
return this._formResponse$.asObservable();
|
|
5411
|
+
}
|
|
5412
|
+
get formResponseValue() {
|
|
5413
|
+
return this._formResponse$.getValue();
|
|
5414
|
+
}
|
|
5376
5415
|
constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService, formMessagesService, settingsService, countryService) {
|
|
5377
5416
|
this.initializeService = initializeService;
|
|
5378
5417
|
this.submitService = submitService;
|
|
@@ -5394,7 +5433,9 @@ class PaymentService {
|
|
|
5394
5433
|
this.fields = [];
|
|
5395
5434
|
this.destroy$ = new Subject();
|
|
5396
5435
|
this.formDestroy$ = new Subject();
|
|
5436
|
+
this._paymentForm$ = new BehaviorSubject(null);
|
|
5397
5437
|
this.formFieldsStatusSubject = new BehaviorSubject(null);
|
|
5438
|
+
this._formResponse$ = new BehaviorSubject(null);
|
|
5398
5439
|
this.isSavingMethodMode = false;
|
|
5399
5440
|
}
|
|
5400
5441
|
async initialize(config) {
|
|
@@ -5403,6 +5444,7 @@ class PaymentService {
|
|
|
5403
5444
|
this.listenFinanceDetails();
|
|
5404
5445
|
this.config = config;
|
|
5405
5446
|
this.data = await this.initializeService.request(config);
|
|
5447
|
+
this.emitFormResponse(this.data);
|
|
5406
5448
|
this.fields = this.getFields();
|
|
5407
5449
|
this.form = this.formService.createForm(this.fields);
|
|
5408
5450
|
this.updatePidConfig();
|
|
@@ -5425,6 +5467,7 @@ class PaymentService {
|
|
|
5425
5467
|
this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
|
|
5426
5468
|
const submitResponse = await this.submitService.request(this.fields, this.form);
|
|
5427
5469
|
this.data = submitResponse;
|
|
5470
|
+
this.emitFormResponse(this.data);
|
|
5428
5471
|
if (!this.isSavingMethodMode) {
|
|
5429
5472
|
this.emitFinanceDetails(submitResponse.summary);
|
|
5430
5473
|
}
|
|
@@ -5457,6 +5500,12 @@ class PaymentService {
|
|
|
5457
5500
|
country: this.countryService.getCountry(),
|
|
5458
5501
|
};
|
|
5459
5502
|
}
|
|
5503
|
+
getQrCode() {
|
|
5504
|
+
if (!isSubmitResponse(this.data)) {
|
|
5505
|
+
throw new Error('Should submit form first');
|
|
5506
|
+
}
|
|
5507
|
+
return this.data.parameters.form.qr.title;
|
|
5508
|
+
}
|
|
5460
5509
|
getPid() {
|
|
5461
5510
|
if (this.data instanceof SubmitResponse) {
|
|
5462
5511
|
return (Number(this.data.fields.find((field) => field.name === 'fix_pid')?.value) || null);
|
|
@@ -5529,6 +5578,30 @@ class PaymentService {
|
|
|
5529
5578
|
}
|
|
5530
5579
|
this.emitFormFieldsStatus(this.form);
|
|
5531
5580
|
}
|
|
5581
|
+
addExtraField(name, value) {
|
|
5582
|
+
const isHaveField = this.fields.find((field) => {
|
|
5583
|
+
return field.name === name;
|
|
5584
|
+
});
|
|
5585
|
+
if (isHaveField) {
|
|
5586
|
+
this.fields = this.fields.map((field) => {
|
|
5587
|
+
if (field.name === name) {
|
|
5588
|
+
field.value = value;
|
|
5589
|
+
}
|
|
5590
|
+
return field;
|
|
5591
|
+
});
|
|
5592
|
+
return;
|
|
5593
|
+
}
|
|
5594
|
+
const field = {
|
|
5595
|
+
name: name,
|
|
5596
|
+
value: value,
|
|
5597
|
+
title: '',
|
|
5598
|
+
type: 'text',
|
|
5599
|
+
example: '',
|
|
5600
|
+
isMandatory: "1" /* XpsBoolean.true */,
|
|
5601
|
+
isVisible: "0" /* XpsBoolean.false */,
|
|
5602
|
+
};
|
|
5603
|
+
this.fields.push(field);
|
|
5604
|
+
}
|
|
5532
5605
|
destroy() {
|
|
5533
5606
|
this.data = null;
|
|
5534
5607
|
this.financeDetails = null;
|
|
@@ -5568,6 +5641,7 @@ class PaymentService {
|
|
|
5568
5641
|
.subscribe((response) => {
|
|
5569
5642
|
this.emitFinanceDetails(response.summary);
|
|
5570
5643
|
this.emitFormMessages(response.messages);
|
|
5644
|
+
this.emitFormResponse(response);
|
|
5571
5645
|
});
|
|
5572
5646
|
this.syncService.fieldAsyncValidation$
|
|
5573
5647
|
.pipe(takeUntil(this.destroy$))
|
|
@@ -5586,7 +5660,10 @@ class PaymentService {
|
|
|
5586
5660
|
listenFormStatusChanges(form) {
|
|
5587
5661
|
form.statusChanges
|
|
5588
5662
|
.pipe(takeUntil(this.formDestroy$))
|
|
5589
|
-
.subscribe(() =>
|
|
5663
|
+
.subscribe((status) => {
|
|
5664
|
+
this.emitFormFieldsStatus(form);
|
|
5665
|
+
this._paymentForm$.next(status);
|
|
5666
|
+
});
|
|
5590
5667
|
}
|
|
5591
5668
|
/*
|
|
5592
5669
|
* in case the form pid changes despite the one passed during initialization
|
|
@@ -5597,6 +5674,19 @@ class PaymentService {
|
|
|
5597
5674
|
this.config.paymentMethodId = currentPid;
|
|
5598
5675
|
}
|
|
5599
5676
|
}
|
|
5677
|
+
emitFormResponse(data) {
|
|
5678
|
+
let type;
|
|
5679
|
+
if (data instanceof InitializeResponse) {
|
|
5680
|
+
type = 'initialize';
|
|
5681
|
+
}
|
|
5682
|
+
else if (data instanceof SubmitResponse) {
|
|
5683
|
+
type = 'submit';
|
|
5684
|
+
}
|
|
5685
|
+
else {
|
|
5686
|
+
type = 'sync';
|
|
5687
|
+
}
|
|
5688
|
+
this._formResponse$.next({ type, data, token: this.settingsService.token });
|
|
5689
|
+
}
|
|
5600
5690
|
}
|
|
5601
5691
|
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 });
|
|
5602
5692
|
PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
|
|
@@ -6044,6 +6134,12 @@ class CoreLibraryService {
|
|
|
6044
6134
|
async getStatus(url) {
|
|
6045
6135
|
return this.statusService.getStatusWithUrlSearchParams(url);
|
|
6046
6136
|
}
|
|
6137
|
+
getQrCodeInitialData() {
|
|
6138
|
+
return {
|
|
6139
|
+
qrCode: this.paymentService.getQrCode(),
|
|
6140
|
+
pid: this.paymentService.getPid(),
|
|
6141
|
+
};
|
|
6142
|
+
}
|
|
6047
6143
|
setCountry(country) {
|
|
6048
6144
|
this.countryService.setCountry(country);
|
|
6049
6145
|
}
|
|
@@ -6071,6 +6167,7 @@ class CoreLibraryService {
|
|
|
6071
6167
|
formMessages$: this.formMessagesService.data$,
|
|
6072
6168
|
getFormStatus: () => this.paymentService.form?.status,
|
|
6073
6169
|
},
|
|
6170
|
+
addExtraField: (name, value) => this.paymentService.addExtraField(name, value),
|
|
6074
6171
|
};
|
|
6075
6172
|
}
|
|
6076
6173
|
getCreditCardService() {
|
|
@@ -6099,6 +6196,15 @@ class CoreLibraryService {
|
|
|
6099
6196
|
getUserBalanceValue() {
|
|
6100
6197
|
return this.userBalanceService.getUserBalanceValue();
|
|
6101
6198
|
}
|
|
6199
|
+
get paymentForm$() {
|
|
6200
|
+
return this.paymentService.paymentForm$;
|
|
6201
|
+
}
|
|
6202
|
+
get formResponse$() {
|
|
6203
|
+
return this.paymentService.formResponse$;
|
|
6204
|
+
}
|
|
6205
|
+
get formResponseValue() {
|
|
6206
|
+
return this.paymentService.formResponseValue;
|
|
6207
|
+
}
|
|
6102
6208
|
}
|
|
6103
6209
|
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 });
|
|
6104
6210
|
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|
|
@@ -6330,6 +6436,779 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
6330
6436
|
}]
|
|
6331
6437
|
}] });
|
|
6332
6438
|
|
|
6439
|
+
const applePayVersion = 3;
|
|
6440
|
+
|
|
6441
|
+
const agreementsGroup = [
|
|
6442
|
+
FieldNames.termsAndConditions,
|
|
6443
|
+
FieldNames.termsAndConditionsHtcEula,
|
|
6444
|
+
FieldNames.termsAndConditionsAtariTc,
|
|
6445
|
+
FieldNames.termsAndConditionsAtariPp,
|
|
6446
|
+
FieldNames.termsAndConditionsRolandEula,
|
|
6447
|
+
FieldNames.termsAndConditionsRobloxEula,
|
|
6448
|
+
FieldNames.termsAndConditionsOnzenga,
|
|
6449
|
+
FieldNames.take2Taxes,
|
|
6450
|
+
FieldNames.rockstarTaxes,
|
|
6451
|
+
FieldNames.omnibusDirective,
|
|
6452
|
+
];
|
|
6453
|
+
|
|
6454
|
+
var ApplePayErrors;
|
|
6455
|
+
(function (ApplePayErrors) {
|
|
6456
|
+
ApplePayErrors["paymentError"] = "paymentError";
|
|
6457
|
+
ApplePayErrors["deviceIsNotCapableError"] = "deviceIsNotCapableError";
|
|
6458
|
+
})(ApplePayErrors || (ApplePayErrors = {}));
|
|
6459
|
+
|
|
6460
|
+
const unknownValue = 'unknown';
|
|
6461
|
+
const browsers = [
|
|
6462
|
+
{
|
|
6463
|
+
sentName: 'Mozilla Firefox',
|
|
6464
|
+
shortName: 'Firefox',
|
|
6465
|
+
regexpBrowserNameWithVersion: '(Firefox)\\/(.+)',
|
|
6466
|
+
},
|
|
6467
|
+
{
|
|
6468
|
+
sentName: 'Samsung Internet',
|
|
6469
|
+
shortName: 'SamsungBrowser',
|
|
6470
|
+
regexpBrowserNameWithVersion: '(SamsungBrowser)\\/(.+)\\s',
|
|
6471
|
+
},
|
|
6472
|
+
{
|
|
6473
|
+
sentName: 'Opera',
|
|
6474
|
+
shortName: 'Opera',
|
|
6475
|
+
regexpBrowserNameWithVersion: '(Opera)\\/(.+)',
|
|
6476
|
+
},
|
|
6477
|
+
{
|
|
6478
|
+
sentName: 'Opera',
|
|
6479
|
+
shortName: 'Opera',
|
|
6480
|
+
regexpBrowserNameWithVersion: '(OPR)\\/(.+)',
|
|
6481
|
+
},
|
|
6482
|
+
{
|
|
6483
|
+
sentName: 'Microsoft Edge (Legacy)',
|
|
6484
|
+
shortName: 'MSEdge-legacy',
|
|
6485
|
+
regexpBrowserNameWithVersion: '(Edge)\\/(.+)',
|
|
6486
|
+
},
|
|
6487
|
+
{
|
|
6488
|
+
sentName: 'Microsoft Edge (Chromium)',
|
|
6489
|
+
shortName: 'MSEdge',
|
|
6490
|
+
regexpBrowserNameWithVersion: '(Edg)\\/(.+)',
|
|
6491
|
+
},
|
|
6492
|
+
{
|
|
6493
|
+
sentName: 'Google Chrome or Chromium',
|
|
6494
|
+
shortName: 'Chrome',
|
|
6495
|
+
regexpBrowserNameWithVersion: '(Chrome)\\/(.+)\\s',
|
|
6496
|
+
},
|
|
6497
|
+
{
|
|
6498
|
+
sentName: 'Apple Safari',
|
|
6499
|
+
shortName: 'Safari',
|
|
6500
|
+
regexpBrowserNameWithVersion: '(Safari)\\/(.+)',
|
|
6501
|
+
},
|
|
6502
|
+
];
|
|
6503
|
+
|
|
6504
|
+
var Device;
|
|
6505
|
+
(function (Device) {
|
|
6506
|
+
Device["mobile"] = "mobile";
|
|
6507
|
+
Device["desktop"] = "desktop";
|
|
6508
|
+
})(Device || (Device = {}));
|
|
6509
|
+
|
|
6510
|
+
const osList = [
|
|
6511
|
+
{
|
|
6512
|
+
name: 'Windows XP',
|
|
6513
|
+
regExp: 'Windows XP',
|
|
6514
|
+
},
|
|
6515
|
+
{
|
|
6516
|
+
name: 'Windows XP',
|
|
6517
|
+
regExp: 'Windows NT 5.1|Windows NT5.1',
|
|
6518
|
+
},
|
|
6519
|
+
{
|
|
6520
|
+
name: 'Windows Vista',
|
|
6521
|
+
regExp: 'Windows NT 6.0',
|
|
6522
|
+
},
|
|
6523
|
+
{
|
|
6524
|
+
name: 'Windows 7',
|
|
6525
|
+
regExp: 'Windows NT 6.1',
|
|
6526
|
+
},
|
|
6527
|
+
{
|
|
6528
|
+
name: 'Windows 8',
|
|
6529
|
+
regExp: 'Windows NT 6.2',
|
|
6530
|
+
},
|
|
6531
|
+
{
|
|
6532
|
+
name: 'Windows 8.1',
|
|
6533
|
+
regExp: 'Windows NT 6.3',
|
|
6534
|
+
},
|
|
6535
|
+
{
|
|
6536
|
+
name: 'Windows 10',
|
|
6537
|
+
regExp: 'Windows NT 10.0',
|
|
6538
|
+
},
|
|
6539
|
+
{
|
|
6540
|
+
name: 'Windows CE',
|
|
6541
|
+
regExp: 'Windows CE',
|
|
6542
|
+
},
|
|
6543
|
+
{
|
|
6544
|
+
name: 'iPhone',
|
|
6545
|
+
regExp: 'iphone',
|
|
6546
|
+
},
|
|
6547
|
+
{
|
|
6548
|
+
name: 'iPod',
|
|
6549
|
+
regExp: 'ipod',
|
|
6550
|
+
},
|
|
6551
|
+
{
|
|
6552
|
+
name: 'iPad',
|
|
6553
|
+
regExp: 'ipad',
|
|
6554
|
+
},
|
|
6555
|
+
{
|
|
6556
|
+
name: 'Android',
|
|
6557
|
+
regExp: 'Android ([0-9]{1,2}.[0-9]{1,2}.?[0-9]{0,3})',
|
|
6558
|
+
},
|
|
6559
|
+
{
|
|
6560
|
+
name: 'Android',
|
|
6561
|
+
regExp: 'Android',
|
|
6562
|
+
},
|
|
6563
|
+
{
|
|
6564
|
+
name: 'Android',
|
|
6565
|
+
regExp: 'android',
|
|
6566
|
+
},
|
|
6567
|
+
{
|
|
6568
|
+
name: 'BlackBerry',
|
|
6569
|
+
regExp: 'blackberry',
|
|
6570
|
+
},
|
|
6571
|
+
{
|
|
6572
|
+
name: 'Mobile',
|
|
6573
|
+
regExp: 'webos',
|
|
6574
|
+
},
|
|
6575
|
+
{
|
|
6576
|
+
name: 'Nintendo WiiU',
|
|
6577
|
+
regExp: 'Nintendo WiiU',
|
|
6578
|
+
},
|
|
6579
|
+
{
|
|
6580
|
+
name: 'Xbox One S',
|
|
6581
|
+
regExp: 'XBOX_ONE_ED',
|
|
6582
|
+
},
|
|
6583
|
+
{
|
|
6584
|
+
name: 'Xbox One',
|
|
6585
|
+
regExp: 'Xbox; Xbox One',
|
|
6586
|
+
},
|
|
6587
|
+
{
|
|
6588
|
+
name: 'PlayStation',
|
|
6589
|
+
regExp: 'PlayStation',
|
|
6590
|
+
},
|
|
6591
|
+
{
|
|
6592
|
+
name: 'Windows',
|
|
6593
|
+
regExp: '(win)([0-9]{1,2}\\.[0-9x]{1,2})',
|
|
6594
|
+
},
|
|
6595
|
+
{
|
|
6596
|
+
name: 'Windows',
|
|
6597
|
+
regExp: '(windows)([0-9x]{2})',
|
|
6598
|
+
},
|
|
6599
|
+
{
|
|
6600
|
+
name: 'Windows',
|
|
6601
|
+
regExp: '(windows)([0-9]{1,2}\\.[0-9]{1,2})',
|
|
6602
|
+
},
|
|
6603
|
+
{
|
|
6604
|
+
name: 'Windows',
|
|
6605
|
+
regExp: 'win32',
|
|
6606
|
+
},
|
|
6607
|
+
{
|
|
6608
|
+
name: 'Java',
|
|
6609
|
+
regExp: '(java)([0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,2})',
|
|
6610
|
+
},
|
|
6611
|
+
{
|
|
6612
|
+
name: 'Solaris',
|
|
6613
|
+
regExp: '(Solaris)([0-9]{1,2}\\.[0-9x]{1,2}){0,1}',
|
|
6614
|
+
},
|
|
6615
|
+
{
|
|
6616
|
+
name: 'Unix',
|
|
6617
|
+
regExp: 'unix',
|
|
6618
|
+
},
|
|
6619
|
+
{
|
|
6620
|
+
name: 'Mac OS X',
|
|
6621
|
+
regExp: 'Mac OS X',
|
|
6622
|
+
},
|
|
6623
|
+
{
|
|
6624
|
+
name: 'Mac OS',
|
|
6625
|
+
regExp: '(mac|Macintosh)',
|
|
6626
|
+
},
|
|
6627
|
+
{
|
|
6628
|
+
name: 'SunOS',
|
|
6629
|
+
regExp: '(sunos)([0-9]{1,2}\\.[0-9]{1,2}){0,1}',
|
|
6630
|
+
},
|
|
6631
|
+
{
|
|
6632
|
+
name: 'BeOS',
|
|
6633
|
+
regExp: '(beos)([0-9]{1,2}\\.[0-9]{1,2}){0,1}',
|
|
6634
|
+
},
|
|
6635
|
+
{
|
|
6636
|
+
name: 'RISC OS',
|
|
6637
|
+
regExp: '(risc os)([0-9]{1,2}\\.[0-9]{1,2})',
|
|
6638
|
+
},
|
|
6639
|
+
{
|
|
6640
|
+
name: 'FreeBSD',
|
|
6641
|
+
regExp: 'freebsd',
|
|
6642
|
+
},
|
|
6643
|
+
{
|
|
6644
|
+
name: 'OpenBSD',
|
|
6645
|
+
regExp: 'openbsd',
|
|
6646
|
+
},
|
|
6647
|
+
{
|
|
6648
|
+
name: 'NetBSD',
|
|
6649
|
+
regExp: 'netbsd',
|
|
6650
|
+
},
|
|
6651
|
+
{
|
|
6652
|
+
name: 'IRIX',
|
|
6653
|
+
regExp: 'irix',
|
|
6654
|
+
},
|
|
6655
|
+
{
|
|
6656
|
+
name: 'Plan9',
|
|
6657
|
+
regExp: 'plan9',
|
|
6658
|
+
},
|
|
6659
|
+
{
|
|
6660
|
+
name: 'OSF',
|
|
6661
|
+
regExp: 'osf',
|
|
6662
|
+
},
|
|
6663
|
+
{
|
|
6664
|
+
name: 'AIX',
|
|
6665
|
+
regExp: 'aix',
|
|
6666
|
+
},
|
|
6667
|
+
{
|
|
6668
|
+
name: 'GNU Hurd',
|
|
6669
|
+
regExp: 'GNU Hurd',
|
|
6670
|
+
},
|
|
6671
|
+
{
|
|
6672
|
+
name: 'Linux - Fedora',
|
|
6673
|
+
regExp: '(fedora)',
|
|
6674
|
+
},
|
|
6675
|
+
{
|
|
6676
|
+
name: 'Linux - Kubuntu',
|
|
6677
|
+
regExp: '(kubuntu)',
|
|
6678
|
+
},
|
|
6679
|
+
{
|
|
6680
|
+
name: 'Linux - Ubuntu',
|
|
6681
|
+
regExp: '(ubuntu)',
|
|
6682
|
+
},
|
|
6683
|
+
{
|
|
6684
|
+
name: 'Linux - Debian',
|
|
6685
|
+
regExp: '(debian)',
|
|
6686
|
+
},
|
|
6687
|
+
{
|
|
6688
|
+
name: 'Linux - CentOS',
|
|
6689
|
+
regExp: '(CentOS)',
|
|
6690
|
+
},
|
|
6691
|
+
{
|
|
6692
|
+
name: 'Linux - Mandriva',
|
|
6693
|
+
regExp: '(Mandriva).([0-9]{1,3}(\\.[0-9]{1,3})?(\\.[0-9]{1,3})?)',
|
|
6694
|
+
},
|
|
6695
|
+
{
|
|
6696
|
+
name: 'Linux - SUSE',
|
|
6697
|
+
regExp: '(SUSE).([0-9]{1,3}(\\.[0-9]{1,3})?(\\.[0-9]{1,3})?)',
|
|
6698
|
+
},
|
|
6699
|
+
{
|
|
6700
|
+
name: 'Linux - Slackware (Dropline GNOME)',
|
|
6701
|
+
regExp: '(Dropline)',
|
|
6702
|
+
},
|
|
6703
|
+
{
|
|
6704
|
+
name: 'Linux - ASPLinux',
|
|
6705
|
+
regExp: '(ASPLinux)',
|
|
6706
|
+
},
|
|
6707
|
+
{
|
|
6708
|
+
name: 'Linux - Red Hat',
|
|
6709
|
+
regExp: '(Red Hat)',
|
|
6710
|
+
},
|
|
6711
|
+
{
|
|
6712
|
+
name: 'Linux',
|
|
6713
|
+
regExp: '(linux)',
|
|
6714
|
+
},
|
|
6715
|
+
{
|
|
6716
|
+
name: 'AmigaOS',
|
|
6717
|
+
regExp: '(amigaos)([0-9]{1,2}\\.[0-9]{1,2})',
|
|
6718
|
+
},
|
|
6719
|
+
{
|
|
6720
|
+
name: 'AmigaOS',
|
|
6721
|
+
regExp: 'amiga-aweb',
|
|
6722
|
+
},
|
|
6723
|
+
{
|
|
6724
|
+
name: 'Amiga',
|
|
6725
|
+
regExp: 'amiga',
|
|
6726
|
+
},
|
|
6727
|
+
{
|
|
6728
|
+
name: 'PalmOS',
|
|
6729
|
+
regExp: 'AvantGo',
|
|
6730
|
+
},
|
|
6731
|
+
{
|
|
6732
|
+
name: 'WebTV',
|
|
6733
|
+
regExp: '(webtv)/([0-9]{1,2}\\.[0-9]{1,2})',
|
|
6734
|
+
},
|
|
6735
|
+
{
|
|
6736
|
+
name: 'Dreamcast OS',
|
|
6737
|
+
regExp: 'Dreamcast',
|
|
6738
|
+
},
|
|
6739
|
+
{
|
|
6740
|
+
name: 'Windows',
|
|
6741
|
+
regExp: 'wget',
|
|
6742
|
+
},
|
|
6743
|
+
{
|
|
6744
|
+
name: 'Unknown',
|
|
6745
|
+
regExp: 'Java',
|
|
6746
|
+
},
|
|
6747
|
+
{
|
|
6748
|
+
name: 'Windows',
|
|
6749
|
+
regExp: '(msie)([0-9]{1,2}.[0-9]{1,2})',
|
|
6750
|
+
},
|
|
6751
|
+
{
|
|
6752
|
+
name: 'Unix',
|
|
6753
|
+
regExp: 'libwww-perl',
|
|
6754
|
+
},
|
|
6755
|
+
{
|
|
6756
|
+
name: 'Windows CE',
|
|
6757
|
+
regExp: 'UP.Browser',
|
|
6758
|
+
},
|
|
6759
|
+
{
|
|
6760
|
+
name: 'Windows',
|
|
6761
|
+
regExp: 'NetAnts',
|
|
6762
|
+
},
|
|
6763
|
+
];
|
|
6764
|
+
|
|
6765
|
+
class UserAgentService {
|
|
6766
|
+
constructor(window) {
|
|
6767
|
+
this.window = window;
|
|
6768
|
+
this._browserName = null;
|
|
6769
|
+
this._browserVersion = null;
|
|
6770
|
+
this._browserApp = null;
|
|
6771
|
+
this._platform = null;
|
|
6772
|
+
this._os = null;
|
|
6773
|
+
this.getUserPlatform();
|
|
6774
|
+
this.getBrowserInformation();
|
|
6775
|
+
this.getOsInformation();
|
|
6776
|
+
}
|
|
6777
|
+
get browserVersion() {
|
|
6778
|
+
return this._browserVersion;
|
|
6779
|
+
}
|
|
6780
|
+
get browserApp() {
|
|
6781
|
+
return this._browserApp;
|
|
6782
|
+
}
|
|
6783
|
+
get platform() {
|
|
6784
|
+
if (this._platform === unknownValue) {
|
|
6785
|
+
return this.osType;
|
|
6786
|
+
}
|
|
6787
|
+
return this._platform;
|
|
6788
|
+
}
|
|
6789
|
+
get userAgent() {
|
|
6790
|
+
return this.window.navigator.userAgent;
|
|
6791
|
+
}
|
|
6792
|
+
get browserDescription() {
|
|
6793
|
+
if (this.browserName === unknownValue || this.browserName === null) {
|
|
6794
|
+
return this.userAgent;
|
|
6795
|
+
}
|
|
6796
|
+
return this.browserName;
|
|
6797
|
+
}
|
|
6798
|
+
get isSafari() {
|
|
6799
|
+
return this._browserName === 'Apple Safari';
|
|
6800
|
+
}
|
|
6801
|
+
get iOsVersion() {
|
|
6802
|
+
if (this.osType !== 'ios') {
|
|
6803
|
+
return null;
|
|
6804
|
+
}
|
|
6805
|
+
const version = /OS (\d+)_(\d+)_?(\d+)?/.exec(this.window.navigator.appVersion);
|
|
6806
|
+
return version ? `${version[1]}.${version[2]}.${version[3] ?? 0}` : null;
|
|
6807
|
+
}
|
|
6808
|
+
get browserInfo() {
|
|
6809
|
+
const browserInfo = {
|
|
6810
|
+
name: this.browserDescription,
|
|
6811
|
+
[this.browserApp?.toLowerCase() ?? unknownValue]: true,
|
|
6812
|
+
version: this.browserVersion,
|
|
6813
|
+
[this.browserEngine.toLowerCase()]: true,
|
|
6814
|
+
ui_version: this.isMobileDevice ? Device.mobile : Device.desktop,
|
|
6815
|
+
os: this.os,
|
|
6816
|
+
};
|
|
6817
|
+
if (this.isMobileDevice) {
|
|
6818
|
+
browserInfo.mobile = true;
|
|
6819
|
+
}
|
|
6820
|
+
if (this.osType) {
|
|
6821
|
+
// @ts-expect-error index is string
|
|
6822
|
+
browserInfo[this.osType.toLowerCase()] = true;
|
|
6823
|
+
}
|
|
6824
|
+
if (this.window.navigator.platform?.includes('iPhone')) {
|
|
6825
|
+
browserInfo.iphone = true;
|
|
6826
|
+
}
|
|
6827
|
+
if (this.window.navigator.platform?.includes('iPod')) {
|
|
6828
|
+
browserInfo.ipod = true;
|
|
6829
|
+
}
|
|
6830
|
+
if (this.window.navigator.platform?.includes('iPad')) {
|
|
6831
|
+
browserInfo.ipad = true;
|
|
6832
|
+
browserInfo.tablet = true;
|
|
6833
|
+
}
|
|
6834
|
+
if (this.isAndroid) {
|
|
6835
|
+
browserInfo.android = true;
|
|
6836
|
+
}
|
|
6837
|
+
return browserInfo;
|
|
6838
|
+
}
|
|
6839
|
+
get isMobileDevice() {
|
|
6840
|
+
const deviceAgents = [
|
|
6841
|
+
'Android',
|
|
6842
|
+
'webOS',
|
|
6843
|
+
'iPhone',
|
|
6844
|
+
'iPad',
|
|
6845
|
+
'iPod',
|
|
6846
|
+
'BlackBerry',
|
|
6847
|
+
'IEMobile',
|
|
6848
|
+
'Opera Mini',
|
|
6849
|
+
'Mobile',
|
|
6850
|
+
'Tablet',
|
|
6851
|
+
'Kindle',
|
|
6852
|
+
'Playbook',
|
|
6853
|
+
'Silk',
|
|
6854
|
+
'Puffin',
|
|
6855
|
+
'CriOS',
|
|
6856
|
+
];
|
|
6857
|
+
return new RegExp(deviceAgents.join('|'), 'i').test(this.userAgent);
|
|
6858
|
+
}
|
|
6859
|
+
get isIosAndNotIpad() {
|
|
6860
|
+
return ['iPhone', 'iPod'].includes(this.window.navigator.platform);
|
|
6861
|
+
}
|
|
6862
|
+
getUserPlatform() {
|
|
6863
|
+
const experimentalPlatformApi = this.window.navigator?.userAgentData;
|
|
6864
|
+
const platform = experimentalPlatformApi?.platform ??
|
|
6865
|
+
this.window?.navigator?.platform ??
|
|
6866
|
+
unknownValue;
|
|
6867
|
+
this._platform = platform.toLowerCase();
|
|
6868
|
+
}
|
|
6869
|
+
getBrowserInformation() {
|
|
6870
|
+
for (const browser of browsers) {
|
|
6871
|
+
const browserRegExp = new RegExp(browser.regexpBrowserNameWithVersion);
|
|
6872
|
+
const browserNameWithVersion = browserRegExp.exec(this.userAgent);
|
|
6873
|
+
if (browserNameWithVersion !== null) {
|
|
6874
|
+
this._browserName = browser.sentName;
|
|
6875
|
+
this._browserApp = browser.shortName;
|
|
6876
|
+
this._browserVersion = browserNameWithVersion[2];
|
|
6877
|
+
break;
|
|
6878
|
+
}
|
|
6879
|
+
this._browserName = unknownValue;
|
|
6880
|
+
this._browserApp = unknownValue;
|
|
6881
|
+
this._browserVersion = unknownValue;
|
|
6882
|
+
}
|
|
6883
|
+
}
|
|
6884
|
+
getOsInformation() {
|
|
6885
|
+
for (const os of osList) {
|
|
6886
|
+
const osRegExp = new RegExp(os.regExp);
|
|
6887
|
+
const osName = osRegExp.exec(this.userAgent);
|
|
6888
|
+
if (osName !== null) {
|
|
6889
|
+
this._os = os.name;
|
|
6890
|
+
break;
|
|
6891
|
+
}
|
|
6892
|
+
this._os = unknownValue;
|
|
6893
|
+
}
|
|
6894
|
+
}
|
|
6895
|
+
get browserName() {
|
|
6896
|
+
return this._browserName;
|
|
6897
|
+
}
|
|
6898
|
+
get isAndroid() {
|
|
6899
|
+
return /Android\s+([\d.]+)/.test(this.userAgent);
|
|
6900
|
+
}
|
|
6901
|
+
get isXbox() {
|
|
6902
|
+
return /xbox/i.test(this.userAgent);
|
|
6903
|
+
}
|
|
6904
|
+
get isLinux() {
|
|
6905
|
+
return /linux/i.test(this.userAgent);
|
|
6906
|
+
}
|
|
6907
|
+
get isWindows() {
|
|
6908
|
+
return /windows/i.test(this.userAgent);
|
|
6909
|
+
}
|
|
6910
|
+
get browserEngine() {
|
|
6911
|
+
const engines = new Map([
|
|
6912
|
+
['Firefox', 'Gecko'],
|
|
6913
|
+
['Safari', 'Webkit'],
|
|
6914
|
+
['MSEdge-legacy', 'EdgeHTML'],
|
|
6915
|
+
['Chrome', 'Blink'],
|
|
6916
|
+
['Opera', 'Blink'],
|
|
6917
|
+
['MSEdge', 'Blink'],
|
|
6918
|
+
['SamsungBrowser', 'Blink'],
|
|
6919
|
+
]);
|
|
6920
|
+
return engines.get(this.browserApp) ?? unknownValue;
|
|
6921
|
+
}
|
|
6922
|
+
get os() {
|
|
6923
|
+
return this._os;
|
|
6924
|
+
}
|
|
6925
|
+
get osType() {
|
|
6926
|
+
if (['iPhone', 'iPod', 'iPad'].includes(this.window.navigator.platform)) {
|
|
6927
|
+
return 'ios';
|
|
6928
|
+
}
|
|
6929
|
+
if (this.window.navigator.platform?.includes('MacIntel')) {
|
|
6930
|
+
return 'mac';
|
|
6931
|
+
}
|
|
6932
|
+
if (this.isXbox) {
|
|
6933
|
+
return 'xbox';
|
|
6934
|
+
}
|
|
6935
|
+
if (this.isWindows) {
|
|
6936
|
+
return 'windows';
|
|
6937
|
+
}
|
|
6938
|
+
if (this.isAndroid) {
|
|
6939
|
+
return 'android';
|
|
6940
|
+
}
|
|
6941
|
+
if (this.isLinux) {
|
|
6942
|
+
return 'linux';
|
|
6943
|
+
}
|
|
6944
|
+
return null;
|
|
6945
|
+
}
|
|
6946
|
+
}
|
|
6947
|
+
UserAgentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UserAgentService, deps: [{ token: windowToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
6948
|
+
UserAgentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UserAgentService, providedIn: 'root' });
|
|
6949
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: UserAgentService, decorators: [{
|
|
6950
|
+
type: Injectable,
|
|
6951
|
+
args: [{
|
|
6952
|
+
providedIn: 'root',
|
|
6953
|
+
}]
|
|
6954
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
6955
|
+
type: Inject,
|
|
6956
|
+
args: [windowToken]
|
|
6957
|
+
}] }]; } });
|
|
6958
|
+
|
|
6959
|
+
class ApplePayService {
|
|
6960
|
+
get paymentParameters() {
|
|
6961
|
+
return this.applePayParams;
|
|
6962
|
+
}
|
|
6963
|
+
get payment$() {
|
|
6964
|
+
return this.payment.asObservable();
|
|
6965
|
+
}
|
|
6966
|
+
get error$() {
|
|
6967
|
+
return this.error.asObservable();
|
|
6968
|
+
}
|
|
6969
|
+
get integrationType$() {
|
|
6970
|
+
return this.integrationType.asObservable();
|
|
6971
|
+
}
|
|
6972
|
+
constructor(window, userAgentService, summaryFinanceDetailsAdapterService) {
|
|
6973
|
+
this.window = window;
|
|
6974
|
+
this.userAgentService = userAgentService;
|
|
6975
|
+
this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
|
|
6976
|
+
this.agreementFieldsNames = agreementsGroup;
|
|
6977
|
+
this.payment = new Subject();
|
|
6978
|
+
this.error = new Subject();
|
|
6979
|
+
this.integrationType = new Subject();
|
|
6980
|
+
this.paymentClient = null;
|
|
6981
|
+
this.applePayParams = null;
|
|
6982
|
+
this.order = null;
|
|
6983
|
+
this.api = this.loadBraintree();
|
|
6984
|
+
}
|
|
6985
|
+
setApplePayParams(data) {
|
|
6986
|
+
const formFields = data?.paymentForm?.fields;
|
|
6987
|
+
const summary = data?.paymentForm?.summary;
|
|
6988
|
+
if (!formFields || !summary) {
|
|
6989
|
+
return;
|
|
6990
|
+
}
|
|
6991
|
+
const fields = formFields.reduce((acc, field) => {
|
|
6992
|
+
if (this.agreementFieldsNames.includes(field.name) &&
|
|
6993
|
+
field.isVisible === '1') {
|
|
6994
|
+
acc[field.name] = field.title;
|
|
6995
|
+
}
|
|
6996
|
+
else {
|
|
6997
|
+
acc[field.name] = field.value;
|
|
6998
|
+
}
|
|
6999
|
+
return acc;
|
|
7000
|
+
}, {});
|
|
7001
|
+
const agreements = this.agreementFieldsNames
|
|
7002
|
+
.map((fieldName) => fields[fieldName])
|
|
7003
|
+
.filter(Boolean);
|
|
7004
|
+
this.applePayParams = {
|
|
7005
|
+
tokenKey: this.getAppleToken(formFields),
|
|
7006
|
+
totalLabel: fields['label_applePay'] ?? '',
|
|
7007
|
+
totalAmount: this.getTotalAmount(summary),
|
|
7008
|
+
currencyCode: this.getTotalCurrency(summary),
|
|
7009
|
+
countryCode: fields['countryCode'] ?? '',
|
|
7010
|
+
merchantCapabilities: this.getJsonValueFromField(fields, 'merchantCapabilities'),
|
|
7011
|
+
supportedNetworks: this.getJsonValueFromField(fields, 'supportedNetworks'),
|
|
7012
|
+
agreements: agreements,
|
|
7013
|
+
};
|
|
7014
|
+
}
|
|
7015
|
+
async initLibrary(tokenKey) {
|
|
7016
|
+
try {
|
|
7017
|
+
const api = await this.api;
|
|
7018
|
+
const clientInstance = await api.client.create({
|
|
7019
|
+
authorization: tokenKey,
|
|
7020
|
+
});
|
|
7021
|
+
this.paymentClient = await api.applePay.create({
|
|
7022
|
+
client: clientInstance,
|
|
7023
|
+
});
|
|
7024
|
+
}
|
|
7025
|
+
catch (error) {
|
|
7026
|
+
console.error('apple pay: initialize failed', error);
|
|
7027
|
+
}
|
|
7028
|
+
this.emitIntegrationType();
|
|
7029
|
+
if (!this.paymentClient ||
|
|
7030
|
+
(!this.isDeviceCapable() && !this.userAgentService.isSafari)) {
|
|
7031
|
+
this.emitError(ApplePayErrors.deviceIsNotCapableError);
|
|
7032
|
+
}
|
|
7033
|
+
}
|
|
7034
|
+
redirectToPaymentPage(parameters, token) {
|
|
7035
|
+
const route = pagesRoutes.get(applePayId);
|
|
7036
|
+
if (!route) {
|
|
7037
|
+
return;
|
|
7038
|
+
}
|
|
7039
|
+
const query = new URLSearchParams({
|
|
7040
|
+
...parameters,
|
|
7041
|
+
merchantCapabilities: JSON.stringify(parameters.merchantCapabilities),
|
|
7042
|
+
supportedNetworks: JSON.stringify(parameters.supportedNetworks),
|
|
7043
|
+
token,
|
|
7044
|
+
agreements: JSON.stringify(parameters.agreements),
|
|
7045
|
+
});
|
|
7046
|
+
if (this.order) {
|
|
7047
|
+
query.append('order', this.order);
|
|
7048
|
+
}
|
|
7049
|
+
const url = `${route}?${query.toString()}`;
|
|
7050
|
+
return url;
|
|
7051
|
+
}
|
|
7052
|
+
setOrder(data) {
|
|
7053
|
+
const summary = data?.paymentForm?.summary;
|
|
7054
|
+
if (!summary) {
|
|
7055
|
+
return;
|
|
7056
|
+
}
|
|
7057
|
+
const financeDetails = this.summaryFinanceDetailsAdapterService.getFinanceDetails(summary);
|
|
7058
|
+
if (financeDetails?.purchase && financeDetails?.finance) {
|
|
7059
|
+
const cartItems = financeDetails.cartItems;
|
|
7060
|
+
this.order = cartItems?.reduce((curr, item) => {
|
|
7061
|
+
if (curr) {
|
|
7062
|
+
return curr + `; ${item.title}`;
|
|
7063
|
+
}
|
|
7064
|
+
return curr + item.title;
|
|
7065
|
+
}, '');
|
|
7066
|
+
}
|
|
7067
|
+
}
|
|
7068
|
+
proceedCheckout(parameters) {
|
|
7069
|
+
if (!parameters) {
|
|
7070
|
+
return;
|
|
7071
|
+
}
|
|
7072
|
+
if (!this.paymentClient || !this.isDeviceCapable()) {
|
|
7073
|
+
console.warn('apple pay: device is not capable', this.paymentClient);
|
|
7074
|
+
this.emitError(ApplePayErrors.deviceIsNotCapableError);
|
|
7075
|
+
return;
|
|
7076
|
+
}
|
|
7077
|
+
try {
|
|
7078
|
+
const paymentRequest = this.paymentClient.createPaymentRequest({
|
|
7079
|
+
total: {
|
|
7080
|
+
label: parameters.totalLabel,
|
|
7081
|
+
amount: parameters.totalAmount,
|
|
7082
|
+
},
|
|
7083
|
+
currencyCode: parameters.currencyCode,
|
|
7084
|
+
countryCode: parameters.countryCode,
|
|
7085
|
+
merchantCapabilities: parameters.merchantCapabilities,
|
|
7086
|
+
supportedNetworks: parameters.supportedNetworks,
|
|
7087
|
+
});
|
|
7088
|
+
const session = new this.window.ApplePaySession(applePayVersion, paymentRequest);
|
|
7089
|
+
session.onvalidatemerchant = (event) => {
|
|
7090
|
+
console.info('apple pay: merchant validation', event);
|
|
7091
|
+
this.paymentClient
|
|
7092
|
+
?.performValidation({
|
|
7093
|
+
validationURL: event.validationURL,
|
|
7094
|
+
displayName: parameters?.totalLabel,
|
|
7095
|
+
})
|
|
7096
|
+
.then((merchantSession) => {
|
|
7097
|
+
session.completeMerchantValidation(merchantSession);
|
|
7098
|
+
})
|
|
7099
|
+
.catch((error) => {
|
|
7100
|
+
console.error('apple pay: merchant validation error', error);
|
|
7101
|
+
session.abort();
|
|
7102
|
+
});
|
|
7103
|
+
};
|
|
7104
|
+
session.onpaymentauthorized = (event) => {
|
|
7105
|
+
console.info('apple pay: payment authorization', event);
|
|
7106
|
+
this.paymentClient
|
|
7107
|
+
?.tokenize({
|
|
7108
|
+
token: event.payment.token,
|
|
7109
|
+
})
|
|
7110
|
+
.then((authorizationResponse) => {
|
|
7111
|
+
this.payment.next(authorizationResponse?.nonce ?? '');
|
|
7112
|
+
session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
|
|
7113
|
+
})
|
|
7114
|
+
.catch((error) => {
|
|
7115
|
+
console.error('apple pay: payment authorization error', error);
|
|
7116
|
+
session.completePayment(this.window.ApplePaySession.STATUS_FAILURE);
|
|
7117
|
+
});
|
|
7118
|
+
};
|
|
7119
|
+
session.oncancel = (event) => {
|
|
7120
|
+
this.emitError(ApplePayErrors.paymentError);
|
|
7121
|
+
console.error('apple pay: user cancel payment', event);
|
|
7122
|
+
};
|
|
7123
|
+
session.begin();
|
|
7124
|
+
}
|
|
7125
|
+
catch (error) {
|
|
7126
|
+
console.error('apple pay: checkout error', error);
|
|
7127
|
+
this.emitError(ApplePayErrors.paymentError);
|
|
7128
|
+
}
|
|
7129
|
+
}
|
|
7130
|
+
isDeviceCapable() {
|
|
7131
|
+
try {
|
|
7132
|
+
return Boolean(this.window.ApplePaySession?.supportsVersion(applePayVersion) &&
|
|
7133
|
+
this.window.ApplePaySession?.canMakePayments());
|
|
7134
|
+
}
|
|
7135
|
+
catch (error) {
|
|
7136
|
+
return false;
|
|
7137
|
+
}
|
|
7138
|
+
}
|
|
7139
|
+
getTokenNonceFieldData(tokenNonce) {
|
|
7140
|
+
const name = FieldNames.tokenApplePay;
|
|
7141
|
+
const value = btoa(tokenNonce);
|
|
7142
|
+
return { name, value };
|
|
7143
|
+
}
|
|
7144
|
+
updateApplePayParams(data) {
|
|
7145
|
+
const summary = data?.summary;
|
|
7146
|
+
if (!this.applePayParams || !summary) {
|
|
7147
|
+
return;
|
|
7148
|
+
}
|
|
7149
|
+
this.applePayParams.totalAmount = this.getTotalAmount(summary);
|
|
7150
|
+
this.applePayParams.currencyCode = this.getTotalCurrency(summary);
|
|
7151
|
+
}
|
|
7152
|
+
async loadBraintree() {
|
|
7153
|
+
const api = await import('braintree-web');
|
|
7154
|
+
return api;
|
|
7155
|
+
}
|
|
7156
|
+
getAppleToken(formFields) {
|
|
7157
|
+
const appleTokenField = formFields.find((field) => {
|
|
7158
|
+
return field.name === 'token_key';
|
|
7159
|
+
});
|
|
7160
|
+
if (!appleTokenField) {
|
|
7161
|
+
return '';
|
|
7162
|
+
}
|
|
7163
|
+
return appleTokenField.value;
|
|
7164
|
+
}
|
|
7165
|
+
getTotalAmount(summary) {
|
|
7166
|
+
const finance = summary?.finance;
|
|
7167
|
+
const total = finance?.grand_total?.amount ?? finance?.total.amount;
|
|
7168
|
+
return total?.toString() ?? '';
|
|
7169
|
+
}
|
|
7170
|
+
getTotalCurrency(summary) {
|
|
7171
|
+
const finance = summary?.finance;
|
|
7172
|
+
return finance?.grand_total?.currency ?? finance?.total?.currency ?? '';
|
|
7173
|
+
}
|
|
7174
|
+
getJsonValueFromField(fields, fieldName) {
|
|
7175
|
+
const field = fields[fieldName];
|
|
7176
|
+
try {
|
|
7177
|
+
return field ? JSON.parse(field) : undefined;
|
|
7178
|
+
}
|
|
7179
|
+
catch (error) {
|
|
7180
|
+
return undefined;
|
|
7181
|
+
}
|
|
7182
|
+
}
|
|
7183
|
+
emitError(error) {
|
|
7184
|
+
this.error.next(error);
|
|
7185
|
+
}
|
|
7186
|
+
emitIntegrationType() {
|
|
7187
|
+
let integrationType;
|
|
7188
|
+
if (this.paymentClient && this.isDeviceCapable()) {
|
|
7189
|
+
integrationType = 'sdk';
|
|
7190
|
+
}
|
|
7191
|
+
else if (this.userAgentService.isSafari) {
|
|
7192
|
+
integrationType = 'redirect';
|
|
7193
|
+
}
|
|
7194
|
+
else {
|
|
7195
|
+
integrationType = 'none';
|
|
7196
|
+
}
|
|
7197
|
+
this.integrationType.next(integrationType);
|
|
7198
|
+
}
|
|
7199
|
+
}
|
|
7200
|
+
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 });
|
|
7201
|
+
ApplePayService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ApplePayService, providedIn: 'root' });
|
|
7202
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ApplePayService, decorators: [{
|
|
7203
|
+
type: Injectable,
|
|
7204
|
+
args: [{
|
|
7205
|
+
providedIn: 'root',
|
|
7206
|
+
}]
|
|
7207
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
7208
|
+
type: Inject,
|
|
7209
|
+
args: [windowToken]
|
|
7210
|
+
}] }, { type: UserAgentService }, { type: SummaryFinanceDetailsAdapterService }]; } });
|
|
7211
|
+
|
|
6333
7212
|
/*
|
|
6334
7213
|
* Public API Surface of core-library
|
|
6335
7214
|
*/
|
|
@@ -6338,5 +7217,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
6338
7217
|
* Generated bundle index. Do not edit.
|
|
6339
7218
|
*/
|
|
6340
7219
|
|
|
6341
|
-
export { CoreLibraryModule, CoreLibraryService };
|
|
7220
|
+
export { ApplePayService, CoreLibraryModule, CoreLibraryService };
|
|
6342
7221
|
//# sourceMappingURL=xsolla-payment-client-core.mjs.map
|