@xsolla/payment-client-core 0.2.9 → 0.2.11

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.
Files changed (33) hide show
  1. package/esm2020/lib/core/payment/actions/next-action.interface.mjs +1 -1
  2. package/esm2020/lib/core/payment/actions/next-actions.mjs +3 -1
  3. package/esm2020/lib/core/payment/actions/show-mobile-payment-screen/show-mobile-payment-screen.action.class.mjs +26 -0
  4. package/esm2020/lib/core/payment/actions/show-mobile-payment-screen/show-mobile-payment-screen.action.type.mjs +2 -0
  5. package/esm2020/lib/core/payment/actions/show-qr-code/show-qr-code.action.class.mjs +6 -3
  6. package/esm2020/lib/core/payment/actions/show-qr-code/show-qr-code.action.type.mjs +1 -1
  7. package/esm2020/lib/core/payment/form-response.interface.mjs +1 -1
  8. package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
  9. package/esm2020/lib/core/payment/payment.service.mjs +24 -7
  10. package/esm2020/lib/core/payment/status/status.service.mjs +4 -1
  11. package/esm2020/lib/core/sdk-payment-systems/apple-pay/apple-pay.const.mjs +2 -1
  12. package/esm2020/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.mjs +13 -6
  13. package/esm2020/lib/core/user-agent/user-agent.service.mjs +12 -1
  14. package/esm2020/lib/core-library.service.mjs +2 -1
  15. package/fesm2015/xsolla-payment-client-core.mjs +78 -11
  16. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  17. package/fesm2020/xsolla-payment-client-core.mjs +76 -11
  18. package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
  19. package/lib/core/payment/actions/next-action.interface.d.ts +2 -1
  20. package/lib/core/payment/actions/show-mobile-payment-screen/show-mobile-payment-screen.action.class.d.ts +11 -0
  21. package/lib/core/payment/actions/show-mobile-payment-screen/show-mobile-payment-screen.action.type.d.ts +6 -0
  22. package/lib/core/payment/actions/show-qr-code/show-qr-code.action.class.d.ts +1 -1
  23. package/lib/core/payment/actions/show-qr-code/show-qr-code.action.type.d.ts +4 -1
  24. package/lib/core/payment/form-response.interface.d.ts +1 -0
  25. package/lib/core/payment/payment.interface.d.ts +1 -0
  26. package/lib/core/payment/payment.service.d.ts +4 -1
  27. package/lib/core/payment/status/status.service.d.ts +3 -0
  28. package/lib/core/sdk-payment-systems/apple-pay/apple-pay.const.d.ts +1 -0
  29. package/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.d.ts +2 -1
  30. package/lib/core/user-agent/user-agent.service.d.ts +1 -0
  31. package/package.json +1 -1
  32. package/xsolla-payment-client-core-0.2.11.tgz +0 -0
  33. package/xsolla-payment-client-core-0.2.9.tgz +0 -0
@@ -1108,10 +1108,13 @@ class ShowQrCodeActionCreator {
1108
1108
  constructor() {
1109
1109
  this.type = 'show_qr_code';
1110
1110
  }
1111
- getActionData() {
1111
+ getActionData(response) {
1112
+ const submitButtonText = response.parameters.buyData.value;
1112
1113
  return {
1113
1114
  type: this.type,
1114
- data: null,
1115
+ data: {
1116
+ submitButtonText,
1117
+ },
1115
1118
  };
1116
1119
  }
1117
1120
  isSuitable(response) {
@@ -1124,6 +1127,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
1124
1127
  type: Injectable
1125
1128
  }] });
1126
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
+
1127
1153
  const nextActionsToken = new InjectionToken('Action');
1128
1154
  const nextActions = [
1129
1155
  ShowFieldsActionCreator,
@@ -1131,6 +1157,7 @@ const nextActions = [
1131
1157
  SpecialButtonActionCreator,
1132
1158
  ShowQrCodeActionCreator,
1133
1159
  RedirectActionCreator,
1160
+ ShowMobilePaymentScreenActionCreator,
1134
1161
  ];
1135
1162
  const flowUpdateNextActions = [
1136
1163
  ShowErrorsActionCreator,
@@ -4920,6 +4947,9 @@ class StatusService {
4920
4947
  }
4921
4948
  return this.getStatus(searchParams);
4922
4949
  }
4950
+ listenFinalStatus(invoice) {
4951
+ return this.listenStatusService.listen(invoice);
4952
+ }
4923
4953
  getRequestParamsFromUrl(url) {
4924
4954
  const searchParams = this.urlService.getSearchParams(url ?? '');
4925
4955
  const keys = new Set(Object.keys(searchParams));
@@ -5412,7 +5442,7 @@ class PaymentService {
5412
5442
  get formResponseValue() {
5413
5443
  return this._formResponse$.getValue();
5414
5444
  }
5415
- 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) {
5416
5446
  this.initializeService = initializeService;
5417
5447
  this.submitService = submitService;
5418
5448
  this.syncService = syncService;
@@ -5426,6 +5456,7 @@ class PaymentService {
5426
5456
  this.formMessagesService = formMessagesService;
5427
5457
  this.settingsService = settingsService;
5428
5458
  this.countryService = countryService;
5459
+ this.checkStatusActionCreator = checkStatusActionCreator;
5429
5460
  this.form = null;
5430
5461
  this.data = null;
5431
5462
  this.financeDetails = null;
@@ -5473,7 +5504,8 @@ class PaymentService {
5473
5504
  }
5474
5505
  this.emitFormMessages(submitResponse.messages);
5475
5506
  // Handle 3ds flow
5476
- if (submitResponse.currentCommand === XpsCommand.create) {
5507
+ if (submitResponse.currentCommand === XpsCommand.create &&
5508
+ submitResponse.parameters.threeDSForm) {
5477
5509
  this.runThreeDs();
5478
5510
  return;
5479
5511
  }
@@ -5552,6 +5584,15 @@ class PaymentService {
5552
5584
  };
5553
5585
  return this.statusService.getStatus(params);
5554
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
+ }
5555
5596
  getFieldConfig(field) {
5556
5597
  return this.controlConfigService.getConfig(field);
5557
5598
  }
@@ -5685,17 +5726,22 @@ class PaymentService {
5685
5726
  else {
5686
5727
  type = 'sync';
5687
5728
  }
5688
- this._formResponse$.next({ type, data, token: this.settingsService.token });
5729
+ this._formResponse$.next({
5730
+ type,
5731
+ data,
5732
+ token: this.settingsService.token,
5733
+ isSandbox: this.settingsService.isSandboxMode(),
5734
+ });
5689
5735
  }
5690
5736
  }
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 });
5737
+ 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 });
5692
5738
  PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
