Git Product home page Git Product logo

dev-center-template-fullfilment-app's Introduction

This is a Next.js project bootstrapped with create-next-app. Aimed to provide an example Shipping Fulfillment App for Wix App Market.

Getting Started

The application requires the following environment variables to be set:

  • WIX_APP_ID - The application ID in Wix Development Center (The application you created in Wix Development Center)
  • WIX_APP_SECRET - The application secret in Wix Development Center, as described in the Ouath flow documentation
  • WIX_APP_JWT_KEY - Your application webhooks public key, as described in the Webhooks documentation

For local development, these variables should be set in the .env.local file, which is not committed to source control. Also, they are all server side variables, your public key and secret should not be exposed to the client.
You can use .env.template as a template.
When deploying to production, these variables should be set as environment variables according to the hosting platform guidelines, for example:

Running the application locally

By default, the applications uses npm, but you can use yarn or pnpm as well.
To install dependencies:

npm install
# or
yarn
# or
pnpm install

To run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev

Open https://localhost:3000/dashboard with your browser to see the result.

In order to test an actual integration with the backend systems, use one of the following methods:

  • Change the urls in the dev center to point to https://localhost:3000/
  • Debug the application in the actual dashboard and copy the access token sent to provided to it by the dashboard sdk page and pass it as a query parameter accessToken
    • This will set it as an Authorization header in the requests to the backend systems.
    • See - middleware.ts for more details
  • Use a tool/plugin (i.e. Chrome plugin or hosts file on MacOS) to proxy calls from your deployment server to your local server in your browser so opening the dashboard page in Wix business manager will actually route the calls to your local server.

Features

Dashboard page

app dashboard Pre-integrated with Wix Design System and Wix Dashboard SDK

  • Including SSR support
    • Server components are not yet supported by Wix Design System, but SSR is supported.
  • Provides a simple dashboard page with navigations to relevant pages and a simple example of a shipping delivery form
  • Integrates with Wix Data API to query last orders and present last 3 orders in the dashboard

Note: This example dashboard implementation does not include the actual persistence of the model to an actual DB

Development Entry point

  1. dashboard/page.tsx
    • The page uses the sample app model implementation in app-data.model.ts. It provides an array of shipping delivery methods, which can be extended to your needs
    • The dashboard page uses both the client side SDK implementation wix-sdk.client.ts and server side - wix-sdk.ssr.ts for SSR support.

Delivery method SPI implementation

Checkout Delivery method

Development Entry point

  1. /api/shipping-rates/v1/getRates/(route.ts)
  • Provides a simple implementation of a shipping delivery method, which can be extended to your needs.
  • The provided implementation receives the ordered items, their weight and quantity, and returns a list of delivery methods with their price and estimated delivery time
    • If the calculation of the delivery method is by weight, the implementation checks the unit of the weight, and converts it from KG to LB or vice versa if needed.

Oauth

Development Entry points

  1. /api/oauth/v1/authorize/(route.ts)
    • Implements the installation URL in Wix App Oauth flow, which defines some state and redirects to Wix App Oauth URL, including the redirect URL to the callback endpoint in the application.
  2. /api/oauth/v1/signup/(route.ts)

Webhooks

  • Webhooks support using Wix Apps Webhooks API
  • Parse JWT token from Wix using app secret and verify signature
  • Example "App Installed" and "App Removed" webhooks

Development Entry points

  1. /api/webhooks/v1/install/(route.ts)
    • Parse the JWT token from Wix using app secret and verify signature, allowing you to add your logic to handle the "App Installed" webhook
  2. /api/webhooks/v1/uninstall/(route.ts)
    • Parse the JWT token from Wix using app secret and verify signature, allowing you to add your logic to handle the "App Installed" webhook

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deployment

This template is written in Next.js 14 using Next.js app router. To learn more about Next.js, see the following resources:

One click deployment to Netlify or Vercel

Netlify

Deploy to Netlify

For more information, see How to Deploy Next.js Sites to Netlify.


Vercel

Deploy with Vercel

For more information, see How to Deploy Next.js Sites to Vercel

dev-center-template-fullfilment-app's People

Contributors

adsac avatar carmelc avatar netanelgilad avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.