@xsolla/payment-client-core 0.2.52 → 0.2.53

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 (191) hide show
  1. package/esm2022/lib/core/encrypt-credit-card/encrypt-credit-card.service.mjs +1 -1
  2. package/esm2022/lib/core/payment/actions/action.interface.mjs +1 -1
  3. package/esm2022/lib/core/payment/actions/check-status/check-status.action.class.mjs +1 -1
  4. package/esm2022/lib/core/payment/actions/next-action.service.mjs +1 -1
  5. package/esm2022/lib/core/payment/actions/redirect/redirect.action.class.mjs +1 -1
  6. package/esm2022/lib/core/payment/actions/show-cash-payment-instruction/show-cash-payment-instruction.action.class.mjs +1 -1
  7. package/esm2022/lib/core/payment/actions/show-errors/show-errors.action.class.mjs +1 -1
  8. package/esm2022/lib/core/payment/actions/show-fields/show-fields.action.class.mjs +1 -1
  9. package/esm2022/lib/core/payment/actions/show-mobile-payment-screen/show-mobile-payment-screen.action.class.mjs +1 -1
  10. package/esm2022/lib/core/payment/actions/show-qr-code/show-qr-code.action.class.mjs +1 -1
  11. package/esm2022/lib/core/payment/actions/show-xsolla-number/show-xsolla-number.action.class.mjs +1 -1
  12. package/esm2022/lib/core/payment/actions/special-button/special-button.action.class.mjs +1 -1
  13. package/esm2022/lib/core/payment/form/converters/birth-date/birth-date.converter.mjs +2 -2
  14. package/esm2022/lib/core/payment/form/converters/card-expiration/card-expiration.converter.mjs +2 -2
  15. package/esm2022/lib/core/payment/form/converters/card-month/card-month.converter.mjs +2 -2
  16. package/esm2022/lib/core/payment/form/converters/card-number/card-number.converter.mjs +2 -2
  17. package/esm2022/lib/core/payment/form/converters/card-year/card-year.converter.mjs +2 -2
  18. package/esm2022/lib/core/payment/form/converters/cardholder-name/cardholder-name.converter.mjs +2 -2
  19. package/esm2022/lib/core/payment/form/converters/checkbox/checkbox.converter.mjs +2 -2
  20. package/esm2022/lib/core/payment/form/converters/converter.abstract.mjs +1 -1
  21. package/esm2022/lib/core/payment/form/converters/converters-map.mjs +2 -2
  22. package/esm2022/lib/core/payment/form/converters/coupon/coupon.converter.mjs +2 -2
  23. package/esm2022/lib/core/payment/form/converters/cpf-name/cpf-name.converter.mjs +2 -2
  24. package/esm2022/lib/core/payment/form/converters/cpf-number/cpf-number.converter.mjs +2 -2
  25. package/esm2022/lib/core/payment/form/converters/cvv/cvv.converter.mjs +2 -2
  26. package/esm2022/lib/core/payment/form/converters/email/email.converter.mjs +2 -2
  27. package/esm2022/lib/core/payment/form/converters/phone/phone.converter.mjs +39 -0
  28. package/esm2022/lib/core/payment/form/converters/pin/pin.converter.mjs +2 -2
  29. package/esm2022/lib/core/payment/form/converters/pricepoint/pricepoint.converter.mjs +2 -2
  30. package/esm2022/lib/core/payment/form/converters/radio-group/radio-group.converter.mjs +2 -2
  31. package/esm2022/lib/core/payment/form/converters/select/select.converter.mjs +2 -2
  32. package/esm2022/lib/core/payment/form/converters/street-number/street-number.converter.mjs +2 -2
  33. package/esm2022/lib/core/payment/form/converters/text/text.converter.mjs +2 -2
  34. package/esm2022/lib/core/payment/form/converters/zip/zip.converter.mjs +2 -2
  35. package/esm2022/lib/core/payment/form/form.module.mjs +2 -2
  36. package/esm2022/lib/core/payment/form-response.interface.mjs +1 -1
  37. package/esm2022/lib/core/payment/initialize-actions/action.interface.mjs +1 -1
  38. package/esm2022/lib/core/payment/initialize-actions/initialize-next-action.service.mjs +1 -1
  39. package/esm2022/lib/core/payment/initialize-actions/special-button/special-button.action.class.mjs +1 -1
  40. package/esm2022/lib/core/payment/payment-behaviour/behaviour-strategies.mjs +7 -0
  41. package/esm2022/lib/core/payment/payment-behaviour/payment-behaviour.module.mjs +33 -0
  42. package/esm2022/lib/core/payment/payment-behaviour/payment-behaviour.service.mjs +29 -0
  43. package/esm2022/lib/core/payment/payment-behaviour/strategies/apple-pay-with-shipping-address/apple-pay-with-shipping-address.strategy.mjs +38 -0
  44. package/esm2022/lib/core/payment/payment-behaviour/strategies/behaviour-strategy.abstract.mjs +20 -0
  45. package/esm2022/lib/core/payment/payment.service.mjs +26 -10
  46. package/esm2022/lib/core/payment/requests/initialize/initialize-request-params.interface.mjs +2 -0
  47. package/esm2022/lib/core/payment/requests/initialize/initialize.service.mjs +89 -0
  48. package/esm2022/lib/core/payment/requests/initialize/is-initialize-response.function.mjs +5 -0
  49. package/esm2022/lib/core/payment/requests/initialize/response/initialize-response.class.mjs +43 -0
  50. package/esm2022/lib/core/payment/requests/initialize/response/initialize-response.token.mjs +8 -0
  51. package/esm2022/lib/core/payment/{submit/response → requests/submit}/is-submit-response.function.mjs +2 -2
  52. package/esm2022/lib/core/payment/requests/submit/request/submit-request.class.mjs +36 -0
  53. package/esm2022/lib/core/payment/requests/submit/request/submit-request.token.mjs +8 -0
  54. package/esm2022/lib/core/payment/requests/submit/response/submit-response.class.mjs +35 -0
  55. package/esm2022/lib/core/payment/requests/submit/response/submit-response.token.mjs +8 -0
  56. package/esm2022/lib/core/payment/requests/submit/response/xsolla-number.interface.mjs +2 -0
  57. package/esm2022/lib/core/payment/requests/submit/submit.service.mjs +82 -0
  58. package/esm2022/lib/core/payment/requests/sync/field-async-validation.interface.mjs +2 -0
  59. package/esm2022/lib/core/payment/requests/sync/field-sync-state.interface.mjs +2 -0
  60. package/esm2022/lib/core/payment/requests/sync/request/sync-request.class.mjs +34 -0
  61. package/esm2022/lib/core/payment/requests/sync/request/sync-request.token.mjs +8 -0
  62. package/esm2022/lib/core/payment/requests/sync/response/sync-response.class.mjs +17 -0
  63. package/esm2022/lib/core/payment/requests/sync/response/sync-response.token.mjs +8 -0
  64. package/esm2022/lib/core/payment/requests/sync/sync.service.mjs +184 -0
  65. package/esm2022/lib/core/payment/status/check-status/check-status.service.mjs +2 -2
  66. package/esm2022/lib/core/payment/status/check-status/request/check-status-request.class.mjs +2 -2
  67. package/esm2022/lib/core/payment/status/status-request/request/status-request.class.mjs +2 -2
  68. package/esm2022/lib/core/payment/status/status-request/status-request.service.mjs +2 -2
  69. package/esm2022/lib/core/payment/three-ds/three-ds.service.mjs +1 -1
  70. package/esm2022/lib/core/payment/xps-api/xps-api-part-request.abstract.mjs +13 -0
  71. package/esm2022/lib/core/payment/xps-api/xps-api-part.abstract.mjs +19 -0
  72. package/esm2022/lib/core/payment/xps-finance.interface.mjs +1 -1
  73. package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.mjs +56 -0
  74. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/apple-pay-session.interface.mjs +1 -1
  75. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.mjs +27 -4
  76. package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.mjs +27 -4
  77. package/esm2022/lib/core/sdk-payment-systems/apple-pay/shipping-address.interface.mjs +2 -0
  78. package/esm2022/lib/core/sdk-payment-systems/apple-pay/updated-price.interface.mjs +2 -0
  79. package/esm2022/lib/core/sdk-payment-systems/google-pay/check-payment-device-data.interface.mjs +1 -1
  80. package/esm2022/lib/core/sdk-payment-systems/sdk-payment-systems-initial-data.interface.mjs +1 -1
  81. package/esm2022/lib/core-library.module.mjs +10 -9
  82. package/esm2022/lib/core-library.service.mjs +1 -1
  83. package/esm2022/public-api.mjs +2 -1
  84. package/fesm2022/xsolla-payment-client-core.mjs +256 -13
  85. package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
  86. package/lib/core/encrypt-credit-card/encrypt-credit-card.service.d.ts +1 -1
  87. package/lib/core/payment/actions/action.interface.d.ts +1 -1
  88. package/lib/core/payment/actions/check-status/check-status.action.class.d.ts +1 -1
  89. package/lib/core/payment/actions/next-action.service.d.ts +1 -1
  90. package/lib/core/payment/actions/next-actions.d.ts +1 -1
  91. package/lib/core/payment/actions/redirect/redirect.action.class.d.ts +1 -1
  92. package/lib/core/payment/actions/show-cash-payment-instruction/show-cash-payment-instruction.action.class.d.ts +1 -1
  93. package/lib/core/payment/actions/show-errors/show-errors.action.class.d.ts +1 -1
  94. package/lib/core/payment/actions/show-fields/show-fields.action.class.d.ts +1 -1
  95. package/lib/core/payment/actions/show-mobile-payment-screen/show-mobile-payment-screen.action.class.d.ts +1 -1
  96. package/lib/core/payment/actions/show-qr-code/show-qr-code.action.class.d.ts +1 -1
  97. package/lib/core/payment/actions/show-xsolla-number/show-xsolla-number.action.class.d.ts +1 -1
  98. package/lib/core/payment/actions/special-button/special-button.action.class.d.ts +1 -1
  99. package/lib/core/payment/form/converters/birth-date/birth-date.converter.d.ts +1 -1
  100. package/lib/core/payment/form/converters/card-expiration/card-expiration.converter.d.ts +1 -1
  101. package/lib/core/payment/form/converters/card-month/card-month.converter.d.ts +1 -1
  102. package/lib/core/payment/form/converters/card-number/card-number.converter.d.ts +1 -1
  103. package/lib/core/payment/form/converters/card-year/card-year.converter.d.ts +1 -1
  104. package/lib/core/payment/form/converters/cardholder-name/cardholder-name.converter.d.ts +1 -1
  105. package/lib/core/payment/form/converters/checkbox/checkbox.converter.d.ts +1 -1
  106. package/lib/core/payment/form/converters/converter.abstract.d.ts +1 -1
  107. package/lib/core/payment/form/converters/coupon/coupon.converter.d.ts +1 -1
  108. package/lib/core/payment/form/converters/cpf-name/cpf-name.converter.d.ts +1 -1
  109. package/lib/core/payment/form/converters/cpf-number/cpf-number.converter.d.ts +1 -1
  110. package/lib/core/payment/form/converters/cvv/cvv.converter.d.ts +1 -1
  111. package/lib/core/payment/form/converters/email/email.converter.d.ts +1 -1
  112. package/lib/core/payment/form/converters/{phone.converter.d.ts → phone/phone.converter.d.ts} +4 -4
  113. package/lib/core/payment/form/converters/pin/pin.converter.d.ts +1 -1
  114. package/lib/core/payment/form/converters/pricepoint/pricepoint.converter.d.ts +1 -1
  115. package/lib/core/payment/form/converters/radio-group/radio-group.converter.d.ts +1 -1
  116. package/lib/core/payment/form/converters/select/select.converter.d.ts +1 -1
  117. package/lib/core/payment/form/converters/street-number/street-number.converter.d.ts +1 -1
  118. package/lib/core/payment/form/converters/text/text.converter.d.ts +1 -1
  119. package/lib/core/payment/form/converters/zip/zip.converter.d.ts +1 -1
  120. package/lib/core/payment/form-response.interface.d.ts +2 -2
  121. package/lib/core/payment/initialize-actions/action.interface.d.ts +2 -2
  122. package/lib/core/payment/initialize-actions/initialize-next-action.service.d.ts +1 -1
  123. package/lib/core/payment/initialize-actions/initialize-next-actions.d.ts +1 -1
  124. package/lib/core/payment/initialize-actions/special-button/special-button.action.class.d.ts +1 -1
  125. package/lib/core/payment/payment-behaviour/behaviour-strategies.d.ts +5 -0
  126. package/lib/core/payment/payment-behaviour/payment-behaviour.module.d.ts +7 -0
  127. package/lib/core/payment/payment-behaviour/payment-behaviour.service.d.ts +16 -0
  128. package/lib/core/payment/payment-behaviour/strategies/apple-pay-with-shipping-address/apple-pay-with-shipping-address.strategy.d.ts +10 -0
  129. package/lib/core/payment/payment-behaviour/strategies/behaviour-strategy.abstract.d.ts +15 -0
  130. package/lib/core/payment/payment.service.d.ts +10 -6
  131. package/lib/core/payment/{initialize → requests/initialize}/initialize-request-params.interface.d.ts +1 -1
  132. package/lib/core/payment/{initialize → requests/initialize}/initialize.service.d.ts +10 -10
  133. package/lib/core/payment/requests/initialize/is-initialize-response.function.d.ts +2 -0
  134. package/lib/core/payment/{initialize → requests/initialize}/response/initialize-response.class.d.ts +2 -2
  135. package/lib/core/payment/{submit/response → requests/submit}/is-submit-response.function.d.ts +1 -1
  136. package/lib/core/payment/{submit → requests/submit}/request/submit-request.class.d.ts +2 -2
  137. package/lib/core/payment/{submit → requests/submit}/response/submit-response.class.d.ts +4 -4
  138. package/lib/core/payment/{submit → requests/submit}/submit.service.d.ts +9 -9
  139. package/lib/core/payment/{sync → requests/sync}/field-async-validation.interface.d.ts +1 -1
  140. package/lib/core/payment/{sync → requests/sync}/request/sync-request.class.d.ts +2 -2
  141. package/lib/core/payment/{sync → requests/sync}/response/sync-response.class.d.ts +2 -2
  142. package/lib/core/payment/{sync → requests/sync}/sync.service.d.ts +14 -12
  143. package/lib/core/payment/status/check-status/check-status.service.d.ts +1 -1
  144. package/lib/core/payment/status/check-status/request/check-status-request.class.d.ts +1 -1
  145. package/lib/core/payment/status/status-request/request/status-request.class.d.ts +1 -1
  146. package/lib/core/payment/status/status-request/status-request.service.d.ts +1 -1
  147. package/lib/core/payment/three-ds/three-ds.service.d.ts +1 -1
  148. package/lib/core/payment/xps-finance.interface.d.ts +20 -0
  149. package/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.d.ts +21 -0
  150. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/apple-pay-session.interface.d.ts +17 -8
  151. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.d.ts +3 -1
  152. package/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.d.ts +3 -1
  153. package/lib/core/sdk-payment-systems/apple-pay/shipping-address.interface.d.ts +4 -0
  154. package/lib/core/sdk-payment-systems/apple-pay/updated-price.interface.d.ts +7 -0
  155. package/lib/core/sdk-payment-systems/google-pay/check-payment-device-data.interface.d.ts +1 -1
  156. package/lib/core/sdk-payment-systems/sdk-payment-systems-initial-data.interface.d.ts +1 -1
  157. package/lib/core-library.module.d.ts +2 -1
  158. package/lib/core-library.service.d.ts +2 -2
  159. package/package.json +1 -1
  160. package/public-api.d.ts +1 -0
  161. package/xsolla-payment-client-core-0.2.53.tgz +0 -0
  162. package/esm2022/lib/core/payment/form/converters/phone.converter.mjs +0 -39
  163. package/esm2022/lib/core/payment/initialize/initialize-request-params.interface.mjs +0 -2
  164. package/esm2022/lib/core/payment/initialize/initialize.service.mjs +0 -89
  165. package/esm2022/lib/core/payment/initialize/response/initialize-response.class.mjs +0 -43
  166. package/esm2022/lib/core/payment/initialize/response/initialize-response.token.mjs +0 -8
  167. package/esm2022/lib/core/payment/submit/request/submit-request.class.mjs +0 -36
  168. package/esm2022/lib/core/payment/submit/request/submit-request.token.mjs +0 -8
  169. package/esm2022/lib/core/payment/submit/response/submit-response.class.mjs +0 -35
  170. package/esm2022/lib/core/payment/submit/response/submit-response.token.mjs +0 -8
  171. package/esm2022/lib/core/payment/submit/response/xsolla-number.interface.mjs +0 -2
  172. package/esm2022/lib/core/payment/submit/submit.service.mjs +0 -82
  173. package/esm2022/lib/core/payment/sync/field-async-validation.interface.mjs +0 -2
  174. package/esm2022/lib/core/payment/sync/field-sync-state.interface.mjs +0 -2
  175. package/esm2022/lib/core/payment/sync/request/sync-request.class.mjs +0 -34
  176. package/esm2022/lib/core/payment/sync/request/sync-request.token.mjs +0 -8
  177. package/esm2022/lib/core/payment/sync/response/sync-response.class.mjs +0 -17
  178. package/esm2022/lib/core/payment/sync/response/sync-response.token.mjs +0 -8
  179. package/esm2022/lib/core/payment/sync/sync.service.mjs +0 -164
  180. package/esm2022/lib/core/payment/xps-api-part-request.abstract.mjs +0 -13
  181. package/esm2022/lib/core/payment/xps-api-part.abstract.mjs +0 -19
  182. package/xsolla-payment-client-core-0.2.52.tgz +0 -0
  183. /package/lib/core/payment/{initialize → requests/initialize}/response/initialize-response.token.d.ts +0 -0
  184. /package/lib/core/payment/{submit → requests/submit}/request/submit-request.token.d.ts +0 -0
  185. /package/lib/core/payment/{submit → requests/submit}/response/submit-response.token.d.ts +0 -0
  186. /package/lib/core/payment/{submit → requests/submit}/response/xsolla-number.interface.d.ts +0 -0
  187. /package/lib/core/payment/{sync → requests/sync}/field-sync-state.interface.d.ts +0 -0
  188. /package/lib/core/payment/{sync → requests/sync}/request/sync-request.token.d.ts +0 -0
  189. /package/lib/core/payment/{sync → requests/sync}/response/sync-response.token.d.ts +0 -0
  190. /package/lib/core/payment/{xps-api-part-request.abstract.d.ts → xps-api/xps-api-part-request.abstract.d.ts} +0 -0
  191. /package/lib/core/payment/{xps-api-part.abstract.d.ts → xps-api/xps-api-part.abstract.d.ts} +0 -0
