npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@justeat/f-checkout

v4.13.0

Published

Fozzie Checkout - Fozzie Checkout Component

Downloads

87

Readme


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:

| Prop | Type | Default | Description | | ----- |------------|--------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | updateCheckoutUrl | String | - | URL for the API called to update the Checkout Data | | getCheckoutUrl | String | - | 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. | | checkoutAvailableFulfilmentUrl | String | - | URL for the API called to load the Available Fulfilment data. | | createGuestUrl | String | - | URL for the API called to load the Create a Guest User. | | getBasketUrl | String | - | 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. | | placeOrderUrl | String | - | 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. | | getGeoLocationUrl | String | - | 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. | | checkoutTimeout | Number | 10000 | Timeout for the different API calls in the component. | | authToken | String | '' | Authorisation token used when submitting the checkout form. | | otacToAuthExchanger | Function | throw new Error('otacToAuthExchanger is not implemented'); | Function to exchange OTAC to JWT auth token | | loginUrl | String | - | URL to navigate to if the user wishes to change account. | | paymentPageUrlPrefix | String | - | 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. | | applicationName | String | - | The name of the application using this component. | | getNoteConfigUrl | String | - | URL for the API called to get the note configuration for split notes | | checkoutFeatures | Object | - | Object containing relevant feature flags | | shouldLoadAddressFromLocalStorage | Boolean | true | Flag to control where to retrieve the address from storage (local storage/cookies) | | showAddressAlert | Boolean | false | If true, displays an alert on the checkout page for delivery orders reminding customers to check that their address is entered correctly. |

Events

| Event | Description | | ----- | ----------- | | checkout-payment-success | Emitted when checkout form is successfully submitted. | | checkout-payment-failure | Emitted when checkout form fails when submitted. | | checkout-get-success | Emitted when checkout data is successfully loaded. | | checkout-get-failure | Emitted when checkout data fails to load. | | checkout-available-fulfilment-get-success | Emitted when available fulfilment times are successfully loaded. | | checkout-available-fulfilment-get-failure | Emitted when available fulfilment times fail to load. | | checkout-visit-login-page | Emitted when user clicks the Not you? link | | checkout-basket-get-success | Emitted when basket data is successfully loaded. | | checkout-basket-get-failure | Emitted when basket data is not successfully loaded. | | checkout-setup-guest-success | Emitted when guest user is created successfully. | | checkout-setup-guest-failure | Emitted when guest user is not created successfully. | | checkout-validation-error | Emitted validation error occurs. | | checkout-address-get-success | Emitted when address is returned successfully. | | checkout-address-get-failure | Emitted when address is not returned successfully. | | checkout-error-dialog-button-click | Emitted when the error dialog ok is clicked. | | checkout-dialog-close-button-click | Emitted when the error dialog close is clicked. | | checkout-place-order-success | Emitted when order is successfully placed. | | checkout-place-order-failure | Emitted when order is not successfully placed. | | checkout-update-success | Emitted when checkout is successfully updated. | | checkout-update-failure | Emitted 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.