@xsolla/payment-client-core 0.6.0 → 0.7.0

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 (37) hide show
  1. package/esm2022/lib/core/payment/three-ds/dfp-collect/dfp-collect.service.mjs +18 -14
  2. package/esm2022/lib/core/payment/three-ds/three-ds-20/three-ds20.service.mjs +5 -2
  3. package/esm2022/lib/core/payment/three-ds/three-ds-form.interface.mjs +1 -1
  4. package/esm2022/lib/core/sdk-payment-systems/apple-pay/instant-flow-check/apple-pay-instant-flow-check.service.mjs +85 -0
  5. package/esm2022/lib/core/sdk-payment-systems/apple-pay/instant-flow-check/check-errors.enum.mjs +9 -0
  6. package/esm2022/lib/core/sdk-payment-systems/apple-pay/instant-flow-check/instant-flow-checker-response.interface.mjs +2 -0
  7. package/esm2022/lib/core/sdk-payment-systems/google-pay/instant-flow-check/check-errors.enum.mjs +6 -0
  8. package/esm2022/lib/core/sdk-payment-systems/google-pay/instant-flow-check/google-pay-instant-flow-check.service.mjs +43 -0
  9. package/esm2022/lib/core/sdk-payment-systems/instant-flow-checks/instant-flow-analytics.service.mjs +38 -0
  10. package/esm2022/lib/core/sdk-payment-systems/instant-flow-checks/instant-flow-check-name.enum.mjs +8 -0
  11. package/esm2022/lib/core/sdk-payment-systems/instant-flow-checks/instant-flow-check-result.interface.mjs +2 -0
  12. package/esm2022/lib/core/sdk-payment-systems/instant-flow-checks/instant-flow-check-state.enum.mjs +6 -0
  13. package/esm2022/lib/core/sdk-payment-systems/instant-flow-checks/instant-flow-checks.collector.mjs +26 -0
  14. package/esm2022/lib/core/sdk-payment-systems/instant-flow-checks/instant-flow-trigger.enum.mjs +6 -0
  15. package/esm2022/lib/core/user-behaviour-analytics/user-behaviour-event-name.enum.mjs +2 -1
  16. package/esm2022/lib/version.mjs +2 -2
  17. package/esm2022/public-api.mjs +12 -1
  18. package/fesm2022/xsolla-payment-client-core.mjs +224 -16
  19. package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
  20. package/lib/core/payment/three-ds/dfp-collect/dfp-collect.service.d.ts +0 -1
  21. package/lib/core/payment/three-ds/three-ds-20/three-ds20.service.d.ts +1 -0
  22. package/lib/core/payment/three-ds/three-ds-form.interface.d.ts +1 -0
  23. package/lib/core/sdk-payment-systems/apple-pay/instant-flow-check/apple-pay-instant-flow-check.service.d.ts +19 -0
  24. package/lib/core/sdk-payment-systems/apple-pay/instant-flow-check/check-errors.enum.d.ts +7 -0
  25. package/lib/core/sdk-payment-systems/apple-pay/instant-flow-check/instant-flow-checker-response.interface.d.ts +3 -0
  26. package/lib/core/sdk-payment-systems/google-pay/instant-flow-check/check-errors.enum.d.ts +4 -0
  27. package/lib/core/sdk-payment-systems/google-pay/instant-flow-check/google-pay-instant-flow-check.service.d.ts +14 -0
  28. package/lib/core/sdk-payment-systems/instant-flow-checks/instant-flow-analytics.service.d.ts +12 -0
  29. package/lib/core/sdk-payment-systems/instant-flow-checks/instant-flow-check-name.enum.d.ts +6 -0
  30. package/lib/core/sdk-payment-systems/instant-flow-checks/instant-flow-check-result.interface.d.ts +8 -0
  31. package/lib/core/sdk-payment-systems/instant-flow-checks/instant-flow-check-state.enum.d.ts +4 -0
  32. package/lib/core/sdk-payment-systems/instant-flow-checks/instant-flow-checks.collector.d.ts +10 -0
  33. package/lib/core/sdk-payment-systems/instant-flow-checks/instant-flow-trigger.enum.d.ts +4 -0
  34. package/lib/core/user-behaviour-analytics/user-behaviour-event-name.enum.d.ts +2 -1
  35. package/lib/version.d.ts +1 -1
  36. package/package.json +1 -1
  37. package/public-api.d.ts +11 -0
@@ -13,7 +13,7 @@ import { CommonModule } from '@angular/common';
13
13
  import { provideTranslateHttpLoader } from '@ngx-translate/http-loader';