@@ -3192,6 +3192,26 @@ class SyncService extends EmitDataService {
3192
3192
  }
3193
3193
  });
3194
3194
  }
3195
+ async forceValidate(field) {
3196
+ const control = this.form.get(field.name);
3197
+ const value = control?.value;
3198
+ const isHaveField = this.fields.some((savedFields) => savedFields.name === field.name);
3199
+ if (!isHaveField) {
3200
+ this.fields.push(field);
3201
+ }
3202
+ return this.request(field).then((syncResponse) => {
3203
+ this.setPrevFieldSyncState(field, value, Promise.resolve(syncResponse));
3204
+ this.fieldAsyncValidation.next({
3205
+ value,
3206
+ field,
3207
+ response: syncResponse,
3208
+ });
3209
+ return syncResponse;
3210
+ });
3211
+ }
3212
+ removeField(fieldName) {
3213
+ this.fields = this.fields.filter((field) => field.name !== fieldName);
3214
+ }
3195
3215
  getSyncValidationErrors(field) {
3196
3216
  const control = this.form.get(field.name);
3197
3217
  return control?.errors ?? null;
@@ -6695,6 +6715,91 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
6695
6715
  args: [printInstructionRequestFactoryToken]
6696
6716
  }] }] });
6697
6717
 
6718
+ class BehaviourStrategy {
6719
+ isSuitable() {
6720
+ return false;
6721
+ }
6722
+ onDestroy() { }
6723
+ setPaymentData(paymentData) {
6724
+ this.paymentData = paymentData;
6725
+ }
6726
+ setPaymentConfig(config) {
6727
+ this.paymentConfig = config;
6728
+ }
6729
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BehaviourStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
6730
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BehaviourStrategy }); }
6731
+ }
6732
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BehaviourStrategy, decorators: [{
6733
+ type: Injectable
6734
+ }] });
6735
+
6736
+ const isInitializeResponse = (value) => {
6737
+ return value instanceof InitializeResponse;
6738
+ };
6739
+
6740
+ class ApplePayWithShippingAddressStrategy extends BehaviourStrategy {
6741
+ constructor() {
6742
+ super();
6743
+ }
6744
+ isSuitable() {
6745
+ if (!isInitializeResponse(this.paymentData)) {
6746
+ return false;
6747
+ }
6748
+ return this.paymentData.paymentForm?.pid === applePayId;
6749
+ }
6750
+ onInit() {
6751
+ this.hideField(FieldNames.zip);
6752
+ this.hideField(FieldNames.email);
6753
+ }
6754
+ hideField(fieldName) {
6755
+ if (!isInitializeResponse(this.paymentData)) {
6756
+ return;
6757
+ }
6758
+ const fieldForHide = this.paymentData.paymentForm?.fields.find((field) => {
6759
+ return field.name === fieldName;
6760
+ });
6761
+ if (fieldForHide) {
6762
+ fieldForHide.isVisible = "0" /* XpsBoolean.false */;
6763
+ }
6764
+ }
6765
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayWithShippingAddressStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
6766
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayWithShippingAddressStrategy }); }
6767
+ }
6768
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayWithShippingAddressStrategy, decorators: [{
6769
+ type: Injectable
6770
+ }], ctorParameters: () => [] });
6771
+
6772
+ const behaviourStrategiesToken = new InjectionToken('BehaviourStrategies');
6773
+ const behaviourStrategies = [
6774
+ ApplePayWithShippingAddressStrategy,
6775
+ ];
6776
+
6777
+ class PaymentBehaviourService {
6778
+ constructor(behaviourStrategyTokens, injector) {
6779
+ this.behaviourStrategyTokens = behaviourStrategyTokens;
6780
+ this.injector = injector;
6781
+ }
6782
+ getApplicableBehaviourStrategies(paymentData, config) {
6783
+ const strategies = this.getBehaviourStrategies();
6784
+ return strategies.filter((behaviourStrategy) => {
6785
+ behaviourStrategy.setPaymentData(paymentData);
6786
+ behaviourStrategy.setPaymentConfig(config);
6787
+ return behaviourStrategy.isSuitable();
6788
+ });
6789
+ }
6790
+ getBehaviourStrategies() {
6791
+ return this.behaviourStrategyTokens.map((behaviourStrategyToken) => this.injector.get(behaviourStrategyToken));
6792
+ }
6793
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourService, deps: [{ token: behaviourStrategiesToken }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
6794
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourService }); }
6795
+ }
6796
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourService, decorators: [{
6797
+ type: Injectable
6798
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
6799
+ type: Inject,
6800
+ args: [behaviourStrategiesToken]
6801
+ }] }, { type: i0.Injector }] });
6802
+
6698
6803
  class PaymentService {
6699
6804
  get formFieldsStatus$() {
6700
6805
  return this.formFieldsStatusSubject.asObservable().pipe(filter$1(Boolean));
@@ -6708,7 +6813,7 @@ class PaymentService {
6708
6813
  get formResponseValue() {
6709
6814
  return this._formResponse$.getValue();
6710
6815
  }
6711
- constructor(elkLoggerService, initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, initializeNextActionService, controlConfigService, threeDsService, formMessagesService, settingsService, countryService, checkStatusActionCreator, printInstructionService) {
6816
+ constructor(elkLoggerService, initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, initializeNextActionService, controlConfigService, threeDsService, formMessagesService, settingsService, countryService, checkStatusActionCreator, printInstructionService, paymentBehaviourService) {
6712
6817
  this.elkLoggerService = elkLoggerService;
6713
6818
  this.initializeService = initializeService;
6714
6819
  this.submitService = submitService;
@@ -6726,6 +6831,7 @@ class PaymentService {
6726
6831
  this.countryService = countryService;
6727
6832
  this.checkStatusActionCreator = checkStatusActionCreator;
6728
6833
  this.printInstructionService = printInstructionService;
6834
+ this.paymentBehaviourService = paymentBehaviourService;
6729
6835
  this.form = null;
6730
6836
  this.data = null;
6731
6837
  this.financeDetails = null;
@@ -6744,6 +6850,7 @@ class PaymentService {
6744
6850
  this.listenFinanceDetails();
6745
6851
  this.config = config;
6746
6852
  this.data = await this.initializeService.request(config);
6853
+ this.initializeBehaviourStrategies(config);
6747
6854
  this.emitFormResponse(this.data);
6748
6855
  this.fields = this.getFields();
6749
6856
  this.form = this.formService.createForm(this.fields);
@@ -6994,6 +7101,7 @@ class PaymentService {
6994
7101
  this.fields.push(field);
6995
7102
  }
6996
7103
  destroy() {
7104
+ this.destroyBehaviourStrategies(this.config);
6997
7105
  this.data = null;
6998
7106
  this.financeDetails = null;
6999
7107
  this.form = null;
@@ -7119,7 +7227,19 @@ class PaymentService {
7119
7227
  summary: data.paymentForm?.summary ?? null,
7120
7228
  };
7121
7229
  }
7122
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentService, deps: [{ token: ElkLoggerService }, { token: InitializeService }, { token: SubmitService }, { token: SyncService }, { token: FormService }, { token: StatusService }, { token: FinanceDetailsService }, { token: CreditCardStateService }, { token: NextActionService }, { token: InitializeNextActionService }, { token: ControlConfigService }, { token: ThreeDsService }, { token: FormMessagesService }, { token: SettingsService }, { token: CountryService }, { token: CheckStatusActionCreator }, { token: PrintInstructionService }], target: i0.ɵɵFactoryTarget.Injectable }); }
7230
+ initializeBehaviourStrategies(config) {
7231
+ const behaviourStrategies = this.paymentBehaviourService.getApplicableBehaviourStrategies(this.data, config);
7232
+ behaviourStrategies.forEach((strategy) => {
7233
+ strategy.onInit();
7234
+ });
7235
+ }
7236
+ destroyBehaviourStrategies(config) {
7237
+ const behaviourStrategies = this.paymentBehaviourService.getApplicableBehaviourStrategies(this.data, config);
7238
+ behaviourStrategies.forEach((strategy) => {
7239
+ strategy.onDestroy();
7240
+ });
7241
+ }
7242
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentService, deps: [{ token: ElkLoggerService }, { token: InitializeService }, { token: SubmitService }, { token: SyncService }, { token: FormService }, { token: StatusService }, { token: FinanceDetailsService }, { token: CreditCardStateService }, { token: NextActionService }, { token: InitializeNextActionService }, { token: ControlConfigService }, { token: ThreeDsService }, { token: FormMessagesService }, { token: SettingsService }, { token: CountryService }, { token: CheckStatusActionCreator }, { token: PrintInstructionService }, { token: PaymentBehaviourService }], target: i0.ɵɵFactoryTarget.Injectable }); }
7123
7243
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentService, providedIn: 'root' }); }
7124
7244
  }
