@xsolla/payment-client-core 0.2.57 → 0.2.59
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 +20 -12
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.mjs +41 -35
- 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 +150 -137
- 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 +6 -4
- package/lib/core/sdk-payment-systems/apple-pay/apple-pay.service.d.ts +19 -3
- 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.59.tgz +0 -0
- package/xsolla-payment-client-core-0.2.57.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,8 @@ class ApplePayCartService {
|
|
|
8344
8251
|
get cartRecalculationRequest$() {
|
|
8345
8252
|
return this.cartRecalculationRequest.asObservable();
|
|
8346
8253
|
}
|
|
8347
|
-
constructor(
|
|
8348
|
-
this.
|
|
8254
|
+
constructor(summaryFinanceDetailsAdapterService) {
|
|
8255
|
+
this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
|
|
8349
8256
|
this.cartSuccessfulRecalculated = new Subject();
|
|
8350
8257
|
this.cartErrorRecalculated = new Subject();
|
|
8351
8258
|
this.cartRecalculationRequest = new Subject();
|
|
@@ -8369,11 +8276,16 @@ class ApplePayCartService {
|
|
|
8369
8276
|
newLineItems: this.getLineItems(updatedPrice),
|
|
8370
8277
|
};
|
|
8371
8278
|
}
|
|
8372
|
-
sendSuccessfulRecalculatedCart(
|
|
8279
|
+
sendSuccessfulRecalculatedCart(xpsResponse) {
|
|
8280
|
+
const financeDetails = this.summaryFinanceDetailsAdapterService.getFinanceDetails(xpsResponse.summary);
|
|
8281
|
+
const updatedPrice = {
|
|
8282
|
+
// @ts-expect-error finance exist
|
|
8283
|
+
total: this.getTotalAmount(xpsResponse.summary.finance),
|
|
8284
|
+
subtotalDetails: financeDetails.cartSummary.subtotalDetails,
|
|
8285
|
+
totalDetails: financeDetails.cartSummary.totalDetails,
|
|
8286
|
+
subtotalPayment: financeDetails.cartSummary.subtotalPayment,
|
|
8287
|
+
};
|
|
8373
8288
|
this.cartSuccessfulRecalculated.next(updatedPrice);
|
|
8374
|
-
void this.externalWindowCommunicationService.sendMessageToAnotherWindow("apple-pay-update-price" /* CommandsForPages.APPLE_PAY_UPDATE_PRICE */, {
|
|
8375
|
-
newCartPricing: updatedPrice,
|
|
8376
|
-
});
|
|
8377
8289
|
}
|
|
8378
8290
|
sendErrorRecalculatedCart(error) {
|
|
8379
8291
|
this.cartErrorRecalculated.next(error);
|
|
@@ -8407,7 +8319,10 @@ class ApplePayCartService {
|
|
|
8407
8319
|
});
|
|
8408
8320
|
return newLineItems;
|
|
8409
8321
|
}
|
|
8410
|
-
|
|
8322
|
+
getTotalAmount(finance) {
|
|
8323
|
+
return finance?.grand_total?.amount ?? finance?.total?.amount;
|
|
8324
|
+
}
|
|
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 }); }
|
|
8411
8326
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, providedIn: 'root' }); }
|
|
8412
8327
|
}
|
|
8413
8328
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayCartService, decorators: [{
|
|
@@ -8415,7 +8330,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
8415
8330
|
args: [{
|
|
8416
8331
|
providedIn: 'root',
|
|
8417
8332
|
}]
|
|
8418
|
-
}], ctorParameters: () => [{ type:
|
|
8333
|
+
}], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }] });
|
|
8419
8334
|
|
|
8420
8335
|
class BraintreeHandler extends ApplePaySessionHandlerAbstract {
|
|
8421
8336
|
constructor(window, elkLoggerService, applePayCartService) {
|
|
@@ -9374,6 +9289,99 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
9374
9289
|
args: [windowToken]
|
|
9375
9290
|
}] }, { type: ElkLoggerService }] });
|
|
9376
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
|
+
|
|
9377
9385
|
class ApplePayService {
|
|
9378
9386
|
get paymentParameters() {
|
|
9379
9387
|
return this.applePayParams;
|
|
@@ -9395,7 +9403,27 @@ class ApplePayService {
|
|
|
9395
9403
|
get integrationType$() {
|
|
9396
9404
|
return this.integrationType.asObservable();
|
|
9397
9405
|
}
|
|
9398
|
-
|
|
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, applePayCartService, settingsService) {
|
|
9399
9427
|
this.window = window;
|
|
9400
9428
|
this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
|
|
9401
9429
|
this.braintreeHandler = braintreeHandler;
|
|
@@ -9405,6 +9433,7 @@ class ApplePayService {
|
|
|
9405
9433
|
this.applePaySdkService = applePaySdkService;
|
|
9406
9434
|
this.externalWindowCommunicationService = externalWindowCommunicationService;
|
|
9407
9435
|
this.applePayCartService = applePayCartService;
|
|
9436
|
+
this.settingsService = settingsService;
|
|
9408
9437
|
this.payment = new Subject();
|
|
9409
9438
|
this.error = new Subject();
|
|
9410
9439
|
this.integrationType = new Subject();
|
|
@@ -9462,14 +9491,19 @@ class ApplePayService {
|
|
|
9462
9491
|
}
|
|
9463
9492
|
this.emitIntegrationType();
|
|
9464
9493
|
}
|
|
9465
|
-
async
|
|
9494
|
+
async startWindowCommunication() {
|
|
9495
|
+
await this.externalWindowCommunicationService.openWebSocketConnection(this.settingsService.token);
|
|
9496
|
+
}
|
|
9497
|
+
sendUpdatedPriceViaWindowCommunication(updatedPrice) {
|
|
9498
|
+
void this.externalWindowCommunicationService.sendMessageToAnotherWindow("apple-pay-update-price" /* CommandsForPages.APPLE_PAY_UPDATE_PRICE */, {
|
|
9499
|
+
newCartPricing: updatedPrice,
|
|
9500
|
+
});
|
|
9501
|
+
}
|
|
9502
|
+
redirectToPaymentPage(parameters, token, isSandbox) {
|
|
9466
9503
|
const route = pagesRoutes.get(applePayId);
|
|
9467
9504
|
if (!route) {
|
|
9468
9505
|
return;
|
|
9469
9506
|
}
|
|
9470
|
-
console.log('🟡[LOG] token :>>', token);
|
|
9471
|
-
await this.externalWindowCommunicationService.openWebSocketConnection(token);
|
|
9472
|
-
this.listenWebsocketMessages();
|
|
9473
9507
|
const query = new URLSearchParams({
|
|
9474
9508
|
...parameters,
|
|
9475
9509
|
merchantCapabilities: JSON.stringify(parameters.merchantCapabilities),
|
|
@@ -9534,6 +9568,12 @@ class ApplePayService {
|
|
|
9534
9568
|
sessionHandler.startSession(parameters, additionalParams, () => this.applePaySdkService.emitWindowClosing());
|
|
9535
9569
|
this.emitApplePayOpened();
|
|
9536
9570
|
}
|
|
9571
|
+
mapShippingAddressToContact(shippingAddress) {
|
|
9572
|
+
return mapShippingAddressToContact(shippingAddress);
|
|
9573
|
+
}
|
|
9574
|
+
setToken(token) {
|
|
9575
|
+
this.payment.next(token);
|
|
9576
|
+
}
|
|
9537
9577
|
getSessionHandler(acquirer) {
|
|
9538
9578
|
switch (acquirer) {
|
|
9539
9579
|
case 'braintree':
|
|
@@ -9575,34 +9615,7 @@ class ApplePayService {
|
|
|
9575
9615
|
this.applePayQrOpened.next();
|
|
9576
9616
|
}
|
|
9577
9617
|
}
|
|
9578
|
-
|
|
9579
|
-
// Cart recalculation
|
|
9580
|
-
this.externalWindowCommunicationService
|
|
9581
|
-
.getCartRecalculationMessage$()
|
|
9582
|
-
.pipe(takeUntil(this.destroy$))
|
|
9583
|
-
.subscribe((message) => {
|
|
9584
|
-
const shippingContact = mapShippingAddressToContact(message.data.shippingAddress);
|
|
9585
|
-
this.applePayCartService.recalculateCartTaxes(shippingContact);
|
|
9586
|
-
});
|
|
9587
|
-
// Send token
|
|
9588
|
-
this.externalWindowCommunicationService
|
|
9589
|
-
.getWindowSendTokenMessage$()
|
|
9590
|
-
.pipe(takeUntil(this.destroy$))
|
|
9591
|
-
.subscribe((message) => {
|
|
9592
|
-
this.payment.next(message.data.applePayToken);
|
|
9593
|
-
});
|
|
9594
|
-
// Close window
|
|
9595
|
-
this.externalWindowCommunicationService.getWindowClose$().subscribe(() => {
|
|
9596
|
-
// TODO handle
|
|
9597
|
-
});
|
|
9598
|
-
// Close window with 'back' button
|
|
9599
|
-
this.externalWindowCommunicationService
|
|
9600
|
-
.getWindowReturnMessage$()
|
|
9601
|
-
.subscribe(() => {
|
|
9602
|
-
// TODO handle
|
|
9603
|
-
});
|
|
9604
|
-
}
|
|
9605
|
-
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 }); }
|
|
9618
|
+
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 }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
9606
9619
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, providedIn: 'root' }); }
|
|
9607
9620
|
}
|
|
9608
9621
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ApplePayService, decorators: [{
|
|
@@ -9613,7 +9626,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
9613
9626
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
9614
9627
|
type: Inject,
|
|
9615
9628
|
args: [windowToken]
|
|
9616
|
-
}] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: ElkLoggerService }, { type: ApplePaySdkService }, { type: ApplePayExternalWindowCommunicationService }, { type: ApplePayCartService }] });
|
|
9629
|
+
}] }, { type: SummaryFinanceDetailsAdapterService }, { type: BraintreeHandler }, { type: CheckoutHandler }, { type: ApplePayParamsBuilderService }, { type: ElkLoggerService }, { type: ApplePaySdkService }, { type: ApplePayExternalWindowCommunicationService }, { type: ApplePayCartService }, { type: SettingsService }] });
|
|
9617
9630
|
|
|
9618
9631
|
/*
|
|
9619
9632
|
* Public API Surface of core-library
|