mom-factura-webhooks
npx machina-cli add skill ithustle/momenu-skills/mom-factura-webhooks --openclawMom Factura Webhooks & Status
Receive payment confirmations for deferred payments (Bank Reference and E-kwanza) via webhook with two sequential events. Status polling endpoints available as fallback.
Base URL: https://api.momenu.online
Auth: x-api-key header required on all requests.
How It Works
- Login at momenu.toquemedia.net
- Go to the Desenvolvedores menu
- Add your webhook URL
- Save the configuration
When a payment is confirmed, the API sends two sequential webhook events to your URL:
payment.confirmed— Sent immediately after the order status is updated to PAID (before invoice generation). Use this to update the order state in your system.invoice.created— Sent after the invoice PDF is generated and uploaded. Includes theinvoiceUrlfield with the download link.
Non-paid events (cancelled, failed, error) are sent as a single event without the event field, maintaining backward compatibility.
Webhook Payloads
Event 1: payment.confirmed
{
"event": "payment.confirmed",
"merchantTransactionId": "abc123...",
"ekwanzaTransactionId": "EKZ456...",
"operationStatus": "1",
"operationData": { ... }
}
Event 2: invoice.created
{
"event": "invoice.created",
"merchantTransactionId": "abc123...",
"ekwanzaTransactionId": "EKZ456...",
"operationStatus": "1",
"operationData": { ... },
"invoiceUrl": "https://invoice-momenu.toquemedia.net/invoices/..."
}
Non-paid events (no event field)
{
"merchantTransactionId": "abc123...",
"ekwanzaTransactionId": "EKZ456...",
"operationStatus": "3",
"operationData": { ... }
}
operationStatus values: "1" Paid · "3" Cancelled/Expired · "4" Failed/Refused · "5" Error
Webhook Server Example - Node.js / Express
const express = require("express");
const app = express();
app.use(express.json());
app.post("/webhook/meu-webhook", (req, res) => {
const { event, merchantTransactionId, operationStatus, invoiceUrl } = req.body;
switch (event) {
case "payment.confirmed":
console.log("Payment confirmed:", merchantTransactionId);
// Update order state in your system
break;
case "invoice.created":
console.log("Invoice ready:", invoiceUrl);
// Save invoice URL, send to customer
break;
default:
// Events without "event" field (cancelled, failed, error)
if (["3", "4", "5"].includes(operationStatus)) {
console.log("Payment failed:", operationStatus);
}
}
res.status(200).json({ received: true });
});
app.listen(3000);
Webhook Server Example - Python / Flask
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/webhook/meu-webhook", methods=["POST"])
def momenu_webhook():
data = request.json
event = data.get("event")
transaction_id = data.get("merchantTransactionId")
status = data.get("operationStatus")
if event == "payment.confirmed":
print(f"Payment confirmed: {transaction_id}")
# Update order state
elif event == "invoice.created":
invoice_url = data.get("invoiceUrl")
print(f"Invoice ready: {invoice_url}")
# Save invoice URL
elif status in ["3", "4", "5"]:
print(f"Payment failed: {status}")
return jsonify({"received": True}), 200
Fallback: Status Polling
If webhook delivery fails, use status endpoints as fallback:
E-kwanza: GET /api/payment/ekwanza/status/:code
Reference: GET /api/payment/reference/status/:operationId
When paid, both return invoiceUrl.
async function checkEkwanzaStatus(code) {
const response = await fetch(
`https://api.momenu.online/api/payment/ekwanza/status/${code}`,
{ headers: { "x-api-key": "YOUR_API_KEY" } }
);
const data = await response.json();
if (data.status === "paid") {
console.log("Paid! Invoice:", data.invoiceUrl);
}
return data;
}
Notes
- Webhook works for both Bank Reference and E-kwanza
- Webhook delivery is fire-and-forget (no retries) — implement status endpoints as fallback
- Your webhook endpoint must return HTTP 2xx to acknowledge receipt
- MCX payments are immediate and do not use webhooks or polling
- Rate limiting: 100 req/min general, minimum 5s interval for E-kwanza polling, 30s for Reference polling
Source
git clone https://github.com/ithustle/momenu-skills/blob/main/skills/mom-factura-webhooks/SKILL.mdView on GitHub Overview
Receive payment confirmations for deferred payments (Bank Reference and E-kwanza) via webhook. The API emits two sequential events—payment.confirmed and invoice.created—so you can update order state and capture the invoice URL, with status polling as a fallback if needed.
How This Skill Works
Configure the webhook URL in the Momenu Developer portal. The API delivers two events: payment.confirmed (when the order is PAID) and invoice.created (with an invoiceUrl). If delivery fails, use the status polling endpoints as a fallback, and always include the x-api-key header on requests.
When to Use It
- Building a payment confirmation flow for Mom Factura payments
- Receiving real-time webhook notifications for payment events
- Handling order state transitions from OPEN to PAID
- Integrating Bank Reference and E-kwanza payments via webhooks
- Relying on status polling endpoints as a fallback
Quick Start
- Step 1: In Momenu, go to Desenvolvedores and add your webhook URL; note the base URL https://api.momenu.online
- Step 2: Ensure all requests include the x-api-key header and set up endpoints to handle payment.confirmed and invoice.created
- Step 3: Implement logic to update order state on payment.confirmed, store invoiceUrl from invoice.created, and fall back to status polling if needed
Best Practices
- Secure your webhook by validating requests and using HTTPS; require the x-api-key header on all calls
- Process payment.confirmed before processing invoice.created to keep state consistent
- Handle non-paid events (cancelled/failed/error) correctly when event field is absent
- Make your webhook processing idempotent to tolerate retries and duplicates
- Persist key fields like merchantTransactionId, ekwanzaTransactionId, and invoiceUrl for reconciliation
Example Use Cases
- Update the order status to PAID upon receiving payment.confirmed
- Store and propagate the invoiceUrl from invoice.created to customers
- Log and alert on non-paid events (status 3/4/5) for remediation
- Node.js/Express webhook handler processing payment.confirmed and invoice.created
- Python/Flask webhook handler demonstrating payload processing and persistence