@xsolla/payment-client-core 0.2.58 → 0.2.60
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/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.mjs +7 -12
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.mjs +52 -46
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/external-window-communication/external-window-communication.service.mjs +1 -1
- package/fesm2022/xsolla-payment-client-core.mjs +148 -146
- package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/sdk-payment-systems/apple-pay/apple-pay-cart/apple-pay-cart.service.d.ts +1 -3
- package/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.d.ts +20 -6
- package/lib/core/sdk-payment-systems/apple-pay/external-window-communication/external-window-communication.service.d.ts +1 -1
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.2.60.tgz +0 -0
- package/xsolla-payment-client-core-0.2.58.tgz +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, Injectable, Inject, isDevMode, Pipe, NgModule } from '@angular/core';
|
|
3
|
-
import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, skip, take, of, interval, throwError } from 'rxjs';
|
|
3
|
+
import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, skip, take, of, interval, throwError, share } from 'rxjs';
|
|
4
4
|
import * as i1 from '@angular/common/http';
|
|
5
5
|
import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
6
6
|
import { UntypedFormGroup, Validators, UntypedFormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
|
@@ -8241,102 +8241,9 @@ class ApplePaySessionHandlerAbstract {
|
|
|
8241
8241
|
}
|
|
8242
8242
|
}
|
|
8243
8243
|
|
|
8244
|
-
class SocketBridgeService {
|
|
8245
|
-
constructor(secureApiClient) {
|
|
8246
|
-
this.secureApiClient = secureApiClient;
|
|
8247
|
-
this.apiUrl = 'socket_bridge';
|
|
8248
|
-
}
|
|
8249
|
-
async getBridgeConnectionChannel(token) {
|
|
8250
|
-
this.token = token;
|
|
8251
|
-
const params = new HttpParams().set('access_token', token);
|
|
8252
|
-
return firstValueFrom(this.secureApiClient.get(`${this.apiUrl}/socket_url`, {
|
|
8253
|
-
params,
|
|
8254
|
-
}));
|
|
8255
|
-
}
|
|
8256
|
-
async publishMessage(message, messagePayload) {
|
|
8257
|
-
const requestPayload = {
|
|
8258
|
-
message: {
|
|
8259
|
-
command: message,
|
|
8260
|
-
data: messagePayload,
|
|
8261
|
-
},
|
|
8262
|
-
};
|
|
8263
|
-
const endpointUrl = `${this.apiUrl}/message?access_token=${this.token}`;
|
|
8264
|
-
return firstValueFrom(this.secureApiClient.post(endpointUrl.toString(), requestPayload, {
|
|
8265
|
-
headers: new HttpHeaders().set('Content-Type', 'application/json; charset=utf-8'),
|
|
8266
|
-
responseType: 'json',
|
|
8267
|
-
}));
|
|
8268
|
-
}
|
|
8269
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SocketBridgeService, deps: [{ token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
8270
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SocketBridgeService, providedIn: 'root' }); }
|
|
8271
|
-
}
|
|
8272
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SocketBridgeService, decorators: [{
|
|
8273
|
-
type: Injectable,
|
|
8274
|
-
args: [{
|
|
8275
|
-
providedIn: 'root',
|
|
8276
|
-
}]
|
|
8277
|
-
}], ctorParameters: () => [{ type: SecureApiClient }] });
|
|
8278
|
-
|
|
8279
|
-
class ApplePayExternalWindowCommunicationService {
|
|
8280
|
-
constructor(window, webSocketFactory, socketBridgeService) {
|
|
8281
|
-
this.window = window;
|
|
8282
|
-
this.webSocketFactory = webSocketFactory;
|
|
8283
|
-
this.socketBridgeService = socketBridgeService;
|
|
8284
|
-
}
|
|
8285
|
-
getWindowClose$() {
|
|
8286
|
-
const isWindowCloseMessage = (message) => message.command === "apple-pay-window-close" /* CommandsForPages.APPLE_PAY_WINDOW_CLOSE */;
|
|
8287
|
-
const eventSource$ = this.getEventSource(isWindowCloseMessage);
|
|
8288
|
-
return eventSource$.pipe(tap(() => {
|
|
8289
|
-
this.window.focus();
|
|
8290
|
-
}));
|
|
8291
|
-
}
|
|
8292
|
-
getWindowReturnMessage$() {
|
|
8293
|
-
const isReturnMessage = (message) => message.command === "apple-pay-return" /* CommandsForPages.APPLE_PAY_RETURN */;
|
|
8294
|
-
const eventSource$ = this.getEventSource(isReturnMessage);
|
|
8295
|
-
return eventSource$.pipe(tap(() => {
|
|
8296
|
-
// TODO: send close event to sdk
|
|
8297
|
-
}));
|
|
8298
|
-
}
|
|
8299
|
-
getWindowSendTokenMessage$() {
|
|
8300
|
-
const isSendTokenMessage = (message) => message.command === "apple-pay-send-token" /* CommandsForPages.APPLE_PAY_SEND_TOKEN */;
|
|
8301
|
-
return this.getEventSource(isSendTokenMessage);
|
|
8302
|
-
}
|
|
8303
|
-
getCartRecalculationMessage$() {
|
|
8304
|
-
const isRecalculateCartMessage = (message) => message.command === "apple-pay-recalculate-cart" /* CommandsForPages.APPLE_PAY_RECALCULATE_CART */;
|
|
8305
|
-
return this.getEventSource(isRecalculateCartMessage);
|
|
8306
|
-
}
|
|
8307
|
-
async openWebSocketConnection(token) {
|
|
8308
|
-
const bridgeInfo = await this.socketBridgeService.getBridgeConnectionChannel(token);
|
|
8309
|
-
if (this.websocketClient) {
|
|
8310
|
-
this.websocketClient.close();
|
|
8311
|
-
}
|
|
8312
|
-
this.websocketClient = this.webSocketFactory.createWebSocketClient(bridgeInfo.subscribeUrl, bridgeInfo.clientType);
|
|
8313
|
-
await this.websocketClient.open(bridgeInfo.subscribeUrl, bridgeInfo.channelName);
|
|
8314
|
-
}
|
|
8315
|
-
async sendMessageToAnotherWindow(command, payload) {
|
|
8316
|
-
await this.socketBridgeService.publishMessage(command, payload);
|
|
8317
|
-
}
|
|
8318
|
-
getEventSource(eventHandler) {
|
|
8319
|
-
return this.websocketClient.messages$.pipe(map$1((message) => {
|
|
8320
|
-
console.info('websocket message', message);
|
|
8321
|
-
return JSON.parse(message);
|
|
8322
|
-
}), filter(eventHandler));
|
|
8323
|
-
}
|
|
8324
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, deps: [{ token: windowToken }, { token: WebSocketFactory }, { token: SocketBridgeService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
8325
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, providedIn: 'root' }); }
|
|
8326
|
-
}
|
|
8327
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, decorators: [{
|
|
8328
|
-
type: Injectable,
|
|
8329
|
-
args: [{
|
|
8330
|
-
providedIn: 'root',
|
|
8331
|
-
}]
|
|
8332
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
8333
|
-
type: Inject,
|
|
8334
|
-
args: [windowToken]
|
|
8335
|
-
}] }, { type: WebSocketFactory }, { type: SocketBridgeService }] });
|
|
8336
|
-
|
|
8337
8244
|
class ApplePayCartService {
|
|
8338
8245
|
get cartSuccessfulRecalculated$() {
|
|
8339
|
-
return this.cartSuccessfulRecalculated.asObservable();
|
|
8246
|
+
return this.cartSuccessfulRecalculated.asObservable().pipe(share());
|
|
8340
8247
|
}
|
|
8341
8248
|
get cartErrorRecalculated$() {
|
|
8342
8249
|
return this.cartErrorRecalculated.asObservable();
|
|
@@ -8344,8 +8251,7 @@ class ApplePayCartService {
|
|
|
8344
8251
|
get cartRecalculationRequest$() {
|
|
8345
8252
|
return this.cartRecalculationRequest.asObservable();
|
|
8346
8253
|
}
|
|
8347
|
-
constructor(
|
|
8348
|
-
this.externalWindowCommunicationService = externalWindowCommunicationService;
|
|
8254
|
+
constructor(summaryFinanceDetailsAdapterService) {
|
|
8349
8255
|
this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
|
|
8350
8256
|
this.cartSuccessfulRecalculated = new Subject();
|
|
8351
8257
|
this.cartErrorRecalculated = new Subject();
|
|
@@ -8380,9 +8286,6 @@ class ApplePayCartService {
|
|
|
8380
8286
|
subtotalPayment: financeDetails.cartSummary.subtotalPayment,
|
|
8381
8287
|
};
|
|
8382
8288
|
this.cartSuccessfulRecalculated.next(updatedPrice);
|
|
8383
|
-
void this.externalWindowCommunicationService.sendMessageToAnotherWindow("apple-pay-update-price" /* CommandsForPages.APPLE_PAY_UPDATE_PRICE */, {
|
|
8384
|
-
newCartPricing: updatedPrice,
|
|
8385
|
-
});
|
|
8386
8289
|
}
|
|
8387
8290
|
sendErrorRecalculatedCart(error) {
|
|
8388
8291
|
this.cartErrorRecalculated.next(error);
|
|
@@ -8419,7 +8322,7 @@ class ApplePayCartService {
|
|
|
8419
8322
|
getTotalAmount(finance) {
|
|
8420
8323
|
return finance?.grand_total?.amount ?? finance?.total?.amount;
|
|
8421
8324
|
}
|
|
8422
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, deps: [{ token:
|
|
8325
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, deps: [{ token: SummaryFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
8423
8326
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, providedIn: 'root' }); }
|
|
8424
8327
|
}
|
|
8425
8328
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, decorators: [{
|
|
@@ -8427,7 +8330,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
8427
8330
|
args: [{
|
|
8428
8331
|
providedIn: 'root',
|
|
8429
8332
|
}]
|
|
8430
|
-
}], ctorParameters: () => [{ type:
|
|
8333
|
+
}], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }] });
|
|
8431
8334
|
|
|
8432
8335
|
class BraintreeHandler extends ApplePaySessionHandlerAbstract {
|
|
8433
8336
|
constructor(window, elkLoggerService, applePayCartService) {
|
|
@@ -9386,6 +9289,99 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
9386
9289
|
args: [windowToken]
|
|
9387
9290
|
}] }, { type: ElkLoggerService }] });
|
|
9388
9291
|
|
|
9292
|
+
class SocketBridgeService {
|
|
9293
|
+
constructor(secureApiClient) {
|
|
9294
|
+
this.secureApiClient = secureApiClient;
|
|
9295
|
+
this.apiUrl = 'socket_bridge';
|
|
9296
|
+
}
|
|
9297
|
+
async getBridgeConnectionChannel(token) {
|
|
9298
|
+
this.token = token;
|
|
9299
|
+
const params = new HttpParams().set('access_token', token);
|
|
9300
|
+
return firstValueFrom(this.secureApiClient.get(`${this.apiUrl}/socket_url`, {
|
|
9301
|
+
params,
|
|
9302
|
+
}));
|
|
9303
|
+
}
|
|
9304
|
+
async publishMessage(message, messagePayload) {
|
|
9305
|
+
const requestPayload = {
|
|
9306
|
+
message: {
|
|
9307
|
+
command: message,
|
|
9308
|
+
data: messagePayload,
|
|
9309
|
+
},
|
|
9310
|
+
};
|
|
9311
|
+
const endpointUrl = `${this.apiUrl}/message?access_token=${this.token}`;
|
|
9312
|
+
return firstValueFrom(this.secureApiClient.post(endpointUrl.toString(), requestPayload, {
|
|
9313
|
+
headers: new HttpHeaders().set('Content-Type', 'application/json; charset=utf-8'),
|
|
9314
|
+
responseType: 'json',
|
|
9315
|
+
}));
|
|
9316
|
+
}
|
|
9317
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SocketBridgeService, deps: [{ token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
9318
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SocketBridgeService, providedIn: 'root' }); }
|
|
9319
|
+
}
|
|
9320
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SocketBridgeService, decorators: [{
|
|
9321
|
+
type: Injectable,
|
|
9322
|
+
args: [{
|
|
9323
|
+
providedIn: 'root',
|
|
9324
|
+
}]
|
|
9325
|
+
}], ctorParameters: () => [{ type: SecureApiClient }] });
|
|
9326
|
+
|
|
9327
|
+
class ApplePayExternalWindowCommunicationService {
|
|
9328
|
+
constructor(window, webSocketFactory, socketBridgeService) {
|
|
9329
|
+
this.window = window;
|
|
9330
|
+
this.webSocketFactory = webSocketFactory;
|
|
9331
|
+
this.socketBridgeService = socketBridgeService;
|
|
9332
|
+
}
|
|
9333
|
+
getWindowClose$() {
|
|
9334
|
+
const isWindowCloseMessage = (message) => message.command === "apple-pay-window-close" /* CommandsForPages.APPLE_PAY_WINDOW_CLOSE */;
|
|
9335
|
+
const eventSource$ = this.getEventSource(isWindowCloseMessage);
|
|
9336
|
+
return eventSource$.pipe(tap(() => {
|
|
9337
|
+
this.window.focus();
|
|
9338
|
+
}));
|
|
9339
|
+
}
|
|
9340
|
+
getWindowReturnMessage$() {
|
|
9341
|
+
const isReturnMessage = (message) => message.command === "apple-pay-return" /* CommandsForPages.APPLE_PAY_RETURN */;
|
|
9342
|
+
const eventSource$ = this.getEventSource(isReturnMessage);
|
|
9343
|
+
return eventSource$.pipe(tap(() => {
|
|
9344
|
+
// TODO: send close event to sdk
|
|
9345
|
+
}));
|
|
9346
|
+
}
|
|
9347
|
+
getWindowSendTokenMessage$() {
|
|
9348
|
+
const isSendTokenMessage = (message) => message.command === "apple-pay-send-token" /* CommandsForPages.APPLE_PAY_SEND_TOKEN */;
|
|
9349
|
+
return this.getEventSource(isSendTokenMessage);
|
|
9350
|
+
}
|
|
9351
|
+
getCartRecalculationMessage$() {
|
|
9352
|
+
const isRecalculateCartMessage = (message) => message.command === "apple-pay-recalculate-cart" /* CommandsForPages.APPLE_PAY_RECALCULATE_CART */;
|
|
9353
|
+
return this.getEventSource(isRecalculateCartMessage);
|
|
9354
|
+
}
|
|
9355
|
+
async openWebSocketConnection(token) {
|
|
9356
|
+
const bridgeInfo = await this.socketBridgeService.getBridgeConnectionChannel(token);
|
|
9357
|
+
if (this.websocketClient) {
|
|
9358
|
+
this.websocketClient.close();
|
|
9359
|
+
}
|
|
9360
|
+
this.websocketClient = this.webSocketFactory.createWebSocketClient(bridgeInfo.subscribeUrl, bridgeInfo.clientType);
|
|
9361
|
+
await this.websocketClient.open(bridgeInfo.subscribeUrl, bridgeInfo.channelName);
|
|
9362
|
+
}
|
|
9363
|
+
async sendMessageToAnotherWindow(command, payload) {
|
|
9364
|
+
await this.socketBridgeService.publishMessage(command, payload);
|
|
9365
|
+
}
|
|
9366
|
+
getEventSource(eventHandler) {
|
|
9367
|
+
return this.websocketClient.messages$.pipe(map$1((message) => {
|
|
9368
|
+
console.info('websocket message', message);
|
|
9369
|
+
return JSON.parse(message);
|
|
9370
|
+
}), filter(eventHandler));
|
|
9371
|
+
}
|
|
9372
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, deps: [{ token: windowToken }, { token: WebSocketFactory }, { token: SocketBridgeService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
9373
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, providedIn: 'root' }); }
|
|
9374
|
+
}
|
|
9375
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayExternalWindowCommunicationService, decorators: [{
|
|
9376
|
+
type: Injectable,
|
|
9377
|
+
args: [{
|
|
9378
|
+
providedIn: 'root',
|
|
9379
|
+
}]
|
|
9380
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
9381
|
+
type: Inject,
|
|
9382
|
+
args: [windowToken]
|
|
9383
|
+
}] }, { type: WebSocketFactory }, { type: SocketBridgeService }] });
|
|
9384
|
+
|
|
9389
9385
|
class ApplePayService {
|
|
9390
9386
|
get paymentParameters() {
|
|
9391
9387
|
return this.applePayParams;
|
|
@@ -9407,7 +9403,27 @@ class ApplePayService {
|
|
|
9407
9403
|
get integrationType$() {
|
|
9408
9404
|
return this.integrationType.asObservable();
|
|
9409
9405
|
}
|
|
9410
|
-
|
|
9406
|
+
get getCartRecalculationMessage$() {
|
|
9407
|
+
return this.externalWindowCommunicationService
|
|
9408
|
+
.getCartRecalculationMessage$()
|
|
9409
|
+
.pipe(takeUntil(this.destroy$));
|
|
9410
|
+
}
|
|
9411
|
+
get getWindowSendTokenMessage$() {
|
|
9412
|
+
return this.externalWindowCommunicationService
|
|
9413
|
+
.getWindowSendTokenMessage$()
|
|
9414
|
+
.pipe(takeUntil(this.destroy$));
|
|
9415
|
+
}
|
|
9416
|
+
get getWindowClose$() {
|
|
9417
|
+
return this.externalWindowCommunicationService
|
|
9418
|
+
.getWindowClose$()
|
|
9419
|
+
.pipe(takeUntil(this.destroy$));
|
|
9420
|
+
}
|
|
9421
|
+
get getWindowReturnMessage$() {
|
|
9422
|
+
return this.externalWindowCommunicationService
|
|
9423
|
+
.getWindowReturnMessage$()
|
|
9424
|
+
.pipe(takeUntil(this.destroy$));
|
|
9425
|
+
}
|
|
9426
|
+
constructor(window, summaryFinanceDetailsAdapterService, braintreeHandler, checkoutHandler, appleParamsBuilder, elkLoggerService, applePaySdkService, externalWindowCommunicationService, settingsService) {
|
|
9411
9427
|
this.window = window;
|
|
9412
9428
|
this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
|
|
9413
9429
|
this.braintreeHandler = braintreeHandler;
|
|
@@ -9416,7 +9432,7 @@ class ApplePayService {
|
|
|
9416
9432
|
this.elkLoggerService = elkLoggerService;
|
|
9417
9433
|
this.applePaySdkService = applePaySdkService;
|
|
9418
9434
|
this.externalWindowCommunicationService = externalWindowCommunicationService;
|
|
9419
|
-
this.
|
|
9435
|
+
this.settingsService = settingsService;
|
|
9420
9436
|
this.payment = new Subject();
|
|
9421
9437
|
this.error = new Subject();
|
|
9422
9438
|
this.integrationType = new Subject();
|
|
@@ -9468,20 +9484,25 @@ class ApplePayService {
|
|
|
9468
9484
|
this.emitError(ApplePayErrors.deviceIsNotCapableError);
|
|
9469
9485
|
}
|
|
9470
9486
|
}
|
|
9471
|
-
async initApplePay(tokenKey) {
|
|
9487
|
+
async initApplePay(tokenKey, isApplePayInstantFlowEnabled) {
|
|
9472
9488
|
if (this.applePayParams?.acquirer === 'braintree') {
|
|
9473
9489
|
await this.initBraintreeLibrary(tokenKey);
|
|
9474
9490
|
}
|
|
9475
|
-
this.emitIntegrationType();
|
|
9491
|
+
this.emitIntegrationType(isApplePayInstantFlowEnabled);
|
|
9492
|
+
}
|
|
9493
|
+
async startWindowCommunication() {
|
|
9494
|
+
await this.externalWindowCommunicationService.openWebSocketConnection(this.settingsService.token);
|
|
9476
9495
|
}
|
|
9477
|
-
|
|
9496
|
+
sendUpdatedPriceViaWindowCommunication(updatedPrice) {
|
|
9497
|
+
void this.externalWindowCommunicationService.sendMessageToAnotherWindow("apple-pay-update-price" /* CommandsForPages.APPLE_PAY_UPDATE_PRICE */, {
|
|
9498
|
+
newCartPricing: updatedPrice,
|
|
9499
|
+
});
|
|
9500
|
+
}
|
|
9501
|
+
redirectToPaymentPage(parameters, token, isSandbox) {
|
|
9478
9502
|
const route = pagesRoutes.get(applePayId);
|
|
9479
9503
|
if (!route) {
|
|
9480
9504
|
return;
|
|
9481
9505
|
}
|
|
9482
|
-
console.log('🟡[LOG] token :>>', token);
|
|
9483
|
-
await this.externalWindowCommunicationService.openWebSocketConnection(token);
|
|
9484
|
-
this.listenWebsocketMessages();
|
|
9485
9506
|
const query = new URLSearchParams({
|
|
9486
9507
|
...parameters,
|
|
9487
9508
|
merchantCapabilities: JSON.stringify(parameters.merchantCapabilities),
|
|
@@ -9544,7 +9565,13 @@ class ApplePayService {
|
|
|
9544
9565
|
return;
|
|
9545
9566
|
}
|
|
9546
9567
|
sessionHandler.startSession(parameters, additionalParams, () => this.applePaySdkService.emitWindowClosing());
|
|
9547
|
-
this.emitApplePayOpened();
|
|
9568
|
+
this.emitApplePayOpened(additionalParams.isApplePayInstantFlowEnabled ?? false);
|
|
9569
|
+
}
|
|
9570
|
+
mapShippingAddressToContact(shippingAddress) {
|
|
9571
|
+
return mapShippingAddressToContact(shippingAddress);
|
|
9572
|
+
}
|
|
9573
|
+
setToken(token) {
|
|
9574
|
+
this.payment.next(token);
|
|
9548
9575
|
}
|
|
9549
9576
|
getSessionHandler(acquirer) {
|
|
9550
9577
|
switch (acquirer) {
|
|
@@ -9563,8 +9590,8 @@ class ApplePayService {
|
|
|
9563
9590
|
emitError(error) {
|
|
9564
9591
|
this.error.next(error);
|
|
9565
9592
|
}
|
|
9566
|
-
emitIntegrationType() {
|
|
9567
|
-
this.integrationType.next(this.getIntegrationType());
|
|
9593
|
+
emitIntegrationType(isApplePayInstantFlowEnabled) {
|
|
9594
|
+
this.integrationType.next(this.getIntegrationType(isApplePayInstantFlowEnabled));
|
|
9568
9595
|
}
|
|
9569
9596
|
subscribeToHandlers() {
|
|
9570
9597
|
const handlers = [this.braintreeHandler, this.checkoutHandler];
|
|
@@ -9575,46 +9602,21 @@ class ApplePayService {
|
|
|
9575
9602
|
});
|
|
9576
9603
|
});
|
|
9577
9604
|
}
|
|
9578
|
-
getIntegrationType() {
|
|
9605
|
+
getIntegrationType(isApplePayInstantFlowEnabled) {
|
|
9579
9606
|
/* istanbul ignore next */
|
|
9580
|
-
return this.isDeviceCapable
|
|
9607
|
+
return this.isDeviceCapable && isApplePayInstantFlowEnabled
|
|
9581
9608
|
? ApplePayIntegrationType.native
|
|
9582
9609
|
: ApplePayIntegrationType.redirect;
|
|
9583
9610
|
}
|
|
9584
|
-
emitApplePayOpened() {
|
|
9585
|
-
|
|
9611
|
+
emitApplePayOpened(isApplePayInstantFlowEnabled) {
|
|
9612
|
+
/* istanbul ignore next */
|
|
9613
|
+
if (this.getIntegrationType(isApplePayInstantFlowEnabled) ===
|
|
9614
|
+
ApplePayIntegrationType.native &&
|
|
9586
9615
|
this.applePaySdkService.needToAddApplePayJs) {
|
|
9587
9616
|
this.applePayQrOpened.next();
|
|
9588
9617
|
}
|
|
9589
9618
|
}
|
|
9590
|
-
|
|
9591
|
-
// Cart recalculation
|
|
9592
|
-
this.externalWindowCommunicationService
|
|
9593
|
-
.getCartRecalculationMessage$()
|
|
9594
|
-
.pipe(takeUntil(this.destroy$))
|
|
9595
|
-
.subscribe((message) => {
|
|
9596
|
-
const shippingContact = mapShippingAddressToContact(message.data.shippingAddress);
|
|
9597
|
-
this.applePayCartService.recalculateCartTaxes(shippingContact);
|
|
9598
|
-
});
|
|
9599
|
-
// Send token
|
|
9600
|
-
this.externalWindowCommunicationService
|
|
9601
|
-
.getWindowSendTokenMessage$()
|
|
9602
|
-
.pipe(takeUntil(this.destroy$))
|
|
9603
|
-
.subscribe((message) => {
|
|
9604
|
-
this.payment.next(message.data.applePayToken);
|
|
9605
|
-
});
|
|
9606
|
-
// Close window
|
|
9607
|
-
this.externalWindowCommunicationService.getWindowClose$().subscribe(() => {
|
|
9608
|
-
// TODO handle
|
|
9609
|
-
});
|
|
9610
|
-
// Close window with 'back' button
|
|
9611
|
-
this.externalWindowCommunicationService
|
|
9612
|
-
.getWindowReturnMessage$()
|
|
9613
|
-
.subscribe(() => {
|
|
9614
|
-
// TODO handle
|
|
9615
|
-
});
|
|
9616
|
-
}
|
|
9617
|
-
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 }, { token: ApplePayExternalWindowCommunicationService }, { token: ApplePayCartService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
9619
|
+
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 }, { token: ApplePayExternalWindowCommunicationService }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
9618
9620
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, providedIn: 'root' }); }
|
|
9619
9621
|
}
|
|
9620
9622
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, decorators: [{
|
|
@@ -9625,7 +9627,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
9625
9627
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
9626
9628
|
type: Inject,
|
|
9627
9629
|
args: [windowToken]
|
|
9628
|
-
}] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: ElkLoggerService }, { type: ApplePaySdkService }, { type: ApplePayExternalWindowCommunicationService }, { type:
|
|
9630
|
+
}] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: ElkLoggerService }, { type: ApplePaySdkService }, { type: ApplePayExternalWindowCommunicationService }, { type: SettingsService }] });
|
|
9629
9631
|
|
|
9630
9632
|
/*
|
|
9631
9633
|
* Public API Surface of core-library
|