@xsolla/payment-client-core 0.1.19 → 0.1.20

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.
@@ -595,25 +595,6 @@ class SubmitResponse {
595
595
  }
596
596
  }
597
597
 
598
- const isSubmitResponse = (value) => {
599
- return value instanceof SubmitResponse;
600
- };
601
-
602
- var InputEventName;
603
- (function (InputEventName) {
604
- InputEventName["blur"] = "blur";
605
- InputEventName["focus"] = "focus";
606
- })(InputEventName || (InputEventName = {}));
607
-
608
- class ShowErrorsAction {
609
- constructor(errors) {
610
- this.type = 'show_errors';
611
- this.data = {
612
- errors,
613
- };
614
- }
615
- }
616
-
617
598
  class InitializeResponse {
618
599
  constructor(response) {
619
600
  this.paymentForm = null;
@@ -657,6 +638,25 @@ class InitializeResponse {
657
638
  }
658
639
  }
659
640
 
641
+ const isSubmitResponse = (value) => {
642
+ return value instanceof SubmitResponse;
643
+ };
644
+
645
+ var InputEventName;
646
+ (function (InputEventName) {
647
+ InputEventName["blur"] = "blur";
648
+ InputEventName["focus"] = "focus";
649
+ })(InputEventName || (InputEventName = {}));
650
+
651
+ class ShowErrorsAction {
652
+ constructor(errors) {
653
+ this.type = 'show_errors';
654
+ this.data = {
655
+ errors,
656
+ };
657
+ }
658
+ }
659
+
660
660
  const initializeResponseFactoryToken = new InjectionToken('InitializeResponse');
661
661
  const initializeResponseFactoryProvider = {
662
662
  provide: initializeResponseFactoryToken,
@@ -5306,6 +5306,7 @@ class PaymentService {
5306
5306
  this.data = await this.initializeService.request(config);
5307
5307
  this.fields = this.getFields();
5308
5308
  this.form = this.formService.createForm(this.fields);
5309
+ this.updatePidConfig();
5309
5310
  this.setupSyncService(this.form, this.fields);
5310
5311
  this.listenFormStatusChanges(this.form);
5311
5312
  this.emitFinanceDetails(this.data.paymentForm?.summary);
@@ -5345,6 +5346,15 @@ class PaymentService {
5345
5346
  }
5346
5347
  return this.data?.paymentForm?.fields ?? [];
5347
5348
  }
5349
+ getPid() {
5350
+ if (this.data instanceof SubmitResponse) {
5351
+ return (Number(this.data.fields.find((field) => field.name === 'fix_pid')?.value) || null);
5352
+ }
5353
+ if (this.data instanceof InitializeResponse) {
5354
+ return (Number(this.data.paymentForm?.fields.find((field) => field.name === 'fix_pid')?.value) || null);
5355
+ }
5356
+ return null;
5357
+ }
5348
5358
  async validate(field) {
5349
5359
  const syncErrors = this.syncService.getSyncValidationErrors(field);
5350
5360
  if (syncErrors) {
@@ -5467,6 +5477,15 @@ class PaymentService {
5467
5477
  .pipe(takeUntil(this.formDestroy$))
5468
5478
  .subscribe(() => this.emitFormFieldsStatus(form));
5469
5479
  }
5480
+ /*
5481
+ * in case the form pid changes despite the one passed during initialization
5482
+ * */
5483
+ updatePidConfig() {
5484
+ const currentPid = this.getPid();
5485
+ if (currentPid) {
5486
+ this.config.paymentMethodId = currentPid;
5487
+ }
5488
+ }
5470
5489
  }
5471
5490
  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 }], target: i0.ɵɵFactoryTarget.Injectable });
5472
5491
  PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
@@ -5660,6 +5679,7 @@ class CoreLibraryService {
5660
5679
  initialize: async () => this.paymentService.initialize(enrichedConfig),
5661
5680
  submit: async () => this.paymentService.submit(),
5662
5681
  getFields: () => this.paymentService.getFields(),
5682
+ getPid: () => this.paymentService.getPid(),
5663
5683
  validate: async (field) => this.paymentService.validate(field),
5664
5684
  getFinanceDetails: () => this.paymentService.getFinanceDetails(),
5665
5685
  runThreeDs: () => this.paymentService.runThreeDs(),