7125
7245
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentService, decorators: [{
@@ -7127,7 +7247,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
7127
7247
  args: [{
7128
7248
  providedIn: 'root',
7129
7249
  }]
7130
- }], ctorParameters: () => [{ type: ElkLoggerService }, { type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: InitializeNextActionService }, { type: ControlConfigService }, { type: ThreeDsService }, { type: FormMessagesService }, { type: SettingsService }, { type: CountryService }, { type: CheckStatusActionCreator }, { type: PrintInstructionService }] });
7250
+ }], ctorParameters: () => [{ type: ElkLoggerService }, { type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: InitializeNextActionService }, { type: ControlConfigService }, { type: ThreeDsService }, { type: FormMessagesService }, { type: SettingsService }, { type: CountryService }, { type: CheckStatusActionCreator }, { type: PrintInstructionService }, { type: PaymentBehaviourService }] });
7131
7251
 
7132
7252
  const euCountries = new Set([
7133
7253
  'AT',
@@ -8121,11 +8241,65 @@ class ApplePaySessionHandlerAbstract {
8121
8241
  }
8122
8242
  }
8123
8243
 
8244
+ class ApplePayCartService {
8245
+ constructor() {
8246
+ this.cartSuccessfulRecalculated = new Subject();
8247
+ this.cartErrorRecalculated = new Subject();
8248
+ this.cartRecalculationRequest = new Subject();
8249
+ }
8250
+ get cartSuccessfulRecalculated$() {
8251
+ return this.cartSuccessfulRecalculated.asObservable();
8252
+ }
8253
+ get cartErrorRecalculated$() {
8254
+ return this.cartErrorRecalculated.asObservable();
8255
+ }
8256
+ get cartRecalculationRequest$() {
8257
+ return this.cartRecalculationRequest.asObservable();
8258
+ }
8259
+ recalculateCartTaxes(shippingContact) {
8260
+ const zip = shippingContact.postalCode;
8261
+ const country = shippingContact.countryCode?.toUpperCase() ?? '';
8262
+ const parsedZip = zip?.replace(/\s/g, '');
8263
+ this.cartRecalculationRequest.next({
8264
+ zip: parsedZip,
8265
+ country,
8266
+ });
8267
+ }
8268
+ buildShippingContactUpdate(paymentParams, updatedPrice) {
8269
+ return {
8270
+ status: 'STATUS_SUCCESS',
8271
+ newTotal: {
8272
+ label: paymentParams.totalLabel,
8273
+ amount: updatedPrice.total.toString(),
8274
+ },
8275
+ };
8276
+ }
8277
+ sendSuccessfulRecalculatedCart(updatedPrice) {
8278
+ this.cartSuccessfulRecalculated.next(updatedPrice);
8279
+ // TODO send web socket message to external window here
8280
+ }
8281
+ sendErrorRecalculatedCart(error) {
8282
+ this.cartErrorRecalculated.next(error);
8283
+ }
8284
+ isZipCountry(country) {
8285
+ return ['US', 'CA'].includes(country);
8286
+ }
8287
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
8288
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, providedIn: 'root' }); }
8289
+ }
8290
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, decorators: [{
8291
+ type: Injectable,
8292
+ args: [{
8293
+ providedIn: 'root',
8294
+ }]
8295
+ }] });
8296
+
8124
8297
  class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8125
