4.13.2 • Published 5 days ago

@justeat/f-checkout v4.13.2

Weekly downloads
73
License
Apache-2.0
Repository
github
Last release
5 days ago

npm version CircleCI Coverage Status Known Vulnerabilities

Usage

  1. Install the module using NPM or Yarn:

    yarn add @justeat/f-checkout
    npm install @justeat/f-checkout
  2. Import the component and its module, ensuring the latter is registered in the Vuex store upon creation.

    You can import it in your Vue SFC like this (please note that styles have to be imported separately):

    import { VueCheckout, CheckoutModule } from '@justeat/f-checkout';
    import '@justeat/f-checkout/dist/f-checkout.css';
    
    export default {
        components: {
            VueCheckout
        },
    
        created () {
            if (!this.$store.hasModule('checkout')) {
                this.$store.registerModule('checkout', CheckoutModule);
            }
        },
    }

    If you are using Webpack, you can import the component dynamically to separate the vue-checkout bundle from the main bundle.client.js:

    import '@justeat/f-checkout/dist/f-checkout.css';
    
    export default {
        components: {
            ...
            VueCheckout: () => import(/* webpackChunkName: "vue-checkout" */ '@justeat/f-checkout')
        }
    }

Configuration

Props

f-checkout has a number of props that allow you to customise its functionality.

The props that can be defined are as follows:

PropTypeDefaultDescription
updateCheckoutUrlString-URL for the API called to update the Checkout Data
getCheckoutUrlString-URL for the API called to load the Checkout Data.The data returned from this API contains the serviceType, which determines if the Checkout component is created for Collection or Delivery when the user is authenticated.
checkoutAvailableFulfilmentUrlString-URL for the API called to load the Available Fulfilment data.
createGuestUrlString-URL for the API called to load the Create a Guest User.
getBasketUrlString-URL for the API called to get Basket Details.The data returned from this API contains the serviceType, which determines if the Checkout component is created for Collection or Delivery when the user is not authenticated.
placeOrderUrlString-URL for the API called to place the order.The data returned from this API contains the orderId, which is needed to redirect the user to the payment page.
getGeoLocationUrlString-URL for the API that can return geo location information (Latitude and Longitude) for a given address.The tenant must be provided as the last segment of the URL and all calls must be authenticated.
checkoutTimeoutNumber10000Timeout for the different API calls in the component.
authTokenString''Authorisation token used when submitting the checkout form.
otacToAuthExchangerFunctionthrow new Error('otacToAuthExchanger is not implemented');Function to exchange OTAC to JWT auth token
loginUrlString-URL to navigate to if the user wishes to change account.
paymentPageUrlPrefixString-URL prefix to navigate to after the order has been successfully placed, so the user can pay. The orderId will be appended to this URL to form the full URL.
applicationNameString-The name of the application using this component.
getNoteConfigUrlString-URL for the API called to get the note configuration for split notes
checkoutFeaturesObject-Object containing relevant feature flags
shouldLoadAddressFromLocalStorageBooleantrueFlag to control where to retrieve the address from storage (local storage/cookies)
showAddressAlertBooleanfalseIf true, displays an alert on the checkout page for delivery orders reminding customers to check that their address is entered correctly.

Events

EventDescription
checkout-payment-successEmitted when checkout form is successfully submitted.
checkout-payment-failureEmitted when checkout form fails when submitted.
checkout-get-successEmitted when checkout data is successfully loaded.
checkout-get-failureEmitted when checkout data fails to load.
checkout-available-fulfilment-get-successEmitted when available fulfilment times are successfully loaded.
checkout-available-fulfilment-get-failureEmitted when available fulfilment times fail to load.
checkout-visit-login-pageEmitted when user clicks the Not you? link
checkout-basket-get-successEmitted when basket data is successfully loaded.
checkout-basket-get-failureEmitted when basket data is not successfully loaded.
checkout-setup-guest-successEmitted when guest user is created successfully.
checkout-setup-guest-failureEmitted when guest user is not created successfully.
checkout-validation-errorEmitted validation error occurs.
checkout-address-get-successEmitted when address is returned successfully.
checkout-address-get-failureEmitted when address is not returned successfully.
checkout-error-dialog-button-clickEmitted when the error dialog ok is clicked.
checkout-dialog-close-button-clickEmitted when the error dialog close is clicked.
checkout-place-order-successEmitted when order is successfully placed.
checkout-place-order-failureEmitted when order is not successfully placed.
checkout-update-successEmitted when checkout is successfully updated.
checkout-update-failureEmitted when checkout is not successfully updated.

