@xsolla/payment-client-core 0.1.3 → 0.1.5-1

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 (228) hide show
  1. package/esm2020/lib/core/credit-card/credit-card-settings.interface.mjs +2 -0
  2. package/esm2020/lib/core/credit-card/credit-card-types.enum.mjs +20 -0
  3. package/esm2020/lib/core/credit-card/credit-card.interface.mjs +2 -0
  4. package/esm2020/lib/core/credit-card/credit-card.service.mjs +41 -0
  5. package/esm2020/lib/core/credit-card/credit-cards-map.const.mjs +36 -0
  6. package/esm2020/lib/core/credit-card/default-mask.const.mjs +2 -0
  7. package/esm2020/lib/core/credit-card/four-block-mask.const.mjs +2 -0
  8. package/esm2020/lib/core/credit-card/ordered-cards-settings.const.mjs +45 -0
  9. package/esm2020/lib/core/credit-card/types/american-express.mjs +13 -0
  10. package/esm2020/lib/core/credit-card/types/aura.mjs +15 -0
  11. package/esm2020/lib/core/credit-card/types/china-union-pay.mjs +12 -0
  12. package/esm2020/lib/core/credit-card/types/dankort.mjs +15 -0
  13. package/esm2020/lib/core/credit-card/types/default-card.mjs +13 -0
  14. package/esm2020/lib/core/credit-card/types/diners-clubs.mjs +13 -0
  15. package/esm2020/lib/core/credit-card/types/discover.mjs +13 -0
  16. package/esm2020/lib/core/credit-card/types/elo.mjs +13 -0
  17. package/esm2020/lib/core/credit-card/types/hipercard.mjs +13 -0
  18. package/esm2020/lib/core/credit-card/types/jcb.mjs +13 -0
  19. package/esm2020/lib/core/credit-card/types/maestro.mjs +14 -0
  20. package/esm2020/lib/core/credit-card/types/mastercard.mjs +16 -0
  21. package/esm2020/lib/core/credit-card/types/mir.mjs +15 -0
  22. package/esm2020/lib/core/credit-card/types/naranja.mjs +15 -0
  23. package/esm2020/lib/core/credit-card/types/postepay.mjs +13 -0
  24. package/esm2020/lib/core/credit-card/types/visa.mjs +13 -0
  25. package/esm2020/lib/core/device-finger-print/device-finger-print.service.mjs +26 -126
  26. package/esm2020/lib/core/device-finger-print/hash.type.mjs +1 -1
  27. package/esm2020/lib/core/encrypt-credit-card/encrypt-credit-card.service.mjs +72 -0
  28. package/esm2020/lib/core/encrypt-credit-card/encrypted-card.interface.mjs +2 -0
  29. package/esm2020/lib/core/encrypt-credit-card/open-card.interface.mjs +2 -0
  30. package/esm2020/lib/core/exceptions-handling/errors/encrypt-card-error.mjs +9 -0
  31. package/esm2020/lib/core/payment/actions/check-status/check-status.action.class.mjs +2 -3
  32. package/esm2020/lib/core/payment/actions/next-action.interface.mjs +1 -1
  33. package/esm2020/lib/core/payment/actions/next-actions.mjs +3 -1
  34. package/esm2020/lib/core/payment/actions/three-ds/three-ds.action.class.mjs +7 -0
  35. package/esm2020/lib/core/payment/actions/three-ds/three-ds.action.token.mjs +11 -0
  36. package/esm2020/lib/core/payment/actions/three-ds/three-ds.action.type.mjs +2 -0
  37. package/esm2020/lib/core/payment/credit-card-payment-methods-id.variable.mjs +15 -0
  38. package/esm2020/lib/core/payment/credit-card-state/credit-card-state.interface.mjs +2 -0
  39. package/esm2020/lib/core/payment/credit-card-state/credit-card-state.service.mjs +14 -0
  40. package/esm2020/lib/core/payment/form/controls/card-number-control.config.mjs +10 -0
  41. package/esm2020/lib/core/payment/form/controls/phone-control.config.mjs +8 -0
  42. package/esm2020/lib/core/payment/form/converters/birth-date.converter.mjs +38 -0
  43. package/esm2020/lib/core/payment/form/converters/card-expiration.converter.mjs +36 -0
  44. package/esm2020/lib/core/payment/form/converters/card-number.converter.mjs +45 -0
  45. package/esm2020/lib/core/payment/form/converters/cardholder-name.converter.mjs +25 -0
  46. package/esm2020/lib/core/payment/form/converters/converters-map.mjs +23 -1
  47. package/esm2020/lib/core/payment/form/converters/cpf-name-regex.variable.mjs +2 -0
  48. package/esm2020/lib/core/payment/form/converters/cpf-name.converter.mjs +34 -0
  49. package/esm2020/lib/core/payment/form/converters/cpf-number.converter.mjs +31 -0
  50. package/esm2020/lib/core/payment/form/converters/cvv.converter.mjs +50 -0
  51. package/esm2020/lib/core/payment/form/converters/phone.converter.mjs +37 -0
  52. package/esm2020/lib/core/payment/form/converters/street-number/street-number-from-state.interface.mjs +2 -0
  53. package/esm2020/lib/core/payment/form/converters/street-number/street-number.converter.mjs +28 -0
  54. package/esm2020/lib/core/payment/form/converters/text.converter.mjs +19 -0
  55. package/esm2020/lib/core/payment/form/form.module.mjs +32 -4
  56. package/esm2020/lib/core/payment/form/validators/birth-date.validator.mjs +37 -0
  57. package/esm2020/lib/core/payment/form/validators/credit-card-min-length.validator.mjs +32 -0
  58. package/esm2020/lib/core/payment/form/validators/is-empty-input-value.function.mjs +4 -0
  59. package/esm2020/lib/core/payment/form/validators/luhn-formula-validator/luhn-formula.validator.mjs +40 -0
  60. package/esm2020/lib/core/payment/form/validators/max-length-validator.mjs +6 -0
  61. package/esm2020/lib/core/payment/form/validators/min-length-validator.mjs +6 -0
  62. package/esm2020/lib/core/payment/form/validators/phone-validator.mjs +6 -0
  63. package/esm2020/lib/core/payment/form/validators/validators.module.mjs +18 -0
  64. package/esm2020/lib/core/payment/initialize/initialize-request-params.interface.mjs +1 -1
  65. package/esm2020/lib/core/payment/initialize/initialize.service.mjs +28 -19
  66. package/esm2020/lib/core/payment/initialize/response/initialize-response.class.mjs +43 -0
  67. package/esm2020/lib/core/payment/initialize/response/initialize-response.token.mjs +8 -0
  68. package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
  69. package/esm2020/lib/core/payment/payment.service.mjs +38 -8
  70. package/esm2020/lib/core/payment/status/check-status/check-status.service.mjs +8 -13
  71. package/esm2020/lib/core/payment/status/check-status/response/check-status-response.class.mjs +1 -1
  72. package/esm2020/lib/core/payment/submit/submit.service.mjs +13 -16
  73. package/esm2020/lib/core/payment/sync/field-async-validation.interface.mjs +2 -0
  74. package/esm2020/lib/core/payment/sync/field-sync-state.interface.mjs +1 -1
  75. package/esm2020/lib/core/payment/sync/request/sync-request.class.mjs +31 -0
  76. package/esm2020/lib/core/payment/sync/request/sync-request.token.mjs +8 -0
  77. package/esm2020/lib/core/payment/sync/response/sync-response.class.mjs +17 -0
  78. package/esm2020/lib/core/payment/sync/response/sync-response.token.mjs +8 -0
  79. package/esm2020/lib/core/payment/sync/sync.service.mjs +24 -15
  80. package/esm2020/lib/core/payment/three-ds/api/notify-dfp-status/notify-dfp-status.service.mjs +49 -0
  81. package/esm2020/lib/core/payment/three-ds/api/notify-dfp-status/request/notify-dfp-status-request.class.mjs +8 -0
  82. package/esm2020/lib/core/payment/three-ds/api/notify-dfp-status/request/notify-dfp-status-request.token.mjs +8 -0
  83. package/esm2020/lib/core/payment/three-ds/api/status-three-ds/request/status-three-ds-request.class.mjs +7 -0
  84. package/esm2020/lib/core/payment/three-ds/api/status-three-ds/request/status-three-ds-request.token.mjs +8 -0
  85. package/esm2020/lib/core/payment/three-ds/api/status-three-ds/response/status-three-ds-response.class.mjs +7 -0
  86. package/esm2020/lib/core/payment/three-ds/api/status-three-ds/response/status-three-ds-response.token.mjs +8 -0
  87. package/esm2020/lib/core/payment/three-ds/api/status-three-ds/status-three-ds-response.interface.mjs +2 -0
  88. package/esm2020/lib/core/payment/three-ds/api/status-three-ds/status-three-ds.service.mjs +60 -0
  89. package/esm2020/lib/core/payment/three-ds/api/status-three-ds/status-types.enum.mjs +7 -0
  90. package/esm2020/lib/core/payment/three-ds/api/status-three-ds/three-ds-checkout-form.interface.mjs +2 -0
  91. package/esm2020/lib/core/payment/three-ds/dfp-collect/dfp-collect.service.mjs +105 -0
  92. package/esm2020/lib/core/payment/three-ds/reinsurance-check/reinsurance-check.service.mjs +41 -0
  93. package/esm2020/lib/core/payment/three-ds/reinsurance-check/timer.interface.mjs +2 -0
  94. package/esm2020/lib/core/payment/three-ds/three-ds-20/status-update.interface.mjs +2 -0
  95. package/esm2020/lib/core/payment/three-ds/three-ds-20/three-ds20.service.mjs +109 -0
  96. package/esm2020/lib/core/payment/three-ds/three-ds-form.interface.mjs +2 -0
  97. package/esm2020/lib/core/payment/three-ds/three-ds-status-websocket-types.enum.mjs +5 -0
  98. package/esm2020/lib/core/payment/three-ds/three-ds.service.mjs +40 -0
  99. package/esm2020/lib/core/payment/xps-api/xps-api.service.mjs +79 -0
  100. package/esm2020/lib/core/payment/xps-request-params.interface.mjs +2 -0
  101. package/esm2020/lib/core/payment/xps-request.interface.mjs +2 -0
  102. package/esm2020/lib/core/payment/xps-response.error.mjs +7 -0
  103. package/esm2020/lib/core/payment/xps-response.interface.mjs +1 -1
  104. package/esm2020/lib/core/type-guards/is-string.function.mjs +4 -0
  105. package/esm2020/lib/core-library.module.mjs +13 -4
  106. package/esm2020/lib/core-library.service.mjs +19 -5
  107. package/fesm2015/xsolla-payment-client-core.mjs +1585 -261
  108. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  109. package/fesm2020/xsolla-payment-client-core.mjs +1574 -258
  110. package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
  111. package/lib/core/credit-card/credit-card-settings.interface.d.ts +10 -0
  112. package/lib/core/credit-card/credit-card-types.enum.d.ts +18 -0
  113. package/lib/core/credit-card/credit-card.interface.d.ts +9 -0
  114. package/lib/core/credit-card/credit-card.service.d.ts +11 -0
  115. package/lib/core/credit-card/credit-cards-map.const.d.ts +5 -0
  116. package/lib/core/credit-card/default-mask.const.d.ts +1 -0
  117. package/lib/core/credit-card/four-block-mask.const.d.ts +1 -0
  118. package/lib/core/credit-card/ordered-cards-settings.const.d.ts +12 -0
  119. package/lib/core/credit-card/types/american-express.d.ts +2 -0
  120. package/lib/core/credit-card/types/aura.d.ts +2 -0
  121. package/lib/core/credit-card/types/china-union-pay.d.ts +2 -0
  122. package/lib/core/credit-card/types/dankort.d.ts +2 -0
  123. package/lib/core/credit-card/types/default-card.d.ts +2 -0
  124. package/lib/core/credit-card/types/diners-clubs.d.ts +2 -0
  125. package/lib/core/credit-card/types/discover.d.ts +2 -0
  126. package/lib/core/credit-card/types/elo.d.ts +2 -0
  127. package/lib/core/credit-card/types/hipercard.d.ts +2 -0
  128. package/lib/core/credit-card/types/jcb.d.ts +2 -0
  129. package/lib/core/credit-card/types/maestro.d.ts +2 -0
  130. package/lib/core/credit-card/types/mastercard.d.ts +2 -0
  131. package/lib/core/credit-card/types/mir.d.ts +2 -0
  132. package/lib/core/credit-card/types/naranja.d.ts +2 -0
  133. package/lib/core/credit-card/types/postepay.d.ts +2 -0
  134. package/lib/core/credit-card/types/visa.d.ts +2 -0
  135. package/lib/core/device-finger-print/device-finger-print.service.d.ts +3 -31
  136. package/lib/core/device-finger-print/hash.type.d.ts +1 -1
  137. package/lib/core/encrypt-credit-card/encrypt-credit-card.service.d.ts +16 -0
  138. package/lib/core/encrypt-credit-card/encrypted-card.interface.d.ts +6 -0
  139. package/lib/core/encrypt-credit-card/open-card.interface.d.ts +6 -0
  140. package/lib/core/exceptions-handling/errors/encrypt-card-error.d.ts +5 -0
  141. package/lib/core/payment/actions/next-action.interface.d.ts +2 -1
  142. package/lib/core/payment/actions/three-ds/three-ds.action.class.d.ts +8 -0
  143. package/lib/core/payment/actions/three-ds/three-ds.action.token.d.ts +4 -0
  144. package/lib/core/payment/actions/three-ds/three-ds.action.type.d.ts +5 -0
  145. package/lib/core/payment/credit-card-payment-methods-id.variable.d.ts +6 -0
  146. package/lib/core/payment/credit-card-state/credit-card-state.interface.d.ts +3 -0
  147. package/lib/core/payment/credit-card-state/credit-card-state.service.d.ts +7 -0
  148. package/lib/core/payment/form/controls/card-number-control.config.d.ts +11 -0
  149. package/lib/core/payment/form/controls/phone-control.config.d.ts +6 -0
  150. package/lib/core/payment/form/converters/birth-date.converter.d.ts +13 -0
  151. package/lib/core/payment/form/converters/card-expiration.converter.d.ts +16 -0
  152. package/lib/core/payment/form/converters/card-number.converter.d.ts +19 -0
  153. package/lib/core/payment/form/converters/cardholder-name.converter.d.ts +13 -0
  154. package/lib/core/payment/form/converters/cpf-name-regex.variable.d.ts +1 -0
  155. package/lib/core/payment/form/converters/cpf-name.converter.d.ts +13 -0
  156. package/lib/core/payment/form/converters/cpf-number.converter.d.ts +11 -0
  157. package/lib/core/payment/form/converters/cvv.converter.d.ts +18 -0
  158. package/lib/core/payment/form/converters/phone.converter.d.ts +13 -0
  159. package/lib/core/payment/form/converters/street-number/street-number-from-state.interface.d.ts +3 -0
  160. package/lib/core/payment/form/converters/street-number/street-number.converter.d.ts +14 -0
  161. package/lib/core/payment/form/converters/text.converter.d.ts +11 -0
  162. package/lib/core/payment/form/form.module.d.ts +2 -1
  163. package/lib/core/payment/form/validators/birth-date.validator.d.ts +2 -0
  164. package/lib/core/payment/form/validators/credit-card-min-length.validator.d.ts +12 -0
  165. package/lib/core/payment/form/validators/is-empty-input-value.function.d.ts +1 -0
  166. package/lib/core/payment/form/validators/luhn-formula-validator/luhn-formula.validator.d.ts +6 -0
  167. package/lib/core/payment/form/validators/max-length-validator.d.ts +2 -0
  168. package/lib/core/payment/form/validators/min-length-validator.d.ts +2 -0
  169. package/lib/core/payment/form/validators/phone-validator.d.ts +2 -0
  170. package/lib/core/payment/form/validators/validators.module.d.ts +7 -0
  171. package/lib/core/payment/initialize/initialize-request-params.interface.d.ts +1 -0
  172. package/lib/core/payment/initialize/initialize.service.d.ts +8 -6
  173. package/lib/core/payment/initialize/{initialize-response.class.d.ts → response/initialize-response.class.d.ts} +2 -2
  174. package/lib/core/payment/payment.interface.d.ts +2 -2
  175. package/lib/core/payment/payment.service.d.ts +7 -2
  176. package/lib/core/payment/status/check-status/check-status.service.d.ts +3 -4
  177. package/lib/core/payment/submit/submit.service.d.ts +5 -4
  178. package/lib/core/payment/sync/field-async-validation.interface.d.ts +7 -0
  179. package/lib/core/payment/sync/field-sync-state.interface.d.ts +1 -1
  180. package/lib/core/payment/sync/{sync-request.class.d.ts → request/sync-request.class.d.ts} +3 -3
  181. package/lib/core/payment/sync/{sync-response.class.d.ts → response/sync-response.class.d.ts} +2 -2
  182. package/lib/core/payment/sync/sync.service.d.ts +12 -7
  183. package/lib/core/payment/three-ds/api/notify-dfp-status/notify-dfp-status.service.d.ts +14 -0
  184. package/lib/core/payment/three-ds/api/notify-dfp-status/request/notify-dfp-status-request.class.d.ts +10 -0
  185. package/lib/core/payment/three-ds/api/notify-dfp-status/request/notify-dfp-status-request.token.d.ts +6 -0
  186. package/lib/core/payment/three-ds/api/status-three-ds/request/status-three-ds-request.class.d.ts +5 -0
  187. package/lib/core/payment/three-ds/api/status-three-ds/request/status-three-ds-request.token.d.ts +6 -0
  188. package/lib/core/payment/three-ds/api/status-three-ds/response/status-three-ds-response.class.d.ts +7 -0
  189. package/lib/core/payment/three-ds/api/status-three-ds/response/status-three-ds-response.token.d.ts +6 -0
  190. package/lib/core/payment/three-ds/api/status-three-ds/status-three-ds-response.interface.d.ts +7 -0
  191. package/lib/core/payment/three-ds/api/status-three-ds/status-three-ds.service.d.ts +21 -0
  192. package/lib/core/payment/three-ds/api/status-three-ds/status-types.enum.d.ts +5 -0
  193. package/lib/core/payment/three-ds/api/status-three-ds/three-ds-checkout-form.interface.d.ts +7 -0
  194. package/lib/core/payment/three-ds/dfp-collect/dfp-collect.service.d.ts +20 -0
  195. package/lib/core/payment/three-ds/reinsurance-check/reinsurance-check.service.d.ts +12 -0
  196. package/lib/core/payment/three-ds/reinsurance-check/timer.interface.d.ts +9 -0
  197. package/lib/core/payment/three-ds/three-ds-20/status-update.interface.d.ts +12 -0
  198. package/lib/core/payment/three-ds/three-ds-20/three-ds20.service.d.ts +32 -0
  199. package/lib/core/payment/three-ds/three-ds-form.interface.d.ts +11 -0
  200. package/lib/core/payment/three-ds/three-ds-status-websocket-types.enum.d.ts +3 -0
  201. package/lib/core/payment/three-ds/three-ds.service.d.ts +14 -0
  202. package/lib/core/payment/xps-api/xps-api.service.d.ts +20 -0
  203. package/lib/core/payment/xps-request-params.interface.d.ts +3 -0
  204. package/lib/core/payment/xps-request.interface.d.ts +10 -0
  205. package/lib/core/payment/xps-response.error.d.ts +4 -0
  206. package/lib/core/payment/xps-response.interface.d.ts +3 -10
  207. package/lib/core/type-guards/is-string.function.d.ts +1 -0
  208. package/lib/core-library.service.d.ts +10 -1
  209. package/package.json +2 -3
  210. package/xsolla-payment-client-core-0.1.5-1.tgz +0 -0
  211. package/esm2020/lib/core/device-finger-print/device-finger-print-components.interface.mjs +0 -2
  212. package/esm2020/lib/core/device-finger-print/fingerprint-js.interface.mjs +0 -2
  213. package/esm2020/lib/core/exceptions-handling/errors/default-terminal-error.class.mjs +0 -8
  214. package/esm2020/lib/core/payment/initialize/initialize-response.class.mjs +0 -43
  215. package/esm2020/lib/core/payment/initialize/initialize-response.token.mjs +0 -8
  216. package/esm2020/lib/core/payment/sync/sync-request.class.mjs +0 -31
  217. package/esm2020/lib/core/payment/sync/sync-request.token.mjs +0 -8
  218. package/esm2020/lib/core/payment/sync/sync-response.class.mjs +0 -17
  219. package/esm2020/lib/core/payment/sync/sync-response.token.mjs +0 -8
  220. package/esm2020/lib/core/payment/xps-request.abstract.mjs +0 -8
  221. package/lib/core/device-finger-print/device-finger-print-components.interface.d.ts +0 -4
  222. package/lib/core/device-finger-print/fingerprint-js.interface.d.ts +0 -6
  223. package/lib/core/exceptions-handling/errors/default-terminal-error.class.d.ts +0 -4
  224. package/lib/core/payment/xps-request.abstract.d.ts +0 -6
  225. package/xsolla-payment-client-core-0.1.3.tgz +0 -0
  226. /package/lib/core/payment/initialize/{initialize-response.token.d.ts → response/initialize-response.token.d.ts} +0 -0
  227. /package/lib/core/payment/sync/{sync-request.token.d.ts → request/sync-request.token.d.ts} +0 -0
  228. /package/lib/core/payment/sync/{sync-response.token.d.ts → response/sync-response.token.d.ts} +0 -0
