@xsolla/payment-client-core 0.0.7 → 0.0.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/payment/form/controls/control-config.service.mjs +8 -1
- package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.service.mjs +14 -6
- package/esm2020/lib/core/payment/submit/request/submit-request.class.mjs +10 -2
- package/esm2020/lib/core/payment/submit/submit.service.mjs +3 -3
- package/esm2020/lib/core-library.service.mjs +6 -3
- package/fesm2015/xsolla-payment-client-core.mjs +35 -10
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +35 -10
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/form/controls/control-config.service.d.ts +2 -0
- package/lib/core/payment/payment.interface.d.ts +7 -3
- package/lib/core/payment/payment.service.d.ts +6 -2
- package/lib/core/payment/submit/request/submit-request.class.d.ts +2 -1
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.0.9.tgz +0 -0
- package/xsolla-payment-client-core-0.0.7.tgz +0 -0
|
@@ -501,7 +501,7 @@ class TokenError extends AppError {
|
|
|
501
501
|
class SubmitRequest extends XpsApiPartRequest {
|
|
502
502
|
constructor(parameters) {
|
|
503
503
|
super();
|
|
504
|
-
const { token, dfpHash } = parameters;
|
|
504
|
+
const { token, fields, form, dfpHash } = parameters;
|
|
505
505
|
if (token === null) {
|
|
506
506
|
throw new TokenError();
|
|
507
507
|
}
|
|
@@ -509,6 +509,14 @@ class SubmitRequest extends XpsApiPartRequest {
|
|
|
509
509
|
if (dfpHash) {
|
|
510
510
|
this.xps_dfp_hash = dfpHash;
|
|
511
511
|
}
|
|
512
|
+
this.addXpsParameters(this.getFieldsValues(fields, form));
|
|
513
|
+
}
|
|
514
|
+
getFieldsValues(fields, form) {
|
|
515
|
+
return fields.reduce((xpsParams, field) => {
|
|
516
|
+
const formControl = form.get(field.name);
|
|
517
|
+
xpsParams[field.name] = formControl ? formControl.value : field?.value;
|
|
518
|
+
return xpsParams;
|
|
519
|
+
}, {});
|
|
512
520
|
}
|
|
513
521
|
}
|
|
514
522
|
|
|
@@ -817,13 +825,13 @@ class SubmitService {
|
|
|
817
825
|
.getHash()
|
|
818
826
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
819
827
|
.then((dfpHash) => {
|
|
820
|
-
const
|
|
828
|
+
const requestParams = this.requestFactory({
|
|
821
829
|
token: this.settingsService.token,
|
|
822
830
|
fields,
|
|
823
831
|
form,
|
|
824
832
|
dfpHash,
|
|
825
833
|
});
|
|
826
|
-
return lastValueFrom(this.secureApi.post(this.directPaymentApiRoute,
|
|
834
|
+
return lastValueFrom(this.secureApi.post(this.directPaymentApiRoute, new URLSearchParams({ ...requestParams }), {
|
|
827
835
|
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
828
836
|
responseType: 'json',
|
|
829
837
|
}))
|
|
@@ -1212,6 +1220,13 @@ class ControlConfigService {
|
|
|
1212
1220
|
}
|
|
1213
1221
|
return converter.convertToFormControl(field);
|
|
1214
1222
|
}
|
|
1223
|
+
getConfig(field) {
|
|
1224
|
+
const converter = this.getConverter(field);
|
|
1225
|
+
if (!converter) {
|
|
1226
|
+
return null;
|
|
1227
|
+
}
|
|
1228
|
+
return converter.convertToConfig(field);
|
|
1229
|
+
}
|
|
1215
1230
|
getConverter(field) {
|
|
1216
1231
|
if (!field) {
|
|
1217
1232
|
return null;
|
|
@@ -2387,13 +2402,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2387
2402
|
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
2388
2403
|
|
|
2389
2404
|
class PaymentService {
|
|
2390
|
-
constructor(initializeService, submitService, syncService, formService, statusService, nextActionService) {
|
|
2405
|
+
constructor(initializeService, submitService, syncService, formService, statusService, nextActionService, controlConfigService) {
|
|
2391
2406
|
this.initializeService = initializeService;
|
|
2392
2407
|
this.submitService = submitService;
|
|
2393
2408
|
this.syncService = syncService;
|
|
2394
2409
|
this.formService = formService;
|
|
2395
2410
|
this.statusService = statusService;
|
|
2396
2411
|
this.nextActionService = nextActionService;
|
|
2412
|
+
this.controlConfigService = controlConfigService;
|
|
2397
2413
|
this.form = null;
|
|
2398
2414
|
this.data = null;
|
|
2399
2415
|
this.fields = [];
|
|
@@ -2406,8 +2422,11 @@ class PaymentService {
|
|
|
2406
2422
|
this.syncService.setup(this.form, this.fields);
|
|
2407
2423
|
return this.fields;
|
|
2408
2424
|
}
|
|
2409
|
-
async submit(
|
|
2410
|
-
|
|
2425
|
+
async submit() {
|
|
2426
|
+
if (!this.form) {
|
|
2427
|
+
throw new Error('form is empty!');
|
|
2428
|
+
}
|
|
2429
|
+
const submitResponse = await this.submitService.request(this.fields, this.form);
|
|
2411
2430
|
return this.nextActionService.getNextAction(submitResponse);
|
|
2412
2431
|
}
|
|
2413
2432
|
getFields() {
|
|
@@ -2428,19 +2447,22 @@ class PaymentService {
|
|
|
2428
2447
|
pid: this.config.paymentMethodId,
|
|
2429
2448
|
});
|
|
2430
2449
|
}
|
|
2450
|
+
getFieldConfig(field) {
|
|
2451
|
+
return this.controlConfigService.getConfig(field);
|
|
2452
|
+
}
|
|
2431
2453
|
changeFieldValue(name, value) {
|
|
2432
2454
|
const formControl = this.form?.get(name);
|
|
2433
2455
|
formControl?.setValue(value);
|
|
2434
2456
|
}
|
|
2435
2457
|
}
|
|
2436
|
-
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: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2458
|
+
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: NextActionService }, { token: ControlConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2437
2459
|
PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
|
|
2438
2460
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
|
|
2439
2461
|
type: Injectable,
|
|
2440
2462
|
args: [{
|
|
2441
2463
|
providedIn: 'root',
|
|
2442
2464
|
}]
|
|
2443
|
-
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: NextActionService }]; } });
|
|
2465
|
+
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: NextActionService }, { type: ControlConfigService }]; } });
|
|
2444
2466
|
|
|
2445
2467
|
class RefundPolicyService {
|
|
2446
2468
|
constructor(settingsService) {
|
|
@@ -2572,14 +2594,17 @@ class CoreLibraryService {
|
|
|
2572
2594
|
createPayment(config) {
|
|
2573
2595
|
return {
|
|
2574
2596
|
initialize: async () => this.paymentService.initialize(config),
|
|
2575
|
-
submit: async (
|
|
2597
|
+
submit: async () => this.paymentService.submit(),
|
|
2576
2598
|
getFields: () => this.paymentService.getFields(),
|
|
2577
|
-
changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
|
|
2578
2599
|
validate: async (field) => this.paymentService.validate(field),
|
|
2579
2600
|
getFinanceDetails: () => this.paymentService.getFinanceDetails(),
|
|
2580
2601
|
runThreeDs: () => this.paymentService.runThreeDs(),
|
|
2581
2602
|
getStatus: async (params) => this.paymentService.getStatus(params),
|
|
2582
2603
|
flowUpdates$: this.nextActionService.flowUpdates$,
|
|
2604
|
+
form: {
|
|
2605
|
+
getControlConfig: (field) => this.paymentService.getFieldConfig(field),
|
|
2606
|
+
changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
|
|
2607
|
+
},
|
|
2583
2608
|
};
|
|
2584
2609
|
}
|
|
2585
2610
|
getLegalComponentConfig() {
|