Learn how to seamlessly integrate third-party APIs in your Node.js applications for powerful data access and functionality.
Β
This integration was implemented in a production e-commerce platform for Gift Deevah Ltd. The goal was to enable secure online payments directly on the platform using Wema Bank API, ensuring automated transaction processing, verification, and order confirmation without manual intervention.
π You can view the live project here: https://giftdeevah.com
This system handles real customer transactions, meaning every part of the integration had to be secure, reliable, and production ready.
The payment system was built using a Node.js backend that acts as the central layer between the frontend checkout flow and Wema Bank API services.
Flow of the system:
Frontend
HTML5
CSS3
JavaScript
Bootstrap
Backend
Node.js
Express.js
Database
MySQL
API Integration
Wema Bank Payment API
Webhook event handling
RESTful architecture
Tools
Postman for testing
Git for version control
Environment variables for security
When a user checks out, the backend sends a request to Wema Bank to initialize the transaction.
const axios = require("axios");
async function initializePayment(order) {
try {
const response = await axios.post(
"https://api.wemabank.com/payment/initiate",
{
amount: order.amount,
email: order.customerEmail,
reference: order.referenceId,
callback_url: "https://giftdeevah.com/payment/callback"
},
{
headers: {
Authorization: `Bearer ${process.env.WEMA_SECRET_KEY}`
}
}
);
return response.data;
} catch (error) {
console.error("Payment Init Error:", error.message);
}
}
This step generates a payment session and returns authorization details to the frontend.
After payment is completed, Wema Bank sends a webhook to confirm the transaction status.
app.post("/webhook/wema", async (req, res) => {
try {
const event = req.body;
if (event.status === "success") {
const reference = event.reference;
await db.query(
"UPDATE orders SET status = ? WHERE reference = ?",
["paid", reference]
);
console.log("Payment verified and order updated");
}
res.sendStatus(200);
} catch (error) {
console.error("Webhook Error:", error.message);
res.sendStatus(500);
}
});
This ensures only verified payments update the system.
After verification, the order is automatically updated:
async function updateOrderStatus(reference, status) {
await db.query(
"UPDATE orders SET payment_status = ? WHERE reference_id = ?",
[status, reference]
);
}
This removes manual intervention and ensures accuracy.
Handled multiple states like pending, failed, and successful transactions to avoid inconsistent order records.
Implemented validation checks to ensure only authentic requests from Wema Bank update the database.
Ensured every payment has a unique reference ID to avoid duplication or mismatch in orders.
Built fallback logic for failed API requests and network issues to maintain system stability.
This integration transformed the e-commerce system into a fully automated payment platform. Customers can now complete purchases seamlessly, while the business receives instant payment verification and order updates.
It improved operational efficiency, reduced manual work, and increased trust in the platformβs payment system.
This project demonstrates my ability to build real-world financial integrations using Node.js, combining backend architecture, API communication, security practices, and business logic into a production-ready system.
π Visit the live system here: https://giftdeevah.com
Your email address will not be published. Required fields are marked *