@@ -1,12 +1,14 @@
1
1
  import { __awaiter } from 'tslib';
2
2
  import * as i0 from '@angular/core';
3
3
  import { InjectionToken, Injectable, Inject, isDevMode, NgModule } from '@angular/core';
4
- import { firstValueFrom, lastValueFrom, map, Subject, tap, BehaviorSubject, filter as filter$1, takeUntil, skip, throwError } from 'rxjs';
4
+ import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, skip, throwError } from 'rxjs';
5
5
  import * as i1 from '@angular/common/http';
6
6
  import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
7
+ import JSEncrypt from 'jsencrypt';
7
8
  import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
8
9
  import { filter, map as map$1, catchError } from 'rxjs/operators';
9
10
  import * as i1$1 from '@angular/router';
11
+ import { CommonModule } from '@angular/common';
10
12
 
11
13
  const masksFunctionsMap = {
12
14
  zip: () => {
@@ -604,6 +606,15 @@ var InputEventName;
604
606
  InputEventName["focus"] = "focus";
605
607
  })(InputEventName || (InputEventName = {}));
606
608
 
609
+ class ShowErrorsAction {
610
+ constructor(errors) {
611
+ this.type = 'show_errors';
612
+ this.data = {
613
+ errors,
614
+ };
615
+ }
616
+ }
617
+
607
618
  class InitializeResponse {
608
619
  constructor(response) {
609
620
  this.paymentForm = null;
@@ -654,14 +665,87 @@ const initializeResponseFactoryProvider = {
654
665
  useValue: (...args) => new InitializeResponse(...args),
655
666
  };
656
667
 
657
- class ShowErrorsAction {
658
- constructor(errors) {
659
- this.type = 'show_errors';
660
- this.data = {
661
- errors,
662
- };
668
+ const masterCardAndVisaPaymentMethodId = 26;
669
+ const maestroPaymentMethodId = 490;
670
+ const creditCardPaymentMethodId = 1380;
671
+ const americanExpressMethodId = 714;
672
+ const specialCards = [
673
+ maestroPaymentMethodId,
674
+ masterCardAndVisaPaymentMethodId,
675
+ americanExpressMethodId,
676
+ ];
677
+ const cardsWith3ds = [
678
+ masterCardAndVisaPaymentMethodId,
679
+ maestroPaymentMethodId,
680
+ creditCardPaymentMethodId,
681
+ ];
682
+
683
+ class XpsApiService {
684
+ constructor(window, secureApiClient, settingsService, countryService) {
685
+ this.window = window;
686
+ this.secureApiClient = secureApiClient;
687
+ this.settingsService = settingsService;
688
+ this.countryService = countryService;
689
+ this.directPaymentApiRoute = 'directpayment';
690
+ }
691
+ directPaymentRequest(parameters) {
692
+ var _a, _b, _c, _d, _e;
693
+ return __awaiter(this, void 0, void 0, function* () {
694
+ const pid = (_c = (_b = (_a = parameters.pid) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : parameters.xps_fix_pid) !== null && _c !== void 0 ? _c : '';
695
+ const paymentWithSavedMethod = (_e = (_d = parameters.paymentWithSavedMethod) !== null && _d !== void 0 ? _d : parameters.xps_paymentWithSavedMethod) !== null && _e !== void 0 ? _e : '';
696
+ const requestParams = Object.assign(Object.assign(Object.assign(Object.assign({}, this.collectAnalyticsParameters(pid, paymentWithSavedMethod)), this.collectUserSessionId()), { country: this.countryService.getCountry() }), parameters);
697
+ return lastValueFrom(this.secureApiClient.post(this.directPaymentApiRoute, new URLSearchParams(Object.assign({}, requestParams)), {
698
+ headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
699
+ responseType: 'json',
700
+ }));
701
+ });
702
+ }
703
+ collectAnalyticsParameters(paymentMethodId, paymentWithSavedMethod) {
704
+ const parameters = {};
705
+ parameters.paymentWithSavedMethod = paymentWithSavedMethod
706
+ ? paymentWithSavedMethod
707
+ : "0" /* XpsBoolean.false */;
708
+ if (!paymentMethodId) {
709
+ return parameters;
710
+ }
711
+ /* If payment method with 3DSecure */
712
+ if (cardsWith3ds.includes(Number(paymentMethodId))) {
713
+ parameters.container3DS = JSON.stringify({
714
+ browserjavaenabled: this.window.navigator.javaEnabled(),
715
+ browserlanguage: this.window.navigator.language,
716
+ browsercolordepth: this.window.screen.colorDepth,
717
+ browserscreenheight: this.window.screen.availHeight,
718
+ browserscreenwidth: this.window.screen.availWidth,
719
+ browsertz: new Date().getTimezoneOffset(),
720
+ browserappname: this.window.navigator.appName,
721
+ browserlocaltime: new Date().toString(),
722
+ browserplatform: this.window.navigator.platform || '',
723
+ browsercookiesenabled: this.window.navigator.cookieEnabled,
724
+ });
725
+ }
726
+ return parameters;
727
+ }
728
+ collectUserSessionId() {
729
+ var _a, _b;
730
+ const parameters = {};
731
+ parameters.xps_idUserSession = (_a = this.settingsService.user.session_id) !== null && _a !== void 0 ? _a : '';
732
+ parameters.user_session_id = (_b = this.settingsService.user.session_id) !== null && _b !== void 0 ? _b : '';
733
+ return parameters;
663
734
  }
664
735
  }
736
+ XpsApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: XpsApiService, deps: [{ token: windowToken }, { token: SecureApiClient }, { token: SettingsService }, { token: CountryService }], target: i0.ɵɵFactoryTarget.Injectable });
737
+ XpsApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: XpsApiService, providedIn: 'root' });
738
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: XpsApiService, decorators: [{
739
+ type: Injectable,
740
+ args: [{
741
+ providedIn: 'root',
742
+ }]
743
+ }], ctorParameters: function () {
744
+ return [{ type: undefined, decorators: [{
745
+ type: Inject,
746
+ args: [windowToken]
747
+ }] }, { type: SecureApiClient }, { type: SettingsService }, { type: CountryService }];
748
+ } });
665
749
 
666
750
  class ShowFieldsAction {
667
751
  constructor(submitResponse) {
@@ -693,17 +777,16 @@ const showFieldsActionFactoryProvider = {
693
777
 
694
778
  class CheckStatusAction {
695
779
  constructor(submitResponse) {
696
- var _a, _b, _c, _d, _e, _f;
780
+ var _a, _b, _c, _d, _e, _f, _g;
697
781
  this.type = 'check_status';
698
- const status = submitResponse.parameters.status;
699
782
  this.data = {
700
- invoice: status === null || status === void 0 ? void 0 : status.invoice,
701
- signature: (_a = submitResponse.parameters.form.signature) === null || _a === void 0 ? void 0 : _a.value,
702
- locale: (_b = submitResponse.parameters.form.locale) === null || _b === void 0 ? void 0 : _b.value,
703
- testPs: (_c = submitResponse.parameters.form.testPs) === null || _c === void 0 ? void 0 : _c.value,
704
- testXsolla: (_d = submitResponse.parameters.form.testXsolla) === null || _d === void 0 ? void 0 : _d.value,
705
- testProject: (_e = submitResponse.parameters.form.testProject) === null || _e === void 0 ? void 0 : _e.value,
706
- userReturnStatus: (_f = submitResponse.parameters.form.userReturnStatus) === null || _f === void 0 ? void 0 : _f.value,
783
+ invoice: parseInt((_a = submitResponse.parameters.form.fix_invoice) === null || _a === void 0 ? void 0 : _a.value),
784
+ signature: (_b = submitResponse.parameters.form.signature) === null || _b === void 0 ? void 0 : _b.value,
785
+ locale: (_c = submitResponse.parameters.form.locale) === null || _c === void 0 ? void 0 : _c.value,
786
+ testPs: (_d = submitResponse.parameters.form.testPs) === null || _d === void 0 ? void 0 : _d.value,
787
+ testXsolla: (_e = submitResponse.parameters.form.testXsolla) === null || _e === void 0 ? void 0 : _e.value,
788
+ testProject: (_f = submitResponse.parameters.form.testProject) === null || _f === void 0 ? void 0 : _f.value,
789
+ userReturnStatus: (_g = submitResponse.parameters.form.userReturnStatus) === null || _g === void 0 ? void 0 : _g.value,
707
790
  };
708
791
  }
709
792
  }
@@ -786,6 +869,22 @@ const showErrorsActionFactoryProvider = {
786
869
  },
787
870
  };
788
871
 
872
+ class ThreeDsAction {
873
+ constructor(statusUpdate) {
874
+ this.type = '3DS';
875
+ this.data = statusUpdate;
876
+ }
877
+ }
878
+
879
+ const threeDsActionFactoryToken = new InjectionToken('ThreeDsAction');
880
+ const threeDsActionFactoryProvider = {
881
+ provide: threeDsActionFactoryToken,
882
+ useValue: {
883
+ factory: (...args) => new ThreeDsAction(...args),
884
+ isSuitable: () => false,
885
+ },
886
+ };
887
+
789
888
  const nextActionsToken = new InjectionToken('Action');
790
889
  const nextActions = [
791
890
  showFieldsActionFactoryProvider,
@@ -795,6 +894,7 @@ const nextActions = [
795
894
  const flowUpdateNextActions = [
796
895
  statusUpdatedActionFactoryProvider,
797
896
  showErrorsActionFactoryProvider,
897
+ threeDsActionFactoryProvider,
798
898
  ];
799
899
 
800
900
  class NextActionService {
@@ -855,14 +955,416 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
855
955
  }] }, { type: i0.Injector }];
856
956
  } });
857
957
 
