medusa-plugin-webhooks

Overview

Medusa Plugin Webhooks

Banner

About

Participants

Description

A Medusa plugin giving the power of webhooks to your Medusa store. Receive notifications on discord, slack or anywhere where webhooks can be consumed on events on from your store.

Features

  • A helper function to send webhooks from your custom code
  • A webhook for order-related events
  • Ability to assign custom webhook urls to every event

Preview

Flowchart

Setting up the Medusa Webhooks Plugin

Prerequisites

Install and Setup the Webhooks Plugin

To install the plugin using NPM, run the following command in your Medusa server directory:

npm install medusa-plugin-webhooks

If you prefer using Yarn, run the following command in your Medusa server directory:

yarn add medusa-plugin-webhooks

Once the plugin is installed, we need to add it to the plugins array in the medusa-config.js file in your Medusa server directory:

const plugins = [
  ...{
    resolve: "medusa-plugin-webhooks",
    options: {
      webhook_url: "https://mystore.com/events", // REQUIRED: CHANGE THIS TO A VALID WEBHOOK ENDPOINT
      webhook_headers: {
        "x-api-key": "supersecretapikey", // You can add custom headers (for example, for authentication)
      },
      webhook_config: {
        "order.placed": {
          enabled: true,
          overrideUrl: "https://mystore.com/events/order-placed", // You can override the URL on a per-event basis,
          overrideHeaders: {
            "x-api-key": "supersecretorderplacedapikey", // You can override the headers on a per-event basis
          },
        },
      },
    },
  },
];

Currently these 4 events are supported:

  • order.placed
  • order.updated
  • order.completed
  • order.canceled

By default, notifications for all events are disabled. To enable notifications for any of the above events, set the enabled property to true in the webhook_config object. (see example above)

You can override the URL or headers for any of the above events by setting the overrideUrl or overrideHeaders properties in the webhook_config object. (see example above)

Sending a webhook event from your custom code

You can post a webhook from your code by resolving the webhooks service and then using the postWebhook function. For example:

const webhooksService = scope.resolve("webhooksService");
await webhooksService.postWebhook(
  {
    event: "order.placed",
    data: {
      order_id: "order_id",
      customer_id: "customer_id",
      total_price: 1000,
      currency_code: "USD",
      metadata: {},
    },
  },
  "mystore.com/events/custom", // You can pass in an URL override here as well
  {
    "x-api-key": "customeventsapikey", // You can pass in custom headers here as well
  }
);

If you face any issues or have any questions, feel free to open an issue

Contributing

If you want to suggest a new feature, open a new issue with the feature request template. For bug reports, use the bug report issue template.

To make a pr, fork the repository, clone it, create a new branch that describes the new feature or the bug it is fixing. Then make the required changes, commit them (we strongly recommend that you follow the Conventional Commits specification and gitmojis are welcome as well). The next step is to create a pull request and a maintainer will review it as soon as possible.

License

This project is licensed under the MIT License - see the LICENSE file for more details.

The plugin structure was inspired by the official Sendgrid plugin and borrows some code from it.

Resources

You might also like...

Babel-plugin-amd-checker - Module format checking plugin for Babel usable in both Node.js the web browser environments.

babel-plugin-amd-checker A Babel plugin to check the format of your modules when compiling your code using Babel. This plugin allows you to abort the

Jan 6, 2022

A variety of jQuery plugin patterns for jump starting your plugin development

jQuery Plugin Patterns So, you've tried out jQuery Boilerplate or written a few of your own plugins before. They work to a degree and are readable, bu

Dec 31, 2022

A tool to get plugin statistics of Obsidian plugin ecosystem.

A tool to get plugin statistics of Obsidian plugin ecosystem.

Obsidian Plugin Stats A tool to get plugin statistics of Obsidian plugin ecosystem. Usage You can use this tool to see the plugins that has hit commun

Dec 25, 2022

πŸ“¦ Alpine JS plugin to extend the functionality of the official $persist plugin

Alpine JS Persist Extended Alpine JS magic method $storage extends the official $persist plugin to help you work with local storage πŸ“¦ Example πŸ‘€ div