- constructor(window, elkLoggerService) {
8298
+ constructor(window, elkLoggerService, applePayCartService) {
8126
8299
  super();
8127
8300
  this.window = window;
8128
8301
  this.elkLoggerService = elkLoggerService;
8302
+ this.applePayCartService = applePayCartService;
8129
8303
  this.paymentClient = null;
8130
8304
  }
8131
8305
  setClient(client) {
@@ -8143,6 +8317,25 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8143
8317
  const applePayRequest = this.paymentClient.createPaymentRequest(request);
8144
8318
  const session = new this.window.ApplePaySession(applePayVersion, applePayRequest);
8145
8319
  const { isApplePayInstantFlowEnabled, topLevelDomain } = additionalParams;
8320
+ session.onshippingcontactselected = (event) => {
8321
+ this.applePayCartService.cartSuccessfulRecalculated$
8322
+ .pipe(take(1))
8323
+ .subscribe((updatedPrice) => {
8324
+ const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
8325
+ session.completeShippingContactSelection(contactUpdate);
8326
+ });
8327
+ this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
8328
+ session.completeShippingContactSelection({
8329
+ errors: [error],
8330
+ newTotal: {
8331
+ label: params.totalLabel,
8332
+ amount: params.totalAmount?.toString(),
8333
+ },
8334
+ status: 'STATUS_FAILURE',
8335
+ });
8336
+ });
8337
+ this.applePayCartService.recalculateCartTaxes(event.shippingContact);
8338
+ };
8146
8339
  session.onvalidatemerchant = (event) => {
8147
8340
  const validationParams = {
8148
8341
  validationURL: event.validationURL,
@@ -8170,6 +8363,7 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8170
8363
  token: response?.nonce ?? '',
8171
8364
  email: event.payment.billingContact?.emailAddress ?? null,
8172
8365
  postalCode: event.payment.billingContact?.postalCode ?? null,
8366
+ shippingEmail: event.payment.shippingContact?.emailAddress ?? null,
8173
8367
  }));