958
+ var ErrorTags;
959
+ (function (ErrorTags) {
960
+ ErrorTags["APP"] = "appError";
961
+ ErrorTags["HTTP"] = "httpError";
962
+ ErrorTags["JS"] = "jsError";
963
+ ErrorTags["WS"] = "webSocket";
964
+ ErrorTags["ENCRYPT"] = "encrypt";
965
+ ErrorTags["APPLEPAY"] = "applepay";
966
+ ErrorTags["HEADLESS_UI"] = "headlessUi";
967
+ ErrorTags["GOOGLEPAY"] = "googlepay";
968
+ ErrorTags["PAYTM"] = "paytm";
969
+ })(ErrorTags || (ErrorTags = {}));
970
+
971
+ class TaggedError extends Error {
972
+ constructor(message, tags) {
973
+ super(message);
974
+ this.tags = [];
975
+ this.parentTag = ErrorTags.HEADLESS_UI;
976
+ this.tags = this.childTag
977
+ ? [this.parentTag, this.childTag]
978
+ : [this.parentTag];
979
+ if (tags) {
980
+ const newTags = tags.filter((t, i, arr) => !this.tags.includes(t) && arr.indexOf(t) == i);
981
+ this.tags = [...this.tags, ...newTags];
982
+ }
983
+ }
984
+ }
985
+
986
+ class EncryptCreditCardError extends TaggedError {
987
+ constructor(message, tags) {
988
+ tags = tags ? [...tags, ErrorTags.ENCRYPT] : [ErrorTags.ENCRYPT];
989
+ super(message, tags);
990
+ }
991
+ }
992
+
993
+ const fourBlockMask = '9999 9999 9999 9999';
994
+
995
+ var CreditCardTypes;
996
+ (function (CreditCardTypes) {
997
+ CreditCardTypes["DEFAULT"] = "0";
998
+ CreditCardTypes["VISA"] = "1";
999
+ CreditCardTypes["MASTERCARD"] = "2";
1000
+ CreditCardTypes["MAESTRO"] = "3";
1001
+ CreditCardTypes["AMERICAN_EXPRESS"] = "4";
1002
+ CreditCardTypes["DINERS_CLUBS"] = "5";
1003
+ CreditCardTypes["DISCOVER"] = "6";
1004
+ CreditCardTypes["JCB"] = "9";
1005
+ CreditCardTypes["DANKORT"] = "11";
1006
+ CreditCardTypes["HIPERCARD"] = "12";
1007
+ CreditCardTypes["ELO"] = "13";
1008
+ CreditCardTypes["AURA"] = "14";
1009
+ CreditCardTypes["NARANJA"] = "15";
1010
+ CreditCardTypes["MIR"] = "16";
1011
+ CreditCardTypes["CHINA_UNION_PAY"] = "17";
1012
+ CreditCardTypes["POSTEPAY"] = "18";
1013
+ })(CreditCardTypes || (CreditCardTypes = {}));
1014
+
1015
+ const visa = {
1016
+ id: CreditCardTypes.VISA,
1017
+ minLength: 13,
1018
+ maxLength: 16,
1019
+ iconName: 'visa',
1020
+ mask: fourBlockMask,
1021
+ checkNumber(number) {
1022
+ return number.startsWith('4');
1023
+ },
1024
+ };
1025
+
1026
+ const mastercard = {
1027
+ id: CreditCardTypes.MASTERCARD,
1028
+ minLength: 16,
1029
+ maxLength: 16,
1030
+ iconName: 'mastercard',
1031
+ mask: fourBlockMask,
1032
+ checkNumber(number) {
1033
+ const subLength = 6;
1034
+ const cardNumberSub = number.substring(0, subLength);
1035
+ return (new RegExp(/^5[1-5]/).test(number) ||
1036
+ (cardNumberSub >= '222100' && cardNumberSub <= '272099'));
1037
+ },
1038
+ };
1039
+
1040
+ const defaultMask = '9999 9999 9999 9999 999';
1041
+
1042
+ const maestro = {
1043
+ id: CreditCardTypes.MAESTRO,
1044
+ minLength: 12,
1045
+ maxLength: 19,
1046
+ iconName: 'maestro',
1047
+ mask: defaultMask,
1048
+ checkNumber(number) {
1049
+ return new RegExp(/^(5018)|^(5020)|^(5038)|^(5893)|^(6304)|^(6759)|^(6761)|^(6762)|^(6763)|^(0604)|^(6706)|^(6771)|^(6709)/).test(number);
1050
+ },
1051
+ maxCvvLength: 3,
1052
+ };
1053
+
1054
+ const americanExpress = {
1055
+ id: CreditCardTypes.AMERICAN_EXPRESS,
1056
+ minLength: 15,
1057
+ maxLength: 15,
1058
+ iconName: 'american-express',
1059
+ mask: '9999 999999 99999',
1060
+ checkNumber(number) {
1061
+ return new RegExp(/^(34)|^(37)/).test(number);
1062
+ },
1063
+ maxCvvLength: 4,
1064
+ };
1065
+
1066
+ const dinersClubs = {
1067
+ id: CreditCardTypes.DINERS_CLUBS,
1068
+ minLength: 14,
1069
+ maxLength: 14,
1070
+ iconName: 'dinersclub',
1071
+ mask: '9999 9999 9999 99',
1072
+ checkNumber(number) {
1073
+ const regex = /^(36[0-9]|3(?:0[0-59]|[68][0-9])[0-9])/;
1074
+ return regex.test(number);
1075
+ },
1076
+ };
1077
+
1078
+ const discover = {
1079
+ id: CreditCardTypes.DISCOVER,
1080
+ minLength: 16,
1081
+ maxLength: 19,
1082
+ iconName: 'discover',
1083
+ mask: defaultMask,
1084
+ checkNumber(number) {
1085
+ return new RegExp(/^(6011)|^(622(1(2[6-9]|[3-9][0-9])|[2-8][0-9]{2}|9([01][0-9]|2[0-5])))|^(64[4-9])|^65/).test(number);
1086
+ },
1087
+ };
1088
+
1089
+ const jcb = {
1090
+ id: CreditCardTypes.JCB,
1091
+ minLength: 15,
1092
+ maxLength: 16,
1093
+ iconName: 'jcb',
1094
+ mask: fourBlockMask,
1095
+ checkNumber(number) {
1096
+ return new RegExp(/^35(2[89]|[3-8][0-9])/).test(number);
1097
+ },
1098
+ };
1099
+
1100
+ const dankort = {
1101
+ id: CreditCardTypes.DANKORT,
1102
+ minLength: 16,
1103
+ maxLength: 16,
1104
+ iconName: 'dankort',
1105
+ mask: fourBlockMask,
1106
+ checkNumber(number) {
1107
+ const subLength = 4;
1108
+ const cardNumberSub = number.substring(0, subLength);
1109
+ return cardNumberSub === '5019';
1110
+ },
1111
+ };
1112
+
1113
+ const hipercard = {
1114
+ id: CreditCardTypes.HIPERCARD,
1115
+ minLength: 13,
1116
+ maxLength: 19,
1117
+ iconName: 'hipercard',
1118
+ mask: defaultMask,
1119
+ checkNumber(number) {
1120
+ return new RegExp(/^((606282|637095|637568)[0-9]|38[0-9]{14,17})/).test(number);
1121
+ },
1122
+ };
1123
+
1124
+ const elo = {
1125
+ id: CreditCardTypes.ELO,
1126
+ minLength: 16,
1127
+ maxLength: 19,
1128
+ iconName: 'elo',
1129
+ mask: defaultMask,
1130
+ checkNumber(number) {
1131
+ return new RegExp(/^(40117[8-9]|431274|438935|451416|457393|45763[1-2]|506(699|7[0-6][0-9]|77[0-8])|509\d{3}|504175|627780|636297|636368|65003[1-3]|6500(3[5-9]|4[0-9]|5[0-1])|6504(0[5-9]|[1-3][0-9])|650(4[8-9][0-9]|5[0-2][0-9]|53[0-8])|6505(4[1-9]|[5-8][0-9]|9[0-8])|6507(0[0-9]|1[0-8])|65072[0-7]|6509(0[1-9]|1[0-9]|20)|6516(5[2-9]|[6-7][0-9])|6550([0-1][0-9]|2[1-9]|[3-4][0-9]|5[0-8]))/).test(number);
1132
+ },
1133
+ };
1134
+
1135
+ const aura = {
1136
+ id: CreditCardTypes.AURA,
1137
+ minLength: 16,
1138
+ maxLength: 19,
1139
+ iconName: 'aura',
1140
+ mask: defaultMask,
1141
+ checkNumber(number) {
1142
+ const subLength = 8;
1143
+ const cardNumberSub = number.substring(0, subLength);
1144
+ return ['50786000', '50786018', '50786019'].includes(cardNumberSub);
1145
+ },
1146
+ };
1147
+
1148
+ const naranja = {
1149
+ id: CreditCardTypes.NARANJA,
1150
+ minLength: 12,
1151
+ maxLength: 19,
1152
+ iconName: 'naranja',
1153
+ mask: defaultMask,
1154
+ checkNumber(number) {
1155
+ const subLength = 6;
1156
+ const cardNumberSub = number.substring(0, subLength);
1157
+ return cardNumberSub === '589562';
1158
+ },
1159
+ };
1160
+
1161
+ const mir = {
1162
+ id: CreditCardTypes.MIR,
1163
+ minLength: 16,
1164
+ maxLength: 16,
1165
+ iconName: 'mir',
1166
+ mask: defaultMask,
1167
+ checkNumber(number) {
1168
+ const subLength = 4;
1169
+ const cardNumberSub = number.substring(0, subLength);
1170
+ return cardNumberSub >= '2200' && cardNumberSub <= '2204';
1171
+ },
1172
+ };
1173
+
1174
+ const chinaUnionPay = {
1175
+ id: CreditCardTypes.CHINA_UNION_PAY,
1176
+ minLength: 16,
1177
+ maxLength: 19,
1178
+ iconName: 'unionpay',
1179
+ mask: '999 9999 9999 99999999',
1180
+ checkNumber(number) {
1181
+ return number.startsWith('62');
1182
+ },
1183
+ };
1184
+
1185
+ const defaultCard = {
1186
+ id: CreditCardTypes.DEFAULT,
1187
+ minLength: 12,
1188
+ maxLength: 19,
1189
+ iconName: null,
1190
+ mask: defaultMask,
1191
+ checkNumber() {
1192
+ return false;
1193
+ },
1194
+ };
1195
+
1196
+ const postePay = {
1197
+ id: CreditCardTypes.POSTEPAY,
1198
+ minLength: 12,
1199
+ maxLength: 19,
1200
+ iconName: 'poste_pay',
1201
+ mask: '9999 9999 9999 9999 999',
1202
+ checkNumber(number) {
1203
+ const regex = /^(5018)|^(5020)|^(5038)|^(5893)|^(6304)|^(6759)|^(6761)|^(6762)|^(6763)|^(0604)|^(6706)|^(6771)|^(6709)/;
1204
+ return regex.test(number);
1205
+ },
1206
+ };
1207
+
1208
+ /**
1209
+ * order does matter
1210
+ * settings with more specific pattern should be placed above
1211
+ * Example:
1212
+ * - 12*
1213
+ * - 12
1214
+ * - 1
1215
+ * "12*" pattern should be checked first, otherwise pattern "1" will be taken
1216
+ * before "12*" checked
1217
+ */
1218
+ const orderedCardSettings = [
1219
+ aura,
1220
+ naranja,
1221
+ maestro,
1222
+ postePay,
1223
+ elo,
1224
+ discover,
1225
+ dankort,
1226
+ hipercard,
1227
+ mir,
1228
+ jcb,
1229
+ dinersClubs,
1230
+ americanExpress,
1231
+ mastercard,
1232
+ chinaUnionPay,
1233
+ visa,
1234
+ defaultCard,
1235
+ ];
1236
+
1237
+ const creditCardsMap = {
1238
+ [CreditCardTypes.DEFAULT]: defaultCard,
1239
+ [CreditCardTypes.VISA]: visa,
1240
+ [CreditCardTypes.MASTERCARD]: mastercard,
1241
+ [CreditCardTypes.MAESTRO]: maestro,
1242
+ [CreditCardTypes.AMERICAN_EXPRESS]: americanExpress,
1243
+ [CreditCardTypes.DINERS_CLUBS]: dinersClubs,
1244
+ [CreditCardTypes.DISCOVER]: discover,
1245
+ [CreditCardTypes.JCB]: jcb,
1246
+ [CreditCardTypes.DANKORT]: dankort,
1247
+ [CreditCardTypes.HIPERCARD]: hipercard,
1248
+ [CreditCardTypes.ELO]: elo,
1249
+ [CreditCardTypes.AURA]: aura,
1250
+ [CreditCardTypes.NARANJA]: naranja,
1251
+ [CreditCardTypes.MIR]: mir,
1252
+ [CreditCardTypes.CHINA_UNION_PAY]: chinaUnionPay,
1253
+ [CreditCardTypes.POSTEPAY]: postePay,
1254
+ };
1255
+
1256
+ class CreditCardService {
1257
+ getBinNumber(cardNumber) {
1258
+ const binNumberLength = 6;
1259
+ return cardNumber.replace(/\s+/g, '').substring(0, binNumberLength);
1260
+ }
1261
+ getAccountSuffix(cardNumber) {
1262
+ const accountSuffixLength = 4;
1263
+ return cardNumber
1264
+ .replace(/\s+/g, '')
1265
+ .substring(cardNumber.length - accountSuffixLength);
1266
+ }
1267
+ getTypeByNumber(cardNumber) {
1268
+ cardNumber = cardNumber.replace(/\s+/g, '');
1269
+ const cardSettings = orderedCardSettings.find((settings) => {
1270
+ const isNumberMatched = settings.checkNumber(cardNumber);
1271
+ return isNumberMatched ? settings.id : false;
1272
+ });
1273
+ return cardSettings ? cardSettings.id : defaultCard.id;
1274
+ }
1275
+ getCreditCardSettings(cardType) {
1276
+ const creditCard = creditCardsMap[cardType];
1277
+ if (!creditCard) {
1278
+ return defaultCard;
1279
+ }
1280
+ return creditCard;
1281
+ }
1282
+ }
1283
+ CreditCardService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1284
+ CreditCardService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardService, providedIn: 'root' });
1285
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardService, decorators: [{
1286
+ type: Injectable,
1287
+ args: [{
1288
+ providedIn: 'root',
1289
+ }]
1290
+ }] });
1291
+
1292
+ class EncryptCreditCardService {
1293
+ constructor(creditCardService) {
1294
+ this.creditCardService = creditCardService;
1295
+ this.secureFieldNames = [
1296
+ 'xps_card_number',
1297
+ 'xps_cvv',
1298
+ 'xps_extra_cvv',
1299
+ 'xps_card_year',
1300
+ 'xps_card_month',
1301
+ ];
1302
+ this.jsEncrypt = new JSEncrypt();
1303
+ }
1304
+ setPublicKey(publicKey) {
1305
+ this.jsEncrypt.setPublicKey(publicKey);
1306
+ }
1307
+ encryptCreditCard(request) {
1308
+ if (request.xps_card_number) {
1309
+ const openCard = this.createOpenCard(request);
1310
+ request.xps_open_card = JSON.stringify(openCard);
1311
+ }
1312
+ const encryptedCard = this.createEncryptedCard(request);
1313
+ if (!request.xps_encrypted_card && JSON.stringify(encryptedCard) !== '{}') {
1314
+ request.xps_encrypted_card = this.encrypt(JSON.stringify(encryptedCard));
1315
+ }
1316
+ this.secureFieldNames.forEach((secureFieldName) => {
1317
+ delete request[secureFieldName];
1318
+ });
1319
+ return request;
1320
+ }
1321
+ encrypt(value) {
1322
+ var _a;
1323
+ if (!((_a = this.jsEncrypt) === null || _a === void 0 ? void 0 : _a.getPublicKey())) {
1324
+ throw new EncryptCreditCardError('Empty public key');
1325
+ }
1326
+ const encryptedValue = this.jsEncrypt.encrypt(value);
1327
+ if (!encryptedValue) {
1328
+ throw new EncryptCreditCardError('Encryption returns false instead of encrypted string');
1329
+ }
1330
+ return encryptedValue;
1331
+ }
1332
+ createEncryptedCard(request) {
1333
+ const encryptedCard = {
1334
+ card_number: request.xps_card_number,
1335
+ card_year: request.xps_card_year,
1336
+ card_month: request.xps_card_month,
1337
+ cvv: request.xps_cvv,
1338
+ };
1339
+ if (request.xps_extra_cvv) {
1340
+ encryptedCard.cvv = request.xps_extra_cvv;
1341
+ }
1342
+ return encryptedCard;
1343
+ }
1344
+ createOpenCard(request) {
1345
+ return {
1346
+ card_bin: this.creditCardService.getBinNumber(request.xps_card_number),
1347
+ card_suffix: this.creditCardService.getAccountSuffix(request.xps_card_number),
1348
+ card_year: request.xps_card_year,
1349
+ card_month: request.xps_card_month,
1350
+ };
1351
+ }
1352
+ }
1353
+ EncryptCreditCardService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: EncryptCreditCardService, deps: [{ token: CreditCardService }], target: i0.ɵɵFactoryTarget.Injectable });
1354
+ EncryptCreditCardService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: EncryptCreditCardService, providedIn: 'root' });
1355
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: EncryptCreditCardService, decorators: [{
1356
+ type: Injectable,
1357
+ args: [{ providedIn: 'root' }]
1358
+ }], ctorParameters: function () { return [{ type: CreditCardService }]; } });
1359
+
858
1360
  class InitializeService {
859
- constructor(responseFactory, secureApi, settingsService, countryService, nextActionService) {
1361
+ constructor(responseFactory, xpsApiService, settingsService, countryService, nextActionService, encryptCreditCardService) {
860
1362
  this.responseFactory = responseFactory;
861
- this.secureApi = secureApi;
1363
+ this.xpsApiService = xpsApiService;
862
1364
  this.settingsService = settingsService;
863
1365
  this.countryService = countryService;
864
1366
  this.nextActionService = nextActionService;
865
- this.apiRoute = 'directpayment';
1367
+ this.encryptCreditCardService = encryptCreditCardService;
866
1368
  // TODO PAYMENTS-15743: replace with new refer id for headless core
867
1369
  this.ps4ReferId = '22';
868
1370
  }
@@ -875,23 +1377,33 @@ class InitializeService {
875
1377
  country: this.countryService.getCountry(),
876
1378
  returnUrl: config.returnUrl,
877
1379
  };
878
- return lastValueFrom(this.secureApi
879
- .post(this.apiRoute, new URLSearchParams(Object.assign({}, requestParams)), {
880
- headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
881
- responseType: 'json',
882
- })
883
- .pipe(map((response) => this.responseFactory(response)), tap((response) => {
1380
+ return this.xpsApiService
1381
+ .directPaymentRequest(requestParams)
1382
+ .then((response) => {
884
1383
  var _a, _b;
885
- if ((_b = (_a = response.paymentForm) === null || _a === void 0 ? void 0 : _a.errors) === null || _b === void 0 ? void 0 : _b.length) {
886
- this.nextActionService.emitFlowUpdates(new ShowErrorsAction(response.paymentForm.errors));
1384
+ const initializeResponse = this.responseFactory(response);
1385
+ if ((_b = (_a = initializeResponse.paymentForm) === null || _a === void 0 ? void 0 : _a.errors) === null || _b === void 0 ? void 0 : _b.length) {
1386
+ this.nextActionService.emitFlowUpdates(new ShowErrorsAction(initializeResponse.paymentForm.errors));
887
1387
  }
888
- }))).catch((error) => {
1388
+ if (initializeResponse.paymentForm) {
1389
+ this.setCreditCardEncryptKey(initializeResponse.paymentForm);
1390
+ }
1391
+ return initializeResponse;
1392
+ })
1393
+ .catch((error) => {
889
1394
  throw new ResponseError(error.message);
890
1395
  });
891
1396
  });
892
1397
  }
1398
+ setCreditCardEncryptKey(paymentForm) {
1399
+ const publicKeyField = paymentForm.fields.find((field) => field.name === 'public_key');
1400
+ if (!publicKeyField) {
1401
+ return;
1402
+ }
1403
+ this.encryptCreditCardService.setPublicKey(atob(publicKeyField.value));
1404
+ }
893
1405
  }
894
- InitializeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, deps: [{ token: initializeResponseFactoryToken }, { token: SecureApiClient }, { token: SettingsService }, { token: CountryService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
1406
+ InitializeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, deps: [{ token: initializeResponseFactoryToken }, { token: XpsApiService }, { token: SettingsService }, { token: CountryService }, { token: NextActionService }, { token: EncryptCreditCardService }], target: i0.ɵɵFactoryTarget.Injectable });
895
1407
  InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, providedIn: 'root' });