Dec 28, 2022

kakaolink-plugin is a remote-kakao plugin for sending KakaoLinks instead of plain text

kakaolink-plugin is a remote-kakao plugin for sending KakaoLinks instead of plain text

kakaolink-plugin Discord Server About kakaolink-plugin is a remote-kakao plugin for sending KakaoLinks instead of plain text. Requirements Node.js v17

Oct 1, 2022

A markdown-it plugin that process images through the eleventy-img plugin. Can be used in any projects that uses markdown-it.

markdown-it-eleventy-img A markdown-it plugin that process images through the eleventy-img plugin. Can be used in any projects that use markdown-it. F

Dec 20, 2022

This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way, this plugin works after page load.

Jquery-SingleImagePopup This is a simple Image popup Jquery plugin. With a very simple configuration, you can show a popup on your webpage. By the way

Aug 22, 2022

An obsidian toolbar plugin, modified from the Cmenu plugin

An obsidian toolbar plugin, modified from the Cmenu plugin

obsidian-editing-toolbar Plugin Thanks to the cmenu plugin, which gave me a lot of inspiration, but this plugin has not been maintained for more than

Dec 29, 2022

Deploy WordPress plugin and theme to the wordpress.org plugin directory.

wp-deployer Deploy WordPress plugin and theme to the wordpress.org plugin directory. Install npm install --save-dev wp-deployer Settings slug : Plugin

Sep 6, 2022
Releases(v0.1.0)
Owner
Anish De
15 β€’ 🌐 Fullstack Web Developer β€’ πŸ“ Blogger β€’ πŸš€ Web3 Enthusiast β€’ πŸ“± Tech Enthusiast
Anish De
A plugin starter for medusa pre-configured and using typescript

Plugin starter (Typescript) Start to write your own plugin as quick as possible Getting started Installation git clone [email protected]:adrien2p/medusa-

Adrien de Peretti 12 Nov 9, 2022
Integrate Railway Project events with Telegram Chat/Channel using Railway Webhooks

Railway to Telegram Integrate Railway Project events with Telegram Chat/Channel using Railway Webhooks! One Click Self Deploy Manual Self Deploy Fork

Agampreet Singh 9 Jul 5, 2022
Medusa + Next.js starter frontend UI project as a part of Open source contribution.

Medusa Next.js Starter Medusa is an open-source headless commerce engine that enables developers to create amazing digital commerce experiences. Prere

Gourav Singh Rawat 9 Dec 15, 2022
NX workspace for running medusa backend, storefront and admin panel with marketplace functionalities

Medusa Marketplace Project status Assigned store_id to Order, Product to make them store specific Create and process payment for an order with multipl

Keith Hon 8 Nov 13, 2022
Generate social preview images in your Next.js API from Sanity webhooks

sanity-next-social-image-generator Automatically generate social share images using Sanity webhooks, and your Next.js API! Requirements A Next.js appl

Jordan McRae 9 Sep 4, 2022
An application for sending webhooks on Discord.

Cordhook ?? Cordhook is an application for sending webhooks on Discord with ease. ?? Built with Tauri for desktop and Next.js for web. ?? Styled with

Marin HeΔ‘eΕ‘ 5 Jan 4, 2023
Slack Integration to receive incoming webhooks from openpix.com.br

Slack Integration This is a aws lambda function to receive new transaction informations from OpenPix @ your company's slack workspace. Getting Started

Leandro Alencar 6 Sep 19, 2022
Type safe library for interacting with Mindbody's Public API (v6) and Webhooks

Mindbody API Type safe library for interacting with Mindbody's Public API (v6) and Webhooks ⚠️ Read before installing This library is typed according

SplitPass 4 Dec 9, 2022
A beautiful NextJS storefront for a Medusa store (The opensource alternative to Shopify)

medusa-starter-monster About Participants Yinka - @yinkakun Description Medusa Storefronts don't have to be boring. This starter is an elegant and bea

Yinka Adedire 12 Dec 16, 2022