Overview
Webhooks simplify the communication between your App and Salla APIs. In this way, you will be notified whenever your app receives payload/data from the Salla APIs. These webhooks are triggered along with many actions such as an order or product being created, a customer logs in, a coupon is applied, and much more.
This module helps you to listen for notifications from Salla APIs within your Nodejs applications and Expressjs,
By using it you can impelement listernes for every event sent by Salla to your server .
For more information about Salla's Webhooks implementation, check our
Webhooks Explained.
Webhooks Workflow
Installation
$ npm install @salla.sa/webhooks-actions
(back to top)
Usage
With Salla Webhooks Actions you can listen for notifications send by Salla to your endpoint set by Expressjs or other frameworks like next.js
Impelement Using Listeners
You you can add listeners as a function, it will be exeucted every time an event is received .
const express = require("express");
const bodyParser = require("body-parser");
const consolidate = require("consolidate");
const SallaWebhook = require("@salla.sa/webhooks-actions");
const port = 8081;
let eventsStack = [];
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
require("dotenv").config();
const SALLA_WEBHOOK_SECRET = process.env.SALLA_WEBHOOK_SECRET;
SallaWebhook.setSecret(SALLA_WEBHOOK_SECRET);
SallaWebhook.on("app.installed", (eventBody, userArgs) => {
});
SallaWebhook.on("app.stroe.authorize", (eventBody, userArgs) => {
});
app.post("/webhook", function (req, res) {
SallaWebhook.checkActions(req.body, req.headers.authorization, {
});
});
app.listen(port, function () {
console.log("App is listening on port " + port);
});
Impelement Using Folder Structure
You you can add listeners as files easly using the salla app create-webhook app.updated
command; the file will be exeucted every time an event is received .
const express = require("express");
const bodyParser = require("body-parser");
const consolidate = require("consolidate");
const SallaWebhook = require("@salla.sa/webhooks-actions");
const port = 8081;
let eventsStack = [];
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
require("dotenv").config();
const SALLA_WEBHOOK_SECRET = process.env.SALLA_WEBHOOK_SECRET;
SallaWebhook.setSecret(SALLA_WEBHOOK_SECRET);
SallaWebhook.on("all", (eventBody, userArgs) => {
});
app.post("/webhooks", (req, res) =>
SallaWebhook.checkActions(
req.body,
req.headers.authorization,
...{
}
)
);
app.listen(port, function () {
console.log("App is listening on port " + port);
});
(back to top)
Salla already defined a list of the webhooks/actions that are triggered automatically. The predefined webhooks/actions can be found in the folder Actions
.
Order Related Webhooks/Actions
(back to top)
Product Related Webhooks/Actions
(back to top)
Shipping Companies Related Webhooks/Actions
** Action Name ** | ** Description ** |
---|
shipping.zone.created | This is triggered when a shipping zone has been created for a custom shipping company |
shipping.zone.updated | This is triggered when a shipping zone has been updated for a custom shipping company |
shipping.company.created | This is triggered when a custom shipping company has been created |
shipping.company.updated | This is triggered when a custom shipping company has been updated |
shipping.company.deleted | This is triggered when a custom shipping company has been deleted |
(back to top)
Customer Related Webhooks/Actions
(back to top)
Category Related Webhooks/Actions
** Action Name ** | ** Description ** |
---|
category.created | Creates a new category for products to be put under |
category.updated | Add new or reform existing category details |
(back to top)
Brand Related Webhooks/Actions
** Action Name ** | ** Description ** |
---|
brand.created | Creates a new Brand. |
brand.updated | Triggered when Information about a sepcific Brand is updated/refurbished/streamlined |
brand.deleted | An existing brand is then deleted and removed from a store |
(back to top)
Store Related Webhooks/Actions
(back to top)
Cart Related Webhooks/Actions
** Action Name ** | ** Description ** |
---|
abandoned.cart | Outputs a list of abandoned carts |
coupon.applied | Creates a discount code in the form of a coupon |
(back to top)
Special Offer Related Webhooks/Actions
(back to top)
Miscellaneous Related Webhooks/Actions
** Action Name ** | ** Description ** |
---|
review.added | A product review has been added |
(back to top)
Tests
$ npm install --dev
$ npm test
(back to top)
Support
The team is always here to help you. Happen to face an issue? Want to report a bug? You can submit one here on Github using the Issue Tracker. If you still have any questions, please contact us via the Telegram Bot or join in the Global Developer Community on Telegram.
Contributing
Contributions are what make the open-source community such an amazing place to learn, inspire, and create.
Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request.
You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
(back to top)
Security
If you discover any securitys-related issues, please email security@salla.sa instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
(back to top)