Skip to content

Commit

Permalink
PayPal Express in Cart and Mini-Cart page (#1122)
Browse files Browse the repository at this point in the history
* Rendering PayPal Expres button (#1076)

* Paypal express payment (#1077)

* Merchant reference set for PayPal Express (#1080)

* Populate payment instrument fields for PayPal Express (#1081)

* Adding the possibility to enable/disable paypal express from BM (#1085)

* feat: adding the possibility to enable/disable paypal ecs from BM

* chore: linting

* fix: fixing klarna e2e test

* PayPal Express update order (#1086)

* feat: paypalUpdateOrder endpoint

* test: unit tests and jsdoc annotations

* feat: paypal update order

* feat(SFI-696): show paypal express if enabled in BM

* chore(SFI-696): add sonar properties file

* refactor(SFI-696): function to create redirectUrl

* feat(SFI-696): add stacktrace for error and fatal logs

* chore(SFI-696): exclude e2e tests from sonar

* fix(SFI-696): clear session.privacy data for paypal express

* chore(SFI-696): undo changes to cartridges

* fix(SFI-696): zero-auth flow

* add spinner for paypal express flow (#1091)

* Added the review page template and controller to render it (#1096)

* Place order button for express payments on review page (#1112)

* feat(SFI-790): new template for checkout review button

* feat(SFI-789): handle payments details call from checkout review page

* feat(SFI-789): create basket view data on express review page

* feat(SFI-789): create basket view data on express review page

* chore: merging develop into SFI-42 and adding required mocks (#1115)

* Added e2e tests for paypal express (#1117)

* test(SFI-798): paypal express unit tests (#1121)

* fix: fixing apple pay express flow

---------

Co-authored-by: Shani <[email protected]>
  • Loading branch information
zenit2001 and shanikantsingh authored Jul 23, 2024
1 parent 1133168 commit 5b1cfd4
Show file tree
Hide file tree
Showing 65 changed files with 3,311 additions and 789 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/SFCC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
npm install
npm run lint:fix
npm run lint
npm test
npm run test:coverage
env:
CI: true
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ function callGetShippingMethods(req, res, next) {
return next();
}
}
module.exports = callGetShippingMethods;
module.exports = callGetShippingMethods;
38 changes: 25 additions & 13 deletions jest/__mocks__/dw/order/BasketMgr.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export const getTotalGrossPrice = jest.fn(() => ({
isAvailable,
}));

export const getAdjustedMerchandizeTotalGrossPrice = jest.fn(() => ({
currencyCode: 'EUR',
isAvailable,
}));

export const getCreditCardToken = jest.fn(() => 'mockedCreditCardToken');
export const getPaymentMethod = jest.fn(() => 'mockedPaymentMethod');

Expand All @@ -47,8 +52,14 @@ export const setCreditCardToken = jest.fn();

export const toArray = jest.fn(() => [
{
custom: {},
paymentTransaction: { paymentProcessor: 'mocked_payment_processor' },
custom: { adyenPaymentMethod: '' },
paymentTransaction: {
paymentProcessor: 'mocked_payment_processor',
amount: {
value: 'mockedValue',
currencyCode: 'mockedValue',
},
},
setCreditCardNumber,
setCreditCardType,
setCreditCardExpirationMonth,
Expand All @@ -73,7 +84,6 @@ export const getDefaultShipment = jest.fn(() => ({
}));
export const getBillingAddress = jest.fn(() => 'mocked_billing_address');


function formatCustomerObject(shopperDetails) {
return {
addressBook: {
Expand Down Expand Up @@ -121,7 +131,9 @@ export const getCurrentBasket = jest.fn(() => ({
setCustomerEmail: jest.fn(),
getAllProductLineItems,
getTotalGrossPrice,
getAdjustedMerchandizeTotalGrossPrice,
getPaymentInstruments,
removeAllPaymentInstruments: jest.fn(),
removePaymentInstrument: jest.fn(),
custom: {
amazonExpressShopperDetails: JSON.stringify({
Expand All @@ -138,15 +150,15 @@ export const getCurrentBasket = jest.fn(() => ({
},
addressBook: {
preferredAddress: {
address1: 'address1',
address2: 'mocked address2',
phone: 'mocked phone',
postalCode: 'mocked postalCode',
countryCode: 'mocked CC',
city: 'mocked city',
lastName: 'mocked name',
firstName: 'mocked name',
stateCode: 'mocked state',
address1: 'address1',
address2: 'mocked address2',
phone: 'mocked phone',
postalCode: 'mocked postalCode',
countryCode: 'mocked CC',
city: 'mocked city',
lastName: 'mocked name',
firstName: 'mocked name',
stateCode: 'mocked state',
},
},
profile: {
Expand All @@ -158,7 +170,7 @@ export const getCurrentBasket = jest.fn(() => ({
}),
},
getUUID: jest.fn(),
createBillingAddress,
createBillingAddress: jest.fn(() => createBillingAddress),
createPaymentInstrument: jest.fn(() => toArray()[0]),
defaultShipment: getDefaultShipment(),
getDefaultShipment,
Expand Down
29 changes: 20 additions & 9 deletions jest/__mocks__/dw/order/OrderMgr.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const paymentInstrument = () => [
{
custom: {
adyenPaymentData: "{ \"paymentMethod\": { \"type\": \"mocked_type\" } }",
adyenPaymentData: '{ "paymentMethod": { "type": "mocked_type" } }',
adyenRedirectURL: 'https://some_mocked_url/signature',
adyenMD: 'mocked_adyen_MD',
adyenAction: 'mocked_adyen_action',
},
paymentTransaction: {
custom: {
Adyen_merchantSig: 'mocked_signature',
Adyen_authResult: "{ \"data\": \"mock\"}",
},
custom: {
Adyen_merchantSig: 'mocked_signature',
Adyen_authResult: '{ "data": "mock"}',
},
},
},
];
Expand All @@ -36,20 +36,31 @@ export const getPaymentInstruments = jest.fn(() => ({
0: toArray()[0],
}));



export const getOrder = jest.fn((statusValue="4"/* orderNo */) => ({
export const getOrder = jest.fn((statusValue = '4' /* orderNo */) => ({
getPaymentInstruments,
setPaymentStatus: jest.fn(),
setExportStatus: jest.fn(),
orderNo: 'mocked_orderNo',
orderToken: 'mocked_orderToken',
getUUID: jest.fn(),
custom: { Adyen_pspReference: 'mocked_pspRef' },
status: { value: statusValue}
status: { value: statusValue },
}));

export const failOrder = jest.fn((orderNo, bool) => ({
orderNo,
bool,
}));

export const createOrderNo = jest.fn(() => 'mocked_orderNo');

export const createOrder = jest.fn(() => ({
getPaymentInstruments,
setPaymentStatus: jest.fn(),
setExportStatus: jest.fn(),
orderNo: 'mocked_orderNo',
orderToken: 'mocked_orderToken',
getUUID: jest.fn(),
custom: { Adyen_pspReference: 'mocked_pspRef' },
status: { value: 'Created' },
}));
5 changes: 5 additions & 0 deletions jest/__mocks__/dw/order/ShippingLocation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function ShippingLocation() {
return jest.fn();
}

module.exports = ShippingLocation;
44 changes: 39 additions & 5 deletions jest/__mocks__/dw/order/ShippingMgr.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
const Money = require('../value/Money');

export const getShipmentShippingModel = jest.fn((shipment) => ({
getApplicableShippingMethods: jest.fn(() => ({
})),
}));

const shippingMethods = [
{
description: 'Order received within 7-10 business days',
displayName: 'Ground',
ID: '001',
custom: {
estimatedArrivalTime: '7-10 Business Days',
},
getTaxClassID: jest.fn(),
},
{
description: 'Order received in 2 business days',
displayName: '2-Day Express',
ID: '002',
shippingCost: '$0.00',
custom: {
estimatedArrivalTime: '2 Business Days',
},
getTaxClassID: jest.fn(),
},
];
const shippingCost = Money();
const shipmentShippingModel = {
getApplicableShippingMethods: jest.fn(() => ({
toArray: jest.fn(() => shippingMethods),
})),
getShippingCost: jest.fn(() => ({
getAmount: jest.fn(() => shippingCost),
})),
};
const productShippingModel = {
getApplicableShippingMethods: jest.fn(() => ({})),
getShippingCost: jest.fn(() => ({
getAmount: jest.fn(() => shippingCost),
})),
};
export const getShipmentShippingModel = jest.fn(() => shipmentShippingModel);
export const getProductShippingModel = jest.fn(() => productShippingModel);
2 changes: 2 additions & 0 deletions jest/__mocks__/dw/order/TaxMgr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const getTaxJurisdictionID = jest.fn();
export const getTaxRate = jest.fn();
2 changes: 1 addition & 1 deletion jest/__mocks__/dw/util/UUIDUtils.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const createUUID = jest.fn();
export const createUUID = jest.fn(() => 'mock_UUID');
35 changes: 30 additions & 5 deletions jest/__mocks__/dw/value/Money.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
export class Money {
constructor() {
return {value: 10, currency: 'TEST'};
}
}
function Money(isAvailable) {
return {
available: isAvailable,
value: '10.99',
currency: 'USD',
getDecimalValue() {
return '10.99';
},
getValue() {
return '10.99';
},
getCurrencyCode() {
return 'USD';
},
subtract() {
return new Money(isAvailable);
},
multiply() {
return new Money(isAvailable);
},
add() {
return new Money(isAvailable);
},
addRate() {
return new Money(isAvailable);
},
};
}

module.exports = Money;
Loading

0 comments on commit 5b1cfd4

Please sign in to comment.