8174
8368
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
8175
8369
  })
@@ -8184,7 +8378,7 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
8184
8378
  };
8185
8379
  session.begin();
8186
8380
  }
8187
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler, deps: [{ token: windowToken }, { token: ElkLoggerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
8381
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler, deps: [{ token: windowToken }, { token: ElkLoggerService }, { token: ApplePayCartService }], target: i0.ɵɵFactoryTarget.Injectable }); }
8188
8382
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler }); }
8189
8383
  }
8190
8384
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler, decorators: [{
@@ -8192,17 +8386,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
8192
8386
  }], ctorParameters: () => [{ type: undefined, decorators: [{
8193
8387
  type: Inject,
8194
8388
  args: [windowToken]
8195
- }] }, { type: ElkLoggerService }] });
8389
+ }] }, { type: ElkLoggerService }, { type: ApplePayCartService }] });
8196
8390
 
8197
8391
  class CheckoutHandler extends ApplePaySessionHandlerAbstract {
8198
- constructor(window, http) {
8392
+ constructor(window, http, applePayCartService) {
8199
8393
  super();
8200
8394
  this.window = window;
8201
8395
  this.http = http;
8396
+ this.applePayCartService = applePayCartService;
8202
8397
  }
8203
8398
  startSession(params, additionalParams) {
8204
8399
  const request = this.buildPaymentRequest(params);
8205
8400
  const session = new this.window.ApplePaySession(applePayVersion, request);
8401
+ session.onshippingcontactselected = (event) => {
8402
+ this.applePayCartService.cartSuccessfulRecalculated$
8403
+ .pipe(take(1))
8404
+ .subscribe((updatedPrice) => {
8405
+ const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
8406
+ session.completeShippingContactSelection(contactUpdate);
8407
+ });
8408
+ this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
8409
+ session.completeShippingContactSelection({
8410
+ errors: [error],
8411
+ newTotal: {
8412
+ label: params.totalLabel,
8413
+ amount: params.totalAmount?.toString(),
8414
+ },
8415
+ status: 'STATUS_FAILURE',
8416
+ });
8417
+ });
8418
+ this.applePayCartService.recalculateCartTaxes(event.shippingContact);
8419
+ };
8206
8420
  session.onvalidatemerchant = (event) => {
8207
8421
  const validationParams = {
8208
8422
  validationURL: event.validationURL,
@@ -8233,6 +8447,7 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
8233
8447
  token: event.payment.token ?? '',
8234
8448
  email: event.payment.billingContact?.emailAddress ?? null,
8235
8449
  postalCode: event.payment.billingContact?.postalCode ?? null,
8450
+ shippingEmail: event.payment.shippingContact?.emailAddress ?? null,
8236
8451
  }));