896
1408
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
897
1409
  type: Injectable,
@@ -902,7 +1414,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
902
1414
  return [{ type: undefined, decorators: [{
903
1415
  type: Inject,
904
1416
  args: [initializeResponseFactoryToken]
905
- }] }, { type: SecureApiClient }, { type: SettingsService }, { type: CountryService }, { type: NextActionService }];
1417
+ }] }, { type: XpsApiService }, { type: SettingsService }, { type: CountryService }, { type: NextActionService }, { type: EncryptCreditCardService }];
906
1418
  } });
907
1419
 
908
1420
  class XpsApiPartRequest {
@@ -953,68 +1465,56 @@ const submitResponseFactoryProvider = {
953
1465
  useValue: (...args) => new SubmitResponse(...args),
954
1466
  };
955
1467
 
956
- class TerminalError extends AppError {
957
- constructor(message, code) {
958
- super(message);
959
- this.code = code;
960
- }
961
- }
962
-
963
- class DefaultTerminalError extends TerminalError {
964
- constructor() {
965
- const message = `It's not you, it's us, but we can help. Please contact our customer support.`;
966
- super(message, '1000-0002');
967
- }
968
- }
969
-
970
1468
  class DeviceFingerPrintService {
971
- constructor(secureApi, settingsService, window) {
972
- this.secureApi = secureApi;
1469
+ constructor(settingsService) {
973
1470
  this.settingsService = settingsService;
974
- this.window = window;
975
- this.apiRoute = 'dfp';
976
- this.fingerprintApiUrl = 'https://afs.xsolla.com/dfp/api/v1/';
977
1471
  }
978
1472
  init() {
979
- return __awaiter(this, void 0, void 0, function* () {
980
- if (!this.settingsService.isInitialized) {
981
- return;
982
- }
983
- this.fingerprintJs = yield this.loadFingerprintJs();
984
- this.hash = yield this.buildHash();
985
- this.antifraudFingerprintLibrary =
986
- yield this.loadAntifraudFingerprintLibrary();
987
- });
1473
+ if (!this.settingsService.isInitialized) {
1474
+ return;
1475
+ }
1476
+ this.antifraudFingerprintLibrary = this.loadAntifraudFingerprintLibrary();
1477
+ this.hash = this.buildHash();
988
1478
  }
989
- // eslint-disable-next-line @typescript-eslint/require-await
990
1479
  getHash() {
991
1480
  return __awaiter(this, void 0, void 0, function* () {
992
1481
  return this.hash;
993
1482
  });
994
1483
  }
995
- loadFingerprintJs() {
1484
+ loadAntifraudFingerprintLibrary() {
996
1485
  return __awaiter(this, void 0, void 0, function* () {
997
- const { default: library, murmurX64Hash128: getHash } = yield import('@fingerprintjs/fingerprintjs');
998
- return { library, getHash };
1486
+ const library = yield import('@xsolla/antifraud-fingerprint');
1487
+ return library.AntifraudFingerprint;
999
1488
  });
1000
1489
  }
1001
- loadAntifraudFingerprintLibrary() {
1490
+ buildHash() {
1002
1491
  return __awaiter(this, void 0, void 0, function* () {
1003
- const library = yield import('@xsolla/antifraud-fingerprint');
1004
- return library.default;
1492
+ const hash = yield this.generate();
1493
+ return JSON.stringify(hash);
1494
+ });
1495
+ }
1496
+ generate() {
1497
+ return __awaiter(this, void 0, void 0, function* () {
1498
+ const fingerprint = yield this.makeAntifraudFingerprint();
1499
+ if (!fingerprint) {
1500
+ return null;
1501
+ }
1502
+ yield fingerprint.dispatch().catch((err) => console.log(err));
1503
+ const afsHash = yield fingerprint.hash();
1504
+ return { '301': afsHash };
1005
1505
  });
1006
1506
  }
1007
- // eslint-disable-next-line @typescript-eslint/require-await
1008
1507
  makeAntifraudFingerprint() {
1009
1508
  return __awaiter(this, void 0, void 0, function* () {
1010
1509
  if (!this.settingsService.token) {
1011
1510
  return null;
1012
1511
  }
1013
- const antifraudFingerprint = this.antifraudFingerprintLibrary;
1512
+ const antifraudFingerprint = yield this
1513
+ .antifraudFingerprintLibrary;
1014
1514
  try {
1015
1515
  return new antifraudFingerprint({
1016
1516
  api: {
1017
- url: this.fingerprintApiUrl,
1517
+ url: 'https://afs.xsolla.com/dfp/api/v1/',
1018
1518
  token: this.settingsService.token,
1019
1519
  timeout: 3000,
1020
1520
  },
@@ -1029,135 +1529,31 @@ class DeviceFingerPrintService {
1029
1529
  }
1030
1530
  });
1031
1531
  }
1032
- /**
1033
- *Загружаем библиотеку, генерируем данные,
1034
- *хешируем с помощью BASE64 и отправляем на бэкенд,
1035
- *в ответ получаем dfp_hash.
1036
- **/
1037
- buildHash() {
1038
- return __awaiter(this, void 0, void 0, function* () {
1039
- const fingerPrintData = yield this.generate();
1040
- const hash = yield this.send(fingerPrintData).catch(() => {
1041
- return null;
1042
- });
1043
- return JSON.stringify(hash);
1044
- });
1045
- }
1046
- /**
1047
- *Новая версия библиотеки содержит не все компоненты, некоторые приходится имплементировать самостоятельно
1048
- **/
1049
- getHasLiedResolution() {
1050
- const { screen } = this.window;
1051
- return (screen.width < screen.availWidth || screen.height < screen.availHeight);
1052
- }
1053
- /**
1054
- *Бэкенд заточен под конкретные поля, которые необходимо смапить.
1055
- **/
1056
- getComponents(components) {
1057
- var _a, _b, _c, _d, _e, _f, _g, _h;
1058
- return {
1059
- user_agent: navigator.userAgent,
1060
- language: (_c = (_b = (_a = components.languages.value) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.shift()) !== null && _c !== void 0 ? _c : '',
1061
- color_depth: components.colorDepth.value,
1062
- device_memory: components.deviceMemory.value,
1063
- hardware_concurrency: components.hardwareConcurrency.value,
1064
- resolution: components.screenResolution.value,
1065
- available_resolution: components.screenResolution.value,
1066
- timezone_offset: new Date().getTimezoneOffset(),
1067
- session_storage: components.sessionStorage.value ? 1 : 0,
1068
- local_storage: components.localStorage.value ? 1 : 0,
1069
- indexed_db: components.indexedDB.value ? 1 : 0,
1070
- open_database: components.openDatabase.value ? 1 : 0,
1071
- navigator_platform: components.platform.value,
1072
- regular_plugins: (_e = (_d = components.plugins.value) === null || _d === void 0 ? void 0 : _d.map((plugin) => plugin.name)) !== null && _e !== void 0 ? _e : [],
1073
- canvas: (_f = components.canvas.value) === null || _f === void 0 ? void 0 : _f.text,
1074
- webgl: (_g = components.canvas.value) === null || _g === void 0 ? void 0 : _g.text,
1075
- webgl_vendor: components.vendor.value,
1076
- has_lied_resolution: this.getHasLiedResolution(),
1077
- touch_support: Object.values((_h = components.touchSupport.value) !== null && _h !== void 0 ? _h : {}),
1078
- js_fonts: components.fonts.value,
1079
- };
1080
- }
1081
- /**
1082
- * Получаем данные dfp с помощью FingerprintJS, мапим необходимые поля, добавляем хэш
1083
- **/
1084
- generate() {
1085
- return __awaiter(this, void 0, void 0, function* () {
1086
- const { library, getHash } = this.fingerprintJs;
1087
- const fingerprint = yield library.load();
1088
- const commonFingerPrintData = yield fingerprint.get();
1089
- const fingerPrintData = this.getComponents(commonFingerPrintData.components);
1090
- fingerPrintData.hash = getHash(JSON.stringify(fingerPrintData));
1091
- return fingerPrintData;
1092
- });
1093
- }
1094
- /**
1095
- * Отправка dfp на сервер, в ответ получаем dfp_hash
1096
- **/
1097
- send(fingerPrintData) {
1098
- return __awaiter(this, void 0, void 0, function* () {
1099
- const token = this.settingsService.token;
1100
- if (token === null) {
1101
- throw new DefaultTerminalError();
1102
- }
1103
- const requestBody = {
1104
- access_token: token,
1105
- 'dfp[200]': '',
1106
- };
1107
- requestBody['dfp[200]'] = btoa(encodeURIComponent(JSON.stringify(fingerPrintData)));
1108
- return lastValueFrom(this.secureApi.post(this.apiRoute, new URLSearchParams(requestBody), {
1109
- headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
1110
- responseType: 'json',
1111
- }))
1112
- .then((response) => {
1113
- return response.dfp_hash;
1114
- })
1115
- .then((hash) => __awaiter(this, void 0, void 0, function* () {
1116
- const fingerprint = yield this.makeAntifraudFingerprint();
1117
- if (!fingerprint) {
1118
- return null;
1119
- }
1120
- yield (fingerprint === null || fingerprint === void 0 ? void 0 : fingerprint.dispatch(hash['200']).catch((err) => console.log(err)));
1121
- const afsHash = yield fingerprint.hash();
1122
- return Object.assign({ '301': afsHash }, hash);
1123
- }))
1124
- .catch((error) => {
1125
- var _a, _b, _c, _d, _e, _f;
1126
- const response = error.getHttpErrorData().response;
1127
- throw new TerminalError((_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.errors[0]) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : '', (_f = (_e = (_d = response.data) === null || _d === void 0 ? void 0 : _d.errors[0]) === null || _e === void 0 ? void 0 : _e.support_code) !== null && _f !== void 0 ? _f : '');
1128
- });
1129
- });
1130
- }
1131
1532
  }
1132
- DeviceFingerPrintService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DeviceFingerPrintService, deps: [{ token: SecureApiClient }, { token: SettingsService }, { token: windowToken }], target: i0.ɵɵFactoryTarget.Injectable });
1533
+ DeviceFingerPrintService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DeviceFingerPrintService, deps: [{ token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
1133
1534
  DeviceFingerPrintService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DeviceFingerPrintService, providedIn: 'root' });
1134
1535
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DeviceFingerPrintService, decorators: [{
1135
1536
  type: Injectable,
1136
1537
  args: [{
1137
1538
  providedIn: 'root',
1138
1539
  }]
1139
- }], ctorParameters: function () {
1140
- return [{ type: SecureApiClient }, { type: SettingsService }, { type: undefined, decorators: [{
1141
- type: Inject,
1142
- args: [windowToken]
1143
- }] }];
1144
- } });
1540
+ }], ctorParameters: function () { return [{ type: SettingsService }]; } });
1145
1541
 
