@xsolla/payment-client-core 0.2.52 → 0.2.54
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.
- package/esm2022/lib/core/encrypt-credit-card/encrypt-credit-card.service.mjs +1 -1
- package/esm2022/lib/core/payment/actions/action.interface.mjs +1 -1
- package/esm2022/lib/core/payment/actions/check-status/check-status.action.class.mjs +1 -1
- package/esm2022/lib/core/payment/actions/next-action.service.mjs +1 -1
- package/esm2022/lib/core/payment/actions/redirect/redirect.action.class.mjs +1 -1
- package/esm2022/lib/core/payment/actions/show-cash-payment-instruction/show-cash-payment-instruction.action.class.mjs +1 -1
- package/esm2022/lib/core/payment/actions/show-errors/show-errors.action.class.mjs +1 -1
- package/esm2022/lib/core/payment/actions/show-fields/show-fields.action.class.mjs +1 -1
- package/esm2022/lib/core/payment/actions/show-mobile-payment-screen/show-mobile-payment-screen.action.class.mjs +1 -1
- package/esm2022/lib/core/payment/actions/show-qr-code/show-qr-code.action.class.mjs +1 -1
- package/esm2022/lib/core/payment/actions/show-xsolla-number/show-xsolla-number.action.class.mjs +1 -1
- package/esm2022/lib/core/payment/actions/special-button/special-button.action.class.mjs +1 -1
- package/esm2022/lib/core/payment/form/converters/birth-date/birth-date.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/card-expiration/card-expiration.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/card-month/card-month.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/card-number/card-number.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/card-year/card-year.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/cardholder-name/cardholder-name.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/checkbox/checkbox.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/converter.abstract.mjs +1 -1
- package/esm2022/lib/core/payment/form/converters/converters-map.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/coupon/coupon.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/cpf-name/cpf-name.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/cpf-number/cpf-number.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/cvv/cvv.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/email/email.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/phone/phone.converter.mjs +39 -0
- package/esm2022/lib/core/payment/form/converters/pin/pin.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/pricepoint/pricepoint.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/radio-group/radio-group.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/select/select.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/street-number/street-number.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/text/text.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/converters/zip/zip.converter.mjs +2 -2
- package/esm2022/lib/core/payment/form/form.module.mjs +2 -2
- package/esm2022/lib/core/payment/form-response.interface.mjs +1 -1
- package/esm2022/lib/core/payment/initialize-actions/action.interface.mjs +1 -1
- package/esm2022/lib/core/payment/initialize-actions/initialize-next-action.service.mjs +1 -1
- package/esm2022/lib/core/payment/initialize-actions/special-button/special-button.action.class.mjs +1 -1
- package/esm2022/lib/core/payment/payment-behaviour/behaviour-strategies.mjs +7 -0
- package/esm2022/lib/core/payment/payment-behaviour/payment-behaviour.module.mjs +33 -0
- package/esm2022/lib/core/payment/payment-behaviour/payment-behaviour.service.mjs +29 -0
- package/esm2022/lib/core/payment/payment-behaviour/strategies/apple-pay-with-shipping-address/apple-pay-with-shipping-address.strategy.mjs +38 -0
- package/esm2022/lib/core/payment/payment-behaviour/strategies/behaviour-strategy.abstract.mjs +20 -0
- package/esm2022/lib/core/payment/payment.service.mjs +26 -10
- package/esm2022/lib/core/payment/requests/initialize/initialize-request-params.interface.mjs +2 -0
- package/esm2022/lib/core/payment/requests/initialize/initialize.service.mjs +89 -0
- package/esm2022/lib/core/payment/requests/initialize/is-initialize-response.function.mjs +5 -0
- package/esm2022/lib/core/payment/requests/initialize/response/initialize-response.class.mjs +43 -0
- package/esm2022/lib/core/payment/requests/initialize/response/initialize-response.token.mjs +8 -0
- package/esm2022/lib/core/payment/{submit/response → requests/submit}/is-submit-response.function.mjs +2 -2
- package/esm2022/lib/core/payment/requests/submit/request/submit-request.class.mjs +36 -0
- package/esm2022/lib/core/payment/requests/submit/request/submit-request.token.mjs +8 -0
- package/esm2022/lib/core/payment/requests/submit/response/submit-response.class.mjs +35 -0
- package/esm2022/lib/core/payment/requests/submit/response/submit-response.token.mjs +8 -0
- package/esm2022/lib/core/payment/requests/submit/response/xsolla-number.interface.mjs +2 -0
- package/esm2022/lib/core/payment/requests/submit/submit.service.mjs +82 -0
- package/esm2022/lib/core/payment/requests/sync/field-async-validation.interface.mjs +2 -0
- package/esm2022/lib/core/payment/requests/sync/field-sync-state.interface.mjs +2 -0
- package/esm2022/lib/core/payment/requests/sync/request/sync-request.class.mjs +34 -0
- package/esm2022/lib/core/payment/requests/sync/request/sync-request.token.mjs +8 -0
- package/esm2022/lib/core/payment/requests/sync/response/sync-response.class.mjs +17 -0
- package/esm2022/lib/core/payment/requests/sync/response/sync-response.token.mjs +8 -0
- package/esm2022/lib/core/payment/requests/sync/sync.service.mjs +184 -0
- package/esm2022/lib/core/payment/status/check-status/check-status.service.mjs +2 -2
- package/esm2022/lib/core/payment/status/check-status/request/check-status-request.class.mjs +2 -2
- package/esm2022/lib/core/payment/status/status-request/request/status-request.class.mjs +2 -2
- package/esm2022/lib/core/payment/status/status-request/status-request.service.mjs +2 -2
- package/esm2022/lib/core/payment/three-ds/three-ds.service.mjs +1 -1
- package/esm2022/lib/core/payment/xps-api/xps-api-part-request.abstract.mjs +13 -0
- package/esm2022/lib/core/payment/xps-api/xps-api-part.abstract.mjs +19 -0
- package/esm2022/lib/core/payment/xps-finance.interface.mjs +1 -1
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.mjs +56 -0
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay-sdk.service.mjs +95 -0
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.mjs +46 -18
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/apple-pay-session.interface.mjs +1 -1
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.mjs +32 -5
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.mjs +31 -5
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/session-handler.abstract.mjs +1 -1
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/shipping-address.interface.mjs +2 -0
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/updated-price.interface.mjs +2 -0
- package/esm2022/lib/core/sdk-payment-systems/google-pay/check-payment-device-data.interface.mjs +1 -1
- package/esm2022/lib/core/sdk-payment-systems/sdk-payment-systems-initial-data.interface.mjs +1 -1
- package/esm2022/lib/core-library.module.mjs +10 -9
- package/esm2022/lib/core-library.service.mjs +1 -1
- package/esm2022/public-api.mjs +2 -1
- package/fesm2022/xsolla-payment-client-core.mjs +393 -26
- package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/encrypt-credit-card/encrypt-credit-card.service.d.ts +1 -1
- package/lib/core/payment/actions/action.interface.d.ts +1 -1
- package/lib/core/payment/actions/check-status/check-status.action.class.d.ts +1 -1
- package/lib/core/payment/actions/next-action.service.d.ts +1 -1
- package/lib/core/payment/actions/next-actions.d.ts +1 -1
- package/lib/core/payment/actions/redirect/redirect.action.class.d.ts +1 -1
- package/lib/core/payment/actions/show-cash-payment-instruction/show-cash-payment-instruction.action.class.d.ts +1 -1
- package/lib/core/payment/actions/show-errors/show-errors.action.class.d.ts +1 -1
- package/lib/core/payment/actions/show-fields/show-fields.action.class.d.ts +1 -1
- package/lib/core/payment/actions/show-mobile-payment-screen/show-mobile-payment-screen.action.class.d.ts +1 -1
- package/lib/core/payment/actions/show-qr-code/show-qr-code.action.class.d.ts +1 -1
- package/lib/core/payment/actions/show-xsolla-number/show-xsolla-number.action.class.d.ts +1 -1
- package/lib/core/payment/actions/special-button/special-button.action.class.d.ts +1 -1
- package/lib/core/payment/form/converters/birth-date/birth-date.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/card-expiration/card-expiration.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/card-month/card-month.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/card-number/card-number.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/card-year/card-year.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/cardholder-name/cardholder-name.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/checkbox/checkbox.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/converter.abstract.d.ts +1 -1
- package/lib/core/payment/form/converters/coupon/coupon.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/cpf-name/cpf-name.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/cpf-number/cpf-number.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/cvv/cvv.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/email/email.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/{phone.converter.d.ts → phone/phone.converter.d.ts} +4 -4
- package/lib/core/payment/form/converters/pin/pin.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/pricepoint/pricepoint.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/radio-group/radio-group.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/select/select.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/street-number/street-number.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/text/text.converter.d.ts +1 -1
- package/lib/core/payment/form/converters/zip/zip.converter.d.ts +1 -1
- package/lib/core/payment/form-response.interface.d.ts +2 -2
- package/lib/core/payment/initialize-actions/action.interface.d.ts +2 -2
- package/lib/core/payment/initialize-actions/initialize-next-action.service.d.ts +1 -1
- package/lib/core/payment/initialize-actions/initialize-next-actions.d.ts +1 -1
- package/lib/core/payment/initialize-actions/special-button/special-button.action.class.d.ts +1 -1
- package/lib/core/payment/payment-behaviour/behaviour-strategies.d.ts +5 -0
- package/lib/core/payment/payment-behaviour/payment-behaviour.module.d.ts +7 -0
- package/lib/core/payment/payment-behaviour/payment-behaviour.service.d.ts +16 -0
- package/lib/core/payment/payment-behaviour/strategies/apple-pay-with-shipping-address/apple-pay-with-shipping-address.strategy.d.ts +10 -0
- package/lib/core/payment/payment-behaviour/strategies/behaviour-strategy.abstract.d.ts +15 -0
- package/lib/core/payment/payment.service.d.ts +10 -6
- package/lib/core/payment/{initialize → requests/initialize}/initialize-request-params.interface.d.ts +1 -1
- package/lib/core/payment/{initialize → requests/initialize}/initialize.service.d.ts +10 -10
- package/lib/core/payment/requests/initialize/is-initialize-response.function.d.ts +2 -0
- package/lib/core/payment/{initialize → requests/initialize}/response/initialize-response.class.d.ts +2 -2
- package/lib/core/payment/{submit/response → requests/submit}/is-submit-response.function.d.ts +1 -1
- package/lib/core/payment/{submit → requests/submit}/request/submit-request.class.d.ts +2 -2
- package/lib/core/payment/{submit → requests/submit}/response/submit-response.class.d.ts +4 -4
- package/lib/core/payment/{submit → requests/submit}/submit.service.d.ts +9 -9
- package/lib/core/payment/{sync → requests/sync}/field-async-validation.interface.d.ts +1 -1
- package/lib/core/payment/{sync → requests/sync}/request/sync-request.class.d.ts +2 -2
- package/lib/core/payment/{sync → requests/sync}/response/sync-response.class.d.ts +2 -2
- package/lib/core/payment/{sync → requests/sync}/sync.service.d.ts +14 -12
- package/lib/core/payment/status/check-status/check-status.service.d.ts +1 -1
- package/lib/core/payment/status/check-status/request/check-status-request.class.d.ts +1 -1
- package/lib/core/payment/status/status-request/request/status-request.class.d.ts +1 -1
- package/lib/core/payment/status/status-request/status-request.service.d.ts +1 -1
- package/lib/core/payment/three-ds/three-ds.service.d.ts +1 -1
- package/lib/core/payment/xps-finance.interface.d.ts +20 -0
- package/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.d.ts +21 -0
- package/lib/core/sdk-payment-systems/apple-pay/apple-pay-sdk.service.d.ts +24 -0
- package/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.d.ts +10 -3
- package/lib/core/sdk-payment-systems/apple-pay/session-handlers/apple-pay-session.interface.d.ts +17 -8
- package/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.d.ts +4 -2
- package/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.d.ts +4 -2
- package/lib/core/sdk-payment-systems/apple-pay/session-handlers/session-handler.abstract.d.ts +1 -1
- package/lib/core/sdk-payment-systems/apple-pay/shipping-address.interface.d.ts +4 -0
- package/lib/core/sdk-payment-systems/apple-pay/updated-price.interface.d.ts +7 -0
- package/lib/core/sdk-payment-systems/google-pay/check-payment-device-data.interface.d.ts +1 -1
- package/lib/core/sdk-payment-systems/sdk-payment-systems-initial-data.interface.d.ts +1 -1
- package/lib/core-library.module.d.ts +2 -1
- package/lib/core-library.service.d.ts +2 -2
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
- package/xsolla-payment-client-core-0.2.54.tgz +0 -0
- package/esm2022/lib/core/payment/form/converters/phone.converter.mjs +0 -39
- package/esm2022/lib/core/payment/initialize/initialize-request-params.interface.mjs +0 -2
- package/esm2022/lib/core/payment/initialize/initialize.service.mjs +0 -89
- package/esm2022/lib/core/payment/initialize/response/initialize-response.class.mjs +0 -43
- package/esm2022/lib/core/payment/initialize/response/initialize-response.token.mjs +0 -8
- package/esm2022/lib/core/payment/submit/request/submit-request.class.mjs +0 -36
- package/esm2022/lib/core/payment/submit/request/submit-request.token.mjs +0 -8
- package/esm2022/lib/core/payment/submit/response/submit-response.class.mjs +0 -35
- package/esm2022/lib/core/payment/submit/response/submit-response.token.mjs +0 -8
- package/esm2022/lib/core/payment/submit/response/xsolla-number.interface.mjs +0 -2
- package/esm2022/lib/core/payment/submit/submit.service.mjs +0 -82
- package/esm2022/lib/core/payment/sync/field-async-validation.interface.mjs +0 -2
- package/esm2022/lib/core/payment/sync/field-sync-state.interface.mjs +0 -2
- package/esm2022/lib/core/payment/sync/request/sync-request.class.mjs +0 -34
- package/esm2022/lib/core/payment/sync/request/sync-request.token.mjs +0 -8
- package/esm2022/lib/core/payment/sync/response/sync-response.class.mjs +0 -17
- package/esm2022/lib/core/payment/sync/response/sync-response.token.mjs +0 -8
- package/esm2022/lib/core/payment/sync/sync.service.mjs +0 -164
- package/esm2022/lib/core/payment/xps-api-part-request.abstract.mjs +0 -13
- package/esm2022/lib/core/payment/xps-api-part.abstract.mjs +0 -19
- package/xsolla-payment-client-core-0.2.52.tgz +0 -0
- /package/lib/core/payment/{initialize → requests/initialize}/response/initialize-response.token.d.ts +0 -0
- /package/lib/core/payment/{submit → requests/submit}/request/submit-request.token.d.ts +0 -0
- /package/lib/core/payment/{submit → requests/submit}/response/submit-response.token.d.ts +0 -0
- /package/lib/core/payment/{submit → requests/submit}/response/xsolla-number.interface.d.ts +0 -0
- /package/lib/core/payment/{sync → requests/sync}/field-sync-state.interface.d.ts +0 -0
- /package/lib/core/payment/{sync → requests/sync}/request/sync-request.token.d.ts +0 -0
- /package/lib/core/payment/{sync → requests/sync}/response/sync-response.token.d.ts +0 -0
- /package/lib/core/payment/{xps-api-part-request.abstract.d.ts → xps-api/xps-api-part-request.abstract.d.ts} +0 -0
- /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
|
-
|
|
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,17 +8241,71 @@ 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) {
|
|
8132
8306
|
this.paymentClient = client;
|
|
8133
8307
|
}
|
|
8134
|
-
startSession(params, additionalParams) {
|
|
8308
|
+
startSession(params, additionalParams, applePayFinallyCallback) {
|
|
8135
8309
|
if (!this.paymentClient) {
|
|
8136
8310
|
console.error(ApplePayErrors.braintreeInitializeError);
|
|
8137
8311
|
this.elkLoggerService.log(ApplePayErrors.braintreeInitializeError, [
|
|
@@ -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,
|
|
@@ -8160,6 +8353,7 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
|
|
|
8160
8353
|
.catch((error) => {
|
|
8161
8354
|
console.error(ApplePayErrors.merchantValidationError, error);
|
|
8162
8355
|
session.abort();
|
|
8356
|
+
applePayFinallyCallback();
|
|
8163
8357
|
});
|
|
8164
8358
|
};
|
|
8165
8359
|
session.onpaymentauthorized = (event) => {
|
|
@@ -8170,21 +8364,25 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
|
|
|
8170
8364
|
token: response?.nonce ?? '',
|
|
8171
8365
|
email: event.payment.billingContact?.emailAddress ?? null,
|
|
8172
8366
|
postalCode: event.payment.billingContact?.postalCode ?? null,
|
|
8367
|
+
shippingEmail: event.payment.shippingContact?.emailAddress ?? null,
|
|
8173
8368
|
}));
|
|
8174
8369
|
session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
|
|
8370
|
+
applePayFinallyCallback();
|
|
8175
8371
|
})
|
|
8176
8372
|
.catch((error) => {
|
|
8177
8373
|
console.error('Apple Pay: Tokenization error', error);
|
|
8178
8374
|
session.completePayment(this.window.ApplePaySession.STATUS_FAILURE);
|
|
8375
|
+
applePayFinallyCallback();
|
|
8179
8376
|
});
|
|
8180
8377
|
};
|
|
8181
8378
|
session.oncancel = (event) => {
|
|
8182
8379
|
console.error(ApplePayErrors.cancelled, event);
|
|
8183
8380
|
this.emitError(ApplePayErrors.cancelled);
|
|
8381
|
+
applePayFinallyCallback();
|
|
8184
8382
|
};
|
|
8185
8383
|
session.begin();
|
|
8186
8384
|
}
|
|
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 }); }
|
|
8385
|
+
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
8386
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler }); }
|
|
8189
8387
|
}
|
|
8190
8388
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: BraintreeHandler, decorators: [{
|
|
@@ -8192,17 +8390,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
8192
8390
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
8193
8391
|
type: Inject,
|
|
8194
8392
|
args: [windowToken]
|
|
8195
|
-
}] }, { type: ElkLoggerService }] });
|
|
8393
|
+
}] }, { type: ElkLoggerService }, { type: ApplePayCartService }] });
|
|
8196
8394
|
|
|
8197
8395
|
class CheckoutHandler extends ApplePaySessionHandlerAbstract {
|
|
8198
|
-
constructor(window, http) {
|
|
8396
|
+
constructor(window, http, applePayCartService) {
|
|
8199
8397
|
super();
|
|
8200
8398
|
this.window = window;
|
|
8201
8399
|
this.http = http;
|
|
8400
|
+
this.applePayCartService = applePayCartService;
|
|
8202
8401
|
}
|
|
8203
|
-
startSession(params, additionalParams) {
|
|
8402
|
+
startSession(params, additionalParams, applePayFinallyCallback) {
|
|
8204
8403
|
const request = this.buildPaymentRequest(params);
|
|
8205
8404
|
const session = new this.window.ApplePaySession(applePayVersion, request);
|
|
8405
|
+
session.onshippingcontactselected = (event) => {
|
|
8406
|
+
this.applePayCartService.cartSuccessfulRecalculated$
|
|
8407
|
+
.pipe(take(1))
|
|
8408
|
+
.subscribe((updatedPrice) => {
|
|
8409
|
+
const contactUpdate = this.applePayCartService.buildShippingContactUpdate(params, updatedPrice);
|
|
8410
|
+
session.completeShippingContactSelection(contactUpdate);
|
|
8411
|
+
});
|
|
8412
|
+
this.applePayCartService.cartErrorRecalculated$.subscribe((error) => {
|
|
8413
|
+
session.completeShippingContactSelection({
|
|
8414
|
+
errors: [error],
|
|
8415
|
+
newTotal: {
|
|
8416
|
+
label: params.totalLabel,
|
|
8417
|
+
amount: params.totalAmount?.toString(),
|
|
8418
|
+
},
|
|
8419
|
+
status: 'STATUS_FAILURE',
|
|
8420
|
+
});
|
|
8421
|
+
});
|
|
8422
|
+
this.applePayCartService.recalculateCartTaxes(event.shippingContact);
|
|
8423
|
+
};
|
|
8206
8424
|
session.onvalidatemerchant = (event) => {
|
|
8207
8425
|
const validationParams = {
|
|
8208
8426
|
validationURL: event.validationURL,
|
|
@@ -8225,6 +8443,7 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
|
|
|
8225
8443
|
error: (error) => {
|
|
8226
8444
|
console.error(ApplePayErrors.merchantValidationError, error);
|
|
8227
8445
|
session.abort();
|
|
8446
|
+
applePayFinallyCallback();
|
|
8228
8447
|
},
|
|
8229
8448
|
});
|
|
8230
8449
|
};
|
|
@@ -8233,16 +8452,19 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
|
|
|
8233
8452
|
token: event.payment.token ?? '',
|
|
8234
8453
|
email: event.payment.billingContact?.emailAddress ?? null,
|
|
8235
8454
|
postalCode: event.payment.billingContact?.postalCode ?? null,
|
|
8455
|
+
shippingEmail: event.payment.shippingContact?.emailAddress ?? null,
|
|
8236
8456
|
}));
|
|
8237
8457
|
session.completePayment(this.window.ApplePaySession.STATUS_SUCCESS);
|
|
8458
|
+
applePayFinallyCallback();
|
|
8238
8459
|
};
|
|
8239
8460
|
session.oncancel = (event) => {
|
|
8240
8461
|
console.error(ApplePayErrors.cancelled, event);
|
|
8241
8462
|
this.emitError(ApplePayErrors.cancelled);
|
|
8463
|
+
applePayFinallyCallback();
|
|
8242
8464
|
};
|
|
8243
8465
|
session.begin();
|
|
8244
8466
|
}
|
|
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 }); }
|
|
8467
|
+
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
8468
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler }); }
|
|
8247
8469
|
}
|
|
8248
8470
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CheckoutHandler, decorators: [{
|
|
@@ -8250,11 +8472,39 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
8250
8472
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
8251
8473
|
type: Inject,
|
|
8252
8474
|
args: [windowToken]
|
|
8253
|
-
}] }, { type: i1.HttpClient }] });
|
|
8475
|
+
}] }, { type: i1.HttpClient }, { type: ApplePayCartService }] });
|
|
8476
|
+
|
|
8477
|
+
class PaymentBehaviourModule {
|
|
8478
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
8479
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourModule, imports: [CommonModule] }); }
|
|
8480
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourModule, providers: [
|
|
8481
|
+
PaymentBehaviourService,
|
|
8482
|
+
{
|
|
8483
|
+
provide: behaviourStrategiesToken,
|
|
8484
|
+
useValue: behaviourStrategies,
|
|
8485
|
+
},
|
|
8486
|
+
...behaviourStrategies,
|
|
8487
|
+
], imports: [CommonModule] }); }
|
|
8488
|
+
}
|
|
8489
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentBehaviourModule, decorators: [{
|
|
8490
|
+
type: NgModule,
|
|
8491
|
+
args: [{
|
|
8492
|
+
declarations: [],
|
|
8493
|
+
imports: [CommonModule],
|
|
8494
|
+
providers: [
|
|
8495
|
+
PaymentBehaviourService,
|
|
8496
|
+
{
|
|
8497
|
+
provide: behaviourStrategiesToken,
|
|
8498
|
+
useValue: behaviourStrategies,
|
|
8499
|
+
},
|
|
8500
|
+
...behaviourStrategies,
|
|
8501
|
+
],
|
|
8502
|
+
}]
|
|
8503
|
+
}] });
|
|
8254
8504
|
|
|
8255
8505
|
class CoreLibraryModule {
|
|
8256
8506
|
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] }); }
|
|
8507
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: CoreLibraryModule, imports: [HttpClientModule, FormModule, PipesModule, PaymentBehaviourModule] }); }
|
|
8258
8508
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CoreLibraryModule, providers: [
|
|
8259
8509
|
{
|
|
8260
8510
|
provide: HTTP_INTERCEPTORS,
|
|
@@ -8293,12 +8543,12 @@ class CoreLibraryModule {
|
|
|
8293
8543
|
sendInstructionStatusResponseFactoryProvider,
|
|
8294
8544
|
BraintreeHandler,
|
|
8295
8545
|
CheckoutHandler,
|
|
8296
|
-
], imports: [HttpClientModule, FormModule, PipesModule] }); }
|
|
8546
|
+
], imports: [HttpClientModule, FormModule, PipesModule, PaymentBehaviourModule] }); }
|
|
8297
8547
|
}
|
|
8298
8548
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CoreLibraryModule, decorators: [{
|
|
8299
8549
|
type: NgModule,
|
|
8300
8550
|
args: [{
|
|
8301
|
-
imports: [HttpClientModule, FormModule, PipesModule],
|
|
8551
|
+
imports: [HttpClientModule, FormModule, PipesModule, PaymentBehaviourModule],
|
|
8302
8552
|
providers: [
|
|
8303
8553
|
{
|
|
8304
8554
|
provide: HTTP_INTERCEPTORS,
|
|
@@ -8903,6 +9153,95 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
8903
9153
|
}]
|
|
8904
9154
|
}] });
|
|
8905
9155
|
|
|
9156
|
+
class ApplePaySdkService {
|
|
9157
|
+
constructor(window, loggerService) {
|
|
9158
|
+
this.window = window;
|
|
9159
|
+
this.loggerService = loggerService;
|
|
9160
|
+
this.sdkLoaded = false;
|
|
9161
|
+
this.jsSdk = 'https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js';
|
|
9162
|
+
this.sdkSuccessfulPayment = new Subject();
|
|
9163
|
+
this.windowClosing = new Subject();
|
|
9164
|
+
this.successPaymentType = 'successClose';
|
|
9165
|
+
this.windowClosingType = 'windowclosing';
|
|
9166
|
+
this.needToAddApplePayJs = !this.window.ApplePaySession;
|
|
9167
|
+
}
|
|
9168
|
+
get windowClosing$() {
|
|
9169
|
+
return this.windowClosing.asObservable();
|
|
9170
|
+
}
|
|
9171
|
+
emitWindowClosing() {
|
|
9172
|
+
return this.windowClosing.next();
|
|
9173
|
+
}
|
|
9174
|
+
addApplePaySdkJs() {
|
|
9175
|
+
const isApplePayJsAdded = this.isAppleSdkExist();
|
|
9176
|
+
if (!this.needToAddApplePayJs) {
|
|
9177
|
+
if (isApplePayJsAdded) {
|
|
9178
|
+
this.sdkLoaded = true;
|
|
9179
|
+
}
|
|
9180
|
+
return;
|
|
9181
|
+
}
|
|
9182
|
+
const listenApplePayPostMessages = () => {
|
|
9183
|
+
this.applePaySdkPostMessagesListener = (event) => {
|
|
9184
|
+
/* istanbul ignore if */
|
|
9185
|
+
if (!event.origin.includes('apple')) {
|
|
9186
|
+
return;
|
|
9187
|
+
}
|
|
9188
|
+
/* istanbul ignore if */
|
|
9189
|
+
if (event.data.messageType === this.windowClosingType) {
|
|
9190
|
+
this.emitWindowClosing();
|
|
9191
|
+
}
|
|
9192
|
+
/* istanbul ignore if */
|
|
9193
|
+
if (event.data.messageType === this.successPaymentType) {
|
|
9194
|
+
this.sdkSuccessfulPayment.next();
|
|
9195
|
+
}
|
|
9196
|
+
};
|
|
9197
|
+
this.window.addEventListener('message', this.applePaySdkPostMessagesListener);
|
|
9198
|
+
};
|
|
9199
|
+
if (isApplePayJsAdded && this.window.ApplePaySession) {
|
|
9200
|
+
this.sdkLoaded = true;
|
|
9201
|
+
listenApplePayPostMessages();
|
|
9202
|
+
return;
|
|
9203
|
+
}
|
|
9204
|
+
const firstScriptElement = this.window.document.getElementsByTagName('script')[0];
|
|
9205
|
+
const script = this.window.document.createElement('script');
|
|
9206
|
+
script.async = true;
|
|
9207
|
+
script.crossOrigin = 'anonymous';
|
|
9208
|
+
script.src = `${this.jsSdk}`;
|
|
9209
|
+
firstScriptElement?.parentNode?.insertBefore(script, firstScriptElement);
|
|
9210
|
+
script.onload = () => {
|
|
9211
|
+
this.sdkLoaded = true;
|
|
9212
|
+
listenApplePayPostMessages();
|
|
9213
|
+
};
|
|
9214
|
+
script.onerror = (error) => {
|
|
9215
|
+
this.loggerService.log('Apple pay: script sdk loading error', [ErrorTags.APPLEPAY],
|
|
9216
|
+
// @ts-expect-error error type
|
|
9217
|
+
{ error: error?.message ? error.toString() : JSON.stringify(error) });
|
|
9218
|
+
console.error('Apple pay: script sdk loading error', error);
|
|
9219
|
+
};
|
|
9220
|
+
}
|
|
9221
|
+
/* istanbul ignore next */
|
|
9222
|
+
removeListeners() {
|
|
9223
|
+
if (!this.applePaySdkPostMessagesListener) {
|
|
9224
|
+
return;
|
|
9225
|
+
}
|
|
9226
|
+
this.window.removeEventListener('message', this.applePaySdkPostMessagesListener);
|
|
9227
|
+
}
|
|
9228
|
+
isAppleSdkExist() {
|
|
9229
|
+
const scriptsElements = this.window.document.querySelectorAll('script');
|
|
9230
|
+
return Array.from(scriptsElements).some((element) => element.src === this.jsSdk);
|
|
9231
|
+
}
|
|
9232
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePaySdkService, deps: [{ token: windowToken }, { token: ElkLoggerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
9233
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePaySdkService, providedIn: 'root' }); }
|
|
9234
|
+
}
|
|
9235
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePaySdkService, decorators: [{
|
|
9236
|
+
type: Injectable,
|
|
9237
|
+
args: [{
|
|
9238
|
+
providedIn: 'root',
|
|
9239
|
+
}]
|
|
9240
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
9241
|
+
type: Inject,
|
|
9242
|
+
args: [windowToken]
|
|
9243
|
+
}] }, { type: ElkLoggerService }] });
|
|
9244
|
+
|
|
8906
9245
|
class ApplePayService {
|
|
8907
9246
|
get paymentParameters() {
|
|
8908
9247
|
return this.applePayParams;
|
|
@@ -8913,26 +9252,43 @@ class ApplePayService {
|
|
|
8913
9252
|
get error$() {
|
|
8914
9253
|
return this.error.asObservable();
|
|
8915
9254
|
}
|
|
9255
|
+
/* istanbul ignore next */
|
|
9256
|
+
get applePayQrOpened$() {
|
|
9257
|
+
return this.applePayQrOpened.asObservable();
|
|
9258
|
+
}
|
|
9259
|
+
/* istanbul ignore next */
|
|
9260
|
+
get windowClosing$() {
|
|
9261
|
+
return this.applePaySdkService.windowClosing$;
|
|
9262
|
+
}
|
|
8916
9263
|
get integrationType$() {
|
|
8917
9264
|
return this.integrationType.asObservable();
|
|
8918
9265
|
}
|
|
8919
|
-
constructor(window,
|
|
9266
|
+
constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, elkLoggerService, applePaySdkService) {
|
|
8920
9267
|
this.window = window;
|
|
8921
|
-
this.userAgentService = userAgentService;
|
|
8922
9268
|
this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
|
|
8923
9269
|
this.braintreeHandler = braintreeHandler;
|
|
8924
9270
|
this.checkoutHandler = checkoutHandler;
|
|
8925
9271
|
this.appleParamsBuilder = appleParamsBuilder;
|
|
8926
9272
|
this.elkLoggerService = elkLoggerService;
|
|
9273
|
+
this.applePaySdkService = applePaySdkService;
|
|
8927
9274
|
this.payment = new Subject();
|
|
8928
9275
|
this.error = new Subject();
|
|
8929
9276
|
this.integrationType = new Subject();
|
|
9277
|
+
this.applePayQrOpened = new Subject();
|
|
8930
9278
|
this.paymentClient = null;
|
|
8931
9279
|
this.applePayParams = null;
|
|
8932
9280
|
this.order = null;
|
|
8933
9281
|
this.api = this.loadBraintree();
|
|
8934
9282
|
this.subscribeToHandlers();
|
|
8935
9283
|
}
|
|
9284
|
+
/* istanbul ignore next */
|
|
9285
|
+
addApplePaySdkJs() {
|
|
9286
|
+
this.applePaySdkService.addApplePaySdkJs();
|
|
9287
|
+
}
|
|
9288
|
+
/* istanbul ignore next */
|
|
9289
|
+
removeListeners() {
|
|
9290
|
+
this.applePaySdkService.removeListeners();
|
|
9291
|
+
}
|
|
8936
9292
|
setApplePayParams(data) {
|
|
8937
9293
|
const paymentForm = data?.paymentForm;
|
|
8938
9294
|
const formFields = paymentForm?.fields;
|
|
@@ -9006,8 +9362,9 @@ class ApplePayService {
|
|
|
9006
9362
|
}
|
|
9007
9363
|
}
|
|
9008
9364
|
get isDeviceCapable() {
|
|
9009
|
-
if (
|
|
9010
|
-
return
|
|
9365
|
+
if (this.applePaySdkService.needToAddApplePayJs) {
|
|
9366
|
+
return true;
|
|
9367
|
+
}
|
|
9011
9368
|
try {
|
|
9012
9369
|
return Boolean(this.window.ApplePaySession?.supportsVersion(applePayVersion) &&
|
|
9013
9370
|
this.window.ApplePaySession?.canMakePayments());
|
|
@@ -9034,7 +9391,8 @@ class ApplePayService {
|
|
|
9034
9391
|
console.error('Apple Pay: Unsupported acquirer:', parameters.acquirer);
|
|
9035
9392
|
return;
|
|
9036
9393
|
}
|
|
9037
|
-
sessionHandler.startSession(parameters, additionalParams);
|
|
9394
|
+
sessionHandler.startSession(parameters, additionalParams, () => this.applePaySdkService.emitWindowClosing());
|
|
9395
|
+
this.emitApplePayOpened();
|
|
9038
9396
|
}
|
|
9039
9397
|
getSessionHandler(acquirer) {
|
|
9040
9398
|
switch (acquirer) {
|
|
@@ -9054,10 +9412,7 @@ class ApplePayService {
|
|
|
9054
9412
|
this.error.next(error);
|
|
9055
9413
|
}
|
|
9056
9414
|
emitIntegrationType() {
|
|
9057
|
-
|
|
9058
|
-
? ApplePayIntegrationType.native
|
|
9059
|
-
: ApplePayIntegrationType.redirect;
|
|
9060
|
-
this.integrationType.next(integration);
|
|
9415
|
+
this.integrationType.next(this.getIntegrationType());
|
|
9061
9416
|
}
|
|
9062
9417
|
subscribeToHandlers() {
|
|
9063
9418
|
const handlers = [this.braintreeHandler, this.checkoutHandler];
|
|
@@ -9068,7 +9423,19 @@ class ApplePayService {
|
|
|
9068
9423
|
});
|
|
9069
9424
|
});
|
|
9070
9425
|
}
|
|
9071
|
-
|
|
9426
|
+
getIntegrationType() {
|
|
9427
|
+
/* istanbul ignore next */
|
|
9428
|
+
return this.isDeviceCapable
|
|
9429
|
+
? ApplePayIntegrationType.native
|
|
9430
|
+
: ApplePayIntegrationType.redirect;
|
|
9431
|
+
}
|
|
9432
|
+
emitApplePayOpened() {
|
|
9433
|
+
if (this.getIntegrationType() === ApplePayIntegrationType.native &&
|
|
9434
|
+
this.applePaySdkService.needToAddApplePayJs) {
|
|
9435
|
+
this.applePayQrOpened.next();
|
|
9436
|
+
}
|
|
9437
|
+
}
|
|
9438
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, deps: [{ token: windowToken }, { token: SummaryFinanceDetailsAdapterService }, { token: BraintreeHandler }, { token: CheckoutHandler }, { token: ApplePayParamsBuilderService }, { token: ElkLoggerService }, { token: ApplePaySdkService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
9072
9439
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, providedIn: 'root' }); }
|
|
9073
9440
|
}
|
|
9074
9441
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, decorators: [{
|
|
@@ -9079,7 +9446,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
9079
9446
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
9080
9447
|
type: Inject,
|
|
9081
9448
|
args: [windowToken]
|
|
9082
|
-
}] }, { type:
|
|
9449
|
+
}] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: ElkLoggerService }, { type: ApplePaySdkService }] });
|
|
9083
9450
|
|
|
9084
9451
|
/*
|
|
9085
9452
|
* Public API Surface of core-library
|
|
@@ -9089,5 +9456,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
9089
9456
|
* Generated bundle index. Do not edit.
|
|
9090
9457
|
*/
|
|
9091
9458
|
|
|
9092
|
-
export { ApplePayService, CoreLibraryModule, CoreLibraryService, CreditCardTypes, FieldNames, GooglePayService, PaymentSystemProcessingService, userBehaviourEventTypes };
|
|
9459
|
+
export { ApplePayCartService, ApplePayService, CoreLibraryModule, CoreLibraryService, CreditCardTypes, FieldNames, GooglePayService, PaymentSystemProcessingService, userBehaviourEventTypes };
|
|
9093
9460
|
//# sourceMappingURL=xsolla-payment-client-core.mjs.map
|