Skip to content

Commit

Permalink
feat: adjust API endpoints (#17796)
Browse files Browse the repository at this point in the history
CXSPA-4389
  • Loading branch information
FollowTheFlo authored Aug 29, 2023
1 parent 7e17779 commit 8b3b549
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// const mockOpfOtpFacade = {
// generateOtpKey: jasmine
// .createSpy('generateOtpKey')
// .and.returnValue(of({ value: 'mockOtpKey' })),
// .and.returnValue(of({ accessCode: 'mockOtpKey' })),
// };

// const mockActiveCartFacade = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const defaultOccOtpConfig: OccConfig = {
backend: {
occ: {
endpoints: {
generateOtpKey: 'users/${userId}/carts/${cartId}/otp',
generateOtpKey: 'users/${userId}/carts/${cartId}/accessCode',
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion integration-libs/opf/base/root/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import {
} from '@spartacus/opf/checkout/root';
import {
BehaviorSubject,
combineLatest,
Observable,
combineLatest,
of,
throwError,
} from 'rxjs';
Expand Down Expand Up @@ -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)),
Expand Down

0 comments on commit 8b3b549

Please sign in to comment.