1146
1542
  class SubmitService {
1147
- constructor(requestFactory, responseFactory, settingsService, deviceFingerPrintService, secureApi) {
1543
+ constructor(requestFactory, responseFactory, settingsService, deviceFingerPrintService, xpsApiService, encryptCreditCardService) {
1148
1544
  this.requestFactory = requestFactory;
1149
1545
  this.responseFactory = responseFactory;
1150
1546
  this.settingsService = settingsService;
1151
1547
  this.deviceFingerPrintService = deviceFingerPrintService;
1152
- this.secureApi = secureApi;
1153
- this.directPaymentApiRoute = 'directpayment';
1548
+ this.xpsApiService = xpsApiService;
1549
+ this.encryptCreditCardService = encryptCreditCardService;
1154
1550
  }
1155
1551
  // NB: Never add 'async' statement for this method!
1156
1552
  // 'Async' statement wraps current promise into another.
1157
1553
  // In this way two promises become unequal, that can broke XPS API requests logic.
1158
1554
  // eslint-disable-next-line @typescript-eslint/promise-function-async
1159
1555
  request(fields, form) {
1160
- const responsePromise = this.deviceFingerPrintService
1556
+ return (this.deviceFingerPrintService
1161
1557
  .getHash()
1162
1558
  // eslint-disable-next-line @typescript-eslint/promise-function-async
1163
1559
  .then((dfpHash) => {
@@ -1167,19 +1563,17 @@ class SubmitService {
1167
1563
  form,
1168
1564
  dfpHash,
1169
1565
  });
1170
- return lastValueFrom(this.secureApi.post(this.directPaymentApiRoute, new URLSearchParams(Object.assign({}, requestParams)), {
1171
- headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
1172
- responseType: 'json',
1173
- }))
1566
+ const encryptedRequest = this.encryptCreditCardService.encryptCreditCard(requestParams);
1567
+ return this.xpsApiService
1568
+ .directPaymentRequest(encryptedRequest)
1174
1569
  .then((response) => this.responseFactory(response))
1175
1570
  .catch((error) => {
1176
1571
  throw new ResponseError(error.message);
1177
1572
  });
1178
- });
1179
- return responsePromise;
1573
+ }));
1180
1574
  }
1181
1575
  }
1182
- SubmitService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SubmitService, deps: [{ token: submitRequestFactoryToken }, { token: submitResponseFactoryToken }, { token: SettingsService }, { token: DeviceFingerPrintService }, { token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable });
1576
+ SubmitService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SubmitService, deps: [{ token: submitRequestFactoryToken }, { token: submitResponseFactoryToken }, { token: SettingsService }, { token: DeviceFingerPrintService }, { token: XpsApiService }, { token: EncryptCreditCardService }], target: i0.ɵɵFactoryTarget.Injectable });
1183
1577
  SubmitService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SubmitService, providedIn: 'root' });
1184
1578
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SubmitService, decorators: [{
1185
1579
  type: Injectable,
@@ -1191,7 +1585,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
1191
1585
  }] }, { type: undefined, decorators: [{
1192
1586
  type: Inject,
1193
1587
  args: [submitResponseFactoryToken]
1194
- }] }, { type: SettingsService }, { type: DeviceFingerPrintService }, { type: SecureApiClient }];
1588
+ }] }, { type: SettingsService }, { type: DeviceFingerPrintService }, { type: XpsApiService }, { type: EncryptCreditCardService }];
1195
1589
  } });
1196
1590
 
1197
1591
  class EmitDataService {
@@ -1204,16 +1598,8 @@ class EmitDataService {
1204
1598
  }
1205
1599
  }
1206
1600
 
1207
- class XpsRequest {
1208
- addXpsParameters(parameters) {
1209
- for (const key in parameters) {
1210
- this[`xps_${key}`] = parameters[key];
1211
- }
1212
- }
1213
- }
1214
-
1215
1601
  /* eslint-disable @typescript-eslint/naming-convention */
1216
- class SyncRequest extends XpsRequest {
1602
+ class SyncRequest extends XpsApiPartRequest {
1217
1603
  constructor(parameters) {
1218
1604
  super();
1219
1605
  this.xps_fix_command = 'calculate';
@@ -1272,17 +1658,21 @@ const syncResponseFactoryProvider = {
1272
1658
  };
1273
1659
 
1274
1660
  class SyncService extends EmitDataService {
1275
- constructor(requestFactory, responseFactory, secureApi, nextActionService, settingsService) {
1661
+ constructor(requestFactory, responseFactory, xpsApiService, nextActionService, settingsService, encryptCreditCardService) {
1276
1662
  super();
1277
1663
  this.requestFactory = requestFactory;
1278
1664
  this.responseFactory = responseFactory;
1279
- this.secureApi = secureApi;
1665
+ this.xpsApiService = xpsApiService;
1280
1666
  this.nextActionService = nextActionService;
1281
1667
  this.settingsService = settingsService;
1282
- this.apiRoute = 'directpayment';
1668
+ this.encryptCreditCardService = encryptCreditCardService;
1283
1669
  this.prevFieldSyncStates = {};
1284
1670
  this.form = new UntypedFormGroup({});
1285
1671
  this.fields = [];
1672
+ this.fieldAsyncValidation = new Subject();
1673
+ }
1674
+ get fieldAsyncValidation$() {
1675
+ return this.fieldAsyncValidation.asObservable();
1286
1676
  }
1287
1677
  setup(form, fields) {
1288
1678
  this.reset();
@@ -1316,6 +1706,11 @@ class SyncService extends EmitDataService {
1316
1706
  this.setPrevFieldSyncState(field, value, requestPromise);
1317
1707
  return requestPromise.then((response) => {
1318
1708
  var _a;
1709
+ this.fieldAsyncValidation.next({
1710
+ value,
1711
+ field,
1712
+ response,
1713
+ });
1319
1714
  return (_a = response.error) !== null && _a !== void 0 ? _a : null;
1320
1715
  });
1321
1716
  });
@@ -1333,10 +1728,10 @@ class SyncService extends EmitDataService {
1333
1728
  fields: this.fields,
1334
1729
  form: this.form,
1335
1730
  });
1336
- return lastValueFrom(this.secureApi.post(this.apiRoute, new URLSearchParams(requestParams), {
1337
- headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
1338
- responseType: 'json',
1339
- })).then((response) => {
1731
+ const encryptedRequest = this.encryptCreditCardService.encryptCreditCard(requestParams);
1732
+ return this.xpsApiService
1733
+ .directPaymentRequest(encryptedRequest)
1734
+ .then((response) => {
1340
1735
  var _a;
1341
1736
  if ((_a = response.errors) === null || _a === void 0 ? void 0 : _a.length) {
1342
1737
  this.nextActionService.emitFlowUpdates(new ShowErrorsAction(response.errors));
@@ -1359,7 +1754,7 @@ class SyncService extends EmitDataService {
1359
1754
  this.prevFieldSyncStates[field.name] = { value, result };
1360
1755
  }
1361
1756
  }
1362
- SyncService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token: SecureApiClient }, { token: NextActionService }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
1757
+ SyncService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token: XpsApiService }, { token: NextActionService }, { token: SettingsService }, { token: EncryptCreditCardService }], target: i0.ɵɵFactoryTarget.Injectable });
1363
1758
  SyncService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, providedIn: 'root' });
1364
1759
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, decorators: [{
1365
1760
  type: Injectable,
@@ -1373,7 +1768,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
1373
1768
  }] }, { type: undefined, decorators: [{
1374
1769
  type: Inject,
1375
1770
  args: [syncResponseFactoryToken]
1376
- }] }, { type: SecureApiClient }, { type: NextActionService }, { type: SettingsService }];
1771
+ }] }, { type: XpsApiService }, { type: NextActionService }, { type: SettingsService }, { type: EncryptCreditCardService }];
1377
1772
  } });
1378
1773
 
1379
1774
  class ControlConfig {
@@ -1558,23 +1953,455 @@ class ZipConverter extends Converter {
1558
1953
  }
1559
1954
  return config;
1560
1955
  }