8237
8452
  session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
8238
8453
  };
@@ -8242,7 +8457,7 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
8242
8457
  };
8243
8458
  session.begin();
8244
8459
  }
8245
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler, deps: [{ token: windowToken }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
8460
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler, deps: [{ token: windowToken }, { token: i1.HttpClient }, { token: ApplePayCartService }], target: i0.ɵɵFactoryTarget.Injectable }); }
8246
8461
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler }); }
8247
8462
  }
8248
8463
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler, decorators: [{
@@ -8250,11 +8465,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
8250
8465
  }], ctorParameters: () => [{ type: undefined, decorators: [{
8251
8466
  type: Inject,
8252
8467
  args: [windowToken]
8253
- }] }, { type: i1.HttpClient }] });
8468
+ }] }, { type: i1.HttpClient }, { type: ApplePayCartService }] });
8469
+
8470
+ class PaymentBehaviourModule {
8471
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
8472
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourModule, imports: [CommonModule] }); }
8473
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourModule, providers: [
8474
+ PaymentBehaviourService,
8475
+ {
8476
+ provide: behaviourStrategiesToken,
8477
+ useValue: behaviourStrategies,
8478
+ },
8479
+ ...behaviourStrategies,
8480
+ ], imports: [CommonModule] }); }
8481
+ }
8482
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourModule, decorators: [{
8483
+ type: NgModule,
8484
+ args: [{
8485
+ declarations: [],
8486
+ imports: [CommonModule],
8487
+ providers: [
8488
+ PaymentBehaviourService,
8489
+ {
8490
+ provide: behaviourStrategiesToken,
8491
+ useValue: behaviourStrategies,
8492
+ },
8493
+ ...behaviourStrategies,
8494
+ ],
8495
+ }]
8496
+ }] });
8254
8497
 