You can add event listeners for these like so

<template>
  <vue-checkout
    @checkoutPaymentSuccess="onPaymentSuccess"
    @checkoutPaymentFailure="onPaymentFailure"
    @checkoutGetSuccess="onGetCheckoutSuccess"
    @checkoutGetFailure="onGetCheckoutFailure"
    @checkoutGetPaymentSuccess="onGetPaymentSuccess"
    @checkoutGetPaymentFailure="onGetPaymentFailure"
    @checkoutGetBasketSuccess="onGetBasketSuccess"
    @checkoutGetBasketFailure="onGetBasketFailure"
    @checkoutSetupGuestSuccess="onSetupGuestSuccess"
    @checkoutSetupGuestFailure="onSetupGuestFailure"
    @checkoutValidationError="onValidationError">
  </vue-checkout>
</template>

<script>
export default {
  methods: {
    onPaymentSuccess () {
      // Do stuff here
    },

    onPaymentFailure () {
      // Do stuff here
    },

    onGetCheckoutSuccess () {
      // Do stuff here
    },

    onGetCheckoutFailure () {
      // Do stuff here
    },


    onGetPaymentSuccess () {
      // Do stuff here
    },

    onGetPaymentFailure () {
      // Do stuff here
    },

    onGetBasketSuccess () {
      // Do stuff here
    },

    onGetBasketFailure () {
      // Do stuff here
    },

  }
}
</script>

Development

It is recommended to run the following commands at the root of the monorepo in order to install dependencies and allow you to view components in isolation via Storybook.

# cd ./fozzie-components
yarn install

## Testing
Unit / Integration / Contract

