Food restaurants remain one of the best lucrative businesses around the world. They get patronage on a daily basis without being much affected by a country's economy because people depend on food for survival.
Creating an avenue for your food restaurant to sell online helps your business reach a wide range of people who won’t be available to buy in your physical shop and increases your daily sales
In this tutorial, you will learn how to build a complete food ecommerce restaurant using Medusa ecommerce engine with Paystack integration.
The full code for this project is on this GitHub repository.
What is Medusa?
Medusa provides bespoke commerce infrastructure for developers. Its composable commerce engine addresses the challenges of existing ecommerce platforms which APIs offer bad developer experiences, extension capabilities are insufficient, and results are hacky and hard to maintain.
The solutions ships as a headless backend with a comprehensive feature set covering core elements related to order, product, and customer handling. In addition, it provides advanced features related to promotions, multi-currency handling, RMA flows, customer group handling and much more. For a comprehensive overview of the solutions and integrations, see Medusa’s documentation.
What is Next.js?
Next.js is a JavaScript open source framework for building superfast and extremely user-friendly frontend websites using React. It is a server-rendered, lightweight, and flexible React framework that requires little or no configuration during usage.
Using Medusa commerce engine to build your online stores gives you the opportunity to work with Medusa Next.js storefront starter, which can be easily installed through CLI commands.
Medusa Next.js storefront is a 100% ready-to-use Medusa storefront template. It comes with all ecommerce storefront features such as product display, featured products, shopping cart, checking out, multiple payment processing, and more.
What is Paystack?
Paystack is the #1 African payment gateway that helps businesses to accept online payments through their ecommerce stores, websites, and applications. Paystack provides other services such as point-of-sale (PoS), payment through an invoice, and more.
The integration between Medusa and Paystack can be achieved using a community plugin, which you’ll learn in this tutorial.
Prerequisites
Before you start, be sure you have the following:
Set up Your Food Restaurant Ecommerce with Medusa
To start building with Medusa, follow these simple steps below:
Install Medusa CLI
Medusa CLI tool can be installed either using
orCopy to clipboardnpm
, but this tutorial is based onCopy to clipboardyarn
. Use the command below to install Medusa CLI:Copy to clipboardnpm
Creating Your New Food Restaurant Store Server
The command below will create a new Medusa store for you:
will be your project name, but you can change this to your preferred choice of name.Copy to clipboardmy-food-restaurant
Switch to the project directory:
Installing Paystack Medusa Plugin
In the root of your project,
, run this command to install Medusa Paystack plugin:Copy to clipboardmy-food-restaurant
Next, you need to configure your Paystack plugin in your project. To do this, first, add PAYSTACK SECRET KEY to your
file:Copy to clipboard.env
In the above, replace
with the secret key gotten from your Paystack API Key.Copy to clipboardexample_key_xxxxx
In
, add the following at the end of theCopy to clipboardmedusa-config.js
array:Copy to clipboardplugins
The above code snippet adds Medusa Paystack plugin to your project configurations.
Installing MinIO Medusa Plugin
Managing images in Medusa requires a file service plugin for uploading images of products. Medusa provides different options for handling image upload for products, but this tutorial will focus only on using MinIO file service plugin.
MinIO is a high-performance open source object storage solution that provides S3 storage functionality. You can follow this documentation to learn how to install it and create a bucket.
Install MinIO plugin in the Medusa server directory with the command below:
Next, add the following block of code to your
:Copy to clipboard.env
Note:
is the URL of your MinIO server,Copy to clipboard<ENDPOINT>
is the name of the bucket you created earlier, andCopy to clipboard<BUCKET>
andCopy to clipboard<ACCESS_KEY>
are the keys you generated in the previous section.Copy to clipboard<SECRET_KEY>
Finally, in
, add the following at the end of theCopy to clipboardmedusa-config.js
array:Copy to clipboardplugins
If you’ve completed the above processes, start your store server with the command below:
You can navigate to
to see available products in your store.Copy to clipboardlocalhost:9000/store/products/
Creating Medusa Admin for your Food Restaurant
To set up your Medusa Admin, follow the steps below.
- Clone the Medusa Admin repository and change to the newly created folder:
- Run the command below to install all necessary dependencies:
- Test it:
(Note: Ensure your Medusa store server is running before testing your admin.)
By default, Medusa Admin runs on port
. You can go toCopy to clipboard7000
on your browser to access your admin page.Copy to clipboardlocalhost:7000
Medusa Server comes with admin login details, which are
as the email address andCopy to clipboardadmin@medusa-test.com
as the password. This demo data is a result ofCopy to clipboardsupersecret
added while creating your store server.Copy to clipboard--seed
You can visit the User Guide to learn more about Medusa Admin.
Adding Paystack Payment Provider to your Regions
Food restaurants could be inter-state or international businesses, which means your store should be focused on selling products to a particular country.
This tutorial will be focused on using the Nigerian currency since it’s one of the Paystack-supported countries.
If you are not selling to Paystack-supported African countries, you can easily integrate Medusa Stripe Payment Plugin in your store.
To add Paystack to your regions, follow the steps below to set your store currency;
1. Go to Settings ⇒ Currencies.
2. Click on the Edit currencies button in the Store Currencies section.
3. In the new window that opens, click on the Add Currencies button and select all the currencies you want to add.
4. Click on the Save and close button.
Note: Set your default currency to Nigerian Naira after the 4th step.
You can learn more about how to manage currencies.
Adding Paystack to your Region:
1. Go to Settings ⇒ Regions.
2. Click on the plus icon at the top right of the Regions section .
3. In the form that opens, enter the Regions details. It is required to enter a title, choose a currency, enter a tax rate, and choose at least one country where your restaurant is based, payment provider (select Paystack), and fulfillment provider.
Once done, click on the Create region button at the top-right side.
Learn more about Regions from Medusa User Guide.
Adding Food Products to your Admin
Medusa Admin supports product management which includes adding new products, editing, publishing, unpublishing, duplicating, and deleting products.
By default, the Medusa store server comes with a few products. You’ll delete them and add new products according to your restaurant's food menu.
Visit Medusa Products Overview for a complete user guide on how to manage products in your store.
Creating Medusa Next.js Storefront
In this tutorial, you will use the Medusa Next.js Storefront Template to build your storefront.
Medusa Next.js Storefront Template already has every feature you may need in your storefront in it; this helps to quicken your development process when you choose to work with Medusa as your commerce engine.
The steps below will help you create your food restaurant Storefront:
1. Run the command below to create a new Next.js starter project:
represents the name of your project; you can rename it as you wish.Copy to clipboardfood-restaurant-storefront
2. Switch to the newly created directory
and rename the template environment variable file to use environment variables in development:Copy to clipboardfood-restaurant-storefront
Customizing Your Storefront
Since you have successfully created your food restaurant storefront, you can customize your storefront to your taste.
You can find all images used for this project in the GitHub repository.
Modify Your Homepage Banner: To do so, locate
and replace its contents with the code below:Copy to clipboardsrc/modules/home/components/hero/index.tsx
The above code block will change the banner image and change the text.
Secondly, modify your Featured Product section. To do so, locate
and replace its contents with the code below:Copy to clipboardsrc/modules/home/components/featured-products/index.tsx
The above code snippet will change the default texts to match what you are building the store for.
Third, modify your part of the footer section. To do so, locate your
and replace its content with the code below:Copy to clipboardsrc/modules/**layout**/components/footer-cta/index.tsx
The above code block will change the background image and text.
Enable Paystack Payment
To enable using Paystack to accept payments from your storefront, you follow the steps below accordingly:
1. Install the React Paystack library:
Once the library is installed successfully, it will add the react Paystack package to your storefront project.
2. Add the Paystack public key to your
file:Copy to clipboard.env.local
On the above, replace
with the secret key gotten from your Paystack API Key.Copy to clipboardpk_test_xxxxxx
3. Modify your payment buttons by adding the block of code below into your
file:Copy to clipboardsrc/modules/checkout/components/payment-button/index.tsx
The above code will import your Paystack button from
library, andCopy to clipboardreact-payment
library for Paytsack button styling.Copy to clipboardclsx
Next, add
among the switch case for the payment session:Copy to clipboardPaystackPaymentButton
Finally, add the block of code before your last line of code on this same file:
The above code block will add Paystack button as part of the payment option for your storefront.
triggers the checkout payment button to process the payment whenever it’s clicked on your storefront.Copy to clipboardPaystackButton
To be sure you got the above two code blocks correctly, you can make a reference here.
4. Modify your payment container by adding the code block as part of the
collection. Here is the file pathCopy to clipboardPaymentInfoMap
:Copy to clipboardsrc/modules/checkout/component/payment-container/index.tsx
The above code makes it possible for Paystack to appear as part of the payment option in your storefront.
To be sure you got the above code block correctly, you can make a reference here.
Test your Storefront
Ensure your Medusa Server is running, then run this command:
If you navigate to
, you’ll see your storefront homepage.Copy to clipboardlocalhost:8000
If you click on Food Menu you’ll see all foods populated from your Medusa Server.
If you click on any of the food items, you’ll see the single product page and an Add to cart option.
If you click on My Bag after adding an item to the cart, you should see the Shopping Bag page.
If you click on GO TO CHECKOUT, you’ll see your Checkout Page, where you will provide your delivery information.
If you click on “PAY WITH PAYSTACK” you’ll see the Paystack Payment pop-up:
If you select Success and click on the Pay button, your payment will be processed and you’ll see the Order Receipt Page;
You can confirm the orders from your Medusa Admin panel for this project.
Conclusion
In this tutorial, you have learned how to use the Medusa commerce engine as your ecommerce store for food restaurants, working with Medusa’s Next.js Storefront Template and Integrating Paystack payment gateway into Medusa.
You can learn more about building awesome ecommerce stores with Medusa; check out Medusa’s Documentation for more guides.
Should you have any issues or questions related to Medusa, then feel free to reach out to the Medusa team via Discord.
Share this post
Try Medusa
Spin up your environment in a few minutes.

You may also like
On this page