1561
- getAutocomplete() {
1562
- return 'postal-code';
1956
+ getAutocomplete() {
1957
+ return 'postal-code';
1958
+ }
1959
+ getDataType() {
1960
+ return 'text';
1961
+ }
1962
+ }
1963
+ ZipConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ZipConverter, deps: [{ token: SyncService }, { token: CountryService }], target: i0.ɵɵFactoryTarget.Injectable });
1964
+ ZipConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ZipConverter });
1965
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ZipConverter, decorators: [{
1966
+ type: Injectable
1967
+ }], ctorParameters: function () { return [{ type: SyncService }, { type: CountryService }]; } });
1968
+
1969
+ function isEmptyInputValue(value) {
1970
+ return value == null || value.length === 0;
1971
+ }
1972
+
1973
+ function isString(value) {
1974
+ return typeof value === 'string';
1975
+ }
1976
+
1977
+ /**
1978
+ * Checks number match Luhn algorithm.
1979
+ * Based on http://en.wikipedia.org/wiki/Luhn.
1980
+ */
1981
+ const luhnFormulaValidator = ({ value }) => {
1982
+ if (isEmptyInputValue(value) || !isString(value)) {
1983
+ return null;
1984
+ }
1985
+ const error = {
1986
+ rewritableError: {
1987
+ message: `Enter a valid card number`,
1988
+ },
1989
+ };
1990
+ if (/[^0-9 -]+/.test(value)) {
1991
+ // accept only spaces, digits and dashes
1992
+ return error;
1993
+ }
1994
+ let resultSum = 0;
1995
+ let digit = 0;
1996
+ let isEven = false;
1997
+ const modBase = 10;
1998
+ const digitRadix = 10;
1999
+ const maxNumber = 9;
2000
+ const digits = value.replace(/\D/g, '');
2001
+ // Checks if number match Luhn algorithm
2002
+ // based on http://en.wikipedia.org/wiki/Luhn
2003
+ for (let index = digits.length - 1; index >= 0; index--) {
2004
+ const char = digits.charAt(index);
2005
+ digit = parseInt(char, digitRadix);
2006
+ if (isEven && (digit *= 2) > maxNumber) {
2007
+ digit -= maxNumber;
2008
+ }
2009
+ resultSum += digit;
2010
+ isEven = !isEven;
2011
+ }
2012
+ return resultSum % modBase === 0 ? null : error;
2013
+ };
2014
+
2015
+ class CardNumberConfig extends ControlConfig {
2016
+ constructor() {
2017
+ super(...arguments);
2018
+ this.controlType = 'card-number';
2019
+ this.availableCardTypes = [];
2020
+ this.customError = '';
2021
+ }
2022
+ }
2023
+
2024
+ class CreditCardMinLengthValidator {
2025
+ constructor(creditService) {
2026
+ this.creditService = creditService;
2027
+ this.validate = (field) => {
2028
+ if (isEmptyInputValue(field.value) || !isString(field.value)) {
2029
+ return null;
2030
+ }
2031
+ const length = field.value.length;
2032
+ const cardType = this.creditService.getTypeByNumber(field.value);
2033
+ const { minLength } = this.creditService.getCreditCardSettings(cardType);
2034
+ return length < minLength
2035
+ ? {
2036
+ rewritableError: {
2037
+ message: `Enter at least ${minLength} characters`,
2038
+ number: minLength,
2039
+ },
2040
+ }
2041
+ : null;
2042
+ };
2043
+ }
2044
+ }
2045
+ CreditCardMinLengthValidator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardMinLengthValidator, deps: [{ token: CreditCardService }], target: i0.ɵɵFactoryTarget.Injectable });
2046
+ CreditCardMinLengthValidator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardMinLengthValidator });
2047
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardMinLengthValidator, decorators: [{
2048
+ type: Injectable
2049
+ }], ctorParameters: function () { return [{ type: CreditCardService }]; } });
2050
+
2051
+ class CardNumberConverter extends Converter {
2052
+ constructor(syncService, maxLengthValidator, minLengthValidator) {
2053
+ super(syncService);
2054
+ this.maxLengthValidator = maxLengthValidator;
2055
+ this.minLengthValidator = minLengthValidator;
2056
+ }
2057
+ getValidators(field) {
2058
+ return super
2059
+ .getValidators(field)
2060
+ .concat([
2061
+ luhnFormulaValidator,
2062
+ this.minLengthValidator.validate,
2063
+ this.maxLengthValidator.validate,
2064
+ ]);
2065
+ }
2066
+ createControlConfig(field, formState) {
2067
+ var _a, _b;
2068
+ const config = this.createDefaultControlConfig(CardNumberConfig, field);
2069
+ config.placeholder = config.title;
2070
+ config.availableCardTypes =
2071
+ (_a = formState === null || formState === void 0 ? void 0 : formState.availableCardTypes) !== null && _a !== void 0 ? _a : [];
2072
+ config.activeCardType = formState === null || formState === void 0 ? void 0 : formState.activeCardType;
2073
+ config.customError = formState === null || formState === void 0 ? void 0 : formState.customError;
2074
+ config.disabled = (_b = formState === null || formState === void 0 ? void 0 : formState.disabled) !== null && _b !== void 0 ? _b : false;
2075
+ return config;
2076
+ }
2077
+ getAutocomplete() {
2078
+ return 'cc-number';
2079
+ }
2080
+ getDataType() {
2081
+ return 'text';
2082
+ }
2083
+ }
2084
+ CardNumberConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardNumberConverter, deps: [{ token: SyncService }, { token: CreditCardMinLengthValidator }, { token: CreditCardMinLengthValidator }], target: i0.ɵɵFactoryTarget.Injectable });
2085
+ CardNumberConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardNumberConverter });
2086
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardNumberConverter, decorators: [{
2087
+ type: Injectable
2088
+ }], ctorParameters: function () { return [{ type: SyncService }, { type: CreditCardMinLengthValidator }, { type: CreditCardMinLengthValidator }]; } });
2089
+
2090
+ class CardExpirationConverter extends Converter {
2091
+ constructor(syncService) {
2092
+ super(syncService);
2093
+ }
2094
+ getValidators() {
2095
+ return [];
2096
+ }
2097
+ createControlConfig(field, formState) {
2098
+ var _a;
2099
+ const config = this.createDefaultControlConfig(TextControlConfig, field);
2100
+ config.maskConfig = {
2101
+ mask: '99',
2102
+ guide: false,
2103
+ };
2104
+ config.inputMode = 'numeric';
2105
+ config.title = 'date';
2106
+ config.disabled = (_a = formState === null || formState === void 0 ? void 0 : formState.disabled) !== null && _a !== void 0 ? _a : false;
2107
+ return config;
2108
+ }
2109
+ getAutocomplete() {
2110
+ return 'cc-exp';
2111
+ }
2112
+ getDataType() {
2113
+ return 'text';
2114
+ }
2115
+ }
2116
+ CardExpirationConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardExpirationConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
2117
+ CardExpirationConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardExpirationConverter });
2118
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardExpirationConverter, decorators: [{
2119
+ type: Injectable
2120
+ }], ctorParameters: function () { return [{ type: SyncService }]; } });
2121
+
2122
+ class CvvConverter extends Converter {
2123
+ constructor(syncService) {
2124
+ super(syncService);
2125
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
2126
+ this.maxFieldLength = 4;
2127
+ }
2128
+ getValidators() {
2129
+ return [];
2130
+ }
2131
+ createControlConfig(field, formState) {
2132
+ var _a;
2133
+ const config = this.createDefaultControlConfig(TextControlConfig, field);
2134
+ config.maskConfig = {
2135
+ mask: () => new Array(this.maxFieldLength).fill('9').join(''),
2136
+ unmaskModelValue: false,
2137
+ guide: false,
2138
+ };
2139
+ config.tooltip = {
2140
+ text: 'The code is on the back of your card',
2141
+ image: 'cvv',
2142
+ parentField: FieldNames.cvv,
2143
+ position: 'input',
2144
+ analyticsAction: 'show-cvv-tooltip',
2145
+ };
2146
+ config.inputMode = 'numeric';
2147
+ config.shouldHideUserInput = this.shouldHideUserInput();
2148
+ config.disabled = (_a = formState === null || formState === void 0 ? void 0 : formState.disabled) !== null && _a !== void 0 ? _a : false;
2149
+ return config;
2150
+ }
2151
+ getAutocomplete() {
2152
+ return 'cc-csc';
2153
+ }
2154
+ getDataType() {
2155
+ return 'password';
2156
+ }
2157
+ shouldHideUserInput() {
2158
+ return true;
2159
+ }
2160
+ }
2161
+ CvvConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CvvConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
2162
+ CvvConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CvvConverter });
2163
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CvvConverter, decorators: [{
2164
+ type: Injectable
2165
+ }], ctorParameters: function () { return [{ type: SyncService }]; } });
2166
+
2167
+ const birthdateValidator = ({ value }) => {
2168
+ if (isEmptyInputValue(value) || typeof value !== 'string') {
2169
+ return null;
2170
+ }
2171
+ const error = {
2172
+ invalidBirthDate: {
2173
+ message: `Enter a valid birth date`,
2174
+ },
2175
+ };
2176
+ const dateArr = value.split('/');
2177
+ const datePartsCount = 3;
2178
+ const dayIndex = 0;
2179
+ const monthIndex = 1;
2180
+ const yearIndex = 2;
2181
+ const maxMonths = 12;
2182
+ const maxDays = 31;
2183
+ const minAge = 16;
2184
+ const maxAge = 120;
2185
+ if (dateArr.length < datePartsCount) {
2186
+ return null;
2187
+ }
2188
+ if (+dateArr[monthIndex] > maxMonths || +dateArr[dayIndex] > maxDays) {
2189
+ return error;
2190
+ }
2191
+ const currentDate = new Date(+dateArr[yearIndex], +dateArr[monthIndex], +dateArr[dayIndex]);
2192
+ const nowDate = new Date();
2193
+ if (isNaN(currentDate.getFullYear()) ||
2194
+ nowDate.getFullYear() - currentDate.getFullYear() <= minAge ||
2195
+ nowDate.getFullYear() - currentDate.getFullYear() > maxAge) {
2196
+ return error;
2197
+ }
2198
+ else {
2199
+ return null;
2200
+ }
2201
+ };
2202
+
2203
+ class BirthDateConverter extends Converter {
2204
+ constructor(syncService) {
2205
+ super(syncService);
2206
+ }
2207
+ getValidators(field) {
2208
+ return super
2209
+ .getValidators(field)
2210
+ .concat([
2211
+ convert(Validators.pattern(/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$/), `Enter a valid birth date`),
2212
+ birthdateValidator,
2213
+ ]);
2214
+ }
2215
+ createControlConfig(field) {
2216
+ const config = this.createDefaultControlConfig(TextControlConfig, field);
2217
+ config.maskConfig = {
2218
+ mask: '99/99/9999',
2219
+ unmaskModelValue: false,
2220
+ guide: false,
2221
+ };
2222
+ config.placeholder = `DD/MM/YYYY`;
2223
+ config.inputMode = 'numeric';
2224
+ return config;
2225
+ }
2226
+ }
2227
+ BirthDateConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BirthDateConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
2228
+ BirthDateConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BirthDateConverter });
2229
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BirthDateConverter, decorators: [{
2230
+ type: Injectable
2231
+ }], ctorParameters: function () { return [{ type: SyncService }]; } });
2232
+
2233
+ class CardholderNameConverter extends Converter {
2234
+ constructor(syncService) {
2235
+ super(syncService);
2236
+ }
2237
+ createControlConfig(field) {
2238
+ return this.createDefaultControlConfig(TextControlConfig, field);
2239
+ }
2240
+ getAutocomplete() {
2241
+ return 'cc-name';
2242
+ }
2243
+ getDataType() {
2244
+ return 'text';
2245
+ }
2246
+ }
2247
+ CardholderNameConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardholderNameConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
2248
+ CardholderNameConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardholderNameConverter });
2249
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardholderNameConverter, decorators: [{
2250
+ type: Injectable
2251
+ }], ctorParameters: function () { return [{ type: SyncService }]; } });
2252
+
2253
+ const cpfNameRegex = /^[a-zA-ZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ.'-]{2,50}(?: [a-zA-ZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ.'-]{2,50}){1,8}$/i; // tslint:disable-line
2254
+
2255
+ class CpfNameConverter extends Converter {
2256
+ constructor(syncService) {
2257
+ super(syncService);
2258
+ }
2259
+ getValidators(field) {
2260
+ return super
2261
+ .getValidators(field)
2262
+ .concat([
2263
+ convert(Validators.pattern(cpfNameRegex), `Enter a valid name`),
2264
+ ]);
2265
+ }
2266
+ createControlConfig(field) {
2267
+ const config = this.createDefaultControlConfig(TextControlConfig, field);
2268
+ config.tooltip = {
2269
+ text: `Where to find your name`,
2270
+ image: 'cpf-name',
2271
+ };
2272
+ return config;
2273
+ }
2274
+ }
2275
+ CpfNameConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CpfNameConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
2276
+ CpfNameConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CpfNameConverter });
2277
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CpfNameConverter, decorators: [{
2278
+ type: Injectable
2279
+ }], ctorParameters: function () { return [{ type: SyncService }]; } });
2280
+
2281
+ class CpfNumberConverter extends Converter {
2282
+ constructor(syncService) {
2283
+ super(syncService);
2284
+ }
2285
+ createControlConfig(field) {
2286
+ const config = this.createDefaultControlConfig(TextControlConfig, field);
2287
+ config.maskConfig = {
2288
+ mask: '999.999.999-99',
2289
+ unmaskModelValue: true,
2290
+ guide: false,
2291
+ };
2292
+ config.inputMode = 'numeric';
2293
+ config.placeholder = '000.000.000-00';
2294
+ config.tooltip = {
2295
+ text: `Where to find your registration number`,
2296
+ image: 'cpf-number',
2297
+ };
2298
+ return config;
2299
+ }
2300
+ }
2301
+ CpfNumberConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CpfNumberConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
2302
+ CpfNumberConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CpfNumberConverter });
2303
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CpfNumberConverter, decorators: [{
2304
+ type: Injectable
2305
+ }], ctorParameters: function () { return [{ type: SyncService }]; } });
2306
+
2307
+ class StreetNumberConverter extends Converter {
2308
+ constructor(syncService) {
2309
+ super(syncService);
2310
+ }
2311
+ getValidators(field, formState) {
2312
+ const validators = super.getValidators(field);
2313
+ if ((formState === null || formState === void 0 ? void 0 : formState.country) === 'BL') {
2314
+ validators.push(convert(restrictedValueValidator('0'), `Enter a valid building number`));
2315
+ }
2316
+ return validators;
2317
+ }
2318
+ createControlConfig(field) {
2319
+ return this.createDefaultControlConfig(TextControlConfig, field);
2320
+ }
2321
+ }
2322
+ StreetNumberConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StreetNumberConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
2323
+ StreetNumberConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StreetNumberConverter });
2324
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StreetNumberConverter, decorators: [{
2325
+ type: Injectable
2326
+ }], ctorParameters: function () { return [{ type: SyncService }]; } });
2327
+
2328
+ class TextConverter extends Converter {
2329
+ constructor(syncService) {
2330
+ super(syncService);
2331
+ }
2332
+ createControlConfig(field) {
2333
+ return this.createDefaultControlConfig(TextControlConfig, field);
2334
+ }
2335
+ }
2336
+ TextConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: TextConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
2337
+ TextConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: TextConverter });
2338
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: TextConverter, decorators: [{
2339
+ type: Injectable
2340
+ }], ctorParameters: function () { return [{ type: SyncService }]; } });
2341
+
2342
+ function phoneValidator() {
2343
+ return convert(Validators.pattern(/^\d*$/), 'Enter a valid phone');
2344
+ }
2345
+
2346
+ function minLengthValidator(minLength) {
2347
+ return convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`);
2348
+ }
2349
+
2350
+ function maxLengthValidator(maxLength) {
2351
+ return convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`);
2352
+ }
2353
+
2354
+ class PhoneControlConfig extends ControlConfig {
2355
+ constructor() {
2356
+ super(...arguments);
2357
+ this.controlType = 'phone';
2358
+ }
2359
+ }
2360
+
2361
+ class PhoneConverter extends Converter {
2362
+ constructor(syncService) {
2363
+ super(syncService);
2364
+ }
2365
+ getValidators(field) {
2366
+ const minLength = 10;
2367
+ const maxLength = 15;
2368
+ return super
2369
+ .getValidators(field)
2370
+ .concat([
2371
+ convertedRequiredValidator(),
2372
+ phoneValidator(),
2373
+ minLengthValidator(minLength),
2374
+ maxLengthValidator(maxLength),
2375
+ ]);
1563
2376
  }
1564
- getDataType() {
1565
- return 'text';
2377
+ createControlConfig(field) {
2378
+ const config = this.createDefaultControlConfig(PhoneControlConfig, field);
2379
+ config.inputMode = 'numeric';
2380
+ return config;
1566
2381
  }
1567
2382
  }
1568
- ZipConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ZipConverter, deps: [{ token: SyncService }, { token: CountryService }], target: i0.ɵɵFactoryTarget.Injectable });
1569
- ZipConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ZipConverter });
1570
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ZipConverter, decorators: [{
2383
+ PhoneConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
2384
+ PhoneConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter });
2385
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter, decorators: [{
1571
2386
  type: Injectable
1572
- }], ctorParameters: function () { return [{ type: SyncService }, { type: CountryService }]; } });
2387
+ }], ctorParameters: function () { return [{ type: SyncService }]; } });
1573
2388
 
1574
2389
  const convertersMapToken = new InjectionToken('ConvertersTokensMap');
1575
2390
  const convertersMap = {
1576
2391
  zip: ZipConverter,
1577
2392
  email: EmailConverter,
2393
+ card_number: CardNumberConverter,
2394
+ card_month: CardExpirationConverter,
2395
+ card_year: CardExpirationConverter,
2396
+ cvv: CvvConverter,
2397
+ extra_cvv: CvvConverter,
2398
+ cardholdername: CardholderNameConverter,
2399
+ cpf_number: CpfNumberConverter,
2400
+ cpf_name: CpfNameConverter,
2401
+ birth_date: BirthDateConverter,
2402
+ street_number: StreetNumberConverter,
2403
+ text: TextConverter,
2404
+ phone: PhoneConverter,
1578
2405
  };
1579
2406
 
1580
2407
  class ControlConfigService {
@@ -1738,6 +2565,13 @@ const statusSearchParamsMap = new Map([
1738
2565
  ],
1739
2566
  ]);
1740
2567
 