14
14
 
15
15
  // eslint-disable-next-line @typescript-eslint/naming-convention
16
- const PAYMENT_CLIENT_CORE_VERSION = '0.6.0';
16
+ const PAYMENT_CLIENT_CORE_VERSION = '0.7.0';
17
17
 
18
18
  class TranslateHelper {
19
19
  static init(service) {
@@ -1605,6 +1605,7 @@ var UserBehaviourEventName;
1605
1605
  UserBehaviourEventName["googlePayHandleSuccessfulPayment"] = "google-pay-handle-successful-payment";
1606
1606
  // Instant flow
1607
1607
  UserBehaviourEventName["sysInstantFlowOpen"] = "sys-instant_flow-open";
1608
+ UserBehaviourEventName["sysInstantFlowData"] = "sys-instant_flow-data";
1608
1609
  })(UserBehaviourEventName || (UserBehaviourEventName = {}));
1609
1610
 
1610
1611
  const userBehaviourEventTypes = {
@@ -7463,30 +7464,34 @@ class DfpCollectService {
7463
7464
  this.formName = 'formDFP';
7464
7465
  }
7465
7466
  collectDfpStatus(threeDsForm) {
7466
- if (threeDsForm.waitCallback) {
7467
- this.openIframeWithPostRequest(threeDsForm, false);
7468
- }
7469
- else {
7470
- this.openIframeWithPostRequest(threeDsForm, true);
7471
- }
7472
- }
7473
- /*
7474
- * This method create invisible iframe with required params and after that it submit form in iframe
7475
- * */
7476
- openIframeWithPostRequest(threeDsForm, isNeedNotifyAfterLoad) {
7477
7467
  this.window.document.getElementById(this.iframeName)?.remove();
7478
7468
  this.window.document.getElementById(this.formName)?.remove();
7469
+ /*
7470
+ * waitCallback only suppresses the onload notification — DFP completion arrives via a
7471
+ * server-side callback instead.
7472
+ */
7473
+ const isNeedNotifyAfterLoad = !threeDsForm.waitCallback;
7474
+ /*
7475
+ * providerHostedDfp (e.g. GPayments) means the provider hosts the DFP page: load the URL
7476
+ * directly as the iframe src. Every other provider — Credorax, Assist — needs the legacy
7477
+ * EMV 3DS Method POST below, because that POST is what tells the ACS where to send its
7478
+ * DFP notification.
7479
+ */
7480
+ if (threeDsForm.providerHostedDfp) {
7481
+ this.createIframe(isNeedNotifyAfterLoad, threeDsForm.threeDSTrXid, threeDsForm.threeDSMethod);
7482
+ return;
7483
+ }
7479
7484
  this.createIframe(isNeedNotifyAfterLoad, threeDsForm.threeDSTrXid);
7480
7485
  this.postFormToIframe(threeDsForm.threeDSMethod, threeDsForm.threeDSMethodData);
7481
7486
  }
7482
7487
  /*
7483
7488
  * isNeedNotifyAfterLoad is need to send notification of dft to server
7484
7489
  * */
7485
- createIframe(isNeedNotifyAfterLoad, threeDsTrXid) {
7490
+ createIframe(isNeedNotifyAfterLoad, threeDsTrXid, src = 'about:blank') {
7486
7491
  const attributes = {
7487
7492
  name: this.iframeName,
7488
7493
  id: this.iframeName,
7489
- src: 'about:blank',
7494
+ src,
7490
7495
  style: 'display:none',
7491
7496
  };
7492
7497
  const iFrame = this.window.document.createElement('iframe');
@@ -7612,6 +7617,7 @@ class ThreeDs20Service {
7612
7617
  this.latestDfpParameters = null;
7613
7618
  this.notifyDfpTimerId = 'notify-dfp';
7614
7619
  this.notifyDfpTimeoutMs = 10000;
7620
+ this.providerHostedDfpNotifyDfpTimeoutMs = 20000;
7615
7621
  this.statusThreeDsTimerId = 'status-three-ds';
7616
7622
  this.statusThreeDsTimeoutMs = 180000;
7617
7623
  }
@@ -7622,7 +7628,9 @@ class ThreeDs20Service {
7622
7628
  this.clearLatestDfpParameters();
7623
7629
  this.reinsuranceCheckService.addTimer({
7624
7630
  id: this.notifyDfpTimerId,
7625
- timeoutMs: this.notifyDfpTimeoutMs,
7631
+ timeoutMs: threeDsForm.providerHostedDfp
7632
+ ? this.providerHostedDfpNotifyDfpTimeoutMs
7633
+ : this.notifyDfpTimeoutMs,
7626
7634
  callback: () => {
7627
7635
  const threeDsTransactionId = this.latestDfpParameters?.threeDSTrXid ?? threeDsForm.threeDSTrXid;
7628
7636
  this.notifyDfpStatusService.request(threeDsTransactionId, false);
@@ -10657,6 +10665,86 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10657
10665
  args: [windowToken]
10658
10666
  }] }, { type: LoggerService }, { type: PaymentSystemProcessingService }, { type: GooglePayCheckoutPaymentService }, { type: GooglePayInstantPaymentService }, { type: i0.Injector }] });
10659
10667
 
10668
+ var InstantFlowCheckName;
10669
+ (function (InstantFlowCheckName) {
10670
+ InstantFlowCheckName["toggle"] = "toggle";
10671
+ InstantFlowCheckName["partnerDomain"] = "partner_domain";
10672
+ InstantFlowCheckName["certificates"] = "certificates";
10673
+ InstantFlowCheckName["backendInstantData"] = "backend_instant_data";
10674
+ })(InstantFlowCheckName || (InstantFlowCheckName = {}));
10675
+
10676
+ var InstantFlowCheckState;
10677
+ (function (InstantFlowCheckState) {
10678
+ InstantFlowCheckState["passed"] = "passed";
10679
+ InstantFlowCheckState["skipped"] = "skipped";
10680
+ })(InstantFlowCheckState || (InstantFlowCheckState = {}));
10681
+
10682
+ class InstantFlowChecksCollector {
10683
+ constructor() {
10684
+ this.checks = {};
10685
+ this.hasFailedChecks = false;
10686
+ }
10687
+ add(name, error) {
10688
+ this.checks[name] = error ?? InstantFlowCheckState.passed;
10689
+ if (error) {
10690
+ this.hasFailedChecks = true;
10691
+ }
10692
+ }
10693
+ skip(name) {
10694
+ this.checks[name] = InstantFlowCheckState.skipped;
10695
+ }
10696
+ isPassing() {
10697
+ return !this.hasFailedChecks;
10698
+ }
10699
+ getResult() {
10700
+ return {
10701
+ allowed: !this.hasFailedChecks,
10702
+ checks: { ...this.checks },
10703
+ };
10704
+ }
10705
+ }
10706
+
10707
+ var GooglePayInstantFlowCheckErrors;
10708
+ (function (GooglePayInstantFlowCheckErrors) {
10709
+ GooglePayInstantFlowCheckErrors["TOGGLE_TURNED_OFF"] = "TOGGLE_TURNED_OFF";
10710
+ GooglePayInstantFlowCheckErrors["INSTANT_DATA_MISSING"] = "INSTANT_DATA_MISSING";
10711
+ })(GooglePayInstantFlowCheckErrors || (GooglePayInstantFlowCheckErrors = {}));
10712
+
10713
+ class GooglePayInstantFlowCheckService {
10714
+ constructor(settingsService, paymentService) {
10715
+ this.settingsService = settingsService;
10716
+ this.paymentService = paymentService;
10717
+ }
10718
+ getInstantFlowChecks() {
10719
+ const collector = new InstantFlowChecksCollector();
10720
+ collector.add(InstantFlowCheckName.toggle, this.checkIntegrationToggle());
10721
+ collector.add(InstantFlowCheckName.backendInstantData, this.checkBackendInstantData());
10722
+ return collector.getResult();
10723
+ }
10724
+ // an unset flag is not a refusal: it leaves the instant flow decision to the backend
10725
+ checkIntegrationToggle() {
10726
+ return this.settingsService.isGooglePayInstantFlowEnabled === false
10727
+ ? GooglePayInstantFlowCheckErrors.TOGGLE_TURNED_OFF
10728
+ : null;
10729
+ }
10730
+ checkBackendInstantData() {
10731
+ const hasInstantData = this.paymentService
10732
+ .getFields()
10733
+ .some((field) => field.name === FieldNames.googlePayInitData);
10734
+ return hasInstantData
10735
+ ? null
10736
+ : GooglePayInstantFlowCheckErrors.INSTANT_DATA_MISSING;
10737
+ }
10738
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayInstantFlowCheckService, deps: [{ token: SettingsService }, { token: PaymentService }], target: i0.ɵɵFactoryTarget.Injectable }); }
10739
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayInstantFlowCheckService, providedIn: 'root' }); }
10740
+ }
10741
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayInstantFlowCheckService, decorators: [{
10742
+ type: Injectable,
10743
+ args: [{
10744
+ providedIn: 'root',
10745
+ }]
10746
+ }], ctorParameters: () => [{ type: SettingsService }, { type: PaymentService }] });
10747
+
10660
10748
  var ApplePayIntegrationType;