8255
8498
  class CoreLibraryModule {
8256
8499
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CoreLibraryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
8257
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: CoreLibraryModule, imports: [HttpClientModule, FormModule, PipesModule] }); }
8500
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: CoreLibraryModule, imports: [HttpClientModule, FormModule, PipesModule, PaymentBehaviourModule] }); }
8258
8501
  static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CoreLibraryModule, providers: [
8259
8502
  {
8260
8503
  provide: HTTP_INTERCEPTORS,
@@ -8293,12 +8536,12 @@ class CoreLibraryModule {
8293
8536
  sendInstructionStatusResponseFactoryProvider,
8294
8537
  BraintreeHandler,
8295
8538
  CheckoutHandler,
8296
- ], imports: [HttpClientModule, FormModule, PipesModule] }); }
8539
+ ], imports: [HttpClientModule, FormModule, PipesModule, PaymentBehaviourModule] }); }
8297
8540
  }
8298
8541
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CoreLibraryModule, decorators: [{
8299
8542
  type: NgModule,
8300
8543
  args: [{
8301
- imports: [HttpClientModule, FormModule, PipesModule],
8544
+ imports: [HttpClientModule, FormModule, PipesModule, PaymentBehaviourModule],
8302
8545
  providers: [
8303
8546
  {
8304
8547
  provide: HTTP_INTERCEPTORS,
@@ -9089,5 +9332,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
9089
9332
  * Generated bundle index. Do not edit.
9090
9333
  */
9091
9334
 
9092
- export { ApplePayService, CoreLibraryModule, CoreLibraryService, CreditCardTypes, FieldNames, GooglePayService, PaymentSystemProcessingService, userBehaviourEventTypes };
9335
+ export { ApplePayCartService, ApplePayService, CoreLibraryModule, CoreLibraryService, CreditCardTypes, FieldNames, GooglePayService, PaymentSystemProcessingService, userBehaviourEventTypes };
9093
9336
  //# sourceMappingURL=xsolla-payment-client-core.mjs.map