diff --git a/integration-libs/opf/base/core/facade/opf-global-functions.service.ts b/integration-libs/opf/base/core/facade/opf-global-functions.service.ts index a82e5a7be9c..c341e977d49 100644 --- a/integration-libs/opf/base/core/facade/opf-global-functions.service.ts +++ b/integration-libs/opf/base/core/facade/opf-global-functions.service.ts @@ -169,6 +169,39 @@ export class OpfGlobalFunctionsService implements OpfGlobalFunctionsFacade { }; } + protected runSubmitComplete( + cartId: string, + additionalData: Array, + callbackArray: [MerchantCallback, MerchantCallback, MerchantCallback], + paymentSessionId: string, + returnPath?: string | undefined, + vcr?: ViewContainerRef + ) { + return this.ngZone.run(() => { + let overlayedSpinner: void | Observable | undefined>; + if (vcr) { + overlayedSpinner = this.startLoaderSpinner(vcr); + } + + return this.opfPaymentFacade + .submitCompletePayment({ + additionalData, + paymentSessionId, + cartId, + callbackArray, + returnPath, + }) + .pipe( + finalize(() => { + if (overlayedSpinner) { + this.stopLoaderSpinner(overlayedSpinner); + } + }) + ) + .toPromise(); + }); + } + protected registerSubmitComplete( paymentSessionId: string, vcr?: ViewContainerRef @@ -192,33 +225,14 @@ export class OpfGlobalFunctionsService implements OpfGlobalFunctionsFacade { submitPending: MerchantCallback; submitFailure: MerchantCallback; }): Promise => { - return this.ngZone.run(() => { - let overlayedSpinner: void | Observable | undefined>; - if (vcr) { - overlayedSpinner = this.startLoaderSpinner(vcr); - } - const callbackArray: [ - MerchantCallback, - MerchantCallback, - MerchantCallback - ] = [submitSuccess, submitPending, submitFailure]; - - return this.opfPaymentFacade - .submitCompletePayment({ - additionalData, - paymentSessionId, - cartId, - callbackArray, - }) - .pipe( - finalize(() => { - if (overlayedSpinner) { - this.stopLoaderSpinner(overlayedSpinner); - } - }) - ) - .toPromise(); - }); + return this.runSubmitComplete( + cartId, + additionalData, + [submitSuccess, submitPending, submitFailure], + paymentSessionId, + undefined, + vcr + ); }; } @@ -245,34 +259,14 @@ export class OpfGlobalFunctionsService implements OpfGlobalFunctionsFacade { submitPending: MerchantCallback; submitFailure: MerchantCallback; }): Promise => { - return this.ngZone.run(() => { - let overlayedSpinner: void | Observable | undefined>; - if (vcr) { - overlayedSpinner = this.startLoaderSpinner(vcr); - } - const callbackArray: [ - MerchantCallback, - MerchantCallback, - MerchantCallback - ] = [submitSuccess, submitPending, submitFailure]; - - return this.opfPaymentFacade - .submitCompletePayment({ - additionalData, - paymentSessionId, - cartId, - callbackArray, - returnPath: 'checkoutReviewOrder', - }) - .pipe( - finalize(() => { - if (overlayedSpinner) { - this.stopLoaderSpinner(overlayedSpinner); - } - }) - ) - .toPromise(); - }); + return this.runSubmitComplete( + cartId, + additionalData, + [submitSuccess, submitPending, submitFailure], + paymentSessionId, + 'checkoutReviewOrder', + vcr + ); }; } } diff --git a/integration-libs/opf/base/occ/adapters/occ-opf.adapter.ts b/integration-libs/opf/base/occ/adapters/occ-opf.adapter.ts index f1c26be7ff4..95bda4c1896 100644 --- a/integration-libs/opf/base/occ/adapters/occ-opf.adapter.ts +++ b/integration-libs/opf/base/occ/adapters/occ-opf.adapter.ts @@ -45,17 +45,25 @@ export class OccOpfPaymentAdapter implements OpfPaymentAdapter { protected config: OpfConfig ) {} - header: { [name: string]: string } = { + protected headerWithNoLanguage: { [name: string]: string } = { accept: 'application/json', 'Content-Type': 'application/json', + }; + protected header: { [name: string]: string } = { + ...this.headerWithNoLanguage, 'Accept-Language': 'en-us', }; + protected headerWithContentLanguage: { [name: string]: string } = { + ...this.headerWithNoLanguage, + 'Content-Language': 'en-us', + }; + verifyPayment( paymentSessionId: string, payload: OpfPaymentVerificationPayload ): Observable { - const headers = new HttpHeaders(this.header).set( + const headers = new HttpHeaders(this.headerWithNoLanguage).set( OPF_CC_PUBLIC_KEY, this.config.opf?.commerceCloudPublicKey || '' ); @@ -110,7 +118,7 @@ export class OccOpfPaymentAdapter implements OpfPaymentAdapter { otpKey: string, paymentSessionId: string ): Observable { - const headers = new HttpHeaders(this.header) + const headers = new HttpHeaders(this.headerWithContentLanguage) .set(OPF_CC_PUBLIC_KEY, this.config.opf?.commerceCloudPublicKey || '') .set(OPF_CC_OTP_KEY, otpKey || ''); diff --git a/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.component.spec.ts b/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.component.spec.ts index ea07b6e76f9..29c1ce1a0b1 100644 --- a/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.component.spec.ts +++ b/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.component.spec.ts @@ -8,7 +8,6 @@ import { Component } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { HttpErrorModel } from '@spartacus/core'; -import { Order } from '@spartacus/order/root'; import { of, throwError } from 'rxjs'; import { KeyValuePair } from '../../model'; import { OpfPaymentVerificationComponent } from './opf-payment-verification.component'; @@ -33,12 +32,11 @@ describe('OpfPaymentVerificationComponent', () => { paymentServiceMock = jasmine.createSpyObj('OpfPaymentVerificationService', [ 'checkIfProcessingCartIdExist', 'verifyResultUrl', - 'verifyPayment', - 'placeOrder', 'goToPage', 'displayError', 'removeResourcesAndGlobalFunctions', 'runHostedFieldsPattern', + 'runHostedPagePattern', ]); TestBed.configureTestingModule({ @@ -83,22 +81,20 @@ describe('OpfPaymentVerificationComponent', () => { paramsMap: mockResponseMap, afterRedirectScriptFlag: mockAfterRedirectScriptFlag, }; - const mockPlaceOrderResult: Order = { guid: 'placeOrderResult' }; paymentServiceMock.verifyResultUrl.and.returnValue(of(mockVerifyResult)); - paymentServiceMock.verifyPayment.and.returnValue(of(true)); - paymentServiceMock.placeOrder.and.returnValue(of(mockPlaceOrderResult)); + paymentServiceMock.runHostedFieldsPattern.and.returnValue(of(true)); + paymentServiceMock.runHostedPagePattern.and.returnValue(of(true)); component.ngOnInit(); expect(paymentServiceMock.verifyResultUrl).toHaveBeenCalledWith( routeMock ); - expect(paymentServiceMock.verifyPayment).toHaveBeenCalledWith( + expect(paymentServiceMock.runHostedPagePattern).toHaveBeenCalledWith( mockPaymentSessionId, mockResponseMap ); - expect(paymentServiceMock.placeOrder).toHaveBeenCalled(); }); it('should handle error scenario', () => { @@ -111,7 +107,9 @@ describe('OpfPaymentVerificationComponent', () => { }; paymentServiceMock.verifyResultUrl.and.returnValue(of(mockVerifyResult)); - paymentServiceMock.verifyPayment.and.returnValue(throwError(mockError)); + paymentServiceMock.runHostedPagePattern.and.returnValue( + throwError(mockError) + ); spyOn(component, 'onError'); @@ -120,7 +118,24 @@ describe('OpfPaymentVerificationComponent', () => { expect(component.onError).toHaveBeenCalledWith(mockError); }); - it('should handle HostedField pattern scenario', () => { + it('should call onError when payment fails', () => { + const mockVerifyResult = { + paymentSessionId: '1', + paramsMap: [], + afterRedirectScriptFlag: 'false', + }; + + paymentServiceMock.verifyResultUrl.and.returnValue(of(mockVerifyResult)); + paymentServiceMock.runHostedPagePattern.and.returnValue(of(false)); + + spyOn(component, 'onError'); + + component.ngOnInit(); + + expect(component.onError).toHaveBeenCalledWith(undefined); + }); + + it('should handle HostedField pattern successful scenario', () => { const mockVerifyResultWithFlag = { paymentSessionId: '1', paramsMap: [], @@ -134,16 +149,7 @@ describe('OpfPaymentVerificationComponent', () => { component.ngOnInit(); expect(paymentServiceMock.runHostedFieldsPattern).toHaveBeenCalled(); - expect(paymentServiceMock.verifyPayment).not.toHaveBeenCalled(); - }); - }); - - describe('onSuccess', () => { - it('should call paymentService.goToPage with "orderConfirmation"', () => { - component.onSuccess(); - expect(paymentServiceMock.goToPage).toHaveBeenCalledWith( - 'orderConfirmation' - ); + expect(paymentServiceMock.runHostedPagePattern).not.toHaveBeenCalled(); }); }); diff --git a/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.component.ts b/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.component.ts index e77be4eac87..d10efaa62c1 100644 --- a/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.component.ts +++ b/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.component.ts @@ -8,10 +8,10 @@ import { Component, OnDestroy, OnInit, ViewContainerRef } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { HttpErrorModel } from '@spartacus/core'; -import { Subscription } from 'rxjs'; -import { concatMap, map, tap } from 'rxjs/operators'; +import { Observable, Subscription } from 'rxjs'; +import { concatMap } from 'rxjs/operators'; -import { TargetPage } from '../../model'; +import { KeyValuePair, TargetPage } from '../../model'; import { OpfPaymentVerificationService } from './opf-payment-verification.service'; @Component({ @@ -39,31 +39,12 @@ export class OpfPaymentVerificationComponent implements OnInit, OnDestroy { paymentSessionId, paramsMap: paramsMap, afterRedirectScriptFlag, - }) => { - if (afterRedirectScriptFlag === 'true') { - this.isHostedFieldPattern = true; - return this.paymentService.runHostedFieldsPattern( - TargetPage.RESULT, - paymentSessionId, - this.vcr, - paramsMap - ); - } else { - return this.paymentService - .verifyPayment(paymentSessionId, paramsMap) - .pipe( - concatMap(() => { - return this.paymentService.placeOrder(); - }), - map((order) => !!order), - tap((success: boolean) => { - if (success) { - this.onSuccess(); - } - }) - ); - } - } + }) => + this.runPaymentPattern({ + paymentSessionId, + paramsMap, + afterRedirectScriptFlag, + }) ) ) .subscribe({ @@ -76,8 +57,29 @@ export class OpfPaymentVerificationComponent implements OnInit, OnDestroy { }); } - onSuccess(): void { - this.paymentService.goToPage('orderConfirmation'); + protected runPaymentPattern({ + paymentSessionId, + paramsMap, + afterRedirectScriptFlag, + }: { + paymentSessionId: string; + paramsMap: KeyValuePair[]; + afterRedirectScriptFlag?: string; + }): Observable { + if (afterRedirectScriptFlag === 'true') { + this.isHostedFieldPattern = true; + return this.paymentService.runHostedFieldsPattern( + TargetPage.RESULT, + paymentSessionId, + this.vcr, + paramsMap + ); + } else { + return this.paymentService.runHostedPagePattern( + paymentSessionId, + paramsMap + ); + } } onError(error: HttpErrorModel | undefined): void { diff --git a/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.service.spec.ts b/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.service.spec.ts index 6d4fdc712b6..53353326d78 100644 --- a/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.service.spec.ts +++ b/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.service.spec.ts @@ -162,20 +162,25 @@ describe('OpfPaymentVerificationService', () => { } ); }); - }); - describe('placeOrder', () => { - it('should call opfOrderFacade.placeOpfOrder with true and return the result', (done) => { - const mockPlaceOrderResult: Order = { guid: 'placeOrderResult' }; - opfOrderFacadeMock.placeOpfOrder.and.returnValue( - of(mockPlaceOrderResult) - ); + it('should throw an error if paymentSessionId is missing', (done) => { + const mockRoute: ActivatedRoute = { + routeConfig: { + data: { + cxRoute: 'paymentVerificationResult', + }, + }, + queryParams: of({ mockKey: 'testKey' }), + } as unknown as ActivatedRoute; - service.placeOrder().subscribe((result) => { - expect(result).toEqual(mockPlaceOrderResult); - expect(opfOrderFacadeMock.placeOpfOrder).toHaveBeenCalledWith(true); - done(); - }); + service.verifyResultUrl(mockRoute).subscribe( + () => {}, + (error) => { + expect(error).toBeDefined(); + expect(error.message).toEqual('opf.payment.errors.proceedPayment'); + done(); + } + ); }); }); @@ -191,8 +196,13 @@ describe('OpfPaymentVerificationService', () => { of(mockVerificationResponse) ); + const mockPlaceOrderResult: Order = { guid: 'placeOrderResult' }; + opfOrderFacadeMock.placeOpfOrder.and.returnValue( + of(mockPlaceOrderResult) + ); + service - .verifyPayment(mockPaymentSessionId, mockResponseMap) + .runHostedPagePattern(mockPaymentSessionId, mockResponseMap) .subscribe((result) => { expect(result).toBeTruthy(); expect(opfPaymentServiceMock.verifyPayment).toHaveBeenCalledWith( @@ -210,12 +220,17 @@ describe('OpfPaymentVerificationService', () => { result: OpfPaymentVerificationResult.DELAYED, }; + const mockPlaceOrderResult: Order = { guid: 'placeOrderResult' }; + opfOrderFacadeMock.placeOpfOrder.and.returnValue( + of(mockPlaceOrderResult) + ); + opfPaymentServiceMock.verifyPayment.and.returnValue( of(mockVerificationResponse) ); service - .verifyPayment(mockPaymentSessionId, mockResponseMap) + .runHostedPagePattern(mockPaymentSessionId, mockResponseMap) .subscribe((result) => { expect(result).toBeTruthy(); expect(opfPaymentServiceMock.verifyPayment).toHaveBeenCalledWith( @@ -237,13 +252,15 @@ describe('OpfPaymentVerificationService', () => { of(mockVerificationResponse) ); - service.verifyPayment(mockPaymentSessionId, mockResponseMap).subscribe( - () => {}, - (error) => { - expect(error.message).toEqual('opf.payment.errors.cancelPayment'); - done(); - } - ); + service + .runHostedPagePattern(mockPaymentSessionId, mockResponseMap) + .subscribe( + () => {}, + (error) => { + expect(error.message).toEqual('opf.payment.errors.cancelPayment'); + done(); + } + ); }); it('should throw an error with defaultError if the result is not AUTHORIZED, DELAYED, or CANCELLED', (done) => { @@ -257,69 +274,15 @@ describe('OpfPaymentVerificationService', () => { of(mockVerificationResponse) ); - service.verifyPayment(mockPaymentSessionId, mockResponseMap).subscribe( - () => {}, - (error) => { - expect(error).toEqual(service.defaultError); - done(); - } - ); - }); - }); - - describe('isPaymentSuccessful', () => { - it('should return true if the response result is AUTHORIZED', (done) => { - const mockVerificationResponse: OpfPaymentVerificationResponse = { - result: OpfPaymentVerificationResult.AUTHORIZED, - }; - service - .isPaymentSuccessful(mockVerificationResponse) - .subscribe((result) => { - expect(result).toBeTruthy(); - done(); - }); - }); - - it('should return true if the response result is DELAYED', (done) => { - const mockVerificationResponse: OpfPaymentVerificationResponse = { - result: OpfPaymentVerificationResult.DELAYED, - }; - - service - .isPaymentSuccessful(mockVerificationResponse) - .subscribe((result) => { - expect(result).toBeTruthy(); - done(); - }); - }); - - it('should throw an error with "opf.payment.errors.cancelPayment" if the response result is CANCELLED', (done) => { - const mockVerificationResponse: OpfPaymentVerificationResponse = { - result: OpfPaymentVerificationResult.CANCELLED, - }; - - service.isPaymentSuccessful(mockVerificationResponse).subscribe( - () => {}, - (error) => { - expect(error.message).toEqual('opf.payment.errors.cancelPayment'); - done(); - } - ); - }); - - it('should throw an error with defaultError if the response result is not AUTHORIZED, DELAYED, or CANCELLED', (done) => { - const mockVerificationResponse: OpfPaymentVerificationResponse = { - result: 'ERROR', - }; - - service.isPaymentSuccessful(mockVerificationResponse).subscribe( - () => {}, - (error) => { - expect(error).toEqual(service.defaultError); - done(); - } - ); + .runHostedPagePattern(mockPaymentSessionId, mockResponseMap) + .subscribe( + () => {}, + (error) => { + expect(error).toEqual(service.defaultError); + done(); + } + ); }); }); @@ -335,10 +298,12 @@ describe('OpfPaymentVerificationService', () => { of({ afterRedirectScript: dynamicScriptMock }) ); globalFunctionsServiceMock.registerGlobalFunctions.and.returnValue(); - spyOn(service, 'renderAfterRedirectScripts').and.returnValue( - Promise.resolve(true) + opfResourceLoaderServiceMock.loadProviderResources.and.returnValue( + Promise.resolve() ); + opfResourceLoaderServiceMock.executeScriptFromHtml.and.returnValue(); + service .runHostedFieldsPattern( TargetPage.RESULT, @@ -347,21 +312,28 @@ describe('OpfPaymentVerificationService', () => { [{ key: 'key test', value: 'value test' }] ) .subscribe((result) => { - expect(service.renderAfterRedirectScripts).toHaveBeenCalled(); + expect( + opfResourceLoaderServiceMock.loadProviderResources + ).toHaveBeenCalled(); + expect( + opfResourceLoaderServiceMock.executeScriptFromHtml + ).toHaveBeenCalled(); expect(result).toBeTruthy(); done(); }); }); - it('should throw error when missing afterRedirectScript property', (done) => { + it('should not executeScriptFromHtml when no html snippet', (done) => { opfPaymentServiceMock.afterRedirectScripts.and.returnValue( - of({ afterRedirectScript: undefined }) + of({ afterRedirectScript: { dynamicScriptMock, html: undefined } }) ); globalFunctionsServiceMock.registerGlobalFunctions.and.returnValue(); - spyOn(service, 'renderAfterRedirectScripts').and.returnValue( - Promise.resolve(true) + opfResourceLoaderServiceMock.loadProviderResources.and.returnValue( + Promise.resolve() ); + opfResourceLoaderServiceMock.executeScriptFromHtml.and.returnValue(); + service .runHostedFieldsPattern( TargetPage.RESULT, @@ -369,76 +341,72 @@ describe('OpfPaymentVerificationService', () => { {} as ViewContainerRef, [{ key: 'key test', value: 'value test' }] ) - .subscribe( - () => {}, - (error) => { - expect(error).toBeDefined(); - expect(error.message).toEqual('opf.payment.errors.proceedPayment'); - done(); - } - ); - }); - }); - - describe('renderAfterRedirectScripts', () => { - const scriptsMock: AfterRedirectDynamicScript = { - cssUrls: [{ url: 'css url test', sri: 'css sri test' }], - jsUrls: [{ url: 'js url test', sri: 'js sri test' }], - html: 'html test', - }; - - it('should fail when html snippet is empty', (done) => { - opfResourceLoaderServiceMock.loadProviderResources.and.returnValue( - Promise.resolve() - ); - service - .renderAfterRedirectScripts({ ...scriptsMock, html: undefined }) - .then((success: boolean) => { + .subscribe((result) => { expect( opfResourceLoaderServiceMock.loadProviderResources ).toHaveBeenCalled(); expect( opfResourceLoaderServiceMock.executeScriptFromHtml ).not.toHaveBeenCalled(); - expect(success).toBeFalsy(); + expect(result).toBeFalsy(); done(); }); }); - it('should throw error when loadProviderResources fails', (done) => { + it('should failed when loadProviderResources fails', (done) => { + opfPaymentServiceMock.afterRedirectScripts.and.returnValue( + of({ afterRedirectScript: { dynamicScriptMock, html: undefined } }) + ); + globalFunctionsServiceMock.registerGlobalFunctions.and.returnValue(); opfResourceLoaderServiceMock.loadProviderResources.and.returnValue( Promise.reject() ); + opfResourceLoaderServiceMock.executeScriptFromHtml.and.returnValue(); + service - .renderAfterRedirectScripts(scriptsMock) - .then((success: boolean) => { + .runHostedFieldsPattern( + TargetPage.RESULT, + 'paymentSessionIdTest', + {} as ViewContainerRef, + [{ key: 'key test', value: 'value test' }] + ) + .subscribe((result) => { expect( opfResourceLoaderServiceMock.loadProviderResources ).toHaveBeenCalled(); expect( opfResourceLoaderServiceMock.executeScriptFromHtml ).not.toHaveBeenCalled(); - expect(success).toBeFalsy(); + expect(result).toBeFalsy(); done(); }); }); - it('should call load provider resources', (done) => { - opfResourceLoaderServiceMock.loadProviderResources.and.returnValue( - Promise.resolve() + + it('should throw error when missing afterRedirectScript property', (done) => { + opfPaymentServiceMock.afterRedirectScripts.and.returnValue( + of({ afterRedirectScript: undefined }) + ); + globalFunctionsServiceMock.registerGlobalFunctions.and.returnValue(); + spyOn(service, 'renderAfterRedirectScripts').and.returnValue( + Promise.resolve(true) ); + service - .renderAfterRedirectScripts(scriptsMock) - .then((success: boolean) => { - expect( - opfResourceLoaderServiceMock.loadProviderResources - ).toHaveBeenCalled(); - expect( - opfResourceLoaderServiceMock.executeScriptFromHtml - ).toHaveBeenCalled(); - expect(success).toBeTruthy(); - done(); - }); + .runHostedFieldsPattern( + TargetPage.RESULT, + 'paymentSessionIdTest', + {} as ViewContainerRef, + [{ key: 'key test', value: 'value test' }] + ) + .subscribe( + () => {}, + (error) => { + expect(error).toBeDefined(); + expect(error.message).toEqual('opf.payment.errors.proceedPayment'); + done(); + } + ); }); }); diff --git a/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.service.ts b/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.service.ts index 7f4ec5063e7..1c5c27a3669 100644 --- a/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.service.ts +++ b/integration-libs/opf/base/root/components/opf-payment-verification/opf-payment-verification.service.ts @@ -15,7 +15,7 @@ import { import { Order } from '@spartacus/order/root'; import { Observable, from, of, throwError } from 'rxjs'; -import { concatMap, filter, take } from 'rxjs/operators'; +import { concatMap, filter, map, take, tap } from 'rxjs/operators'; import { OpfGlobalFunctionsFacade, OpfOrderFacade, @@ -56,9 +56,6 @@ export class OpfPaymentVerificationService { }; protected getParamsMap(params: Params): Array { - if (!params) { - return []; - } return Object.entries(params).map((pair) => { return { key: pair[0], value: pair[1] as string }; }); @@ -112,11 +109,11 @@ export class OpfPaymentVerificationService { }); } - placeOrder(): Observable { + protected placeOrder(): Observable { return this.opfOrderFacade.placeOpfOrder(true); } - verifyPayment( + protected verifyPayment( paymentSessionId: string, responseMap: Array ): Observable { @@ -131,7 +128,7 @@ export class OpfPaymentVerificationService { ); } - isPaymentSuccessful( + protected isPaymentSuccessful( response: OpfPaymentVerificationResponse ): Observable { if ( @@ -183,6 +180,20 @@ export class OpfPaymentVerificationService { }); } + runHostedPagePattern(paymentSessionId: string, paramsMap: KeyValuePair[]) { + return this.verifyPayment(paymentSessionId, paramsMap).pipe( + concatMap(() => { + return this.placeOrder(); + }), + map((order) => !!order), + tap((success: boolean) => { + if (success) { + this.goToPage('orderConfirmation'); + } + }) + ); + } + runHostedFieldsPattern( targetPage: TargetPage, paymentSessionId: string, @@ -208,7 +219,7 @@ export class OpfPaymentVerificationService { ); } - renderAfterRedirectScripts( + protected renderAfterRedirectScripts( script: AfterRedirectDynamicScript ): Promise { const html = script?.html;