10661
10749
  (function (ApplePayIntegrationType) {
10662
10750
  ApplePayIntegrationType["redirect"] = "redirect";
@@ -11235,6 +11323,126 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
11235
11323
  args: [windowToken]
11236
11324
  }] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: LoggerService }, { type: ApplePaySdkService }, { type: ApplePayExternalWindowCommunicationService }, { type: SettingsService }] });
11237
11325
 
11326
+ var InstantFlowCheckErrors;
11327
+ (function (InstantFlowCheckErrors) {
11328
+ InstantFlowCheckErrors["TOGGLE_TURNED_OFF"] = "TOGGLE_TURNED_OFF";
11329
+ InstantFlowCheckErrors["PARTNER_DOMAIN_MISSING"] = "PARTNER_DOMAIN_MISSING";
11330
+ InstantFlowCheckErrors["PARTNER_DOMAIN_WRONG_FORMAT"] = "PARTNER_DOMAIN_WRONG_FORMAT";
11331
+ InstantFlowCheckErrors["CERTIFICATES_MISSING"] = "CERTIFICATES_MISSING";
11332
+ InstantFlowCheckErrors["CERTIFICATES_CHECK_FAILED"] = "CERTIFICATES_CHECK_FAILED";
11333
+ })(InstantFlowCheckErrors || (InstantFlowCheckErrors = {}));
11334
+
11335
+ class ApplePayInstantFlowCheckService {
11336
+ constructor(secureApiClient, settingsService, loggerService) {
11337
+ this.secureApiClient = secureApiClient;
11338
+ this.settingsService = settingsService;
11339
+ this.loggerService = loggerService;
11340
+ this.checkPromise = null;
11341
+ }
11342
+ async isInstantFlowAvailable() {
11343
+ this.checkPromise ??= this.performInstantFlowChecks();
11344
+ return this.checkPromise;
11345
+ }
11346
+ async performInstantFlowChecks() {
11347
+ const partnerDomain = this.settingsService.topLevelDomain ?? '';
11348
+ const collector = new InstantFlowChecksCollector();
11349
+ collector.add(InstantFlowCheckName.toggle, this.checkIntegrationToggle());
11350
+ collector.add(InstantFlowCheckName.partnerDomain, this.checkPartnerDomain(partnerDomain));
11351
+ // will skip request, if check failed
11352
+ if (collector.isPassing()) {
11353
+ collector.add(InstantFlowCheckName.certificates, await this.checkAppleCertificates(partnerDomain));
11354
+ }
11355
+ else {
11356
+ collector.skip(InstantFlowCheckName.certificates);
11357
+ }
11358
+ const result = collector.getResult();
11359
+ if (!result.allowed) {
11360
+ this.loggerService.info(new TaggedMessage('ApplePay - instant flow is unavailable', [MessageTags.HEADLESS_UI], { partnerDomain, checks: result.checks }));
11361
+ }
11362
+ return result;
11363
+ }
11364
+ checkIntegrationToggle() {
11365
+ return this.settingsService.isApplePayInstantFlowEnabled
11366
+ ? null
11367
+ : InstantFlowCheckErrors.TOGGLE_TURNED_OFF;
11368
+ }
11369
+ checkPartnerDomain(partnerDomain) {
11370
+ if (!partnerDomain) {
11371
+ return InstantFlowCheckErrors.PARTNER_DOMAIN_MISSING;
11372
+ }
11373
+ if (partnerDomain.includes('://')) {
11374
+ return InstantFlowCheckErrors.PARTNER_DOMAIN_WRONG_FORMAT;
11375
+ }
11376
+ return null;
11377
+ }
11378
+ async checkAppleCertificates(partnerDomain) {
11379
+ const request = this.secureApiClient.post(`instant_pay_flow_checker/apple_pay?access_token=${this.settingsService.token}`, {
11380
+ certificate_domain: partnerDomain,
11381
+ }, {
11382
+ headers: new HttpHeaders().set('Content-Type', 'application/json; charset=utf-8'),
11383
+ responseType: 'json',
11384
+ });
11385
+ try {
11386
+ const response = await lastValueFrom(request);
11387
+ return response.isCertificatesExist
11388
+ ? null
11389
+ : InstantFlowCheckErrors.CERTIFICATES_MISSING;
11390
+ }
11391
+ catch (error) {
11392
+ this.loggerService.info(new TaggedMessage('ApplePay - instant flow certificates check failed', [MessageTags.HEADLESS_UI], {
11393
+ partnerDomain,
11394
+ message: error instanceof Error ? error.message : error,
11395
+ }));
11396
+ return InstantFlowCheckErrors.CERTIFICATES_CHECK_FAILED;
11397
+ }
11398
+ }
11399
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayInstantFlowCheckService, deps: [{ token: SecureApiClient }, { token: SettingsService }, { token: LoggerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
11400
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayInstantFlowCheckService, providedIn: 'root' }); }
11401
+ }
11402
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ApplePayInstantFlowCheckService, decorators: [{
11403
+ type: Injectable,
11404
+ args: [{
11405
+ providedIn: 'root',
11406
+ }]
11407
+ }], ctorParameters: () => [{ type: SecureApiClient }, { type: SettingsService }, { type: LoggerService }] });
11408
+
11409
+ const clientSideCheckNames = new Set([
11410
+ InstantFlowCheckName.partnerDomain,
11411
+ ]);
11412
+ class InstantFlowAnalyticsService {
11413
+ constructor(userBehaviourAnalyticsService) {
11414
+ this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
11415
+ }
11416
+ sendInstantFlowData(instanceId, trigger, result) {
11417
+ this.userBehaviourAnalyticsService.send(UserBehaviourEventName.sysInstantFlowData, userBehaviourEventTypes.manual, {
11418
+ value: result.allowed,
11419
+ dimension1: trigger,
11420
+ dimension2: this.isSupportedByClient(result.checks) ? '1' : '0',
11421
+ extraValue: JSON.stringify(result.checks),
11422
+ instanceId,
11423
+ });
11424
+ }
11425
+ isSupportedByClient(checks) {
11426
+ return Object.entries(checks).every(([name, state]) => !clientSideCheckNames.has(name) ||
11427
+ state === InstantFlowCheckState.passed ||
11428
+ state === InstantFlowCheckState.skipped);
11429
+ }
11430
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: InstantFlowAnalyticsService, deps: [{ token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
11431
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: InstantFlowAnalyticsService, providedIn: 'root' }); }
11432
+ }
11433
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: InstantFlowAnalyticsService, decorators: [{
11434
+ type: Injectable,
11435
+ args: [{
11436
+ providedIn: 'root',
11437
+ }]
11438
+ }], ctorParameters: () => [{ type: UserBehaviourAnalyticsService }] });
11439
+
11440
+ var InstantFlowTrigger;
11441
+ (function (InstantFlowTrigger) {
11442
+ InstantFlowTrigger["paymentForm"] = "0";
11443
+ InstantFlowTrigger["topButton"] = "1";
11444
+ })(InstantFlowTrigger || (InstantFlowTrigger = {}));
11445
+
11238
11446
  /*
11239
11447
  * Public API Surface of core-library
11240
11448
  */