5693
5739
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
5694
5740
  type: Injectable,
5695
5741
  args: [{
5696
5742
  providedIn: 'root',
5697
5743
  }]
5698
- }], 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 }]; } });
5744
+ }], 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 }]; } });
5699
5745
 
5700
5746
  class RefundPolicyService {
5701
5747
  constructor(settingsService) {
@@ -6157,6 +6203,7 @@ class CoreLibraryService {
6157
6203
  getFinanceDetails: () => this.paymentService.getFinanceDetails(),
6158
6204
  runThreeDs: () => this.paymentService.runThreeDs(),
6159
6205
  getStatus: async () => this.paymentService.getStatus(),
6206
+ listenFinalStatus: async () => this.paymentService.listenFinalStatus(),
6160
6207
  financeDetailsUpdates$: this.financeDetailsService.data$,
6161
6208
  form: {
6162
6209
  fieldsStatus$: this.paymentService.formFieldsStatus$,
@@ -6437,6 +6484,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
6437
6484
  }] });
6438
6485
 
6439
6486
  const applePayVersion = 3;
6487
+ const safariVersionForIframeIntegration = 17;
6440
6488
 
6441
6489
  const agreementsGroup = [
6442
6490
  FieldNames.termsAndConditions,
@@ -6798,6 +6846,17 @@ class UserAgentService {
6798
6846
  get isSafari() {
6799
6847
  return this._browserName === 'Apple Safari';
6800
6848
  }
6849
+ get safariVersion() {
6850
+ if (!this.isSafari) {
6851
+ return null;
6852
+ }
6853
+ const versionRegExp = new RegExp('(Version)\\/(.+)\\s');
6854
+ const version = versionRegExp.exec(this.userAgent);
6855
+ if (!version) {
6856
+ return null;
6857
+ }
6858
+ return Number(version[2].split('.')[0]);
6859
+ }
6801
6860
  get iOsVersion() {
6802
6861
  if (this.osType !== 'ios') {
6803
6862
  return null;
@@ -7031,7 +7090,7 @@ class ApplePayService {
7031
7090
  this.emitError(ApplePayErrors.deviceIsNotCapableError);
7032
7091
  }
7033
7092
  }
7034
- redirectToPaymentPage(parameters, token) {
7093
+ redirectToPaymentPage(parameters, token, isSandbox) {
7035
7094
  const route = pagesRoutes.get(applePayId);
7036
7095
  if (!route) {
7037
7096
  return;
@@ -7046,8 +7105,8 @@ class ApplePayService {
7046
7105
  if (this.order) {
7047
7106
  query.append('order', this.order);
7048
7107
  }
7049
- const url = `${route}?${query.toString()}`;
7050
- return url;
7108
+ const payStationUrl = isSandbox ? sandboxPayStationUrl : payStation4Url;
7109
+ return `${payStationUrl}/en${route}?${query.toString()}`;
7051
7110
  }
7052
7111
  setOrder(data) {
7053
7112
  const summary = data?.paymentForm?.summary;
@@ -7098,6 +7157,7 @@ class ApplePayService {
7098
7157
  })
7099
7158
  .catch((error) => {
7100
7159
  console.error('apple pay: merchant validation error', error);
7160
+ this.emitError(ApplePayErrors.paymentError);
7101
7161
  session.abort();
7102
7162
  });
7103
7163
  };
@@ -7113,6 +7173,7 @@ class ApplePayService {
7113
7173
  })
7114
7174
  .catch((error) => {
7115
7175
  console.error('apple pay: payment authorization error', error);
7176
+ this.emitError(ApplePayErrors.paymentError);
7116
7177
  session.completePayment(this.window.ApplePaySession.STATUS_FAILURE);
7117
7178
  });
7118
7179
  };
@@ -7185,7 +7246,7 @@ class ApplePayService {
7185
7246
  }
7186
7247
  emitIntegrationType() {
7187
7248
  let integrationType;
7188
- if (this.paymentClient && this.isDeviceCapable()) {
7249
+ if (this.paymentClient && this.isDeviceCapable() && this.canUseSdk()) {
7189
7250
  integrationType = 'sdk';
7190
7251
  }
7191
7252
  else if (this.userAgentService.isSafari) {
@@ -7196,6 +7257,10 @@ class ApplePayService {
7196
7257
  }
7197
7258
  this.integrationType.next(integrationType);
7198
7259
  }
7260
+ canUseSdk() {
7261
+ return !!(this.userAgentService.safariVersion &&
7262
+ this.userAgentService.safariVersion >= safariVersionForIframeIntegration);
7263
+ }
7199
7264
  }
7200
7265
  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
7266
  ApplePayService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ApplePayService, providedIn: 'root' });