From 8b3b549a6f7fafcf52e9e93fc5ac2543171a9312 Mon Sep 17 00:00:00 2001 From: Florent Letendre Date: Tue, 29 Aug 2023 13:16:29 -0400 Subject: [PATCH] feat: adjust API endpoints (#17796) CXSPA-4389 --- .../opf-payment-hosted-fields.service.spec.ts | 2 +- .../services/opf-payment-hosted-fields.service.ts | 8 ++++---- .../base/occ/config/default-occ-opf-order-config.ts | 3 ++- .../opf/base/occ/config/default-occ-otp-config.ts | 2 +- integration-libs/opf/base/root/config/constants.ts | 2 +- .../opf-checkout-payment-wrapper.service.spec.ts | 12 +++++++++--- .../opf-checkout-payment-wrapper.service.ts | 6 +++--- 7 files changed, 21 insertions(+), 14 deletions(-) diff --git a/integration-libs/opf/base/core/services/opf-payment-hosted-fields.service.spec.ts b/integration-libs/opf/base/core/services/opf-payment-hosted-fields.service.spec.ts index 27319efb3c1..96accd1519b 100644 --- a/integration-libs/opf/base/core/services/opf-payment-hosted-fields.service.spec.ts +++ b/integration-libs/opf/base/core/services/opf-payment-hosted-fields.service.spec.ts @@ -41,7 +41,7 @@ // const mockOpfOtpFacade = { // generateOtpKey: jasmine // .createSpy('generateOtpKey') -// .and.returnValue(of({ value: 'mockOtpKey' })), +// .and.returnValue(of({ accessCode: 'mockOtpKey' })), // }; // const mockActiveCartFacade = { diff --git a/integration-libs/opf/base/core/services/opf-payment-hosted-fields.service.ts b/integration-libs/opf/base/core/services/opf-payment-hosted-fields.service.ts index b5f5a00055a..75cc5d6f78c 100644 --- a/integration-libs/opf/base/core/services/opf-payment-hosted-fields.service.ts +++ b/integration-libs/opf/base/core/services/opf-payment-hosted-fields.service.ts @@ -87,9 +87,9 @@ export class OpfPaymentHostedFieldsService { submitRequest.cartId = activeCartId; return this.opfOtpFacade.generateOtpKey(userId, activeCartId); }), - filter((response) => Boolean(response?.value)), + filter((response) => Boolean(response?.accessCode)), take(1), - concatMap(({ value: otpKey }) => + concatMap(({ accessCode: otpKey }) => this.opfPaymentConnector.submitPayment( submitRequest, otpKey, @@ -133,9 +133,9 @@ export class OpfPaymentHostedFieldsService { submitCompleteRequest.cartId = activeCartId; return this.opfOtpFacade.generateOtpKey(userId, activeCartId); }), - filter((response) => Boolean(response?.value)), + filter((response) => Boolean(response?.accessCode)), take(1), - concatMap(({ value: otpKey }) => + concatMap(({ accessCode: otpKey }) => this.opfPaymentConnector.submitCompletePayment( submitCompleteRequest, otpKey, diff --git a/integration-libs/opf/base/occ/config/default-occ-opf-order-config.ts b/integration-libs/opf/base/occ/config/default-occ-opf-order-config.ts index 72bb398dc69..de2e0383b5f 100644 --- a/integration-libs/opf/base/occ/config/default-occ-opf-order-config.ts +++ b/integration-libs/opf/base/occ/config/default-occ-opf-order-config.ts @@ -10,7 +10,8 @@ export const defaultOccOpfOrderConfig: OccConfig = { backend: { occ: { endpoints: { - placeOpfOrder: 'users/${userId}/orders/v2?fields=FULL', + placeOpfOrder: + 'users/${userId}/orders/paymentAuthorizedOrderPlacement?fields=FULL', }, }, }, diff --git a/integration-libs/opf/base/occ/config/default-occ-otp-config.ts b/integration-libs/opf/base/occ/config/default-occ-otp-config.ts index a7e4c630983..953fb9d97f8 100644 --- a/integration-libs/opf/base/occ/config/default-occ-otp-config.ts +++ b/integration-libs/opf/base/occ/config/default-occ-otp-config.ts @@ -13,7 +13,7 @@ export const defaultOccOtpConfig: OccConfig = { backend: { occ: { endpoints: { - generateOtpKey: 'users/${userId}/carts/${cartId}/otp', + generateOtpKey: 'users/${userId}/carts/${cartId}/accessCode', }, }, }, diff --git a/integration-libs/opf/base/root/config/constants.ts b/integration-libs/opf/base/root/config/constants.ts index f198605f6f2..618bf63f402 100644 --- a/integration-libs/opf/base/root/config/constants.ts +++ b/integration-libs/opf/base/root/config/constants.ts @@ -5,4 +5,4 @@ */ export const OPF_CC_PUBLIC_KEY = 'sap-commerce-cloud-public-key'; -export const OPF_CC_OTP_KEY = 'sap-commerce-cloud-otp'; +export const OPF_CC_OTP_KEY = 'sap-commerce-cloud-access-code'; diff --git a/integration-libs/opf/checkout/components/opf-checkout-payment-wrapper/opf-checkout-payment-wrapper.service.spec.ts b/integration-libs/opf/checkout/components/opf-checkout-payment-wrapper/opf-checkout-payment-wrapper.service.spec.ts index 1a025fa12f5..e874dd2860e 100644 --- a/integration-libs/opf/checkout/components/opf-checkout-payment-wrapper/opf-checkout-payment-wrapper.service.spec.ts +++ b/integration-libs/opf/checkout/components/opf-checkout-payment-wrapper/opf-checkout-payment-wrapper.service.spec.ts @@ -126,7 +126,9 @@ // opfCheckoutFacadeMock.initiatePayment.and.returnValue( // of(mockPaymentSessionData) // ); -// opfOtpFacadeMock.generateOtpKey.and.returnValue(of({ value: mockOtpKey })); +// opfOtpFacadeMock.generateOtpKey.and.returnValue( +// of({ accessCode: mockOtpKey }) +// ); // userIdServiceMock.getUserId.and.returnValue(of(mockUserId)); // activeCartServiceMock.getActiveCartId.and.returnValue(of(mockCartId)); // routingServiceMock.getRouterState.and.returnValue( @@ -190,7 +192,9 @@ // ); // opfOrderFacadeMock.placeOpfOrder.and.returnValue(of({})); -// opfOtpFacadeMock.generateOtpKey.and.returnValue(of({ value: mockOtpKey })); +// opfOtpFacadeMock.generateOtpKey.and.returnValue( +// of({ accessCode: mockOtpKey }) +// ); // userIdServiceMock.getUserId.and.returnValue(of(mockUserId)); // activeCartServiceMock.getActiveCartId.and.returnValue(of(mockCartId)); // routingServiceMock.getRouterState.and.returnValue( @@ -222,7 +226,9 @@ // throwError({ status: 500 }) // ); -// opfOtpFacadeMock.generateOtpKey.and.returnValue(of({ value: mockOtpKey })); +// opfOtpFacadeMock.generateOtpKey.and.returnValue( +// of({ accessCode: mockOtpKey }) +// ); // userIdServiceMock.getUserId.and.returnValue(of(mockUserId)); // activeCartServiceMock.getActiveCartId.and.returnValue(of(mockCartId)); // routingServiceMock.getRouterState.and.returnValue( diff --git a/integration-libs/opf/checkout/components/opf-checkout-payment-wrapper/opf-checkout-payment-wrapper.service.ts b/integration-libs/opf/checkout/components/opf-checkout-payment-wrapper/opf-checkout-payment-wrapper.service.ts index c511815fa19..c41e174ca54 100644 --- a/integration-libs/opf/checkout/components/opf-checkout-payment-wrapper/opf-checkout-payment-wrapper.service.ts +++ b/integration-libs/opf/checkout/components/opf-checkout-payment-wrapper/opf-checkout-payment-wrapper.service.ts @@ -28,8 +28,8 @@ import { } from '@spartacus/opf/checkout/root'; import { BehaviorSubject, - combineLatest, Observable, + combineLatest, of, throwError, } from 'rxjs'; @@ -109,8 +109,8 @@ export class OpfCheckoutPaymentWrapperService { this.activeCartId = cartId; return this.opfOtpService.generateOtpKey(userId, cartId); }), - filter((response) => Boolean(response?.value)), - map(({ value: otpKey }) => + filter((response) => Boolean(response?.accessCode)), + map(({ accessCode: otpKey }) => this.setPaymentInitiationConfig(otpKey, paymentOptionId) ), switchMap((params) => this.opfCheckoutService.initiatePayment(params)),