@@ -11243,5 +11451,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
11243
11451
  * Generated bundle index. Do not edit.
11244
11452
  */
11245
11453
 
11246
- export { ApplePayCartService, ApplePayService, CoreLibraryModule, CoreLibraryService, CreditCardTypes, ErrorTags, FieldNames, GooglePayService, LoggerService, MessageTags, PAYMENT_CLIENT_CORE_VERSION, PaymentSystemProcessingService, TaggedError, TaggedMessage, americanExpressMethodId, cardsWith3ds, creditCardPaymentMethodId, isCreditCardSettingsGuard, maestroPaymentMethodId, masterCardAndVisaPaymentMethodId, specialCards, userBehaviourEventTypes };
11454
+ export { ApplePayCartService, ApplePayInstantFlowCheckService, ApplePayService, CoreLibraryModule, CoreLibraryService, CreditCardTypes, ErrorTags, FieldNames, GooglePayInstantFlowCheckErrors, GooglePayInstantFlowCheckService, GooglePayService, InstantFlowAnalyticsService, InstantFlowCheckErrors, InstantFlowCheckName, InstantFlowCheckState, InstantFlowChecksCollector, InstantFlowTrigger, LoggerService, MessageTags, PAYMENT_CLIENT_CORE_VERSION, PaymentSystemProcessingService, TaggedError, TaggedMessage, americanExpressMethodId, applePayId, barzahlenPay, cardsWith3ds, creditCardPaymentMethodId, googlePay, isCreditCardSettingsGuard, maestroPaymentMethodId, masterCardAndVisaPaymentMethodId, naverPay, specialCards, userBehaviourEventTypes, venmoPay, vkPay };
11247
11455
  //# sourceMappingURL=xsolla-payment-client-core.mjs.map