2568
+ class TerminalError extends AppError {
2569
+ constructor(message, code) {
2570
+ super(message);
2571
+ this.code = code;
2572
+ }
2573
+ }
2574
+
1741
2575
  class XpsApiPart {
1742
2576
  constructor() {
1743
2577
  this.response = new BehaviorSubject(null);
@@ -1995,23 +2829,20 @@ const checkStatusResponseFactoryProvider = {
1995
2829
  };
1996
2830
 
1997
2831
  class CheckStatusService extends XpsApiPart {
1998
- constructor(secureApiClient, settingsService, requestFactory, responseFactory) {
2832
+ constructor(xpsApiService, settingsService, requestFactory, responseFactory) {
1999
2833
  super();
2000
- this.secureApiClient = secureApiClient;
2834
+ this.xpsApiService = xpsApiService;
2001
2835
  this.settingsService = settingsService;
2002
2836
  this.requestFactory = requestFactory;
2003
2837
  this.responseFactory = responseFactory;
2004
- this.apiRoute = 'directpayment';
2005
2838
  }
2006
2839
  setRequestParams(invoice) {
2007
2840
  this.invoice = invoice;
2008
2841
  }
2009
2842
  request() {
2010
2843
  const requestParams = this.requestFactory(this.settingsService.token, this.invoice);
2011
- lastValueFrom(this.secureApiClient.post(this.apiRoute, new URLSearchParams(Object.assign({}, requestParams)), {
2012
- headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
2013
- responseType: 'json',
2014
- }))
2844
+ this.xpsApiService
2845
+ .directPaymentRequest(requestParams)
2015
2846
  .then((response) => {
2016
2847
  const checkStatusResponse = this.responseFactory({
2017
2848
  status: response.status,
@@ -2025,7 +2856,7 @@ class CheckStatusService extends XpsApiPart {
2025
2856
  });
2026
2857
  }
2027
2858
  }
2028
- CheckStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, deps: [{ token: SecureApiClient }, { token: SettingsService }, { token: checkStatusRequestFactoryToken }, { token: checkStatusResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
2859
+ CheckStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, deps: [{ token: XpsApiService }, { token: SettingsService }, { token: checkStatusRequestFactoryToken }, { token: checkStatusResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
2029
2860
  CheckStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, providedIn: 'root' });
2030
2861
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, decorators: [{
2031
2862
  type: Injectable,
@@ -2033,7 +2864,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
2033
2864
  providedIn: 'root',
2034
2865
  }]
2035
2866
  }], ctorParameters: function () {
2036
- return [{ type: SecureApiClient }, { type: SettingsService }, { type: undefined, decorators: [{
2867
+ return [{ type: XpsApiService }, { type: SettingsService }, { type: undefined, decorators: [{
2037
2868
  type: Inject,
2038
2869
  args: [checkStatusRequestFactoryToken]
2039
2870
  }] }, { type: undefined, decorators: [{
@@ -2173,34 +3004,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
2173
3004
  }]
2174
3005
  }] });
2175
3006
 
2176
- var ErrorTags;
2177
- (function (ErrorTags) {
2178
- ErrorTags["APP"] = "appError";
2179
- ErrorTags["HTTP"] = "httpError";
2180
- ErrorTags["JS"] = "jsError";
2181
- ErrorTags["WS"] = "webSocket";
2182
- ErrorTags["ENCRYPT"] = "encrypt";
2183
- ErrorTags["APPLEPAY"] = "applepay";
2184
- ErrorTags["HEADLESS_UI"] = "headlessUi";
2185
- ErrorTags["GOOGLEPAY"] = "googlepay";
2186
- ErrorTags["PAYTM"] = "paytm";
2187
- })(ErrorTags || (ErrorTags = {}));
2188
-
2189
- class TaggedError extends Error {
2190
- constructor(message, tags) {
2191
- super(message);
2192
- this.tags = [];
2193
- this.parentTag = ErrorTags.HEADLESS_UI;
2194
- this.tags = this.childTag
2195
- ? [this.parentTag, this.childTag]
2196
- : [this.parentTag];
2197
- if (tags) {
2198
- const newTags = tags.filter((t, i, arr) => !this.tags.includes(t) && arr.indexOf(t) == i);
2199
- this.tags = [...this.tags, ...newTags];
2200
- }
2201
- }
2202
- }
2203
-
2204
3007
  class WsError extends TaggedError {
2205
3008
  constructor(message, channelName, tags) {
2206
3009
  tags = tags ? [...tags, ErrorTags.WS] : [ErrorTags.WS];
@@ -3088,19 +3891,466 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
3088
3891
  }] }];
3089
3892
  } });
3090
3893
 
3894
+ class CreditCardStateService extends EmitDataService {
3895
+ }
3896
+ CreditCardStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardStateService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
3897
+ CreditCardStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardStateService, providedIn: 'root' });
3898
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardStateService, decorators: [{
3899
+ type: Injectable,
3900
+ args: [{
3901
+ providedIn: 'root',
3902
+ }]
3903
+ }] });
3904
+
3905
+ var ThreeDsStatusWebSocketTypes;
3906
+ (function (ThreeDsStatusWebSocketTypes) {
3907
+ ThreeDsStatusWebSocketTypes["status3DS_changed"] = "status3DS_changed";
3908
+ })(ThreeDsStatusWebSocketTypes || (ThreeDsStatusWebSocketTypes = {}));
3909
+
3910
+ var ThreeDsStatusTypes;
3911
+ (function (ThreeDsStatusTypes) {
3912
+ ThreeDsStatusTypes["completed"] = "completed";
3913
+ ThreeDsStatusTypes["challenge"] = "challenge";
3914
+ ThreeDsStatusTypes["collectDfp"] = "collect_dfp";
3915
+ })(ThreeDsStatusTypes || (ThreeDsStatusTypes = {}));
3916
+
3917
+ class XpsResponseError extends AppError {
3918
+ constructor(message) {
3919
+ super('XPS response failed' + (message ? `: "${message}".` : '.'));
3920
+ }
3921
+ }
3922
+
3923
+ class StatusThreeDsRequest {
3924
+ constructor(token, threeDsId) {
3925
+ this.access_token = token;
3926
+ this.threeDSTrXid = threeDsId;
3927
+ }
3928
+ }
3929
+
3930
+ const statusThreeDsRequestFactoryToken = new InjectionToken('StatusThreeDsRequest');
3931
+ const statusThreeDsRequestFactoryProvider = {
3932
+ provide: statusThreeDsRequestFactoryToken,
3933
+ useValue: (...args) => new StatusThreeDsRequest(...args),
3934
+ };
3935
+
3936
+ class StatusThreeDsResponse {
3937
+ constructor(params) {
3938
+ this.status = params.status;
3939
+ this.checkoutForm = params.checkoutForm;
3940
+ }
3941
+ }
3942
+
3943
+ const statusThreeDsResponseFactoryToken = new InjectionToken('StatusThreeDsResponse');
3944
+ const statusThreeDsResponseFactoryProvider = {
3945
+ provide: statusThreeDsResponseFactoryToken,
3946
+ useValue: (...args) => new StatusThreeDsResponse(...args),
3947
+ };
3948
+
3949
+ class StatusThreeDsService {
3950
+ get response$() {
3951
+ return this.response.asObservable();
3952
+ }
3953
+ constructor(secureApi, settingsService, requestFactory, responseFactory) {
3954
+ this.secureApi = secureApi;
3955
+ this.settingsService = settingsService;
3956
+ this.requestFactory = requestFactory;
3957
+ this.responseFactory = responseFactory;
3958
+ this.apiRoute = 'secure3d/check';
3959
+ this.response = new Subject();
3960
+ }
3961
+ request(data) {
3962
+ const token = this.settingsService.token;
3963
+ if (!token) {
3964
+ throw new TokenError();
3965
+ }
3966
+ const requestParams = this.requestFactory(token, data.threeDSTrXid);
3967
+ void lastValueFrom(this.secureApi
3968
+ .post(this.apiRoute, new URLSearchParams(Object.assign({}, requestParams)), {
3969
+ headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
3970
+ responseType: 'json',
3971
+ })
3972
+ .pipe(map$1((response) => {
3973
+ const statusResponse = this.responseFactory({
3974
+ status: response.secure3d.status,
3975
+ checkoutForm: response.secure3d.checkout_form,
3976
+ });
3977
+ this.response.next(statusResponse);
3978
+ }))).catch((error) => {
3979
+ throw new XpsResponseError(error.message);
3980
+ });
3981
+ }
3982
+ }
3983
+ StatusThreeDsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusThreeDsService, deps: [{ token: SecureApiClient }, { token: SettingsService }, { token: statusThreeDsRequestFactoryToken }, { token: statusThreeDsResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
3984
+ StatusThreeDsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusThreeDsService, providedIn: 'root' });
3985
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusThreeDsService, decorators: [{
3986
+ type: Injectable,
3987
+ args: [{
3988
+ providedIn: 'root',
3989
+ }]
3990
+ }], ctorParameters: function () {
3991
+ return [{ type: SecureApiClient }, { type: SettingsService }, { type: undefined, decorators: [{
3992
+ type: Inject,
3993
+ args: [statusThreeDsRequestFactoryToken]
3994
+ }] }, { type: undefined, decorators: [{
3995
+ type: Inject,
3996
+ args: [statusThreeDsResponseFactoryToken]
3997
+ }] }];
3998
+ } });
3999
+
4000
+ class NotifyDfpStatusRequest {
4001
+ constructor(params) {
4002
+ this.access_token = params.token;
4003
+ this.threeDSTrXid = params.threeDsTrXid;
4004
+ this.secure3dCompind = params.isCompind ? 'Y' : 'N';
4005
+ }
4006
+ }
4007
+
4008
+ const notifyDfpStatusRequestFactoryToken = new InjectionToken('NotifyDfpStatusRequest');
4009
+ const notifyDfpStatusRequestFactoryProvider = {
4010
+ provide: notifyDfpStatusRequestFactoryToken,
4011
+ useValue: (...args) => new NotifyDfpStatusRequest(...args),
4012
+ };
4013
+
4014
+ class NotifyDfpStatusService {
4015
+ constructor(secureApi, settingsService, requestFactory) {
4016
+ this.secureApi = secureApi;
4017
+ this.settingsService = settingsService;
4018
+ this.requestFactory = requestFactory;
4019
+ this.apiRouteComplete = 'secure3d/notify';
4020
+ }
4021
+ /*
4022
+ * isCompind is a flag of dfp expired state
4023
+ */
4024
+ request(threeDsId, isCompind) {
4025
+ const token = this.settingsService.token;
4026
+ if (!token) {
4027
+ throw new TokenError();
4028
+ }
4029
+ const requestParams = this.requestFactory({
4030
+ token: token,
4031
+ threeDsTrXid: threeDsId,
4032
+ isCompind,
4033
+ });
4034
+ lastValueFrom(this.secureApi.post(this.apiRouteComplete, new URLSearchParams(Object.assign({}, requestParams)), {
4035
+ headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
4036
+ responseType: 'json',
4037
+ })).catch((error) => {
4038
+ throw new XpsResponseError(error.message);
4039
+ });
4040
+ }
4041
+ }
4042
+ NotifyDfpStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NotifyDfpStatusService, deps: [{ token: SecureApiClient }, { token: SettingsService }, { token: notifyDfpStatusRequestFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
4043
+ NotifyDfpStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NotifyDfpStatusService, providedIn: 'root' });
4044
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NotifyDfpStatusService, decorators: [{
4045
+ type: Injectable,
4046
+ args: [{
4047
+ providedIn: 'root',
4048
+ }]
4049
+ }], ctorParameters: function () {
4050
+ return [{ type: SecureApiClient }, { type: SettingsService }, { type: undefined, decorators: [{
4051
+ type: Inject,
4052
+ args: [notifyDfpStatusRequestFactoryToken]
4053
+ }] }];
4054
+ } });
4055
+
4056
+ class DfpCollectService {
4057
+ constructor(window, notifyDfpStatusService) {
4058
+ this.window = window;
4059
+ this.notifyDfpStatusService = notifyDfpStatusService;
4060
+ this.iframeName = 'iframeDFP';
4061
+ this.formName = 'formDFP';
4062
+ }
4063
+ collectDfpStatus(threeDsForm) {
4064
+ if (threeDsForm.waitCallback) {
4065
+ this.openIframeWithPostRequest(threeDsForm, false);
4066
+ }
4067
+ else {
4068
+ this.openIframeWithPostRequest(threeDsForm, true);
4069
+ }
4070
+ }
4071
+ /*
4072
+ * This method create invisible iframe with required params and after that it submit form in iframe
4073
+ * */
4074
+ openIframeWithPostRequest(threeDsForm, isNeedNotifyAfterLoad) {
4075
+ const iFrameElement = this.window.document.getElementById(this.iframeName);
4076
+ if (!iFrameElement) {
4077
+ this.createIframe(isNeedNotifyAfterLoad, threeDsForm.threeDSTrXid);
4078
+ this.postFormToIframe(threeDsForm.threeDSMethod, threeDsForm.threeDSMethodData);
4079
+ }
4080
+ }
4081
+ /*
4082
+ * isNeedNotifyAfterLoad is need to send notification of dft to server
4083
+ * */
4084
+ createIframe(isNeedNotifyAfterLoad, threeDsTrXid) {
4085
+ const attributes = {
4086
+ name: this.iframeName,
4087
+ id: this.iframeName,
4088
+ src: 'javascript:false',
4089
+ style: 'display:none',
4090
+ };
4091
+ const iFrame = this.window.document.createElement('iframe');
4092
+ this.setAttributes(iFrame, attributes);
4093
+ this.window.document.body.appendChild(iFrame);
4094
+ if (isNeedNotifyAfterLoad) {
4095
+ this.window.document.getElementById(this.iframeName).onload = () => {
4096
+ this.notifyDfpStatusService.request(threeDsTrXid, true);
4097
+ };
4098
+ }
4099
+ }
4100
+ /*
4101
+ * This method will submit form in our iframe. Form will be created, if it's don't exist
4102
+ * */
4103
+ postFormToIframe(url, threeDsMethod) {
4104
+ let form = this.window.document.getElementById(this.formName);
4105
+ if (!form) {
4106
+ form = this.createForm();
4107
+ this.window.document.body.appendChild(form);
4108
+ }
4109
+ form.setAttribute('action', url);
4110
+ form.setAttribute('target', this.iframeName);
4111
+ form.appendChild(this.createInput('threeDSMethodData', threeDsMethod));
4112
+ form.submit();
4113
+ }
4114
+ /*
4115
+ * This method will create invisible form with required params
4116
+ */
4117
+ createForm() {
4118
+ const form = this.window.document.createElement('form');
4119
+ const initAttributes = {
4120
+ name: this.formName,
4121
+ id: this.formName,
4122
+ style: 'display:none',
4123
+ method: 'POST',
4124
+ enctype: 'application/x-www-form-urlencoded',
4125
+ };
4126
+ this.setAttributes(form, initAttributes);
4127
+ return form;
4128
+ }
4129
+ createInput(name, value) {
4130
+ const input = this.window.document.createElement('input');
4131
+ input.type = 'hidden';
4132
+ input.name = name;
4133
+ input.value = value;
4134
+ return input;
4135
+ }
4136
+ /*
4137
+ * This method will set attributes to form/iframe
4138
+ * */
4139
+ setAttributes(element, attributes) {
4140
+ Object.keys(attributes).forEach((name) => {
4141
+ element.setAttribute(name, attributes[name]);
4142
+ });
4143
+ }
4144
+ }
4145
+ DfpCollectService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DfpCollectService, deps: [{ token: windowToken }, { token: NotifyDfpStatusService }], target: i0.ɵɵFactoryTarget.Injectable });
4146
+ DfpCollectService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DfpCollectService, providedIn: 'root' });
4147
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DfpCollectService, decorators: [{
4148
+ type: Injectable,
4149
+ args: [{
4150
+ providedIn: 'root',
4151
+ }]
4152
+ }], ctorParameters: function () {
4153
+ return [{ type: undefined, decorators: [{
4154
+ type: Inject,
4155
+ args: [windowToken]
4156
+ }] }, { type: NotifyDfpStatusService }];
4157
+ } });
4158
+
4159
+ class ReinsuranceCheckService {
4160
+ constructor(window) {
4161
+ this.window = window;
4162
+ this.timers = {};
4163
+ }
4164
+ addTimer(timer) {
4165
+ if (!timer) {
4166
+ return;
4167
+ }
4168
+ this.removeTimer(timer.id);
4169
+ this.timers[timer.id] = timer;
4170
+ const timerInStorage = this.timers[timer.id];
4171
+ this.window.setTimeout(() => {
4172
+ timerInStorage.callback();
4173
+ this.timers[timer.id] = null;
4174
+ }, timerInStorage.timeoutMs);
4175
+ }
4176
+ removeTimer(id) {
4177
+ const timerInStorage = this.timers[id];
4178
+ if (!timerInStorage) {
4179
+ return;
4180
+ }
4181
+ this.window.clearTimeout(timerInStorage.timeoutRef);
4182
+ this.timers[id] = null;
4183
+ }
4184
+ }
4185
+ ReinsuranceCheckService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ReinsuranceCheckService, deps: [{ token: windowToken }], target: i0.ɵɵFactoryTarget.Injectable });
4186
+ ReinsuranceCheckService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ReinsuranceCheckService, providedIn: 'root' });
4187
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ReinsuranceCheckService, decorators: [{
4188
+ type: Injectable,
4189
+ args: [{
4190
+ providedIn: 'root',
4191
+ }]
4192
+ }], ctorParameters: function () {
4193
+ return [{ type: undefined, decorators: [{
4194
+ type: Inject,
4195
+ args: [windowToken]
4196
+ }] }];
4197
+ } });
4198
+
4199
+ class ThreeDs20Service {
4200
+ get statusUpdates$() {
4201
+ return this.statusUpdates.asObservable();
4202
+ }
4203
+ constructor(statusThreeDsService, notifyDfpStatusService, webSocketFactory, dfpCollectService, reinsuranceCheckService) {
4204
+ this.statusThreeDsService = statusThreeDsService;
4205
+ this.notifyDfpStatusService = notifyDfpStatusService;
4206
+ this.webSocketFactory = webSocketFactory;
4207
+ this.dfpCollectService = dfpCollectService;
4208
+ this.reinsuranceCheckService = reinsuranceCheckService;
4209
+ this.webSocketClient = null;
4210
+ this.statusUpdates = new Subject();
4211
+ this.statusRequestSubscription = null;
4212
+ this.notifyDfpTimerId = 'notify-dfp';
4213
+ this.notifyDfpTimeoutMs = 10000;
4214
+ this.statusThreeDsTimerId = 'status-three-ds';
4215
+ this.statusThreeDsTimeoutMs = 180000;
4216
+ }
4217
+ checkThreeDs20(threeDsForm) {
4218
+ var _a, _b;
4219
+ return __awaiter(this, void 0, void 0, function* () {
4220
+ if (!threeDsForm) {
4221
+ return;
4222
+ }
4223
+ this.reinsuranceCheckService.addTimer({
4224
+ id: this.notifyDfpTimerId,
4225
+ timeoutMs: this.notifyDfpTimeoutMs,
4226
+ callback: () => {
4227
+ this.notifyDfpStatusService.request(threeDsForm.threeDSTrXid, false);
4228
+ },
4229
+ });
4230
+ this.webSocketClient = this.webSocketFactory.createWebSocketClient(threeDsForm.webSocketChannelUrl, threeDsForm.webSocketClientType);
4231
+ yield this.webSocketClient.open(threeDsForm.webSocketChannelUrl, threeDsForm.webSocketClientType);
4232
+ (_a = this.webSocketSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
4233
+ this.webSocketSubscription = this.webSocketClient.messages$.subscribe((message) => {
4234
+ if (message !== ThreeDsStatusWebSocketTypes.status3DS_changed) {
4235
+ return;
4236
+ }
4237
+ this.statusThreeDsService.request(threeDsForm);
4238
+ });
4239
+ (_b = this.webSocketReconnectionSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
4240
+ this.webSocketReconnectionSubscription =
4241
+ this.webSocketClient.subscribeOnSuccessfulReconnection(() => {
4242
+ this.statusThreeDsService.request(threeDsForm);
4243
+ });
4244
+ this.handleThreeDsUpdates(threeDsForm);
4245
+ this.statusThreeDsService.request(threeDsForm);
4246
+ this.reinsuranceCheckService.addTimer({
4247
+ id: this.statusThreeDsTimerId,
4248
+ timeoutMs: this.statusThreeDsTimeoutMs,
4249
+ callback: () => {
4250
+ this.statusThreeDsService.request(threeDsForm);
4251
+ },
4252
+ });
4253
+ });
4254
+ }
4255
+ handleThreeDsUpdates(threeDsForm) {
4256
+ var _a;
4257
+ (_a = this.statusRequestSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
4258
+ this.statusRequestSubscription =
4259
+ this.statusThreeDsService.response$.subscribe((threeDsStatus) => {
4260
+ if (!threeDsStatus) {
4261
+ return;
4262
+ }
4263
+ if (threeDsStatus.status === ThreeDsStatusTypes.completed) {
4264
+ this.stopReinsuranceMethods();
4265
+ this.statusUpdates.next({
4266
+ type: 'complete',
4267
+ data: {
4268
+ statusUrl: threeDsForm.statusUrl,
4269
+ },
4270
+ });
4271
+ return;
4272
+ }
4273
+ if (threeDsStatus.status === ThreeDsStatusTypes.challenge &&
4274
+ threeDsStatus.checkoutForm) {
4275
+ this.stopReinsuranceMethods();
4276
+ this.statusUpdates.next({
4277
+ type: 'challenge',
4278
+ data: threeDsStatus.checkoutForm,
4279
+ });
4280
+ }
4281
+ if (threeDsStatus.status === ThreeDsStatusTypes.collectDfp) {
4282
+ this.dfpCollectService.collectDfpStatus(threeDsForm);
4283
+ }
4284
+ });
4285
+ }
4286
+ stopReinsuranceMethods() {
4287
+ var _a, _b;
4288
+ this.reinsuranceCheckService.removeTimer(this.notifyDfpTimerId);
4289
+ this.reinsuranceCheckService.removeTimer(this.statusThreeDsTimerId);
4290
+ (_a = this.webSocketClient) === null || _a === void 0 ? void 0 : _a.close();
4291
+ (_b = this.statusRequestSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
4292
+ }
4293
+ }
4294
+ ThreeDs20Service.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDs20Service, deps: [{ token: StatusThreeDsService }, { token: NotifyDfpStatusService }, { token: WebSocketFactory }, { token: DfpCollectService }, { token: ReinsuranceCheckService }], target: i0.ɵɵFactoryTarget.Injectable });
4295
+ ThreeDs20Service.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDs20Service, providedIn: 'root' });
4296
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDs20Service, decorators: [{
4297
+ type: Injectable,
4298
+ args: [{
4299
+ providedIn: 'root',
4300
+ }]
4301
+ }], ctorParameters: function () { return [{ type: StatusThreeDsService }, { type: NotifyDfpStatusService }, { type: WebSocketFactory }, { type: DfpCollectService }, { type: ReinsuranceCheckService }]; } });
4302
+
4303
+ class ThreeDsService {
4304
+ constructor(threeDs20Service, nextActionService) {
4305
+ this.threeDs20Service = threeDs20Service;
4306
+ this.nextActionService = nextActionService;
4307
+ this.statusSubscription = null;
4308
+ }
4309
+ checkThreeDs(params) {
4310
+ var _a;
4311
+ /*
4312
+ At this moment we support only 3ds 2.0 version.
4313
+ 3ds 1.0 currently working by our redirect logic (Redirect NextAction).
4314
+ If in future we will get new version of 3ds, we should add 3ds determination logic to this service
4315
+ */
4316
+ void this.threeDs20Service.checkThreeDs20(params.parameters.threeDSForm);
4317
+ (_a = this.statusSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
4318
+ this.statusSubscription = this.threeDs20Service.statusUpdates$.subscribe((statusUpdate) => {
4319
+ if (statusUpdate.type === 'complete') {
4320
+ return this.nextActionService.emitFlowUpdates(new CheckStatusAction(params));
4321
+ }
4322
+ this.nextActionService.emitFlowUpdates(new ThreeDsAction(statusUpdate));
4323
+ });
4324
+ }
4325
+ stopChecking() {
4326
+ var _a;
4327
+ (_a = this.statusSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
4328
+ }
4329
+ }
4330
+ ThreeDsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDsService, deps: [{ token: ThreeDs20Service }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
4331
+ ThreeDsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDsService, providedIn: 'root' });
4332
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDsService, decorators: [{
4333
+ type: Injectable,
4334
+ args: [{
4335
+ providedIn: 'root',
4336
+ }]
4337
+ }], ctorParameters: function () { return [{ type: ThreeDs20Service }, { type: NextActionService }]; } });
4338
+
3091
4339
  class PaymentService {
3092
4340
  get formFieldsStatus$() {
3093
4341
  return this.formFieldsStatusSubject.asObservable().pipe(filter$1(Boolean));
3094
4342
  }
3095
- constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, nextActionService, controlConfigService) {
4343
+ constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService) {
3096
4344
  this.initializeService = initializeService;
3097
4345
  this.submitService = submitService;
3098
4346
  this.syncService = syncService;
3099
4347
  this.formService = formService;
3100
4348
  this.statusService = statusService;
3101
4349
  this.financeDetailsService = financeDetailsService;
4350
+ this.creditCardStateService = creditCardStateService;
3102
4351
  this.nextActionService = nextActionService;
3103
4352
  this.controlConfigService = controlConfigService;
4353
+ this.threeDsService = threeDsService;
3104
4354
  this.form = null;
3105
4355
  this.data = null;
3106
4356
  this.financeDetails = null;
@@ -3140,6 +4390,13 @@ class PaymentService {
3140
4390
  const submitResponse = yield this.submitService.request(this.fields, this.form);
3141
4391
  this.data = submitResponse;
3142
4392
  this.emitFinanceDetails(submitResponse.summary);
4393
+ // Handle 3ds flow
4394
+ if (submitResponse.currentCommand === XpsCommand.create) {
4395
+ this.runThreeDs();
4396
+ return;
4397
+ }
4398
+ this.fields = this.getFields();
4399
+ this.form = this.formService.createForm(this.fields);
3143
4400
  return this.nextActionService.getNextAction(submitResponse);
3144
4401
  });