```bash
# Run Unit / Integration / Contract tests for all components
cd ./fozzie-components
yarn test

OR

# Run Unit / Integration / Contract tests for f-checkout
cd ./fozzie-components/packages/f-checkout
yarn test

Component Tests

# Run Component tests for all components
# Note: Ensure Storybook is not running when running the following commands
cd ./fozzie-components

yarn storybook:build
yarn storybook:serve-static
yarn test-component:chrome

OR

# Run Component tests for f-checkout
# Note: Ensure Storybook is not running when running the following commands
cd ./fozzie-components/packages/f-checkout
yarn test-component:chrome

Documentation to be completed once module is in stable state.

4.13.2

5 days ago

4.13.1

6 days ago

4.13.0

2 months ago

4.12.0

3 months ago

4.10.0

9 months ago

4.11.0

9 months ago

4.9.1

1 year ago

4.9.0

1 year ago

4.7.0

2 years ago

4.6.1

2 years ago

4.6.1-beta

2 years ago

4.6.0

2 years ago

4.6.0-beta

2 years ago

4.6.0-beta-1

2 years ago

4.5.1

2 years ago

3.31.0

2 years ago

4.4.0

2 years ago

4.0.0

2 years ago

3.32.0

2 years ago

4.3.0

2 years ago

3.33.0

2 years ago

4.2.0

2 years ago

4.4.1-beta

2 years ago

4.5.0

2 years ago

4.1.0

2 years ago

3.28.0

2 years ago

3.29.0

2 years ago

3.26.0

2 years ago

3.30.0

2 years ago

3.30.1

2 years ago

3.27.0

2 years ago

3.24.0

2 years ago

3.24.1

2 years ago

3.25.0

2 years ago

3.23.0

2 years ago

3.22.1

2 years ago

3.22.3

2 years ago

3.20.0

2 years ago

3.13.1

2 years ago

3.17.0

2 years ago

3.17.1

2 years ago

3.21.1

2 years ago

3.21.0

2 years ago

3.14.0

2 years ago

3.18.1

2 years ago

3.21.3-beta

2 years ago

3.22.0

2 years ago

3.19.3

2 years ago

3.15.2

2 years ago

3.15.1

2 years ago

3.15.4

2 years ago

3.15.3

2 years ago

3.19.2

2 years ago

3.19.1

2 years ago

3.16.0

2 years ago

3.6.1

2 years ago

3.6.0

2 years ago

3.12.0

2 years ago

3.9.0

2 years ago

3.8.0

2 years ago

3.11.0

2 years ago

3.7.0

2 years ago

3.0.0

3 years ago

2.4.1

3 years ago

2.3.0

3 years ago

2.2.0

3 years ago

2.6.1

3 years ago

2.5.0

3 years ago

2.5.2

3 years ago

2.5.1

3 years ago

2.0.0

3 years ago

1.6.0

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago

1.0.0-beta.2

3 years ago

1.0.0-beta.1

3 years ago

0.178.0

3 years ago

1.0.0-beta.0

3 years ago

0.175.0

3 years ago

0.173.4

3 years ago

0.173.1

3 years ago

0.172.1

3 years ago

0.172.0

3 years ago

0.167.0

3 years ago

0.165.0

3 years ago

0.164.0

3 years ago

0.163.0

3 years ago

0.161.0

3 years ago

0.162.0

3 years ago

0.159.1

3 years ago

0.160.0

3 years ago

0.158.0

3 years ago

0.159.0

3 years ago

0.154.0

3 years ago

0.152.0

3 years ago

0.153.0

3 years ago

0.151.0

3 years ago

0.150.0

3 years ago

0.148.0

3 years ago

0.146.0

3 years ago

0.147.0

3 years ago

0.145.0

3 years ago

0.143.1

3 years ago

0.139.0

3 years ago

0.136.0

3 years ago

0.141.1

3 years ago

0.141.0

3 years ago

0.135.0

3 years ago

0.133.0

3 years ago

0.127.0

3 years ago

0.123.0

3 years ago

0.121.0

3 years ago

0.124.0

3 years ago

0.122.0

3 years ago

0.118.1

3 years ago

0.114.0

3 years ago

0.99.0

3 years ago

0.116.0

3 years ago

0.95.0

3 years ago

0.97.0

3 years ago

0.108.0

3 years ago

0.104.0

3 years ago

0.115.0

3 years ago

0.111.0

3 years ago

0.113.0

3 years ago

0.94.0

3 years ago

0.107.0

3 years ago

0.101.0

3 years ago

0.90.0

3 years ago

0.89.0

3 years ago

0.86.0

3 years ago

0.87.0

3 years ago

0.85.0

3 years ago

0.84.0

3 years ago

0.83.0

3 years ago

0.80.0

3 years ago

0.80.1

3 years ago

0.79.0

3 years ago

0.78.0

3 years ago

0.77.0

3 years ago

0.75.0

3 years ago

0.74.0

3 years ago

0.71.0

3 years ago

0.70.0

3 years ago

0.69.0

3 years ago

0.66.0

3 years ago

0.68.0

3 years ago

0.65.1

3 years ago

0.65.0

3 years ago

0.64.0

3 years ago

0.62.0

3 years ago

0.59.0

3 years ago

0.58.0

3 years ago

0.56.2

3 years ago

0.56.1

3 years ago

0.55.0

3 years ago

0.53.0

3 years ago

0.52.0

3 years ago

0.51.0

3 years ago

0.50.0

3 years ago

0.48.0

3 years ago

0.47.0

3 years ago

0.46.0

3 years ago

0.45.0

3 years ago

0.44.0

3 years ago

0.43.0

3 years ago

0.41.0

3 years ago

0.39.0

3 years ago

0.38.0

3 years ago

0.36.0

3 years ago

0.34.0

3 years ago

0.32.0

3 years ago

0.23.0

3 years ago