@xsolla/payment-client-core 0.2.8 → 0.2.10
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/payment/actions/next-action.interface.mjs +1 -1
- package/esm2020/lib/core/payment/actions/next-actions.mjs +5 -1
- package/esm2020/lib/core/payment/actions/show-mobile-payment-screen/show-mobile-payment-screen.action.class.mjs +26 -0
- package/esm2020/lib/core/payment/actions/show-mobile-payment-screen/show-mobile-payment-screen.action.type.mjs +2 -0
- package/esm2020/lib/core/payment/actions/show-qr-code/show-qr-code.action.class.mjs +25 -0
- package/esm2020/lib/core/payment/actions/show-qr-code/show-qr-code.action.type.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 +24 -6
- package/esm2020/lib/core/payment/status/status.service.mjs +4 -1
- package/esm2020/lib/core/payment/xps-api/xps-api.service.mjs +4 -1
- package/esm2020/lib/core/settings/configuration.interface.mjs +1 -1
- package/esm2020/lib/core/settings/settings.service.mjs +6 -1
- package/esm2020/lib/core-library.service.mjs +8 -1
- package/fesm2015/xsolla-payment-client-core.mjs +90 -4
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +87 -4
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/actions/next-action.interface.d.ts +3 -1
- package/lib/core/payment/actions/show-mobile-payment-screen/show-mobile-payment-screen.action.class.d.ts +11 -0
- package/lib/core/payment/actions/show-mobile-payment-screen/show-mobile-payment-screen.action.type.d.ts +6 -0
- 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 +6 -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 +5 -1
- package/lib/core/payment/status/status.service.d.ts +3 -0
- package/lib/core/settings/configuration.interface.d.ts +1 -0
- package/lib/core/settings/settings.service.d.ts +2 -0
- package/lib/core-library.service.d.ts +4 -0
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.2.10.tgz +0 -0
- package/xsolla-payment-client-core-0.2.8.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
|
}
|
|
@@ -691,6 +696,9 @@ class XpsApiService {
|
|
|
691
696
|
country: this.countryService.getCountry(),
|
|
692
697
|
...parameters,
|
|
693
698
|
};
|
|
699
|
+
if (this.settingsService.isMobile) {
|
|
700
|
+
requestParams.mobile = "1" /* XpsBoolean.true */;
|
|
701
|
+
}
|
|
694
702
|
return lastValueFrom(this.secureApiClient.post(this.directPaymentApiRoute, new URLSearchParams({ ...requestParams }), {
|
|
695
703
|
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
696
704
|
responseType: 'json',
|
|
@@ -1096,12 +1104,60 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
1096
1104
|
type: Injectable
|
|
1097
1105
|
}] });
|
|
1098
1106
|
|
|
1107
|
+
class ShowQrCodeActionCreator {
|
|
1108
|
+
constructor() {
|
|
1109
|
+
this.type = 'show_qr_code';
|
|
1110
|
+
}
|
|
1111
|
+
getActionData(response) {
|
|
1112
|
+
const submitButtonText = response.parameters.buyData.value;
|
|
1113
|
+
return {
|
|
1114
|
+
type: this.type,
|
|
1115
|
+
data: {
|
|
1116
|
+
submitButtonText,
|
|
1117
|
+
},
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
isSuitable(response) {
|
|
1121
|
+
return Boolean(response.parameters?.form?.qr);
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
ShowQrCodeActionCreator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowQrCodeActionCreator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1125
|
+
ShowQrCodeActionCreator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowQrCodeActionCreator });
|
|
1126
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowQrCodeActionCreator, decorators: [{
|
|
1127
|
+
type: Injectable
|
|
1128
|
+
}] });
|
|
1129
|
+
|
|
1130
|
+
class ShowMobilePaymentScreenActionCreator {
|
|
1131
|
+
constructor() {
|
|
1132
|
+
this.type = 'show_mobile_payment_screen';
|
|
1133
|
+
}
|
|
1134
|
+
getActionData(response) {
|
|
1135
|
+
const submitButtonText = response.parameters.buyData.value;
|
|
1136
|
+
return {
|
|
1137
|
+
type: this.type,
|
|
1138
|
+
data: {
|
|
1139
|
+
submitButtonText,
|
|
1140
|
+
},
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
isSuitable(response) {
|
|
1144
|
+
return response.currentCommand === XpsCommand.create;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
ShowMobilePaymentScreenActionCreator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowMobilePaymentScreenActionCreator, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1148
|
+
ShowMobilePaymentScreenActionCreator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowMobilePaymentScreenActionCreator });
|
|
1149
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ShowMobilePaymentScreenActionCreator, decorators: [{
|
|
1150
|
+
type: Injectable
|
|
1151
|
+
}] });
|
|
1152
|
+
|
|
1099
1153
|
const nextActionsToken = new InjectionToken('Action');
|
|
1100
1154
|
const nextActions = [
|
|
1101
1155
|
ShowFieldsActionCreator,
|
|
1102
1156
|
CheckStatusActionCreator,
|
|
1103
1157
|
SpecialButtonActionCreator,
|
|
1158
|
+
ShowQrCodeActionCreator,
|
|
1104
1159
|
RedirectActionCreator,
|
|
1160
|
+
ShowMobilePaymentScreenActionCreator,
|
|
1105
1161
|
];
|
|
1106
1162
|
const flowUpdateNextActions = [
|
|
1107
1163
|
ShowErrorsActionCreator,
|
|
@@ -4891,6 +4947,9 @@ class StatusService {
|
|
|
4891
4947
|
}
|
|
4892
4948
|
return this.getStatus(searchParams);
|
|
4893
4949
|
}
|
|
4950
|
+
listenFinalStatus(invoice) {
|
|
4951
|
+
return this.listenStatusService.listen(invoice);
|
|
4952
|
+
}
|
|
4894
4953
|
getRequestParamsFromUrl(url) {
|
|
4895
4954
|
const searchParams = this.urlService.getSearchParams(url ?? '');
|
|
4896
4955
|
const keys = new Set(Object.keys(searchParams));
|
|
@@ -5383,7 +5442,7 @@ class PaymentService {
|
|
|
5383
5442
|
get formResponseValue() {
|
|
5384
5443
|
return this._formResponse$.getValue();
|
|
5385
5444
|
}
|
|
5386
|
-
constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService, formMessagesService, settingsService, countryService) {
|
|
5445
|
+
constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService, formMessagesService, settingsService, countryService, checkStatusActionCreator) {
|
|
5387
5446
|
this.initializeService = initializeService;
|
|
5388
5447
|
this.submitService = submitService;
|
|
5389
5448
|
this.syncService = syncService;
|
|
@@ -5397,6 +5456,7 @@ class PaymentService {
|
|
|
5397
5456
|
this.formMessagesService = formMessagesService;
|
|
5398
5457
|
this.settingsService = settingsService;
|
|
5399
5458
|
this.countryService = countryService;
|
|
5459
|
+
this.checkStatusActionCreator = checkStatusActionCreator;
|
|
5400
5460
|
this.form = null;
|
|
5401
5461
|
this.data = null;
|
|
5402
5462
|
this.financeDetails = null;
|
|
@@ -5444,7 +5504,8 @@ class PaymentService {
|
|
|
5444
5504
|
}
|
|
5445
5505
|
this.emitFormMessages(submitResponse.messages);
|
|
5446
5506
|
// Handle 3ds flow
|
|
5447
|
-
if (submitResponse.currentCommand === XpsCommand.create
|
|
5507
|
+
if (submitResponse.currentCommand === XpsCommand.create &&
|
|
5508
|
+
submitResponse.parameters.threeDSForm) {
|
|
5448
5509
|
this.runThreeDs();
|
|
5449
5510
|
return;
|
|
5450
5511
|
}
|
|
@@ -5471,6 +5532,12 @@ class PaymentService {
|
|
|
5471
5532
|
country: this.countryService.getCountry(),
|
|
5472
5533
|
};
|
|
5473
5534
|
}
|
|
5535
|
+
getQrCode() {
|
|
5536
|
+
if (!isSubmitResponse(this.data)) {
|
|
5537
|
+
throw new Error('Should submit form first');
|
|
5538
|
+
}
|
|
5539
|
+
return this.data.parameters.form.qr.title;
|
|
5540
|
+
}
|
|
5474
5541
|
getPid() {
|
|
5475
5542
|
if (this.data instanceof SubmitResponse) {
|
|
5476
5543
|
return (Number(this.data.fields.find((field) => field.name === 'fix_pid')?.value) || null);
|
|
@@ -5517,6 +5584,15 @@ class PaymentService {
|
|
|
5517
5584
|
};
|
|
5518
5585
|
return this.statusService.getStatus(params);
|
|
5519
5586
|
}
|
|
5587
|
+
async listenFinalStatus() {
|
|
5588
|
+
const { invoice } = await this.getStatus();
|
|
5589
|
+
this.statusService
|
|
5590
|
+
.listenFinalStatus(invoice)
|
|
5591
|
+
.pipe(take(1))
|
|
5592
|
+
.subscribe(() => {
|
|
5593
|
+
this.nextActionService.emitFlowUpdates(this.checkStatusActionCreator.getActionData());
|
|
5594
|
+
});
|
|
5595
|
+
}
|
|
5520
5596
|
getFieldConfig(field) {
|
|
5521
5597
|
return this.controlConfigService.getConfig(field);
|
|
5522
5598
|
}
|
|
@@ -5653,14 +5729,14 @@ class PaymentService {
|
|
|
5653
5729
|
this._formResponse$.next({ type, data, token: this.settingsService.token });
|
|
5654
5730
|
}
|
|
5655
5731
|
}
|
|
5656
|
-
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 });
|
|
5732
|
+
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 }, { token: CheckStatusActionCreator }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
5657
5733
|
PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
|
|
5658
5734
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
|
|
5659
5735
|
type: Injectable,
|
|
5660
5736
|
args: [{
|
|
5661
5737
|
providedIn: 'root',
|
|
5662
5738
|
}]
|
|
5663
|
-
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: ControlConfigService }, { type: ThreeDsService }, { type: FormMessagesService }, { type: SettingsService }, { type: CountryService }]; } });
|
|
5739
|
+
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: ControlConfigService }, { type: ThreeDsService }, { type: FormMessagesService }, { type: SettingsService }, { type: CountryService }, { type: CheckStatusActionCreator }]; } });
|
|
5664
5740
|
|
|
5665
5741
|
class RefundPolicyService {
|
|
5666
5742
|
constructor(settingsService) {
|
|
@@ -6099,6 +6175,12 @@ class CoreLibraryService {
|
|
|
6099
6175
|
async getStatus(url) {
|
|
6100
6176
|
return this.statusService.getStatusWithUrlSearchParams(url);
|
|
6101
6177
|
}
|
|
6178
|
+
getQrCodeInitialData() {
|
|
6179
|
+
return {
|
|
6180
|
+
qrCode: this.paymentService.getQrCode(),
|
|
6181
|
+
pid: this.paymentService.getPid(),
|
|
6182
|
+
};
|
|
6183
|
+
}
|
|
6102
6184
|
setCountry(country) {
|
|
6103
6185
|
this.countryService.setCountry(country);
|
|
6104
6186
|
}
|
|
@@ -6116,6 +6198,7 @@ class CoreLibraryService {
|
|
|
6116
6198
|
getFinanceDetails: () => this.paymentService.getFinanceDetails(),
|
|
6117
6199
|
runThreeDs: () => this.paymentService.runThreeDs(),
|
|
6118
6200
|
getStatus: async () => this.paymentService.getStatus(),
|
|
6201
|
+
listenFinalStatus: async () => this.paymentService.listenFinalStatus(),
|
|
6119
6202
|
financeDetailsUpdates$: this.financeDetailsService.data$,
|
|
6120
6203
|
form: {
|
|
6121
6204
|
fieldsStatus$: this.paymentService.formFieldsStatus$,
|