From b1b573a29e8b3f671b3ab7ed51372f538030968c Mon Sep 17 00:00:00 2001 From: aChanEP Date: Sun, 12 Jan 2020 17:09:28 -0800 Subject: [PATCH] rebase payments update (#558) * rebase payments update * update imports --- .gitignore | 3 + ...mocks.js => addressform.main.api.mocks.ts} | 18 +- .../AddressForm/addressform.main.stories.tsx | 44 +- ...i.mocks.js => appheader.main.api.mocks.ts} | 15 +- .../src/AppHeader/appheader.main.stories.tsx | 50 +- .../appheadernavigation.main.api.mocks.tsx | 2 +- ...ModalBundleConfiguration.main.api.mock.ts} | 11 +- ....mocks.js => b2b.accountlist.api.mocks.ts} | 13 +- .../b2b.accountlist.stories.tsx | 19 +- .../b2b.subaccountlist.stories.tsx | 13 +- ....api.mocks.js => cart.create.api.mocks.ts} | 15 +- .../src/CartCreate/cart.create.stories.tsx | 21 +- .../categoryitems.main.api.mocks.ts | 23 +- ...nse.json => anonymous_login_response.json} | 0 .../registered_login_response.json | 8 + .../GET/paymentInstrumentForm_response.json | 746 ++++++++++++++++++ src/components/src/PaymentForm/README.md | 10 +- .../PaymentForm/paymentform.main.api.mocks.ts | 67 ++ .../PaymentForm/paymentform.main.stories.tsx | 54 +- .../src/PaymentForm/paymentform.main.tsx | 565 ++++++++----- .../paymentmethod.container.tsx | 6 +- ...s => productdisplayitem.main.api.mocks.ts} | 50 +- ...ks.js => productlistloadmore.api.mocks.ts} | 10 +- .../productlistloadmore.stories.tsx | 15 +- .../productlistloadmore.tsx | 4 +- .../profilepaymentmethods.main.tsx | 40 +- .../PurchaseDetails/purchasedetails.main.tsx | 4 +- ...js => searchresultsitems.main.mock.api.ts} | 25 +- .../searchresultsitems.main.stories.tsx | 4 +- src/components/src/utils/MockLogins.ts | 39 + src/components/webpack.config.base.js | 1 - src/containers/CheckoutPage.tsx | 102 ++- src/containers/OrderReviewPage.tsx | 1 + src/containers/ProfilePage.tsx | 31 +- src/ep.config.json | 6 - src/tests/e2e/common.js | 23 +- src/tests/e2e/profile.test.js | 2 - src/tests/e2e/purchase.test.js | 14 +- 38 files changed, 1584 insertions(+), 490 deletions(-) rename src/components/src/AddressForm/{addressform.main.api.mocks.js => addressform.main.api.mocks.ts} (90%) rename src/components/src/AppHeader/{appheader.main.api.mocks.js => appheader.main.api.mocks.ts} (74%) rename src/components/src/AppModalBundleConfiguration/{appModalBundleConfiguration.main.api.mock.js => appModalBundleConfiguration.main.api.mock.ts} (84%) rename src/components/src/B2bAccountList/{b2b.accountlist.api.mocks.js => b2b.accountlist.api.mocks.ts} (80%) rename src/components/src/CartCreate/{cart.create.api.mocks.js => cart.create.api.mocks.ts} (72%) rename src/components/src/CommonMockHttpResponses/{login_response.json => anonymous_login_response.json} (100%) create mode 100644 src/components/src/CommonMockHttpResponses/registered_login_response.json create mode 100644 src/components/src/PaymentForm/MockHttpResponses/GET/paymentInstrumentForm_response.json create mode 100644 src/components/src/PaymentForm/paymentform.main.api.mocks.ts rename src/components/src/ProductDisplayItem/{productdisplayitem.main.api.mocks.js => productdisplayitem.main.api.mocks.ts} (67%) rename src/components/src/ProductListLoadmore/{productlistloadmore.api.mocks.js => productlistloadmore.api.mocks.ts} (76%) rename src/components/src/SearchResultsItems/{searchresultsitems.main.mock.api.js => searchresultsitems.main.mock.api.ts} (68%) create mode 100644 src/components/src/utils/MockLogins.ts diff --git a/.gitignore b/.gitignore index a377a8193..60fe53829 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,9 @@ _site build dist + +.vscode + # misc .DS_Store .env.local diff --git a/src/components/src/AddressForm/addressform.main.api.mocks.js b/src/components/src/AddressForm/addressform.main.api.mocks.ts similarity index 90% rename from src/components/src/AddressForm/addressform.main.api.mocks.js rename to src/components/src/AddressForm/addressform.main.api.mocks.ts index 78d8e21d1..d7f72aa56 100644 --- a/src/components/src/AddressForm/addressform.main.api.mocks.js +++ b/src/components/src/AddressForm/addressform.main.api.mocks.ts @@ -22,18 +22,11 @@ import fetchMock from 'fetch-mock/es5/client'; import fetchGeoDataResponse from './MockHttpResponses/GET/fetchGeoData_response.json'; import fetchAddressFormResponse from './MockHttpResponses/GET/fetchAddressForm_response.json'; import fetchAddressDataResponse from './MockHttpResponses/GET/fetchAddressData_response.json'; -import loginResponse from '../CommonMockHttpResponses/login_response.json'; import submitAddressResponse from './MockHttpResponses/POST/submitAddress_response.json'; +import { mockAnonLoginResponse } from '../utils/MockLogins'; fetchMock.config.fallbackToNetwork = true; -function mockLoginResponse(mockObj) { - mockObj.post( - '/cortex/oauth2/tokens', - loginResponse, - ); -} - function mockCountriesResponse(mockObj) { mockObj.get( /* eslint-disable max-len */ @@ -81,15 +74,20 @@ function mockSubmitAddressResponseFailureResponse(mockObj) { } function mockCommonAddressFormResponses(mockObj) { - mockLoginResponse(mockObj); + mockAnonLoginResponse(mockObj); mockCountriesResponse(mockObj); mockAddressFormResponse(mockObj); mockAddressDataResponse(mockObj); } -export default function mockAddressFormSubmit() { +export function mockAddressFormSubmitSuccess() { fetchMock.restore(); mockCommonAddressFormResponses(fetchMock); mockSubmitAddressResponseSuccessResponse(fetchMock); +} + +export function mockAddressFormSubmitFailure() { + fetchMock.restore(); + mockCommonAddressFormResponses(fetchMock); mockSubmitAddressResponseFailureResponse(fetchMock); } diff --git a/src/components/src/AddressForm/addressform.main.stories.tsx b/src/components/src/AddressForm/addressform.main.stories.tsx index 88d44a7c8..a05174100 100644 --- a/src/components/src/AddressForm/addressform.main.stories.tsx +++ b/src/components/src/AddressForm/addressform.main.stories.tsx @@ -19,11 +19,11 @@ * */ import React from 'react'; -import Readme from './README.md'; +import { object, text } from '@storybook/addon-knobs/react'; import { storiesOf } from '@storybook/react'; -import mockAddressFormSubmitSuccess from './addressform.main.api.mocks'; -import { textToFunc } from "../../../../storybook/utils/storybookUtils" -import { object, text } from "@storybook/addon-knobs/react"; +import { textToFunc } from '../../../../storybook/utils/storybookUtils'; +import Readme from './README.md'; +import { mockAddressFormSubmitSuccess, mockAddressFormSubmitFailure } from './addressform.main.api.mocks'; import AddressFormMain from './addressform.main'; @@ -40,26 +40,26 @@ storiesOf('Components|AddressFormMain', module) const addressData = { address: '/addresses/vestri_b2c', }; - let onCloseModalFuncText = text('onCloseModal','() => {alert("onCloseModal invoked")}'); - let fetchDataFuncText = text('fetchData','() => {alert("fetchData invoked")}'); - - return textToFunc(onCloseModalFuncText)} - fetchData={()=>textToFunc(fetchDataFuncText)} - /> + const onCloseModalFuncText = text('onCloseModal', '() => {alert("onCloseModal invoked")}'); + const fetchDataFuncText = text('fetchData', '() => {alert("fetchData invoked")}'); + + return textToFunc(onCloseModalFuncText)} + fetchData={() => textToFunc(fetchDataFuncText)} + />; }) .add('AddressFormMain on save failure', () => { - mockAddressFormSubmitSuccess(); + mockAddressFormSubmitFailure(); const addressData = { - address: '/an/incorrect/save/address/link', + address: '/addresses/vestri_b2c', }; - let onCloseModalFuncText = text('onCloseModal','() => {alert("onCloseModal invoked")}'); - let fetchDataFuncText = text('fetchData','() => {alert("fetchData invoked")}'); - - return textToFunc(onCloseModalFuncText)} - fetchData={()=>textToFunc(fetchDataFuncText)} - /> + const onCloseModalFuncText = text('onCloseModal', '() => {alert("onCloseModal invoked")}'); + const fetchDataFuncText = text('fetchData', '() => {alert("fetchData invoked")}'); + + return textToFunc(onCloseModalFuncText)} + fetchData={() => textToFunc(fetchDataFuncText)} + />; }); diff --git a/src/components/src/AppHeader/appheader.main.api.mocks.js b/src/components/src/AppHeader/appheader.main.api.mocks.ts similarity index 74% rename from src/components/src/AppHeader/appheader.main.api.mocks.js rename to src/components/src/AppHeader/appheader.main.api.mocks.ts index b4c1d7845..88f0e9474 100644 --- a/src/components/src/AppHeader/appheader.main.api.mocks.js +++ b/src/components/src/AppHeader/appheader.main.api.mocks.ts @@ -20,24 +20,17 @@ */ import fetchMock from 'fetch-mock/es5/client'; import itemLookupMultiCartResponse from '../CommonMockHttpResponses/itemLookupMultiCart_response.json'; -import loginResponse from '../CommonMockHttpResponses/login_response.json'; +import { mockAnonLoginResponse } from '../utils/MockLogins'; function mockMultiCartResponse(mockObj) { mockObj.get( - '/cortex/?zoom=carts,carts:element,defaultcart,defaultcart:additemstocartform', + /(.*)\/?zoom=carts,carts:element,defaultcart,defaultcart:additemstocartform/, itemLookupMultiCartResponse, ); } -function mockLoginResponse(mockObj) { - mockObj.post( - '/cortex/oauth2/tokens', - loginResponse, - ); -} - -export function mockProductDisplayItemMainMultiCart() { +export default function mockProductDisplayItemMainMultiCart() { fetchMock.restore(); - mockLoginResponse(fetchMock); + mockAnonLoginResponse(fetchMock); mockMultiCartResponse(fetchMock); } diff --git a/src/components/src/AppHeader/appheader.main.stories.tsx b/src/components/src/AppHeader/appheader.main.stories.tsx index 55c3fc8ef..124b1a813 100644 --- a/src/components/src/AppHeader/appheader.main.stories.tsx +++ b/src/components/src/AppHeader/appheader.main.stories.tsx @@ -22,10 +22,10 @@ import React from 'react'; import Readme from './README.md'; import { storiesOf } from '@storybook/react'; import { MemoryRouter } from 'react-router'; -import { object, text, boolean } from "@storybook/addon-knobs/react"; -import { textToFunc } from "../../../../storybook/utils/storybookUtils" +import { object, text, boolean } from '@storybook/addon-knobs/react'; +import { textToFunc } from '../../../../storybook/utils/storybookUtils'; import AppHeaderMain from './appheader.main'; -import { mockProductDisplayItemMainMultiCart } from './appheader.main.api.mocks.js'; +import mockProductDisplayItemMainMultiCart from './appheader.main.api.mocks'; const appHeaderLinks = { mainPage: '', @@ -58,33 +58,33 @@ storiesOf('Components|AppHeaderMain', module) .add('AppHeaderMain', () => { mockProductDisplayItemMainMultiCart(); - // All AppHeaderMain Callbacks inputted from storybook knobs UI. - let onSearchPageFuncText = text('onSearchPage','() => {alert("onSearchPage invoked")}'); - let redirectToMainPageFuncText = text('redirectToMainPage','() => {alert("redirectToMainPage invoked")}'); - let handleResetPasswordFuncText = text('handleResetPassword','() => {alert("handleResetPassword invoked")}'); - let onCurrencyChangeFuncText = text('onCurrencyChange','() => {alert("onCurrencyChange invoked")}'); - let onLocaleChangeFuncText = text('onLocaleChange','() => {alert("onLocaleChange invoked")}'); - let onContinueCartFuncText = text('onContinueCart','() => {alert("onContinueCart invoked")}'); - let onGoBackFuncText = text('onGoBack','() => {alert("onGoBack invoked")}'); - + const onSearchPageFuncText = text('onSearchPage', '() => {alert("onSearchPage invoked")}'); + const redirectToMainPageFuncText = text('redirectToMainPage', '() => {alert("redirectToMainPage invoked")}'); + const handleResetPasswordFuncText = text('handleResetPassword', '() => {alert("handleResetPassword invoked")}'); + const onCurrencyChangeFuncText = text('onCurrencyChange', '() => {alert("onCurrencyChange invoked")}'); + const onLocaleChangeFuncText = text('onLocaleChange', '() => {alert("onLocaleChange invoked")}'); + const onContinueCartFuncText = text('onContinueCart','() => {alert("onContinueCart invoked")}'); + const onGoBackFuncText = text('onGoBack', '() => {alert("onGoBack invoked")}'); + return ( - textToFunc(onSearchPageFuncText)} - redirectToMainPage={()=>textToFunc(redirectToMainPageFuncText)} - handleResetPassword={()=>textToFunc(handleResetPasswordFuncText)} - onCurrencyChange={()=>textToFunc(onCurrencyChangeFuncText)} - onLocaleChange={()=>textToFunc(onLocaleChangeFuncText)} - onContinueCart={()=>textToFunc(onContinueCartFuncText)} - onGoBack={()=>textToFunc(onGoBackFuncText)} + textToFunc(onSearchPageFuncText)} + redirectToMainPage={() => textToFunc(redirectToMainPageFuncText)} + handleResetPassword={() => textToFunc(handleResetPasswordFuncText)} + onCurrencyChange={() => textToFunc(onCurrencyChangeFuncText)} + onLocaleChange={() => textToFunc(onLocaleChangeFuncText)} + onContinueCart={() => textToFunc(onContinueCartFuncText)} + onGoBack={() => textToFunc(onGoBackFuncText)} checkedLocation={boolean('checkedLocation', false)} isInStandaloneMode={boolean('isInStandaloneMode', false)} locationSearchData={text('locationSearchData', '')} - appHeaderLinks={object('appHeaderLinks',appHeaderLinks)} - appHeaderLoginLinks={object('appHeaderLoonCurrencyChangeFuncTextginLinks', appHeaderLoginLinks)} - appHeaderNavigationLinks={object('appHeaderNavigationLinks', appHeaderNavigationLinks)} - appHeaderTopLinks={object('appHeaderTopLinks', appHeaderTopLinks)} - appModalLoginLinks={object('appModalLoginLinks', appModalLoginLinks)} /> + appHeaderLinks={object('appHeaderLinks', appHeaderLinks)} + appHeaderLoginLinks={object('appHeaderLoonCurrencyChangeFuncTextginLinks', appHeaderLoginLinks)} + appHeaderNavigationLinks={object('appHeaderNavigationLinks', appHeaderNavigationLinks)} + appHeaderTopLinks={object('appHeaderTopLinks', appHeaderTopLinks)} + appModalLoginLinks={object('appModalLoginLinks', appModalLoginLinks)} + /> ); }); diff --git a/src/components/src/AppHeaderNavigation/appheadernavigation.main.api.mocks.tsx b/src/components/src/AppHeaderNavigation/appheadernavigation.main.api.mocks.tsx index 11c5ca7cb..724955f9a 100644 --- a/src/components/src/AppHeaderNavigation/appheadernavigation.main.api.mocks.tsx +++ b/src/components/src/AppHeaderNavigation/appheadernavigation.main.api.mocks.tsx @@ -20,7 +20,7 @@ */ import fetchMock from 'fetch-mock/es5/client'; import fetchNavigationDataResponse from './MockHttpResponses/navigation_data_response.json'; -import loginResponse from '../CommonMockHttpResponses/login_response.json'; +import loginResponse from '../CommonMockHttpResponses/anonymous_login_response.json'; function mockMultiCartResponse(mockObj) { mockObj.get( diff --git a/src/components/src/AppModalBundleConfiguration/appModalBundleConfiguration.main.api.mock.js b/src/components/src/AppModalBundleConfiguration/appModalBundleConfiguration.main.api.mock.ts similarity index 84% rename from src/components/src/AppModalBundleConfiguration/appModalBundleConfiguration.main.api.mock.js rename to src/components/src/AppModalBundleConfiguration/appModalBundleConfiguration.main.api.mock.ts index 1cbf9f117..f4d14110b 100644 --- a/src/components/src/AppModalBundleConfiguration/appModalBundleConfiguration.main.api.mock.js +++ b/src/components/src/AppModalBundleConfiguration/appModalBundleConfiguration.main.api.mock.ts @@ -19,15 +19,8 @@ * */ import fetchMock from 'fetch-mock/es5/client'; -import loginResponse from '../CommonMockHttpResponses/login_response.json'; import mockFetchDependantItemDataResponse from './MockHttpResponses/GET/fetchDependantItemData_response.json'; - -function mockLoginResponse(mockObj) { - mockObj.post( - '/cortex/oauth2/tokens', - loginResponse, - ); -} +import { mockAnonLoginResponse } from '../utils/MockLogins'; function mockFetchDependantItemData(mockObj) { mockObj.get( @@ -38,6 +31,6 @@ function mockFetchDependantItemData(mockObj) { export default function mockAppModalBundleConfigurationMain() { fetchMock.restore(); - mockLoginResponse(fetchMock); + mockAnonLoginResponse(fetchMock); mockFetchDependantItemData(fetchMock); } diff --git a/src/components/src/B2bAccountList/b2b.accountlist.api.mocks.js b/src/components/src/B2bAccountList/b2b.accountlist.api.mocks.ts similarity index 80% rename from src/components/src/B2bAccountList/b2b.accountlist.api.mocks.js rename to src/components/src/B2bAccountList/b2b.accountlist.api.mocks.ts index 4b81782f6..fd908aac3 100644 --- a/src/components/src/B2bAccountList/b2b.accountlist.api.mocks.js +++ b/src/components/src/B2bAccountList/b2b.accountlist.api.mocks.ts @@ -20,7 +20,7 @@ */ import fetchMock from 'fetch-mock/es5/client'; import subAccountResponse from '../CommonMockHttpResponses/b2bSubAccountData_response.json'; -import loginResponse from '../CommonMockHttpResponses/login_response.json'; +import { mockAnonLoginResponse } from '../utils/MockLogins'; function mockSubAccountResponse(mockObj) { mockObj.get( @@ -29,15 +29,8 @@ function mockSubAccountResponse(mockObj) { ); } -function mockLoginResponse(mockObj) { - mockObj.post( - '/cortex/oauth2/tokens', - loginResponse, - ); -} - -export function mockFetchSubAccount() { +export default function mockFetchSubAccount() { fetchMock.restore(); - mockLoginResponse(fetchMock); + mockAnonLoginResponse(fetchMock); mockSubAccountResponse(fetchMock); } diff --git a/src/components/src/B2bAccountList/b2b.accountlist.stories.tsx b/src/components/src/B2bAccountList/b2b.accountlist.stories.tsx index 3395a9f4a..d7bdfe640 100644 --- a/src/components/src/B2bAccountList/b2b.accountlist.stories.tsx +++ b/src/components/src/B2bAccountList/b2b.accountlist.stories.tsx @@ -22,12 +22,11 @@ import React from 'react'; import Readme from './README.md'; import { storiesOf } from '@storybook/react'; import { MemoryRouter } from 'react-router'; -import { object, text, boolean } from "@storybook/addon-knobs/react"; -import { textToFunc } from "../../../../storybook/utils/storybookUtils" +import { object, text } from '@storybook/addon-knobs/react'; +import { textToFunc } from '../../../../storybook/utils/storybookUtils'; +import mockFetchSubAccount from './b2b.accountlist.api.mocks'; import B2bAccountList from './b2b.accountlist'; import SubAccountData from './HttpResponse/accountData_response.json'; -import { mockFetchSubAccount } from './b2b.accountlist.api.mocks'; - const accountListData = { status: 'ENABLED', @@ -51,16 +50,16 @@ storiesOf('Components|B2bAccountList', module) .add('B2bAccountList', () => { mockFetchSubAccount(); - let getAccountDataFuncText = text('getAccountData','() => {alert("getAccountData invoked")}'); - let getSubAccountDataFuncText = text('getSubAccountData','() => {alert("getSubAccountData invoked")}'); - let handleSubAccountClickedFuncText = text('handleSubAccountClicked','() => {alert("handleSubAccountClicked invoked")}'); + const getAccountDataFuncText = text('getAccountData','() => {alert("getAccountData invoked")}'); + const getSubAccountDataFuncText = text('getSubAccountData','() => {alert("getSubAccountData invoked")}'); + const handleSubAccountClickedFuncText = text('handleSubAccountClicked','() => {alert("handleSubAccountClicked invoked")}'); return (
{textToFunc(getAccountDataFuncText)}} - getSubAccountData={()=>{textToFunc(getSubAccountDataFuncText)}} - handleAddSubAccountClicked={()=>{textToFunc(handleSubAccountClickedFuncText)}} + getAccountData={() => { textToFunc(getAccountDataFuncText); }} + getSubAccountData={() => { textToFunc(getSubAccountDataFuncText); }} + handleAddSubAccountClicked={() => { textToFunc(handleSubAccountClickedFuncText); }} accountListData={object('accountListData', accountListData)} accountName={text('accountName', accountName)} registrationNumber={text('registrationNumber', registrationNumber)} diff --git a/src/components/src/B2bSubAccountList/b2b.subaccountlist.stories.tsx b/src/components/src/B2bSubAccountList/b2b.subaccountlist.stories.tsx index c740d898c..2a17ad8ad 100644 --- a/src/components/src/B2bSubAccountList/b2b.subaccountlist.stories.tsx +++ b/src/components/src/B2bSubAccountList/b2b.subaccountlist.stories.tsx @@ -22,12 +22,13 @@ import React from 'react'; import Readme from './README.md'; import { storiesOf } from '@storybook/react'; import { MemoryRouter } from 'react-router'; +import { text, object } from '@storybook/addon-knobs/react'; +import { textToFunc } from '../../../../storybook/utils/storybookUtils'; import SubAccountData from '../B2bAccountList/HttpResponse/accountData_response.json'; import B2bSubAccountList from './b2b.subaccountlist'; -import { mockFetchSubAccount } from '../B2bAccountList/b2b.accountlist.api.mocks'; -import { text, object } from "@storybook/addon-knobs/react"; -import { textToFunc } from "../../../../storybook/utils/storybookUtils" +import mockFetchSubAccount from '../B2bAccountList/b2b.accountlist.api.mocks'; + const accountName = 'Accelsmart'; const registrationNumber = 'cust-00059'; @@ -44,11 +45,11 @@ storiesOf('Components|B2bSubAccountList', module) )) .add('B2bSubAccountList', () => { mockFetchSubAccount(); - let getAccountDataFuncText = text('getAccountData','() => {alert("getAccountData invoked")}'); - + const getAccountDataFuncText = text('getAccountData','() => {alert("getAccountData invoked")}'); + return ( {textToFunc(getAccountDataFuncText)}} + getAccountData={() => { textToFunc(getAccountDataFuncText); }} subAccounts={object('subAccountData', SubAccountData)} accountName={text(accountName)} registrationNumber={text(registrationNumber)} diff --git a/src/components/src/CartCreate/cart.create.api.mocks.js b/src/components/src/CartCreate/cart.create.api.mocks.ts similarity index 72% rename from src/components/src/CartCreate/cart.create.api.mocks.js rename to src/components/src/CartCreate/cart.create.api.mocks.ts index 1ab294ced..3ff4d7bfc 100644 --- a/src/components/src/CartCreate/cart.create.api.mocks.js +++ b/src/components/src/CartCreate/cart.create.api.mocks.ts @@ -20,24 +20,17 @@ */ import fetchMock from 'fetch-mock/es5/client'; import multiCartResponse from '../CommonMockHttpResponses/itemLookupMultiCart_response.json'; -import loginResponse from '../CommonMockHttpResponses/login_response.json'; +import { mockAnonLoginResponse } from '../utils/MockLogins'; function mockMultiCartResponse(mockObj) { mockObj.get( - '/cortex/?zoom=carts,carts:createcartform,carts:element,carts:element:additemstocartform,carts:element:descriptor,carts:element:total', + /(.*)?zoom=carts,carts:createcartform,carts:element,carts:element:additemstocartform,carts:element:descriptor,carts:element:total/, multiCartResponse, ); } -function mockLoginResponse(mockObj) { - mockObj.post( - '/cortex/oauth2/tokens', - loginResponse, - ); -} - -export function mockFetchMultiCart() { +export default function mockFetchMultiCart() { fetchMock.restore(); - mockLoginResponse(fetchMock); + mockAnonLoginResponse(fetchMock); mockMultiCartResponse(fetchMock); } diff --git a/src/components/src/CartCreate/cart.create.stories.tsx b/src/components/src/CartCreate/cart.create.stories.tsx index b2e49eb9b..adbd503c4 100644 --- a/src/components/src/CartCreate/cart.create.stories.tsx +++ b/src/components/src/CartCreate/cart.create.stories.tsx @@ -19,15 +19,14 @@ * */ import React from 'react'; -import Readme from './README.md'; + import { storiesOf } from '@storybook/react'; import { MemoryRouter } from 'react-router'; - +import { text, boolean } from '@storybook/addon-knobs/react'; +import { textToFunc } from '../../../../storybook/utils/storybookUtils'; +import mockFetchMultiCart from './cart.create.api.mocks'; import CartCreate from './cart.create'; - -import { text, boolean } from "@storybook/addon-knobs/react"; -import { textToFunc } from "../../../../storybook/utils/storybookUtils" -import { mockFetchMultiCart } from './cart.create.api.mocks'; +import Readme from './README.md'; storiesOf('Components|CartCreate', module) .addParameters({ @@ -41,12 +40,12 @@ storiesOf('Components|CartCreate', module) )) .add('CartCreate', () => { mockFetchMultiCart(); - let handleModalCloseFuncText = text('handleModalClose','() => {alert("handleModalClose invoked")}'); - let handleCartsUpdateFuncText = text('handleCartsUpdate','() => {alert("handleCartsUpdate invoked")}'); - let handleCartElementSelectFuncText = text('handleCartElementSelect','() => {alert("handleCartElementSelect invoked")}'); - + const handleModalCloseFuncText = text('handleModalClose','() => {alert("handleModalClose invoked")}'); + const handleCartsUpdateFuncText = text('handleCartsUpdate','() => {alert("handleCartsUpdate invoked")}'); + const handleCartElementSelectFuncText = text('handleCartElementSelect','() => {alert("handleCartElementSelect invoked")}'); + return ( - { textToFunc(handleModalCloseFuncText)}} openModal={boolean('openModal', true)} handleCartsUpdate={() => { textToFunc(handleCartsUpdateFuncText)}} diff --git a/src/components/src/CategoryItems/categoryitems.main.api.mocks.ts b/src/components/src/CategoryItems/categoryitems.main.api.mocks.ts index 5cd1280bf..6d7ccfcf2 100644 --- a/src/components/src/CategoryItems/categoryitems.main.api.mocks.ts +++ b/src/components/src/CategoryItems/categoryitems.main.api.mocks.ts @@ -19,20 +19,13 @@ * */ import fetchMock from 'fetch-mock/es5/client'; -import loginResponse from '../CommonMockHttpResponses/login_response.json'; +import { mockAnonLoginResponse } from '../utils/MockLogins'; import fetchNavigationFormResponse from './MockHttpResponses/GET/fetch_navigation_lookup_form_response.json'; import fetchNavigationForm from './MockHttpResponses/POST/fetch_navigation_lookup_response.json'; -function mockLoginResponse(mockObj) { - mockObj.post( - '/cortex/oauth2/tokens', - loginResponse, - ); -} - function mockLookupForm(mockObj) { mockObj.get( - '/cortex/?zoom=lookups:navigationlookupform', + /(.*)?zoom=lookups:navigationlookupform/, fetchNavigationFormResponse, ); } @@ -40,15 +33,15 @@ function mockLookupForm(mockObj) { function mockNavigationLookup(mockObj) { mockObj.post( (url, opts) => { - let matchNavigationLookupRegex = /\/cortex\/navigations\/vestri_reference\/lookups\/form(.*)/; - let categoryToLookupInPayload = 'VV_VEHICLES'; - + const matchNavigationLookupRegex = /\/cortex\/navigations\/vestri_reference\/lookups\/form(.*)/; + const categoryToLookupInPayload = 'VV_VEHICLES'; + if (url.match(matchNavigationLookupRegex)) { - if (opts.body && JSON.parse(opts.body).code==categoryToLookupInPayload) { + if (opts.body && JSON.parse(opts.body).code === categoryToLookupInPayload) { return true; } } - + return false; }, fetchNavigationForm, @@ -57,7 +50,7 @@ function mockNavigationLookup(mockObj) { export default function mockCommonCategoryItemsMainResponses() { fetchMock.restore(); - mockLoginResponse(fetchMock); + mockAnonLoginResponse(fetchMock); mockLookupForm(fetchMock); mockNavigationLookup(fetchMock); } diff --git a/src/components/src/CommonMockHttpResponses/login_response.json b/src/components/src/CommonMockHttpResponses/anonymous_login_response.json similarity index 100% rename from src/components/src/CommonMockHttpResponses/login_response.json rename to src/components/src/CommonMockHttpResponses/anonymous_login_response.json diff --git a/src/components/src/CommonMockHttpResponses/registered_login_response.json b/src/components/src/CommonMockHttpResponses/registered_login_response.json new file mode 100644 index 000000000..54bcb78e3 --- /dev/null +++ b/src/components/src/CommonMockHttpResponses/registered_login_response.json @@ -0,0 +1,8 @@ +{ + "access_token": "9d97df81-e5cd-4a94-8edf-f2c8d1e15ec7", + "token_type": "bearer", + "expires_in": 604799, + "scope": "mobee", + "role": "REGISTERED", + "roles": ["REGISTERED"] +} diff --git a/src/components/src/PaymentForm/MockHttpResponses/GET/paymentInstrumentForm_response.json b/src/components/src/PaymentForm/MockHttpResponses/GET/paymentInstrumentForm_response.json new file mode 100644 index 000000000..26a3da3ed --- /dev/null +++ b/src/components/src/PaymentForm/MockHttpResponses/GET/paymentInstrumentForm_response.json @@ -0,0 +1,746 @@ +{ + "self": { + "type": "elasticpath.collections.links", + "uri": "/?zoom=defaultcart:order:paymentmethodinfo:element:paymentinstrumentform,defaultprofile:paymentmethods:element:paymentinstrumentform", + "href": "https://reference.epdemos.com/cortex/?zoom=defaultcart:order:paymentmethodinfo:element:paymentinstrumentform,defaultprofile:paymentmethods:element:paymentinstrumentform" + }, + "messages": [], + "links": [{ + "rel": "carts", + "type": "carts.carts", + "href": "https://reference.epdemos.com/cortex/carts/mobee" + }, + { + "rel": "defaultcart", + "type": "carts.default-cart", + "href": "https://reference.epdemos.com/cortex/carts/mobee/default" + }, + { + "rel": "data-policies", + "type": "datapolicies.data-policies", + "href": "https://reference.epdemos.com/cortex/datapolicies/mobee" + }, + { + "rel": "countries", + "type": "geographies.countries", + "href": "https://reference.epdemos.com/cortex/geographies/mobee/countries" + }, + { + "rel": "lookups", + "type": "lookups.lookups", + "href": "https://reference.epdemos.com/cortex/lookups/mobee" + }, + { + "rel": "navigations", + "type": "navigations.navigations", + "href": "https://reference.epdemos.com/cortex/navigations/mobee" + }, + { + "rel": "defaultprofile", + "type": "profiles.default-profile", + "href": "https://reference.epdemos.com/cortex/profiles/mobee/default" + }, + { + "rel": "newaccountform", + "type": "registrations.new-account-registration-form", + "href": "https://reference.epdemos.com/cortex/registrations/mobee/newaccount/form" + }, + { + "rel": "searches", + "type": "searches.searches", + "href": "https://reference.epdemos.com/cortex/searches/mobee" + }, + { + "rel": "defaultwishlist", + "type": "wishlists.default-wishlist", + "href": "https://reference.epdemos.com/cortex/wishlists/mobee/default" + } + ], + "_defaultcart": [{ + "_order": [{ + "_paymentmethodinfo": [{ + "_element": [{ + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gezwimbwgbrtolleg43tgljumm2tellcmm2gmljtmu2wkyzrmyywgoldgy=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gezwimbwgbrtolleg43tgljumm2tellcmm2gmljtmu2wkyzrmyywgoldgy=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gezwimbwgbrtolleg43tgljumm2tellcmm2gmljtmu2wkyzrmyywgoldgy=/paymentinstrument/form" + }], + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "display-name": "" + }, + "save-on-profile": false + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gyygmmjymu4tmljqmezdqljumezdsljymrsdoljwmmydgnrygzrtinrwmu=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gyygmmjymu4tmljqmezdqljumezdsljymrsdoljwmmydgnrygzrtinrwmu=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gyygmmjymu4tmljqmezdqljumezdsljymrsdoljwmmydgnrygzrtinrwmu=/paymentinstrument/form" + }], + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "display-name": "" + }, + "save-on-profile": false + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gy3temtgheydsljtgrtgkljumuzgkllbmrtdqllcgbsdmobxmeytezbqgi=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gy3temtgheydsljtgrtgkljumuzgkllbmrtdqllcgbsdmobxmeytezbqgi=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gy3temtgheydsljtgrtgkljumuzgkllbmrtdqllcgbsdmobxmeytezbqgi=/paymentinstrument/form" + }], + "limit-amount": 0, + "payment-instrument-identification-form": { + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gbstenbzgu4delleg5stoljume4wmljygu4tkljtgzqtayzzgfrwkzdbhe=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gbstenbzgu4delleg5stoljume4wmljygu4tkljtgzqtayzzgfrwkzdbhe=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gbstenbzgu4delleg5stoljume4wmljygu4tkljtgzqtayzzgfrwkzdbhe=/paymentinstrument/form" + }], + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "PIC Field A": "", + "PIC Field B": "", + "display-name": "" + }, + "save-on-profile": false + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mfqwmyzyga3teljtgjrggljugvswmllbg42dkllemiywmy3eg5tdgzjyha=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mfqwmyzyga3teljtgjrggljugvswmllbg42dkllemiywmy3eg5tdgzjyha=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mfqwmyzyga3teljtgjrggljugvswmllbg42dkllemiywmy3eg5tdgzjyha=/paymentinstrument/form" + }], + "billing-address": { + "address": { + "country-name": "", + "extended-address": "", + "locality": "", + "postal-code": "", + "region": "", + "street-address": "" + }, + "name": { + "family-name": "", + "given-name": "" + }, + "organization": "", + "phone-number": "" + }, + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "Field 1": "", + "Field 10": "", + "Field 2": "", + "Field 3": "", + "Field 4": "", + "Field 5": "", + "Field 6": "", + "Field 7": "", + "Field 8": "", + "Field 9": "", + "display-name": "" + }, + "save-on-profile": false + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mnswiyrvheydmljvge4giljuhazteljzmmydkllbmq4tgmbzmjqtazjsme=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mnswiyrvheydmljvge4giljuhazteljzmmydkllbmq4tgmbzmjqtazjsme=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mnswiyrvheydmljvge4giljuhazteljzmmydkllbmq4tgmbzmjqtazjsme=/paymentinstrument/form" + }], + "billing-address": { + "address": { + "country-name": "", + "extended-address": "", + "locality": "", + "postal-code": "", + "region": "", + "street-address": "" + }, + "name": { + "family-name": "", + "given-name": "" + }, + "organization": "", + "phone-number": "" + }, + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "PIC Field A": "", + "PIC Field B": "", + "display-name": "" + }, + "save-on-profile": false + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/hfrgkmzqmu3wcljwmvrtsljugfsdsllbmftgiljvmq4wezlbmvswkyzrmm=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/hfrgkmzqmu3wcljwmvrtsljugfsdsllbmftgiljvmq4wezlbmvswkyzrmm=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/hfrgkmzqmu3wcljwmvrtsljugfsdsllbmftgiljvmq4wezlbmvswkyzrmm=/paymentinstrument/form" + }], + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "display-name": "" + }, + "save-on-profile": false + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/ha2dmzdehbtdmllfmnstgljuga3tillcgi3geljzmiytazbvgfswkolghe=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/ha2dmzdehbtdmllfmnstgljuga3tillcgi3geljzmiytazbvgfswkolghe=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/ha2dmzdehbtdmllfmnstgljuga3tillcgi3geljzmiytazbvgfswkolghe=/paymentinstrument/form" + }], + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "display-name": "" + }, + "save-on-profile": false + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gfsdon3dgm2tmljvhfqwcljug43dmljymntgmljthfsgkmtgmmydiodcgi=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gfsdon3dgm2tmljvhfqwcljug43dmljymntgmljthfsgkmtgmmydiodcgi=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gfsdon3dgm2tmljvhfqwcljug43dmljymntgmljthfsgkmtgmmydiodcgi=/paymentinstrument/form" + }], + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "display-name": "" + }, + "save-on-profile": false + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gzrtmyrvg4ydqllfhaztaljumzrtmljymrtgcljrgjswkytdgu3wgytemq=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gzrtmyrvg4ydqllfhaztaljumzrtmljymrtgcljrgjswkytdgu3wgytemq=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/gzrtmyrvg4ydqllfhaztaljumzrtmljymrtgcljrgjswkytdgu3wgytemq=/paymentinstrument/form" + }], + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "display-name": "" + }, + "save-on-profile": false + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mrsdknzygi2dklldgeztcljumm3tallbgfrdqljqmrsdcmzxgnrtcnjvha=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mrsdknzygi2dklldgeztcljumm3tallbgfrdqljqmrsdcmzxgnrtcnjvha=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mrsdknzygi2dklldgeztcljumm3tallbgfrdqljqmrsdcmzxgnrtcnjvha=/paymentinstrument/form" + }], + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "display-name": "" + }, + "save-on-profile": false + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mrtdezjqgjrtmllbgu4deljuhe2tqljzgzrdcljqgnstmobvmnqwcmtcga=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mrtdezjqgjrtmllbgu4deljuhe2tqljzgzrdcljqgnstmobvmnqwcmtcga=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mrtdezjqgjrtmllbgu4deljuhe2tqljzgzrdcljqgnstmobvmnqwcmtcga=/paymentinstrument/form" + }], + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "display-name": "" + }, + "save-on-profile": false + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/giygcztdmmydsljtgy4doljugiztoljzgfswcljwmqztizjugrtdenbuga=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/giygcztdmmydsljtgy4doljugiztoljzgfswcljwmqztizjugrtdenbuga=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/giygcztdmmydsljtgy4doljugiztoljzgfswcljwmqztizjugrtdenbuga=/paymentinstrument/form" + }], + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "display-name": "" + }, + "save-on-profile": false + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/ge3tanjymyytiljvhe2dkljumm4willbmnstcljzhbsdknjxgnstgmzxme=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/ge3tanjymyytiljvhe2dkljumm4willbmnstcljzhbsdknjxgnstgmzxme=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/ge3tanjymyytiljvhe2dkljumm4willbmnstcljzhbsdknjxgnstgmzxme=/paymentinstrument/form" + }], + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "display-name": "" + }, + "save-on-profile": false + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.order-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mi4wgylbgjrwillehfqtaljumvsgellcheywcllbmnrdantegbrtmm3fmm=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mi4wgylbgjrwillehfqtaljumvsgellcheywcllbmnrdantegbrtmm3fmm=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.order-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/orders/mobee/gfrdkzrrge2wiljrgbrwiljugmzgeljymuydqljtg5swgnrxmuytsztggu=/mi4wgylbgjrwillehfqtaljumvsgellcheywcllbmnrdantegbrtmm3fmm=/paymentinstrument/form" + }], + "default-on-profile": false, + "limit-amount": 0, + "payment-instrument-identification-form": { + "PIC Field A": "", + "PIC Field B": "", + "display-name": "" + }, + "save-on-profile": false + }] + } + ] + }] + }] + }], + "_defaultprofile": [{ + "_paymentmethods": [{ + "_element": [{ + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gezwimbwgbrtolleg43tgljumm2tellcmm2gmljtmu2wkyzrmyywgoldgy=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gezwimbwgbrtolleg43tgljumm2tellcmm2gmljtmu2wkyzrmyywgoldgy=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gezwimbwgbrtolleg43tgljumm2tellcmm2gmljtmu2wkyzrmyywgoldgy=/paymentinstrument/form" + }], + "default-on-profile": false, + "payment-instrument-identification-form": { + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gyygmmjymu4tmljqmezdqljumezdsljymrsdoljwmmydgnrygzrtinrwmu=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gyygmmjymu4tmljqmezdqljumezdsljymrsdoljwmmydgnrygzrtinrwmu=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gyygmmjymu4tmljqmezdqljumezdsljymrsdoljwmmydgnrygzrtinrwmu=/paymentinstrument/form" + }], + "default-on-profile": false, + "payment-instrument-identification-form": { + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gbstenbzgu4delleg5stoljume4wmljygu4tkljtgzqtayzzgfrwkzdbhe=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gbstenbzgu4delleg5stoljume4wmljygu4tkljtgzqtayzzgfrwkzdbhe=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gbstenbzgu4delleg5stoljume4wmljygu4tkljtgzqtayzzgfrwkzdbhe=/paymentinstrument/form" + }], + "default-on-profile": false, + "payment-instrument-identification-form": { + "PIC Field A": "", + "PIC Field B": "", + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mfqwmyzyga3teljtgjrggljugvswmllbg42dkllemiywmy3eg5tdgzjyha=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mfqwmyzyga3teljtgjrggljugvswmllbg42dkllemiywmy3eg5tdgzjyha=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mfqwmyzyga3teljtgjrggljugvswmllbg42dkllemiywmy3eg5tdgzjyha=/paymentinstrument/form" + }], + "billing-address": { + "address": { + "country-name": "", + "extended-address": "", + "locality": "", + "postal-code": "", + "region": "", + "street-address": "" + }, + "name": { + "family-name": "", + "given-name": "" + }, + "organization": "", + "phone-number": "" + }, + "default-on-profile": false, + "payment-instrument-identification-form": { + "Field 1": "", + "Field 10": "", + "Field 2": "", + "Field 3": "", + "Field 4": "", + "Field 5": "", + "Field 6": "", + "Field 7": "", + "Field 8": "", + "Field 9": "", + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mnswiyrvheydmljvge4giljuhazteljzmmydkllbmq4tgmbzmjqtazjsme=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mnswiyrvheydmljvge4giljuhazteljzmmydkllbmq4tgmbzmjqtazjsme=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mnswiyrvheydmljvge4giljuhazteljzmmydkllbmq4tgmbzmjqtazjsme=/paymentinstrument/form" + }], + "billing-address": { + "address": { + "country-name": "", + "extended-address": "", + "locality": "", + "postal-code": "", + "region": "", + "street-address": "" + }, + "name": { + "family-name": "", + "given-name": "" + }, + "organization": "", + "phone-number": "" + }, + "default-on-profile": false, + "payment-instrument-identification-form": { + "PIC Field A": "", + "PIC Field B": "", + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/hfrgkmzqmu3wcljwmvrtsljugfsdsllbmftgiljvmq4wezlbmvswkyzrmm=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/hfrgkmzqmu3wcljwmvrtsljugfsdsllbmftgiljvmq4wezlbmvswkyzrmm=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/hfrgkmzqmu3wcljwmvrtsljugfsdsllbmftgiljvmq4wezlbmvswkyzrmm=/paymentinstrument/form" + }], + "default-on-profile": false, + "payment-instrument-identification-form": { + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/ha2dmzdehbtdmllfmnstgljuga3tillcgi3geljzmiytazbvgfswkolghe=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/ha2dmzdehbtdmllfmnstgljuga3tillcgi3geljzmiytazbvgfswkolghe=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/ha2dmzdehbtdmllfmnstgljuga3tillcgi3geljzmiytazbvgfswkolghe=/paymentinstrument/form" + }], + "default-on-profile": false, + "payment-instrument-identification-form": { + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gfsdon3dgm2tmljvhfqwcljug43dmljymntgmljthfsgkmtgmmydiodcgi=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gfsdon3dgm2tmljvhfqwcljug43dmljymntgmljthfsgkmtgmmydiodcgi=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gfsdon3dgm2tmljvhfqwcljug43dmljymntgmljthfsgkmtgmmydiodcgi=/paymentinstrument/form" + }], + "default-on-profile": false, + "payment-instrument-identification-form": { + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gzrtmyrvg4ydqllfhaztaljumzrtmljymrtgcljrgjswkytdgu3wgytemq=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gzrtmyrvg4ydqllfhaztaljumzrtmljymrtgcljrgjswkytdgu3wgytemq=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/gzrtmyrvg4ydqllfhaztaljumzrtmljymrtgcljrgjswkytdgu3wgytemq=/paymentinstrument/form" + }], + "default-on-profile": false, + "payment-instrument-identification-form": { + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mrsdknzygi2dklldgeztcljumm3tallbgfrdqljqmrsdcmzxgnrtcnjvha=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mrsdknzygi2dklldgeztcljumm3tallbgfrdqljqmrsdcmzxgnrtcnjvha=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mrsdknzygi2dklldgeztcljumm3tallbgfrdqljqmrsdcmzxgnrtcnjvha=/paymentinstrument/form" + }], + "default-on-profile": false, + "payment-instrument-identification-form": { + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mrtdezjqgjrtmllbgu4deljuhe2tqljzgzrdcljqgnstmobvmnqwcmtcga=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mrtdezjqgjrtmllbgu4deljuhe2tqljzgzrdcljqgnstmobvmnqwcmtcga=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mrtdezjqgjrtmllbgu4deljuhe2tqljzgzrdcljqgnstmobvmnqwcmtcga=/paymentinstrument/form" + }], + "default-on-profile": false, + "payment-instrument-identification-form": { + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/giygcztdmmydsljtgy4doljugiztoljzgfswcljwmqztizjugrtdenbuga=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/giygcztdmmydsljtgy4doljugiztoljzgfswcljwmqztizjugrtdenbuga=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/giygcztdmmydsljtgy4doljugiztoljzgfswcljwmqztizjugrtdenbuga=/paymentinstrument/form" + }], + "default-on-profile": false, + "payment-instrument-identification-form": { + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/ge3tanjymyytiljvhe2dkljumm4willbmnstcljzhbsdknjxgnstgmzxme=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/ge3tanjymyytiljvhe2dkljumm4willbmnstcljzhbsdknjxgnstgmzxme=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/ge3tanjymyytiljvhe2dkljumm4willbmnstcljzhbsdknjxgnstgmzxme=/paymentinstrument/form" + }], + "default-on-profile": false, + "payment-instrument-identification-form": { + "display-name": "" + } + }] + }, + { + "_paymentinstrumentform": [{ + "self": { + "type": "paymentinstruments.profile-payment-instrument-form", + "uri": "/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mi4wgylbgjrwillehfqtaljumvsgellcheywcllbmnrdantegbrtmm3fmm=/paymentinstrument/form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mi4wgylbgjrwillehfqtaljumvsgellcheywcllbmnrdantegbrtmm3fmm=/paymentinstrument/form" + }, + "messages": [], + "links": [{ + "rel": "createpaymentinstrumentaction", + "type": "paymentinstruments.profile-payment-instrument-form", + "href": "https://reference.epdemos.com/cortex/paymentinstruments/paymentmethods/profiles/mobee/gm4tkntcmjtgillemi4geljuga4tsllcmqydmljxgezdoyjugeydoylcha=/mi4wgylbgjrwillehfqtaljumvsgellcheywcllbmnrdantegbrtmm3fmm=/paymentinstrument/form" + }], + "default-on-profile": false, + "payment-instrument-identification-form": { + "PIC Field A": "", + "PIC Field B": "", + "display-name": "" + } + }] + } + ] + }] + }] +} diff --git a/src/components/src/PaymentForm/README.md b/src/components/src/PaymentForm/README.md index 5bb263a49..4a4ba8d7e 100644 --- a/src/components/src/PaymentForm/README.md +++ b/src/components/src/PaymentForm/README.md @@ -2,7 +2,13 @@ #### Description -Displays modal to add payment informatioon to order. Falls back to generating random string for credit card placeholder if Cybersource accelerator resource is not present. +Displays a credit card form. + +If **defaultPostSelection** is set to true then the component will automatically post and add to the Registered user profiles **paymentinstrumentform**. Passing this property to true is appropriate when consuming this component on a users profile page where the form is always used to save payment information a users profile. If **defaultPostSelection** is not passed or set to false then the component will post to the current users **paymentinstrumentform** under the **orders** resource. Setting false to **defaultPostSelection** is most appropriate when using this component in a checkout flow. + +The checkbox labelled **Save This Payment Method To My Profile** will be available when setting **showSaveToProfileOption** to true and is also recommended to be set to true when consumed in a checkout flow. It gives the user an option to save the payment information to the profile resource. + +Since this is a template component it is hardcoded to take the first **paymentinstrumentform** available in **paymentinstruments** resource. When posting, arbitrary tokenized data is set to the respective **paymentinstrumentform** fields. It is up to the implementor to make changes to how the component tokenizes data as this varies from solution to solution. Comments in the code will guide as to which portions should be removed and filled. #### Usage @@ -13,7 +19,7 @@ import { PaymentFormMain } from '@elasticpath/store-components'; #### Example ```js - + ``` #### Properties diff --git a/src/components/src/PaymentForm/paymentform.main.api.mocks.ts b/src/components/src/PaymentForm/paymentform.main.api.mocks.ts new file mode 100644 index 000000000..d1ddaaf96 --- /dev/null +++ b/src/components/src/PaymentForm/paymentform.main.api.mocks.ts @@ -0,0 +1,67 @@ +/** + * Copyright © 2019 Elastic Path Software Inc. All rights reserved. + * + * This is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this license. If not, see + * + * https://www.gnu.org/licenses/ + * + * + */ +import fetchMock from 'fetch-mock/es5/client'; +import paymentInstrumentFormResponse from './MockHttpResponses/GET/paymentInstrumentForm_response.json'; +import { mockAnonLoginResponse, mockRegisteredLoginResponse } from '../utils/MockLogins'; + +function mockPaymentInstrumentForm(mockObj) { + mockObj.get( + /(.*)(zoom=defaultcart:order:paymentmethodinfo:element:paymentinstrumentform|zoom=defaultprofile:paymentmethods:element:paymentinstrumentform)/, + paymentInstrumentFormResponse, + ); +} + +function mockPaymentInstrumentFormActionSuccess(mockObj) { + const delay = new Promise((res, rej) => setTimeout(res, 10000)); + mockObj.post( + /(.*)\/cortex\/paymentinstruments\/paymentmethods\/(orders|profiles)\/(.*)\/form/, + delay.then(() => paymentInstrumentFormResponse), + ); +} + +function mockPaymentInstrumentFormActionFailure(mockObj) { + const delay = new Promise((res, rej) => setTimeout(res, 10000)); + mockObj.post( + /(.*)\/cortex\/paymentinstruments\/paymentmethods\/(orders|profiles)\/(.*)\/form/, + delay.then(() => 400), + ); +} + +export function mockPaymentFormSuccessWithAnonUser() { + fetchMock.restore(); + mockAnonLoginResponse(fetchMock); + mockPaymentInstrumentForm(fetchMock); + mockPaymentInstrumentFormActionSuccess(fetchMock); +} + +export function mockPaymentFormSuccessWithRegisteredUser() { + fetchMock.restore(); + mockRegisteredLoginResponse(fetchMock); + mockPaymentInstrumentForm(fetchMock); + mockPaymentInstrumentFormActionSuccess(fetchMock); +} + +export function mockPaymentFormFailureWithAnonUser() { + fetchMock.restore(); + mockAnonLoginResponse(fetchMock); + mockPaymentInstrumentForm(fetchMock); + mockPaymentInstrumentFormActionFailure(fetchMock); +} diff --git a/src/components/src/PaymentForm/paymentform.main.stories.tsx b/src/components/src/PaymentForm/paymentform.main.stories.tsx index d5eb2e5d7..6b86365af 100644 --- a/src/components/src/PaymentForm/paymentform.main.stories.tsx +++ b/src/components/src/PaymentForm/paymentform.main.stories.tsx @@ -19,13 +19,14 @@ * */ import React from 'react'; -import Readme from './README.md'; +import { text } from '@storybook/addon-knobs'; import { storiesOf } from '@storybook/react'; - +import { textToFunc } from '../../../../storybook/utils/storybookUtils'; import PaymentFormMain from './paymentform.main'; +import { mockPaymentFormSuccessWithAnonUser, mockPaymentFormFailureWithAnonUser, mockPaymentFormSuccessWithRegisteredUser } from './paymentform.main.api.mocks'; + +import Readme from './README.md'; -import { boolean, object, text } from '@storybook/addon-knobs'; -import { textToFunc } from "../../../../storybook/utils/storybookUtils" storiesOf('Components|PaymentFormMain', module) .addParameters({ @@ -34,8 +35,45 @@ storiesOf('Components|PaymentFormMain', module) sidebar: Readme, }, }) - .add('PaymentFormMain', () => { - let onCloseModalFuncText = text('onCloseModal','() => {alert("onCloseModal invoked")}'); - let onConfigurationAddToCartFuncText = text('onConfigurationAddToCart','() => {alert("onConfigurationAddToCart invoked")}'); - return({textToFunc(onCloseModalFuncText)}} fetchData={()=>{textToFunc(onConfigurationAddToCartFuncText)}} />); + .add('PaymentFormMain with Successful Submission Response', () => { + mockPaymentFormSuccessWithAnonUser(); + const onCloseModalFuncText = text('onCloseModal', '() => {alert("onCloseModal invoked")}'); + const fetchDataFuncText = text('fetchData', '() => {alert("fetchData invoked")}'); + + return ( + { textToFunc(onCloseModalFuncText); }} + fetchData={() => { textToFunc(fetchDataFuncText); }} + /> + ); + }) + .add('PaymentFormMain with SaveToProfile Checkbox and Successful Submission Response', () => { + mockPaymentFormSuccessWithRegisteredUser(); + + const onCloseModalFuncText = text('onCloseModal', '() => {alert("onCloseModal invoked")}'); + const fetchDataFuncText = text('fetchData', '() => {alert("fetchData invoked")}'); + + return ( + { textToFunc(onCloseModalFuncText); }} + fetchData={() => { textToFunc(fetchDataFuncText); }} + showSaveToProfileOption + /> + ); + }) + .add('PaymentFormMain with Failure Submission Response', () => { + mockPaymentFormFailureWithAnonUser(); + + const onCloseModalFuncText = text('onCloseModal', '() => {alert("onCloseModal invoked")}'); + const fetchDataFuncText = text('fetchData', '() => {alert("fetchData invoked")}'); + + return ( + { textToFunc(onCloseModalFuncText); }} + fetchData={() => { textToFunc(fetchDataFuncText); }} + showSaveToProfileOption + /> + ); }); diff --git a/src/components/src/PaymentForm/paymentform.main.tsx b/src/components/src/PaymentForm/paymentform.main.tsx index 02be3ac4e..6e761f7d9 100644 --- a/src/components/src/PaymentForm/paymentform.main.tsx +++ b/src/components/src/PaymentForm/paymentform.main.tsx @@ -31,10 +31,16 @@ let intl = { get: str => str }; const today = new Date(); interface PaymentFormMainProps { + /** dictates whether to add tokenized payment data to the profile resource or order resource. */ + defaultPostSelection: boolean, /** handle close modal */ onCloseModal?: (...args: any[]) => any, /** handle fetch data */ fetchData?: (...args: any[]) => any, + /** Toggles whether or not to show a checkbox that allows user to save payment to profile. + * Only shown if defaultPostSelection is set to false. + */ + showSaveToProfileOption: boolean, } interface PaymentFormMainState { @@ -47,15 +53,18 @@ interface PaymentFormMainState { securityCode: string, saveToProfile: boolean, failedSubmit: boolean, - paymentForm: any, - orderPaymentForm: any, - cybersourceBodyRequest: any, + paymentInstrumentFormFieldsToFill: object, + submitPaymentFormOrderUri: string, + submitPaymentFormProfileUri: string, + doesPaymentInstrumentResourceExist: boolean, } class PaymentFormMain extends Component { static defaultProps = { onCloseModal: () => {}, fetchData: () => {}, + defaultPostSelection: false, + showSaveToProfileOption: false, } formRef: React.RefObject; @@ -75,10 +84,12 @@ class PaymentFormMain extends Component(); + this.makeSubmitPaymentMethodRequest = this.makeSubmitPaymentMethodRequest.bind(this); + this.doesPaymentInstrumentFormExist = this.doesPaymentInstrumentFormExist.bind(this); + } + + doesPaymentInstrumentFormExist(paymentInstrumentForm) { + if (paymentInstrumentForm._defaultprofile || paymentInstrumentForm._defaultcart) { + this.setState({ doesPaymentInstrumentResourceExist: true }); + return true; + } + this.setState({ doesPaymentInstrumentResourceExist: false }); + return false; + } + + async initializeState() { + const paymentInstrumentForm = await PaymentFormMain.fetchPaymentInstrumentForm(); + this.setSubmitPaymentForm(paymentInstrumentForm); + } + + async componentDidMount() { + this.initializeState(); + } + + setSubmitPaymentForm(paymentInstrumentForm) { + if (this.doesPaymentInstrumentFormExist(paymentInstrumentForm)) { + const submitPaymentFormOrderUri = PaymentFormMain.parseOrderPaymentInstrumentFormActionFromResponse(paymentInstrumentForm); + const submitPaymentFormProfileUri = PaymentFormMain.parseProfilePaymentInstrumentFormActionFromResponse(paymentInstrumentForm); + this.setPaymentInstrumentFormFieldsToFill(paymentInstrumentForm); + this.setState({ submitPaymentFormProfileUri, submitPaymentFormOrderUri }); + } else { + // Using Pre Cortex 7.6 legacy paymentmethodform endpoints. + this.fetchPaymentMethodsForm(); + } } - componentDidMount() { - this.fetchPaymentForms(); + setPaymentInstrumentFormFieldsToFill(paymentInstrumentForm) { + const paymentFormFieldsToFill = this.parsePaymentInstrumentFormFieldsFromResponse(paymentInstrumentForm); + this.setState({ paymentInstrumentFormFieldsToFill: paymentFormFieldsToFill }); } - componentDidUpdate() { - const formCardNumberExists = document.getElementById('card_number'); - const formBillEmailExists = document.getElementById('bill_to_email'); - const formExists = document.getElementById('payment_confirmation'); + shouldShowSaveToProfile() { + const { defaultPostSelection, showSaveToProfileOption } = this.props; - if (formExists && formCardNumberExists && formBillEmailExists) { - this.formRef.current.submit(); + if (!defaultPostSelection && showSaveToProfileOption) { + return true; + } + + return false; + } + + static parseOrderPaymentInstrumentFormActionFromResponse(paymentInstrumentForm) { + try { + return paymentInstrumentForm._defaultcart[0]._order[0]._paymentmethodinfo[0]._element[0]._paymentinstrumentform[0].self.uri; + } catch (err) { + return null; + } + } + + static parseProfilePaymentInstrumentFormActionFromResponse(paymentInstrumentForm) { + try { + return paymentInstrumentForm._defaultprofile[0]._paymentmethods[0]._element[0]._paymentinstrumentform[0].self.uri; + } catch (err) { + return null; + } + } + + async componentDidUpdate(prevProps, prevState) { + const { defaultPostSelection } = this.props; + + if (defaultPostSelection !== prevProps.defaultPostSelection) { + this.initializeState(); } } + static async fetchPaymentInstrumentForm() { + let paymentInstrumentFormUnserialized; + + const zoomQuery = '/?zoom=defaultcart:order:paymentmethodinfo:element:paymentinstrumentform,defaultprofile:paymentmethods:element:paymentinstrumentform'; + + try { + await login(); + + const paymentInstrumentForm = await cortexFetch( + zoomQuery, + { + headers: { + 'Content-Type': 'application/json', + Authorization: localStorage.getItem(`${Config.cortexApi.scope}_oAuthToken`), + }, + }, + ); + + paymentInstrumentFormUnserialized = await paymentInstrumentForm.json(); + + return paymentInstrumentFormUnserialized; + } catch (err) { + // eslint-disable-next-line no-console + console.error('Unable to fetch PaymentInstrumentForm ', err); + } + + return paymentInstrumentFormUnserialized; + } + + parsePaymentInstrumentFormFieldsFromResponse(paymentInstrumentForm) { + const { defaultPostSelection } = this.props; + let zoomResult; + + if (defaultPostSelection) { + // eslint-disable-next-line prefer-destructuring + zoomResult = paymentInstrumentForm._defaultprofile[0]._paymentmethods[0]._element[0]._paymentinstrumentform[0]; + } else { + // eslint-disable-next-line prefer-destructuring + zoomResult = paymentInstrumentForm._defaultcart[0]._order[0]._paymentmethodinfo[0]._element[0]._paymentinstrumentform[0]; + } + + const paymentInstrumentFormKeys = Object.keys(zoomResult).filter((key) => { + if (key === 'self' || key === 'links' || key === 'messages') { + return false; + } + return true; + }); + + return paymentInstrumentFormKeys.reduce((acc, cKey) => ({ + ...acc, + [cKey]: zoomResult[cKey], + }), {}); + } + setCardType(event) { this.setState({ cardType: event.target.value }); } @@ -134,29 +263,158 @@ class PaymentFormMain extends Component { + cortexFetch(link, { + method: 'post', + headers: { + 'Content-Type': 'application/json', + Authorization: localStorage.getItem(`${Config.cortexApi.scope}_oAuthToken`), + }, + body: JSON.stringify({ + 'display-name': `${cardHolderName}'s ${card} ending in: ****${cardNumber.substring(cardNumber.length - 4)}`, + token: Math.random() + .toString(36) + .substr(2, 9), + /* token is being randomly generated here to be passed to the demo payment gateway + ** in a true implementation this token should be received from the actual payment gateway + ** when doing so, make sure you're compliant with PCI DSS + */ + }), + }) + .then((res) => { + this.setState({ + showLoader: false, + }); + if (res.status === 400) { + this.setState({ failedSubmit: true }); + } else if (res.status === 201 || res.status === 200 || res.status === 204) { + this.setState({ failedSubmit: false }, () => { + fetchData(); + onCloseModal(); + }); + } + }) + .catch((error) => { + this.setState({ + showLoader: false, + }); + // eslint-disable-next-line no-console + console.error(error.message); + }); }); - let link; - if (saveToProfile) { - link = paymentForm; + } + + /** + * NOTE: + * This function makes a post request to the paymentinstrumentform resource in either the profile or orders resource depending on logged in status + * and if the checkbox to `save to profile` is checked. In customer implementation this portion will need to be rewritten to suit specific needs. + */ + async makeSubmitPaymentRequest() { + const { + fetchData, + onCloseModal, + defaultPostSelection, + } = this.props; + const { + paymentInstrumentFormFieldsToFill, + submitPaymentFormOrderUri, + submitPaymentFormProfileUri, + saveToProfile, + doesPaymentInstrumentResourceExist, + } = this.state; + + let submitPaymentFormUri; + + if (defaultPostSelection || saveToProfile) { + submitPaymentFormUri = submitPaymentFormProfileUri; } else { - link = orderPaymentForm; + submitPaymentFormUri = submitPaymentFormOrderUri; } + + if (doesPaymentInstrumentResourceExist) { + const formFieldsFilled = this.fillPaymentInstrumentFormFields(paymentInstrumentFormFieldsToFill); + + try { + const addPaymentResponse = await cortexFetch(submitPaymentFormUri, + { + method: 'post', + headers: { + 'Content-Type': 'application/json', + Authorization: localStorage.getItem(`${Config.cortexApi.scope}_oAuthToken`), + }, + body: JSON.stringify(formFieldsFilled), + }); + + this.setState({ + showLoader: false, + }); + + if (addPaymentResponse.status === 400) { + this.setState({ failedSubmit: true }); + } else if (addPaymentResponse.status === 201 || addPaymentResponse.status === 200 || addPaymentResponse.status === 204) { + this.setState({ failedSubmit: false }, () => { + fetchData(); + onCloseModal(); + }); + } + } catch (err) { + // eslint-disable-next-line no-console + console.error(err); + } + } else { + this.makeSubmitPaymentMethodRequest(submitPaymentFormUri); + } + } + + submitPayment(event) { + event.preventDefault(); + + if (this.areCreditCardFieldsValid()) { + this.setState({ showLoader: true, failedSubmit: false }); + this.makeSubmitPaymentRequest(); + } else { + this.setState({ failedSubmit: true }); + } + } + + static findCardTypeFromCode(code) { let card; - switch (cardType) { + switch (code) { case '001': card = 'Visa'; break; @@ -167,165 +425,55 @@ class PaymentFormMain extends Component { - cortexFetch(`/?zoom=${zoomArrayProfile.join()}`, - { - headers: { - 'Content-Type': 'application/json', - Authorization: localStorage.getItem(`${Config.cortexApi.scope}_oAuthToken`), - }, - }) - .then(profileData => profileData.json()) - .then((profileData) => { - bodyLambdaRequest = { - ...bodyLambdaRequest, - currency: profileData._defaultcart[0]._total[0].cost[0].currency, - bill_to_email: profileData._defaultprofile[0]._emails[0]._element[0].email, - bill_to_address_city: profileData._defaultprofile[0]._addresses[0]._element[0].address.locality, - bill_to_address_state: profileData._defaultprofile[0]._addresses[0]._element[0].address.region, - bill_to_address_country: profileData._defaultprofile[0]._addresses[0]._element[0].address['country-name'], - bill_to_address_postal_code: profileData._defaultprofile[0]._addresses[0]._element[0].address['postal-code'], - bill_to_address_line1: profileData._defaultprofile[0]._addresses[0]._element[0].address['street-address'], - }; - fetch(Config.creditCardTokenization.lambdaURI, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify(bodyLambdaRequest), - }) - .then(lambdaResponse => lambdaResponse.json()) - .then((lambdaResponse) => { - const cardData = { - bill_to_forename: name[0], - bill_to_surname: name[1], - card_type: cardType.toString(), - card_number: cardNumber.toString(), - cardExpiryDate: `${formatedExpiryMonth}-${expiryYear}`, - card_cvn: securityCode.toString(), - }; - const cybersourceBodyRequest = { ...cardData, ...lambdaResponse }; - this.setState({ cybersourceBodyRequest }); - }); - }); - }) - .catch((error) => { - this.setState({ - showLoader: false, - }); - // eslint-disable-next-line no-console - console.error(error.message); - }); - } else { - login().then(() => { - cortexFetch(link, { - method: 'post', - headers: { - 'Content-Type': 'application/json', - Authorization: localStorage.getItem(`${Config.cortexApi.scope}_oAuthToken`), - }, - body: JSON.stringify({ - 'display-name': `${cardHolderName}'s ${card} ending in: ****${cardNumber.substring(cardNumber.length - 4)}`, - token: Math.random() - .toString(36) - .substr(2, 9), - /* token is being randomly generated here to be passed to the demo payment gateway - ** in a true implementation this token should be received from the actual payment gateway - ** when doing so, make sure you're compliant with PCI DSS - */ - }), - }) - .then((res) => { - this.setState({ - showLoader: false, - }); - if (res.status === 400) { - this.setState({ failedSubmit: true }); - } else if (res.status === 201 || res.status === 200 || res.status === 204) { - this.setState({ failedSubmit: false }, () => { - fetchData(); - onCloseModal(); - }); - } - }) - .catch((error) => { - this.setState({ - showLoader: false, - }); - // eslint-disable-next-line no-console - console.error(error.message); - }); - }); + return card; + } + + fillPaymentInstrumentFormFields(paymentInstrumentFormFieldsToFill) { + const { + cardType, cardHolderName, cardNumber, + } = this.state; + + const card = PaymentFormMain.findCardTypeFromCode(cardType); + + const keys = Object.keys(paymentInstrumentFormFieldsToFill); + const formFieldsToFill = paymentInstrumentFormFieldsToFill; + + for (let i = 0; i < keys.length; i++) { + const cKey = keys[i]; + + if (typeof paymentInstrumentFormFieldsToFill[cKey] === 'string') { + if (cKey === 'display-name') { + formFieldsToFill[cKey] = `${cardHolderName}'s ${card} ending in: ****${cardNumber.substring(cardNumber.length - 4)}`; + } else { + formFieldsToFill[cKey] = PaymentFormMain.generateToken(); + } + } else { + formFieldsToFill[cKey] = this.fillPaymentInstrumentFormFields(formFieldsToFill[cKey]); + } } + + return paymentInstrumentFormFieldsToFill; } - // eslint-disable-next-line class-methods-use-this - fetchCybersourceForm(cybersourceBodyRequest) { - return ( -
- - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - -
-
-
- ); + cancel() { + const { onCloseModal } = this.props; + onCloseModal(); } - fetchPaymentForms() { + static renderYears() { + const options = []; + for (let i = 0; i < 10; i += 1) { + options.push( + , + ); + } + return options; + } + + /** Note that this fetches the legacy form.. pre 7.6. */ + fetchPaymentMethodsForm() { login().then(() => { cortexFetch('/?zoom=defaultcart:order:paymentmethodinfo:paymenttokenform,defaultprofile:paymentmethods:paymenttokenform', { headers: { @@ -342,37 +490,20 @@ class PaymentFormMain extends Component link.rel === 'createpaymenttokenfororderaction', ); this.setState({ - paymentForm: paymentFormLink.uri, - orderPaymentForm: orderPaymentFormLink.uri, + submitPaymentFormProfileUri: paymentFormLink.uri, + submitPaymentFormOrderUri: orderPaymentFormLink.uri, }); }); }); } - cancel() { - const { onCloseModal } = this.props; - onCloseModal(); - } - - static renderYears() { - const options = []; - for (let i = 0; i < 10; i += 1) { - options.push( - , - ); - } - return options; - } - render() { const { - cardType, cardHolderName, cardNumber, expiryMonth, expiryYear, securityCode, saveToProfile, failedSubmit, showLoader, cybersourceBodyRequest, + cardType, cardHolderName, cardNumber, expiryMonth, expiryYear, securityCode, saveToProfile, failedSubmit, showLoader, } = this.state; + return (
- {cybersourceBodyRequest.access_key && this.fetchCybersourceForm(cybersourceBodyRequest)}
{failedSubmit ? intl.get('failed-to-save-message') : ''}
@@ -480,16 +611,22 @@ class PaymentFormMain extends Component
-
-
- {/* eslint-disable-next-line max-len */} - -
- -
+ + { this.shouldShowSaveToProfile() + ? ( +
+
+ {/* eslint-disable-next-line max-len */} + +
+ +
+ ) + : null } +
diff --git a/src/components/src/PaymentMethodContainer/paymentmethod.container.tsx b/src/components/src/PaymentMethodContainer/paymentmethod.container.tsx index da4af05b2..130d55dd4 100644 --- a/src/components/src/PaymentMethodContainer/paymentmethod.container.tsx +++ b/src/components/src/PaymentMethodContainer/paymentmethod.container.tsx @@ -30,8 +30,12 @@ function PaymentMethodContainer(props: PaymentMethodContainerProps) { const { displayName } = props; const displayAppliedAmount = (displayName['applied-amount-display']) ? (` - ${displayName['applied-amount-display'] || ''}`) : ''; const displayTransactionType = (displayName['transaction-type']) ? (` - ${displayName['transaction-type'] || ''}`) : ''; + let displayNameVar = displayName['display-value'] || displayName['display-name'] || displayName.name; + + if (displayName._description) { + displayNameVar = displayName._description[0].name; + } - let displayNameVar = displayName['display-value'] || displayName['display-name']; if (!displayNameVar) { displayNameVar = `${displayName.provider.toLowerCase().replace(/_/g, ' ')}`; } diff --git a/src/components/src/ProductDisplayItem/productdisplayitem.main.api.mocks.js b/src/components/src/ProductDisplayItem/productdisplayitem.main.api.mocks.ts similarity index 67% rename from src/components/src/ProductDisplayItem/productdisplayitem.main.api.mocks.js rename to src/components/src/ProductDisplayItem/productdisplayitem.main.api.mocks.ts index c1cbb2c2e..150a87216 100644 --- a/src/components/src/ProductDisplayItem/productdisplayitem.main.api.mocks.js +++ b/src/components/src/ProductDisplayItem/productdisplayitem.main.api.mocks.ts @@ -29,92 +29,84 @@ import blackMultiSkuSelectionResponse from './MockHttpResponses/POST/blackMultiS import largeMultiSkuSelectionResponse from './MockHttpResponses/POST/largeMultiSkuSelection_response.json'; import mediumMultiSkuSelectionResponse from './MockHttpResponses/POST/mediumMultiSkuSelection_response.json'; import smallMultiSkuSelectionResponse from './MockHttpResponses/POST/smallMultiSkuSelection_response.json'; -import loginResponse from '../CommonMockHttpResponses/login_response.json'; - -function mockLoginResponse(mockObj) { - mockObj.post( - '/cortex/oauth2/tokens', - loginResponse, - ); -} +import { mockAnonLoginResponse } from '../utils/MockLogins'; function mockLookupForm(mockObj) { mockObj.get( - '/cortex/?zoom=lookups:itemlookupform', + /(.*)?zoom=lookups:itemlookupform/, itemLookupFormResponse, ); } function mockItemLookupPlain(mockObj) { mockObj.post( - /\/cortex\/items\/vestri_b2c\/lookups\/form?(.*)/, + /(.*)\/cortex\/items\/vestri_b2c\/lookups\/form?(.*)/, itemLookupPlainResponse, ); } function mockItemLookupColorAndSize(mockObj) { mockObj.post( - /\/cortex\/items\/vestri_b2c\/lookups\/form?(.*)/, + /(.*)\/cortex\/items\/vestri_b2c\/lookups\/form?(.*)/, itemLookupColorAndSizeResponse, ); } function mockItemLookupInputResponse(mockObj) { mockObj.post( - /\/cortex\/items\/vestri_b2c\/lookups\/form?(.*)/, + /(.*)\/cortex\/items\/vestri_b2c\/lookups\/form?(.*)/, itemLookupInputResponse, ); } function mockMultiCartResponse(mockObj) { mockObj.get( - '/cortex?zoom=carts,carts:element,carts:element:additemstocartform,carts:element:descriptor', + /(.*)?zoom=carts,carts:element,carts:element:additemstocartform,carts:element:descriptor/, itemLookupMultiCartResponse, ); } -function mockAllSizeOptions(fetchMock) { - fetchMock.post( // large - /\/cortex\/itemselections\/[a-zA-Z0-9_]*\/qgqvhjjsgqydioa=\/options\/kzcvgvcsjfpucucqifjektc7knevuri=\/selector\/kzcvgvcsjfpvgsk2ivpuyqksi5cq(.*)/, +function mockAllSizeOptions(mockObj) { + mockObj.post( // large + /(.*)\/cortex\/itemselections\/[a-zA-Z0-9_]*\/qgqvhjjsgqydioa=\/options\/kzcvgvcsjfpucucqifjektc7knevuri=\/selector\/kzcvgvcsjfpvgsk2ivpuyqksi5cq(.*)/, largeMultiSkuSelectionResponse, ) .post( // medium - /\/cortex\/itemselections\/[a-zA-Z0-9_]*\/qgqvhjjygm4tkmi=\/options\/kzcvgvcsjfpucucqifjektc7knevuri=\/selector\/kzcvgvcsjfpvgsk2ivpu2rkejfku2(.*)/, + /(.*)\/cortex\/itemselections\/[a-zA-Z0-9_]*\/qgqvhjjygm4tkmi=\/options\/kzcvgvcsjfpucucqifjektc7knevuri=\/selector\/kzcvgvcsjfpvgsk2ivpu2rkejfku2(.*)/, mediumMultiSkuSelectionResponse, ) .post( // small - /\/cortex\/itemselections\/[a-zA-Z0-9_]*\/qgqvhjjygm4tkmi=\/options\/kzcvgvcsjfpucucqifjektc7knevuri=\/selector\/kzcvgvcsjfpvgsk2ivpvgtkbjrga(.*)/, + /(.*)\/cortex\/itemselections\/[a-zA-Z0-9_]*\/qgqvhjjygm4tkmi=\/options\/kzcvgvcsjfpucucqifjektc7knevuri=\/selector\/kzcvgvcsjfpvgsk2ivpvgtkbjrga(.*)/, smallMultiSkuSelectionResponse, ); } -function mockAllColorOptions(fetchMock) { - fetchMock +function mockAllColorOptions(mockObj) { + mockObj .post( // Yellow - /\/cortex\/itemselections\/[a-zA-Z0-9_]*\/qgqvhjjygm4tkmi=\/options\/kzcvgvcsjfpucucqifjektc7inhuyt2s=\/selector\/kzcvgvcsjfpugt2mj5jf6wkfjrge6vy=(.*)/, + /(.*)\/cortex\/itemselections\/[a-zA-Z0-9_]*\/qgqvhjjygm4tkmi=\/options\/kzcvgvcsjfpucucqifjektc7inhuyt2s=\/selector\/kzcvgvcsjfpugt2mj5jf6wkfjrge6vy=(.*)/, yellowMultiSkuSelectionResponse, ) .post( // Black - /\/cortex\/itemselections\/[a-zA-Z0-9_]*\/qgqvhjjrg44tgmy=\/options\/kzcvgvcsjfpucucqifjektc7inhuyt2s=\/selector\/kzcvgvcsjfpugt2mj5jf6qsmifbuw(.*)/, + /(.*)\/cortex\/itemselections\/[a-zA-Z0-9_]*\/qgqvhjjrg44tgmy=\/options\/kzcvgvcsjfpucucqifjektc7inhuyt2s=\/selector\/kzcvgvcsjfpugt2mj5jf6qsmifbuw(.*)/, blackMultiSkuSelectionResponse, ); } -function mockAddToCart(fetchMock) { - `/cortex/carts/items/vestri_b2c/qgqvhjjygm4tkmi=/form`; - fetchMock.post( - /\/cortex\/carts\/items\/[a-zA-Z0-9_]*\/[a-zA-Z0-9_=]*\/form/, +function mockAddToCart(mockObj) { + mockObj.post( + /(.*)\/cortex\/carts\/items\/[a-zA-Z0-9_]*\/[a-zA-Z0-9_=]*\/form/, 201, ); } -function mockItemSelections(fetchMock) { +function mockItemSelections(mockObj) { mockAllSizeOptions(fetchMock); mockAllColorOptions(fetchMock); } -function mockCommonProductDisplayResponses(fetchMock) { - mockLoginResponse(fetchMock); +function mockCommonProductDisplayResponses(mockObj) { + mockAnonLoginResponse(fetchMock); mockLookupForm(fetchMock); mockAddToCart(fetchMock); } diff --git a/src/components/src/ProductListLoadmore/productlistloadmore.api.mocks.js b/src/components/src/ProductListLoadmore/productlistloadmore.api.mocks.ts similarity index 76% rename from src/components/src/ProductListLoadmore/productlistloadmore.api.mocks.js rename to src/components/src/ProductListLoadmore/productlistloadmore.api.mocks.ts index b7c6fab00..cb55cb248 100644 --- a/src/components/src/ProductListLoadmore/productlistloadmore.api.mocks.js +++ b/src/components/src/ProductListLoadmore/productlistloadmore.api.mocks.ts @@ -20,15 +20,17 @@ */ import fetchMock from 'fetch-mock/es5/client'; import searchLookupResponse from './MockHttpResponses/GET/searchLookup_response.json'; +import { mockAnonLoginResponse } from '../utils/MockLogins'; -function mockSearchResponse(fetchMock) { - fetchMock.get( - /\/cortex\/\/offersearches\/[a-zA-Z0-9_]*\/offers\/(.*)/, +function mockSearchResponse(mockObj) { + mockObj.get( + /(.*)\/cortex\/\/offersearches\/[a-zA-Z0-9_]*\/offers\/(.*)/, searchLookupResponse, ); } -export function mockProductListLoadMoreFromSearchResponse() { +export default function mockProductListLoadMoreFromSearchResponse() { fetchMock.restore(); + mockAnonLoginResponse(fetchMock); mockSearchResponse(fetchMock); } diff --git a/src/components/src/ProductListLoadmore/productlistloadmore.stories.tsx b/src/components/src/ProductListLoadmore/productlistloadmore.stories.tsx index f3e9647dd..c164bc558 100644 --- a/src/components/src/ProductListLoadmore/productlistloadmore.stories.tsx +++ b/src/components/src/ProductListLoadmore/productlistloadmore.stories.tsx @@ -22,11 +22,12 @@ import React from 'react'; import Readme from './README.md'; import { storiesOf } from '@storybook/react'; import { MemoryRouter } from 'react-router'; +import { text, object } from '@storybook/addon-knobs/react'; +import { textToFunc } from '../../../../storybook/utils/storybookUtils'; + import productsData from './MockHttpResponses/GET/productData_response.json'; -import { text, object } from "@storybook/addon-knobs/react"; -import { textToFunc } from "../../../../storybook/utils/storybookUtils"; import ProductListLoadMore from './productlistloadmore'; -import { mockProductListLoadMoreFromSearchResponse } from './productlistloadmore.api.mocks'; +import mockProductListLoadMoreFromSearchResponse from './productlistloadmore.api.mocks'; let handleDataChangeFuncText; let onLoadMoreFuncText; @@ -50,10 +51,10 @@ storiesOf('Components|ProductListLoadMore', module) mockProductListLoadMoreFromSearchResponse(); processProductListLoadmoreKnobCallbacks(); return ( - {textToFunc(handleDataChangeFuncText)}} - onLoadMore={()=>{textToFunc(onLoadMoreFuncText)}} + { textToFunc(handleDataChangeFuncText); }} + onLoadMore={() => { textToFunc(onLoadMoreFuncText); }} /> ); }); diff --git a/src/components/src/ProductListLoadmore/productlistloadmore.tsx b/src/components/src/ProductListLoadmore/productlistloadmore.tsx index 4a14ee210..d2bebb185 100644 --- a/src/components/src/ProductListLoadmore/productlistloadmore.tsx +++ b/src/components/src/ProductListLoadmore/productlistloadmore.tsx @@ -32,9 +32,9 @@ interface ProductListLoadMoreProps{ [key: string]: any }, /** handle product data change */ - handleDataChange: (...args: any[]) => any, + handleDataChange: any, /** handle load more */ - onLoadMore: (...args: any[]) => any, + onLoadMore: any, } interface ProductListLoadMoreState { canLoadMore: boolean, diff --git a/src/components/src/ProfilePaymentMethods/profilepaymentmethods.main.tsx b/src/components/src/ProfilePaymentMethods/profilepaymentmethods.main.tsx index 1fb862452..7d5264c29 100644 --- a/src/components/src/ProfilePaymentMethods/profilepaymentmethods.main.tsx +++ b/src/components/src/ProfilePaymentMethods/profilepaymentmethods.main.tsx @@ -39,7 +39,11 @@ interface ProfilePaymentMethodsMainProps { /** handle payment method change */ onChange: (...args: any[]) => any, /** disable add a new payment method */ - disableAddPayment: boolean, + disableAddPayment?: boolean, + + paymentInstruments?: { + [key: string]: any, + } } interface ProfilePaymentMethodsMainState { openNewPaymentModal: boolean @@ -83,7 +87,29 @@ class ProfilePaymentMethodsMain extends Component { + const displayName = paymentElement.name; + return ( +
    +
  • +
    + + {displayName} + +
    + +
  • +
+ ); + }) + ); + } if (paymentMethods._element) { return ( paymentMethods._element.map((paymentElement) => { @@ -119,7 +145,7 @@ class ProfilePaymentMethodsMain extends Component @@ -128,7 +154,7 @@ class ProfilePaymentMethodsMain extends Component {this.renderPaymentMethods()} - @@ -140,7 +166,11 @@ class ProfilePaymentMethodsMain extends Component
- +
diff --git a/src/components/src/PurchaseDetails/purchasedetails.main.tsx b/src/components/src/PurchaseDetails/purchasedetails.main.tsx index a7b1db3e8..b77d42b7e 100644 --- a/src/components/src/PurchaseDetails/purchasedetails.main.tsx +++ b/src/components/src/PurchaseDetails/purchasedetails.main.tsx @@ -114,14 +114,14 @@ function PurchaseDetailsMain(props: PurchaseDetailsMainProps) { }; const renderPaymentMethod = () => { - const postedPayments = data._postedpayments || data._paymentmeans; + const postedPayments = data._postedpayments || data._paymentmeans || data._paymentinstruments; return (

{intl.get('payment-method')}

{postedPayments[0]._element.map(postedpayment => ( - + ))}
); diff --git a/src/components/src/SearchResultsItems/searchresultsitems.main.mock.api.js b/src/components/src/SearchResultsItems/searchresultsitems.main.mock.api.ts similarity index 68% rename from src/components/src/SearchResultsItems/searchresultsitems.main.mock.api.js rename to src/components/src/SearchResultsItems/searchresultsitems.main.mock.api.ts index e20ae16e9..d08a6fb2c 100644 --- a/src/components/src/SearchResultsItems/searchresultsitems.main.mock.api.js +++ b/src/components/src/SearchResultsItems/searchresultsitems.main.mock.api.ts @@ -21,32 +21,25 @@ import fetchMock from 'fetch-mock/es5/client'; import getSearchFromResponse from './MockHttpResponses/GET/getSearchForm_response.json'; import offerSearchResponse from './MockHttpResponses/POST/offerSearch_response.json'; -import loginResponse from '../CommonMockHttpResponses/login_response.json'; +import { mockAnonLoginResponse } from '../utils/MockLogins'; -function mockGetSearchForm(fetchMock) { - fetchMock.get( - '/cortex/?zoom=searches:keywordsearchform,searches:offersearchform', +function mockGetSearchForm(mockObj) { + mockObj.get( + /(.*)?zoom=searches:keywordsearchform,searches:offersearchform/, getSearchFromResponse, ); } -function mockOfferSearch(fetchMock) { - fetchMock.post( - /\/cortex\/offersearches\/[a-zA-Z0-9_]*\/offers\/form?(.*)/, +function mockOfferSearch(mockObj) { + mockObj.post( + /(.*)\/cortex\/offersearches\/[a-zA-Z0-9_]*\/offers\/form?(.*)/, offerSearchResponse, ); } -function mockLoginResponse(fetchMock) { - fetchMock.post( - '/cortex/oauth2/tokens', - loginResponse, - ); -} - -export function mockSearchResults() { +export default function mockSearchResults() { fetchMock.restore(); - mockLoginResponse(fetchMock); + mockAnonLoginResponse(fetchMock); mockGetSearchForm(fetchMock); mockOfferSearch(fetchMock); } diff --git a/src/components/src/SearchResultsItems/searchresultsitems.main.stories.tsx b/src/components/src/SearchResultsItems/searchresultsitems.main.stories.tsx index cdffdb6be..5b739ffa4 100644 --- a/src/components/src/SearchResultsItems/searchresultsitems.main.stories.tsx +++ b/src/components/src/SearchResultsItems/searchresultsitems.main.stories.tsx @@ -23,9 +23,9 @@ import Readme from './README.md'; import { storiesOf } from '@storybook/react'; import { MemoryRouter } from 'react-router'; +import { text, object } from '@storybook/addon-knobs/react'; import SearchResultsItemsMain from './searchresultsitems.main'; -import { text, object } from "@storybook/addon-knobs/react"; -import { mockSearchResults } from './searchresultsitems.main.mock.api'; +import mockSearchResults from './searchresultsitems.main.mock.api'; import { textToFunc } from '../../../../storybook/utils/storybookUtils'; const props = { diff --git a/src/components/src/utils/MockLogins.ts b/src/components/src/utils/MockLogins.ts new file mode 100644 index 000000000..bf10cf53f --- /dev/null +++ b/src/components/src/utils/MockLogins.ts @@ -0,0 +1,39 @@ +/** + * Copyright © 2019 Elastic Path Software Inc. All rights reserved. + * + * This is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this license. If not, see + * + * https://www.gnu.org/licenses/ + * + * + */ + +import registeredResponse from '../CommonMockHttpResponses/registered_login_response.json'; +import anonLoginResponse from '../CommonMockHttpResponses/anonymous_login_response.json'; + +export function mockRegisteredLoginResponse(mockObj) { + localStorage.clear(); + mockObj.post( + /(.*)\/cortex\/oauth2\/tokens/, + registeredResponse, + ); +} + +export function mockAnonLoginResponse(mockObj) { + localStorage.clear(); + mockObj.post( + /(.*)\/cortex\/oauth2\/tokens/, + anonLoginResponse, + ); +} diff --git a/src/components/webpack.config.base.js b/src/components/webpack.config.base.js index 214dfd600..5fc7bf8f3 100644 --- a/src/components/webpack.config.base.js +++ b/src/components/webpack.config.base.js @@ -21,7 +21,6 @@ const path = require('path'); module.exports = { - devtool: 'source-map', mode: 'production', entry: './src/index', module: { diff --git a/src/containers/CheckoutPage.tsx b/src/containers/CheckoutPage.tsx index 337372c3c..106fd0d6d 100644 --- a/src/containers/CheckoutPage.tsx +++ b/src/containers/CheckoutPage.tsx @@ -69,6 +69,10 @@ const zoomArray = [ 'order:paymentmethodinfo:paymentmethod', 'order:paymentmethodinfo:selector:choice', 'order:paymentmethodinfo:selector:choice:description', + // zooms for payment plugin update + 'order:paymentinstrumentselector:choice', + 'order:paymentinstrumentselector:choice:description', + 'order:paymentinstrumentselector:chosen:description', ]; interface MatchParams { @@ -107,6 +111,7 @@ class CheckoutPage extends React.Component this.handleCloseNewPaymentModal = this.handleCloseNewPaymentModal.bind(this); this.fetchOrderData = this.fetchOrderData.bind(this); this.handleCloseAddressModal = this.handleCloseAddressModal.bind(this); + this.renderPaymentInstrumentSelector = this.renderPaymentInstrumentSelector.bind(this); } componentDidMount() { @@ -539,32 +544,14 @@ class CheckoutPage extends React.Component }); } return ( - paymentMethods.map((payment) => { - const { - checked, deletable, selectaction, - } = payment; - return ( -
-
- this.handleChange(selectaction)} /> - -
- {deletable && ( -
- -
- )} -
- ); - }) + paymentMethods.map(payment => this.renderPaymentChoice(payment)) ); } + + if (orderData._order[0]._paymentinstrumentselector) { + return this.renderPaymentInstrumentSelector(orderData._order[0]._paymentinstrumentselector[0]); + } + return (

@@ -574,13 +561,61 @@ class CheckoutPage extends React.Component ); } - renderPaymentSelector() { - const { profileData, openNewPaymentModal, orderData } = this.state; - let disableAddPayment = false; - if (Config.creditCardTokenization && Config.creditCardTokenization.enable && Config.creditCardTokenization.lambdaURI !== '') { - disableAddPayment = !(orderData && orderData._order && orderData._order[0] && orderData._order[0]._deliveries); + renderPaymentChoice(payment) { + const { + checked, deletable, selectaction, + } = payment; + + return ( +

+
+ this.handleChange(selectaction)} /> + +
+ {deletable && ( +
+ +
+ )} +
+ ); + } + + renderPaymentInstrumentSelector(paymentInstrumentSelector) { + const paymentMethods = []; + if (paymentInstrumentSelector._chosen) { + const [description] = paymentInstrumentSelector._chosen; + description.checked = true; + description.deletable = false; + paymentMethods.push(description); } + if (paymentInstrumentSelector._choice) { + const choices = paymentInstrumentSelector._choice; + choices.map((choice) => { + const [description] = choice._description; + description.selectaction = choice.links.find(link => link.rel === 'selectaction').uri; + description.checked = false; + description.deletable = true; + paymentMethods.push(description); + return description; + }); + } + + return ( + paymentMethods.map(payment => this.renderPaymentChoice(payment)) + ); + } + + renderPaymentSelector() { + const { profileData, openNewPaymentModal } = this.state; const isDisabled = !(!profileData || (profileData && profileData._emails[0]._element)); + return (

@@ -589,7 +624,7 @@ class CheckoutPage extends React.Component
{this.renderPayments()}
- @@ -601,7 +636,12 @@ class CheckoutPage extends React.Component

- + { + localStorage.getItem(`${Config.cortexApi.scope}_oAuthRole`) === 'PUBLIC' ? ( + + ) : ( + ) + }
diff --git a/src/containers/OrderReviewPage.tsx b/src/containers/OrderReviewPage.tsx index 442e60f8b..8602ab049 100644 --- a/src/containers/OrderReviewPage.tsx +++ b/src/containers/OrderReviewPage.tsx @@ -160,6 +160,7 @@ class OrderReviewPage extends React.Component 7.6 + 'defaultprofile:paymentinstruments:element', + 'defaultprofile:paymentinstruments:default', + + 'defaultprofile:paymentmethods:paymenttokenform', 'defaultprofile:paymentmethods', 'defaultprofile:paymentmethods:paymenttokenform', 'defaultprofile:paymentmethods:element', @@ -80,6 +86,7 @@ class ProfilePage extends React.Component this.handleNewAddress = this.handleNewAddress.bind(this); this.handleEditAddress = this.handleEditAddress.bind(this); this.handleCloseAddressModal = this.handleCloseAddressModal.bind(this); + this.renderPayments = this.renderPayments.bind(this); } componentDidMount() { @@ -181,12 +188,24 @@ class ProfilePage extends React.Component ); } + renderPayments() { + const { profileData } = this.state; + + const disableAddPayment = false; + + if (profileData._paymentmethods) { + if (profileData._paymentinstruments) { + return ; + } + return ; + } + + return null; + } + render() { const { profileData, showResetPasswordButton, dataPolicyData } = this.state; - let disableAddPayment = false; - if (Config.creditCardTokenization && Config.creditCardTokenization.enable && Config.creditCardTokenization.lambdaURI !== '') { - disableAddPayment = !(profileData && profileData._addresses && profileData._addresses[0]._billingaddresses); - } + return (
@@ -235,9 +254,7 @@ class ProfilePage extends React.Component
- {(profileData._paymentmethods) ? ( - - ) : ('')} + {this.renderPayments()}
diff --git a/src/ep.config.json b/src/ep.config.json index 400a678bd..cf587f3e4 100644 --- a/src/ep.config.json +++ b/src/ep.config.json @@ -134,12 +134,6 @@ "noself": false, "nodatalinks": true }, - "creditCardTokenization": { - "enable": false, - "lambdaURI": "/cssign", - "overrideCustomReceiptURI": "/postredirector", - "overrideCustomCancelURI": "" - }, "chatbot": { "enable": false, "name": "EPConversationalInterface" diff --git a/src/tests/e2e/common.js b/src/tests/e2e/common.js index 04c88cb1e..22a7c6b7b 100644 --- a/src/tests/e2e/common.js +++ b/src/tests/e2e/common.js @@ -138,14 +138,32 @@ module.exports = { await page.click(FORM_SUBMIT_BUTTON); }, - async addPaymentMethod(page, paymentMethod) { + async addPaymentMethodToOrder(page, paymentMethod) { + const CARD_TYPE = '#CardType'; + const CARD_HOLDER_NAME = '#CardHolderName'; + const CARD_NUMBER = '#CardNumber'; + const EXPIRY_MONTH = '#ExpiryMonth'; + const EXPIRY_YEAR = '#ExpiryYear'; + const SECURITY_CODE = '#SecurityCode'; + const CONTINUE_BUTTON = 'button.payment-save-btn'; + + await page.waitForSelector(CARD_TYPE); + await page.type(CARD_TYPE, paymentMethod.cardType); + await page.type(CARD_HOLDER_NAME, paymentMethod.cardHolderName); + await page.type(CARD_NUMBER, paymentMethod.cardNumber); + await page.type(EXPIRY_MONTH, paymentMethod.expiryMonth); + await page.type(EXPIRY_YEAR, paymentMethod.expiryYear); + await page.type(SECURITY_CODE, paymentMethod.securityCode); + await page.click(CONTINUE_BUTTON); + }, + + async addPaymentMethodToProfile(page, paymentMethod) { const CARD_TYPE = '#CardType'; const CARD_HOLDER_NAME = '#CardHolderName'; const CARD_NUMBER = '#CardNumber'; const EXPIRY_MONTH = '#ExpiryMonth'; const EXPIRY_YEAR = '#ExpiryYear'; const SECURITY_CODE = '#SecurityCode'; - const SAVE_TO_PROFILE = 'label[for="saveToProfile"]'; const CONTINUE_BUTTON = 'button.payment-save-btn'; await page.waitForSelector(CARD_TYPE); @@ -155,7 +173,6 @@ module.exports = { await page.type(EXPIRY_MONTH, paymentMethod.expiryMonth); await page.type(EXPIRY_YEAR, paymentMethod.expiryYear); await page.type(SECURITY_CODE, paymentMethod.securityCode); - await page.click(SAVE_TO_PROFILE); await page.click(CONTINUE_BUTTON); }, diff --git a/src/tests/e2e/profile.test.js b/src/tests/e2e/profile.test.js index 8f398bca7..164109a03 100644 --- a/src/tests/e2e/profile.test.js +++ b/src/tests/e2e/profile.test.js @@ -91,7 +91,6 @@ const CARD_NUMBER = "#CardNumber"; const EXPIRY_MONTH = "#ExpiryMonth"; const EXPIRY_YEAR = "#ExpiryYear"; const SECURITY_CODE = "#SecurityCode"; -const SAVE_TO_PROFILE = 'label[for="saveToProfile"]'; const CONTINUE_BUTTON = "button.payment-save-btn"; const ADDRESS_NAME = ".address-name"; const CREATED_PAYMENT_METHOD = "ul.profile-payment-methods-listing:nth-child(2)"; @@ -243,7 +242,6 @@ describe('Profile', () => { await page.type(EXPIRY_MONTH, paymentMethod.expiryMonth); await page.type(EXPIRY_YEAR, paymentMethod.expiryYear); await page.type(SECURITY_CODE, paymentMethod.securityCode); - await page.click(SAVE_TO_PROFILE); await page.click(CONTINUE_BUTTON); // When I navigate to the profile page diff --git a/src/tests/e2e/purchase.test.js b/src/tests/e2e/purchase.test.js index 630ddf2ce..aeeb7b3f6 100644 --- a/src/tests/e2e/purchase.test.js +++ b/src/tests/e2e/purchase.test.js @@ -24,7 +24,7 @@ const { registerUser, addAddress, - addPaymentMethod, + addPaymentMethodToOrder, loginUserRegister, loginUser, addProductToCart @@ -142,7 +142,7 @@ describe('Purchase feature', () => { securityCode: '123', }; - await addPaymentMethod(page, paymentMethod); + await addPaymentMethodToOrder(page, paymentMethod); await page.waitForSelector(CREATED_PAYMENT_METHOD); await page.waitFor(3000); @@ -211,7 +211,7 @@ describe('Purchase feature', () => { securityCode: '123', }; - await addPaymentMethod(page, paymentMethod); + await addPaymentMethodToOrder(page, paymentMethod); await page.waitForSelector(CREATED_PAYMENT_METHOD); await page.waitFor(3000); await page.waitForSelector(COMPLETE_ORDER_BUTTON_CSS); @@ -292,7 +292,7 @@ describe('Purchase feature', () => { securityCode: '123', }; - await addPaymentMethod(page, paymentMethod); + await addPaymentMethodToOrder(page, paymentMethod); await page.waitForSelector(CREATED_PAYMENT_METHOD); await page.waitFor(3000); } @@ -383,7 +383,7 @@ describe('Purchase feature', () => { securityCode: '123', }; - await addPaymentMethod(page, paymentMethod); + await addPaymentMethodToOrder(page, paymentMethod); await page.waitForSelector(CREATED_PAYMENT_METHOD); await page.waitFor(3000); } @@ -475,7 +475,7 @@ describe('Purchase feature', () => { securityCode: '123', }; - await addPaymentMethod(page, paymentMethod); + await addPaymentMethodToOrder(page, paymentMethod); await page.waitForSelector(CREATED_PAYMENT_METHOD); await page.waitFor(3000); } @@ -656,7 +656,7 @@ describe('Purchase feature', () => { securityCode: '123', }; - await addPaymentMethod(page, paymentMethod); + await addPaymentMethodToOrder(page, paymentMethod); await page.waitForSelector(CREATED_PAYMENT_METHOD); await page.waitFor(3000); await page.waitForSelector(COMPLETE_ORDER_BUTTON_CSS);