3145
4402
  }
@@ -3160,7 +4417,10 @@ class PaymentService {
3160
4417
  });
3161
4418
  }
3162
4419
  runThreeDs() {
3163
- throw new Error('Method not implemented.');
4420
+ if (!isSubmitResponse(this.data)) {
4421
+ throw new Error('Should submit form first');
4422
+ }
4423
+ this.threeDsService.checkThreeDs(this.data);
3164
4424
  }
3165
4425
  getFinanceDetails() {
3166
4426
  return this.financeDetails;
@@ -3215,10 +4475,14 @@ class PaymentService {
3215
4475
  this.fields = [];
3216
4476
  this.formDestroy$.next();
3217
4477
  this.destroy$.next();
4478
+ this.threeDsService.stopChecking();
3218
4479
  }
3219
4480
  emitFinanceDetails(summary) {
3220
4481
  this.financeDetailsService.emit(summary);
3221
4482
  }
4483
+ emitCreditCardState(idCardType) {
4484
+ this.creditCardStateService.emit({ idCardType });
4485
+ }
3222
4486
  emitFormFieldsStatus(form) {
3223
4487
  const formFieldsStatus = {};
3224
4488
  Object.keys(form.controls).forEach((name) => {
@@ -3236,7 +4500,17 @@ class PaymentService {
3236
4500
  this.syncService.setup(form, fields);
3237
4501
  this.syncService.data$
3238
4502
  .pipe(takeUntil(this.destroy$))
3239
- .subscribe((response) => this.emitFinanceDetails(response.summary));
4503
+ .subscribe((response) => {
4504
+ this.emitFinanceDetails(response.summary);
4505
+ });
4506
+ this.syncService.fieldAsyncValidation$
4507
+ .pipe(takeUntil(this.destroy$))
4508
+ .subscribe((fieldAsyncValidation) => {
4509
+ switch (fieldAsyncValidation.field.name) {
4510
+ case FieldNames.cardNumber:
4511
+ this.emitCreditCardState(fieldAsyncValidation.response.parameters.idCardType);
4512
+ }
4513
+ });
3240
4514
  }
3241
4515
  listenFinanceDetails() {
3242
4516
  this.financeDetailsService.data$
@@ -3249,14 +4523,14 @@ class PaymentService {
3249
4523
  .subscribe(() => this.emitFormFieldsStatus(form));
3250
4524
  }
3251
4525
  }
3252
- 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: NextActionService }, { token: ControlConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
4526
+ 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 }], target: i0.ɵɵFactoryTarget.Injectable });
3253
4527
  PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
3254
4528
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
3255
4529
  type: Injectable,
3256
4530
  args: [{
3257
4531
  providedIn: 'root',
3258
4532
  }]
3259
- }], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: NextActionService }, { type: ControlConfigService }]; } });
4533
+ }], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: ControlConfigService }, { type: ThreeDsService }]; } });
3260
4534
 
3261
4535
  class RefundPolicyService {
3262
4536
  constructor(settingsService) {
@@ -3364,7 +4638,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
3364
4638
  }], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
3365
4639
 
3366
4640
  class CoreLibraryService {
3367
- constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService) {
4641
+ constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService) {
3368
4642
  this.settingsService = settingsService;
3369
4643
  this.countryService = countryService;
3370
4644
  this.paymentMethodsService = paymentMethodsService;
@@ -3377,6 +4651,8 @@ class CoreLibraryService {
3377
4651
  this.legalService = legalService;
3378
4652
  this.statusService = statusService;
3379
4653
  this.nextActionService = nextActionService;
4654
+ this.creditCardService = creditCardService;
4655
+ this.creditCardStateService = creditCardStateService;
3380
4656
  this.paymentMethods = {
3381
4657
  getList: () => __awaiter(this, void 0, void 0, function* () { return this.paymentMethodsService.getList(); }),
3382
4658
  getQuickMethods: () => __awaiter(this, void 0, void 0, function* () { return this.paymentMethodsService.getQuickMethods(); }),
@@ -3387,7 +4663,7 @@ class CoreLibraryService {
3387
4663
  init(configuration) {
3388
4664
  return __awaiter(this, void 0, void 0, function* () {
3389
4665
  yield this.settingsService.init(configuration);
3390
- yield this.deviceFingerPrintService.init();
4666
+ this.deviceFingerPrintService.init();
3391
4667
  });
3392
4668
  }
3393
4669
  getStatus(url) {
@@ -3418,6 +4694,16 @@ class CoreLibraryService {
3418
4694
  },
3419
4695
  };
3420
4696
  }
4697
+ getCreditCardService() {
4698
+ return {
4699
+ getTypeByNumber: (cardNumber) => this.creditCardService.getTypeByNumber(cardNumber),
4700
+ getCreditCardSettings: (cardType) => this.creditCardService.getCreditCardSettings(cardType),
4701
+ cardTypeUpdates$: this.creditCardStateService.data$,
4702
+ };
4703
+ }
4704
+ get cardTypeUpdates$() {
4705
+ return this.creditCardStateService.data$;
4706
+ }
3421
4707
  getLegalComponentConfig() {
3422
4708
  return this.legalService.getLegalComponentConfig();
3423
4709
  }
@@ -3426,14 +4712,14 @@ class CoreLibraryService {
3426
4712
  return masksFunctionsMap[sanitizedName];
3427
4713
  }
3428
4714
  }
3429
- CoreLibraryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, deps: [{ token: SettingsService }, { token: CountryService }, { token: PaymentMethodsService }, { token: SavedMethodsService }, { token: UserBalanceService }, { token: PaymentConfigService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: StatusService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
4715
+ CoreLibraryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, deps: [{ token: SettingsService }, { token: CountryService }, { token: PaymentMethodsService }, { token: SavedMethodsService }, { token: UserBalanceService }, { token: PaymentConfigService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: StatusService }, { token: NextActionService }, { token: CreditCardService }, { token: CreditCardStateService }], target: i0.ɵɵFactoryTarget.Injectable });
3430
4716
  CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
3431
4717
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
3432
4718
  type: Injectable,
3433
4719
  args: [{
3434
4720
  providedIn: 'root',
3435
4721
  }]
3436
- }], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentConfigService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: StatusService }, { type: NextActionService }]; } });
4722
+ }], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentConfigService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: StatusService }, { type: NextActionService }, { type: CreditCardService }, { type: CreditCardStateService }]; } });
3437
4723
 
3438
4724
  class HttpError extends AppError {
3439
4725
  constructor(error, req) {
@@ -3488,26 +4774,58 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
3488
4774
  type: Injectable
3489
4775
  }], ctorParameters: function () { return [{ type: i1$1.Router }]; } });
3490
4776
 
4777
+ class ValidatorsModule {
4778
+ }
4779
+ ValidatorsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ValidatorsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
4780
+ ValidatorsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: ValidatorsModule, imports: [CommonModule] });
4781
+ ValidatorsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ValidatorsModule, providers: [CreditCardMinLengthValidator], imports: [CommonModule] });
4782
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ValidatorsModule, decorators: [{
4783
+ type: NgModule,
4784
+ args: [{
4785
+ declarations: [],
4786
+ imports: [CommonModule],
4787
+ providers: [CreditCardMinLengthValidator],
4788
+ }]
4789
+ }] });
4790
+
3491
4791
  class FormModule {
3492
4792
  }
3493
4793
  FormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3494
- FormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: FormModule, imports: [ReactiveFormsModule] });
4794
+ FormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: FormModule, imports: [ReactiveFormsModule, ValidatorsModule] });
3495
4795
  FormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, providers: [
3496
4796
  FormService,
3497
4797
  ControlConfigService,
3498
4798
  ZipConverter,
3499
4799
  EmailConverter,
4800
+ CardNumberConverter,
4801
+ CardExpirationConverter,
4802
+ CvvConverter,
4803
+ CardholderNameConverter,
4804
+ CpfNumberConverter,
4805
+ CpfNameConverter,
4806
+ BirthDateConverter,
4807
+ StreetNumberConverter,
4808
+ TextConverter,
3500
4809
  { provide: convertersMapToken, useValue: convertersMap },
3501
- ], imports: [ReactiveFormsModule] });
4810
+ ], imports: [ReactiveFormsModule, ValidatorsModule] });
3502
4811
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, decorators: [{
3503
4812
  type: NgModule,
3504
4813
  args: [{
3505
- imports: [ReactiveFormsModule],
4814
+ imports: [ReactiveFormsModule, ValidatorsModule],
3506
4815
  providers: [
3507
4816
  FormService,
3508
4817
  ControlConfigService,
3509
4818
  ZipConverter,
3510
4819
  EmailConverter,
4820
+ CardNumberConverter,
4821
+ CardExpirationConverter,
4822
+ CvvConverter,
4823
+ CardholderNameConverter,
4824
+ CpfNumberConverter,
4825
+ CpfNameConverter,
4826
+ BirthDateConverter,
4827
+ StreetNumberConverter,
4828
+ TextConverter,
3511
4829
  { provide: convertersMapToken, useValue: convertersMap },
3512
4830
  ],
3513
4831
  }]
@@ -3537,6 +4855,9 @@ CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", versi
3537
4855
  checkStatusRequestFactoryProvider,
3538
4856
  checkStatusResponseFactoryProvider,
3539
4857
  financeDetailsResponseFactoryProvider,
4858
+ statusThreeDsRequestFactoryProvider,
4859
+ statusThreeDsResponseFactoryProvider,
4860
+ notifyDfpStatusRequestFactoryProvider,
3540
4861
  {
3541
4862
  provide: nextActionsToken,
3542
4863
  useValue: nextActions,
@@ -3568,6 +4889,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
3568
4889
  checkStatusRequestFactoryProvider,
3569
4890
  checkStatusResponseFactoryProvider,
3570
4891
  financeDetailsResponseFactoryProvider,
4892
+ statusThreeDsRequestFactoryProvider,
4893
+ statusThreeDsResponseFactoryProvider,
4894
+ notifyDfpStatusRequestFactoryProvider,
3571
4895
  {
3572
4896
  provide: nextActionsToken,
3573
4897
  useValue: nextActions,