The post Setup Marketplaces Payments with ClickPesa BillPay appeared first on ClickPesa.
]]>That is where ClickPesa BillPay comes in.
If you are a marketplace or platform managing multiple vendors, ClickPesa enables you to assign dedicated BillPay numbers to each of your clients, together with your own system this can functioning like sub-accounts. These can be used to collect payments from their end customers directly, whether for goods, services, subscriptions, or deliveries.
Each BillPay number connects your merchants, whereby you ensure instant settlement to their account together with clean reporting and easy reconciliation.
To make reconciliation even easier, we support custom merchant and transaction reference codes, combining a unique merchant ID and order number into a single payment reference string.
For example:
FDS002FDS0027482This approach brings several advantages:
Unlike static payment codes or shared references, structured codes like MERCHANT0009999 are scalable and future-proof.
You may be familiar with systems like M-Pesa Lipa Kwa Simu, where each merchant collects through a separate number. ClickPesa offers a smarter, more flexible alternative:
This setup is perfect for logistics companies, delivery apps, e-commerce platforms, service marketplaces, or any platform managing merchant payments.
If you’ are looking to enable structured, merchant-specific payment flows that scale with your business, ClickPesa BillPay offers the flexibility and infrastructure to support it.
The post Setup Marketplaces Payments with ClickPesa BillPay appeared first on ClickPesa.
]]>The post How to use Customer BillPay for School Management Systems appeared first on ClickPesa.
]]>A Customer BillPay Control Number is a static, unique number assigned by a merchant to a specific customer (e.g., a student, guardian, or fee category). It is reusable for multiple transactions, making it ideal for frequent or subscription-style payments.
In a school context, you assign each student, or each fee bucket for that student, a control number. Parents then pay using Tanzanian mobile money and CRDB channels. Control numbers can be created manually in the dashboard or programmatically via the Customer BillPay API.
Docs: Customer BillPay Control Numbers
Create a static control number tied to a specific customer or fee bucket. This enables automatic payment tracking and clean, student-level reconciliation.
Two ways to generate:
API: Create Customer Control Number
Webhooks: Overview & Checksum
Communicate the control number clearly in the parent portal, SMS reminders, and printed slips. The same number works across all supported channels, so parents never need to ask for “the latest” payment details.
Parents can pay using:
Step-by-step instructions are available on each control number page and can be shared with parents: Instructions
Your system receives real-time webhooks for each successful payment. Use these to update the student balance immediately, apply the receipt to the correct fee bucket, and post journals. For audits and nightly checks, query the Payments API and match against settlement files.
This integration keeps data consistent from collection through accounting.
Good setup prevents most issues and simplifies audits.
Use the same platform to pay transport providers, caterers, book suppliers, and casual staff, keeping your audit trail intact.
Docs: Payout API
Do parents need a special app?
No. They pay through their usual mobile money or CRDB channel using the control number you provide. Your system receives a confirmation immediately and updates balances.
What if parents do not want to use their customer bill pay number?
We also support USSD Push Payments, this can be implemented in your app and trigger a USSD popup asking the parents to pay. They do not have to enter a reference number, we make sure the payment is automatically booked to the right reference. Docs: USSD Push Payments
How are refunds handled?
Issue a payout to the parent and link it to the original payment reference for audit.
The post How to use Customer BillPay for School Management Systems appeared first on ClickPesa.
]]>The post Introducing BillPay APIs for Invoices and Customers appeared first on ClickPesa.
]]>A BillPay Control Number (BillPay-Namba) is a static, unique number linked to a specific customer or bill. It acts like a payment rail that you can reuse for multiple transactions if you allow partial or recurring payments. Because each payment against the number triggers a webhook, your system can update balances, post entries, and reconcile automatically.
The APIs let you programmatically generate and manage control numbers, removing manual setup and reducing operational overhead. You can:
Read more: https://docs.clickpesa.com/bill-pay/bill-pay-overview
Customer BillPay Control Numbers
A single, permanent number linked to a customer, contract, or cost center that accepts multiple payments against the same reference. Ideal for ongoing relationships, installments, subscriptions/retainers, maintenance, repeat donations, because the number never changes, reducing payer confusion and making reconciliation predictable.
Read more: https://docs.clickpesa.com/bill-pay/customer-billpay-namba
Order BillPay Control Numbers
A one-time number tied to a specific bill (invoice, order, POS/restaurant tab) so the payer completes that transaction in a single flow. You control its behavior and lifespan (amount rules, partial/overpayment settings, expiry/closure) and can add a description and custom reference.
Read more: https://docs.clickpesa.com/bill-pay/order-billpay-namba
Read more: https://docs.clickpesa.com/bill-pay/billpay-api-overview
We here explain how to integrate the BillPay APIs with your system and keeps data consistent from collection through accounting.
Docs: https://docs.clickpesa.com/api-reference/collection/querying-for-payments/querying-for-payments
The BillPay API (for creating and managing Customer and Order Control Numbers) is a secure, maintained service that we operate end-to-end, cloud infrastructure, uptime monitoring, webhook delivery, fraud/abuse safeguards, and ongoing product support. That work carries real operating costs, so we charge a 1% per successful transaction. In return, businesses typically cut manual administration and reconciliation dramatically (companies report up to 85% less admin), turning BillPay into a net cost saver.
Can one customer have multiple control numbers?
Yes. Use separate numbers for different services, projects, or income centers.
Do you support partial payments and overpayments?
Yes, this can be done through Customer BillPay Control Numbers. You choose the behavior per control number.
How are confirmations delivered?
Each successful payment triggers a webhook so your system can update balances immediately.
What is my customers do not want to pay with a reference, can I still track payments coming from them?
Yes, we also provide USSD Push Payments. It triggers a USSD prompt from your app to ask the customer to pay, no reference entry required. The payment is automatically matched to the correct reference.
Which channels are supported?
All major Tanzanian mobile money networks and CRDB banking channels.
Why does it cost my business 1% per transaction?
The fee covers the secure operation and continuous improvement of the BillPay API, hosting, monitoring, webhook reliability, integrations and support. It is designed to reduce manual work and errors; many customers see up to 85% less admin effort.
What’s included in the fee?
API access, real-time webhooks, control-number management, observability/monitoring, and merchant support.
Does the 1% apply to both Customer and Order Control Numbers?
Yes. The fee applies to each successful payment processed via BillPay channels, regardless of control-number type.
How are partial payments handled?
Each successful payment against a control number (including partials) is processed and charged individually.
Can I still assign control numbers from the Merchant Dashboard without using the API?
Yes. The Dashboard flow remains available for manual workflows and quick starts; the API adds automation and system-to-system control.
Who pays the fee, us or our customers?
By default, fees for BillPay are charged to the merchant account.
Where do I see the fees and settlements?
In your settlement reports and transaction detail within the Merchant Dashboard (and via our reporting/Query APIs)
Do you have any questions about this setup? Contact us here: https://clickpesa.com/customer-support/
The post Introducing BillPay APIs for Invoices and Customers appeared first on ClickPesa.
]]>The post Simplifying Donation Payments for NGOs with ClickPesa appeared first on ClickPesa.
]]>ClickPesa is designed to solve that problem. It brings all your donation payments into one simple, structured, and reliable system. Whether you are collecting small recurring donations from local supporters or large one-time contributions from abroad, ClickPesa gives NGOs a unified payment gateway that is easy to set up, easy to use, and built for scale.
ClickPesa enables NGOs to receive donations from anyone, anywhere, whether through mobile money, bank transfers, or credit and debit cards. Instead of managing multiple accounts or payment processors, your organization can use a single, consolidated system that handles every incoming donation.
This eliminates the traditional bottlenecks that come with managing separate bank accounts, mobile money lines or donation platforms. Donors enjoy a simple and trustworthy payment experience, while NGOs gain real-time visibility and control over their inflows.
When donations come from multiple sources, maintaining clarity is crucial. ClickPesa’s structured reference system makes it possible to organize and monitor donations with precision. NGOs can define custom codes for each campaign, program, or project, allowing both donors and finance teams to see exactly where every contribution belongs.
For example:
EDU001 – Education FundHLT002 – Health CampaignWOM003 – Women Empowerment InitiativeEach donation carries its unique reference, automatically linked to your internal reporting. This ensures every payment can be traced to its purpose, making audits and donor reporting effortless. It also improves transparency, a vital factor in maintaining donor trust.
Traditional donation systems are often either too localized or too fragmented. Mobile money is ideal for local supporters but doesn’t support international cards. Bank transfers are reliable but can take days to clear. Payment gateways for cards often lack strong reconciliation and local integrations.
ClickPesa bridges all these gaps with a single infrastructure that connects every payment source. NGOs benefit from:
By simplifying financial management, NGOs can focus on their mission, not their payment logistics.
Whether you are a small community-based organization or a large international NGO, ClickPesa BillPay scales with your needs. Smaller organizations can easily create a single BillPay number to start collecting donations immediately, while larger NGOs can segment their payment flow by department, project, or country.
The platform supports enabling long-term fundraising campaigns. Integration with your website or mobile app via the ClickPesa API allows for seamless online donation experiences, complete with automatic notifications and digital receipts.
Because ClickPesa is designed for transparency and flexibility, it also helps NGOs comply with the financial reporting requirements often set by international donors, foundations, and governments.
In the world of fundraising, simplicity builds trust. Donors are far more likely to complete a contribution when the process feels intuitive, transparent, and secure. ClickPesa’s unified payment experience achieves just that, it reduces friction for the donor while giving the NGO full visibility into every transaction.
This transparency creates stronger donor relationships and a higher likelihood of repeat contributions. Donors can see exactly where their funds go, NGOs can issue acknowledgments promptly, and internal teams spend less time chasing payment confirmations.
For global NGOs, this also means they can bridge local and international funding streams effortlessly. A donor in Tanzania can pay through M-Pesa or Tigo Pesa, while a donor in Europe or the U.S. can use a credit card or bank payment.
Every NGO’s mission depends on effective resource management. The more efficiently funds are collected, tracked, and reported, the more time and energy can be devoted to impact. ClickPesa BillPay helps NGOs build that foundation by transforming donation payments into a transparent, automated, and trusted process.
Whether your organization supports education, healthcare, women empowerment, or climate initiatives, ClickPesa is designed to simplify how you collect and manage funds.
With support for mobile money, bank transfers, and credit card payments, ClickPesa gives NGOs and donors a single, unified experience that’s fast, transparent, and built for the modern financial ecosystem.
The post Simplifying Donation Payments for NGOs with ClickPesa appeared first on ClickPesa.
]]>The post International Money Transfer and Remittances to Tanzania through TIPS appeared first on ClickPesa.
]]>
The directive mandates that all banks, mobile money operators, and financial service providers receiving inbound remittances must route these transactions exclusively through TIPS, the national real-time payment system managed by the Bank of Tanzania.
The Tanzania Instant Payment System (TIPS) is a central payment infrastructure that facilitates real-time money transfers between financial institutions in Tanzania. Initially launched for domestic payments, TIPS has grown to support interoperability between banks, mobile money operators, and other financial players. The new directive expands TIPS’ role to handle all inbound international remittances.
This upgrade follows a period of system enhancements and stakeholder consultations. The Bank of Tanzania has now introduced a dedicated use case within TIPS specifically for managing international money transfer (IMT) transactions.
According to the official circular issued on 1st July 2025:
The directive represents a major evolution in Tanzania’s financial system. It is part of a broader trend across Africa to digitize financial services, improve regulatory control, and support innovation in cross-border payments.
Faster Settlement:
Routing all transactions through TIPS means recipients will receive funds more quickly. Real-time settlement improves access and reduces delays, especially in rural or underserved areas.
Transparency and Predictability:
The flat fee of TZS 1,000 per transaction introduces consistency in pricing, eliminating the complexity and unpredictability that often accompanies cross-border remittances.
Stronger Regulatory Compliance:
TIPS enables better enforcement of financial regulations, including AML and foreign exchange rules. It provides the central bank with greater oversight and reduces the risk of fraud and illicit transfers.
Enablement of Fintech Innovation:
By creating a standardized infrastructure, this policy makes it easier for fintechs and new market entrants to integrate with the national system and offer compliant, efficient remittance solutions.
Better Data and Analytics:
Centralizing remittance flows into TIPS gives policymakers and regulators access to high-quality, real-time data, supporting better decision-making and planning.
While the directive offers clear benefits, it also introduces new challenges for financial institutions, remittance providers, and end users.
Integration Pressures:
Financial service providers must prioritize technical integration with TIPS to remain compliant. For those not yet fully integrated, the timeline may be tight, especially for smaller providers.
Impact on Small Transfers:
The fixed fee model, while transparent, may represent a significant cost for small-value transfers. For example, a fee of TZS 1,000 on a TZS 10,000 remittance translates to a 10% transaction cost.
Reduced Provider Flexibility:
Customers may have fewer choices in how they send and receive money. All providers must comply with the TIPS framework, which could limit differentiation and service customization.
Transition Risks:
Any major change in infrastructure carries risks of service disruption. Ensuring that all participants are ready and tested before the go-live date will be critical to avoid issues for customers.
This shift positions Tanzania as a regional leader in digital payments and regulatory innovation. With an estimated USD 500 million flowing into the country each year through remittances, the new system is poised to make a significant impact on financial inclusion, especially among underserved populations.
By enabling real-time access to funds through both bank accounts and mobile wallets, the new TIPS requirement could improve household liquidity and strengthen the link between diaspora communities and the domestic economy.
At the same time, centralizing inbound remittances will help the Bank of Tanzania achieve more accurate monitoring of foreign currency flows and reduce reliance on informal channels.
ClickPesa is fully integrated with the Tanzania Instant Payment System (TIPS) and ready to support this policy transition. For international remittance companies, financial institutions, and payment service providers looking to enter or expand in the Tanzanian market, ClickPesa provides a compliant, efficient, and user-friendly platform for cross-border transfers.
Our platform simplifies integration with TIPS, helps manage regulatory requirements, and ensures your customers can access real-time payment capabilities across Tanzania.
Whether you’re navigating the upcoming mandate or looking to improve your remittance infrastructure, ClickPesa can help.
Contact us today to learn how we can support your business ahead of the 1st August 2025 deadline.
The post International Money Transfer and Remittances to Tanzania through TIPS appeared first on ClickPesa.
]]>The post How to Safely Make Payments to Safari Tour Operators in Tanzania appeared first on ClickPesa.
]]>This article explores safely how to make payments to safari tour operators in Tanzania, key things to check before paying, and how payment service providers like ClickPesa help simplify the payment process using SEPA, RTP, and card payments.
Before transferring any money, take a moment to verify that the safari company is legitimate. Here’s how:
Taking these steps reduces the risk of scams and ensures that you’re dealing with a legitimate business.
Most larger safari operators accept international card payments via Visa or Mastercard. This is one of the fastest and most familiar methods for travelers.
Pros:
Cons:
ClickPesa supports card payments, giving operators a secure and reliable way to accept international bookings.
If you’re based in the European Union or EEA, a SEPA bank transfer is one of the most affordable and efficient options.
Why SEPA works well:
ClickPesa allows safari operators to receive SEPA payments directly into their Tanzanian accounts, avoiding high intermediary fees.
Real-Time Payments (RTP) are supported by many major U.S. banks and provide an instant alternative to traditional wire transfers.
Advantages:
ClickPesa enables RTP from the U.S. directly to Tanzanian operators, making it ideal for American travelers who want to pay quickly and securely.
SWIFT transfers are the traditional go-to for international payments, but they are increasingly outdated in terms of speed and cost.
Limitations include:
Use SWIFT only if SEPA, RTP, or card payments are unavailable.
ClickPesa bridges the gap between international travelers and Tanzanian safari operators by offering a secure, regulated platform that supports:
Operators using ClickPesa benefit from lower fees, instant confirmation options, and a payment infrastructure built for cross-border transparency. Travelers get peace of mind knowing their funds are sent through a trusted, traceable process.
To protect your funds and ensure a smooth booking process, keep the following in mind:
Paying your safari operator in Tanzania doesn’t need to be stressful or expensive. Travelers in Europe can take advantage of SEPA transfers via ClickPesa for fast, low-cost payments. U.S. travelers can use RTP for instant settlements without SWIFT delays. And for anyone preferring card payments, ClickPesa offers a secure and straightforward solution.
Before you make payments to Safari Tour Operators, always confirm who you are dealing with, and choose a payment method that protects your time, money, and travel experience.
The post How to Safely Make Payments to Safari Tour Operators in Tanzania appeared first on ClickPesa.
]]>The post How to Add Developers to the ClickPesa Developers Portal for Payment Integration appeared first on ClickPesa.
]]>This guide outlines how to add developers through the dashboard, what permissions they receive, and how to manage their roles.
Giving your developers access to our developer portal ensures they can:
Developers cannot create or authorize payouts, ensuring your financial workflows remain secure while enabling effective troubleshooting and integration.
The process to add a developer to the developer portal is identical to adding any other team member.
Settings → TeamThe invited user will receive an email with access instructions.
Once the developer accepts the invitation to the developer portal, they will have access to:
Developers cannot authorize or create payouts, preserving security and financial control.
While developer access is limited to integration settings and transaction visibility, admins still retain full control over who has access and what roles they hold.
As an admin, you can:
There are no further role-based permission granularity for developers—what they see is fixed to integration tools and transaction viewing only.
Adding a developer to ClickPesa Developers Portal takes less than a minute and ensures a smooth, secure integration process. Whether you’re managing APIs, monitoring payouts, or troubleshooting webhooks, proper access makes collaboration easier and keeps your workflows clean.
Log in to your ClickPesa dashboard, navigate to your team settings, and invite your developers today.
The post How to Add Developers to the ClickPesa Developers Portal for Payment Integration appeared first on ClickPesa.
]]>The post Track Invoice Payments in Excel Using ClickPesa Control Numbers appeared first on ClickPesa.
]]>ClickPesa’s Order BillPay Control Number system makes it possible to generate unique payment references per invoice and automatically track payments, even from a simple Excel sheet.
ClickPesa’s Order BillPay Control Number system makes it possible to generate unique payment references per invoice and automatically track payments, even from a simple Excel sheet.
This guide walks through how to:
Imagine you have a list of 50 unpaid invoices in an Excel file. For each invoice, you want to:
This is exactly what Order BillPay Control Numbers solve.
An Order BillPay Control Number is a dynamic number used by customers when making a payment. It is generated by combining:
Formula:
Order BillPay Control Number = [BillPay-Namba] + [Order Reference]
Example:
1122INV00451122INV0045This control number is shared with the customer, who uses it when paying via mobile money or bank.
Start with a basic sheet containing your invoice data. Include the following columns:
| Invoice Number | Customer Name | Amount Due | Control Number | Payment Status | Amount Paid |
|---|---|---|---|---|---|
| INV001 | Jane Doe | 150,000 TZS | 1122INV001 | Unpaid | 0 |
| INV002 | John Smith | 200,000 TZS | 1122INV002 | Unpaid | 0 |
="1122"&A2You can now send payment instructions to each customer using their unique control number. This can be done via:
Make sure to clearly display the Order BillPay Control Number and inform customers that they can pay using:
ClickPesa sends a webhook whenever a payment is made using a BillPay Control Number. To automatically update your Excel sheet, you’ll use Power Automate, Microsoft’s no-code automation tool.
{
"type": "object",
"properties": {
"orderReference": { "type": "string" },
"controlNumber": { "type": "string" },
"amountPaid": { "type": "number" },
"status": { "type": "string" }
}
}
Invoice Number equals orderReferencePayment Status to “Paid” or “Partially Paid” based on amountPaidAmount Paid to the received valueIn Excel, use conditional formatting to visually mark:
This gives you a fast visual overview of the invoice status.
You don’t need expensive tools to track mobile money and bank payments. With ClickPesa’s Order BillPay Control Numbers and a basic Excel setup, you can fully automate invoice tracking with just a bit of Power Automate integration.
If you like any other integration, reach out to ClickPesa, anything is possible with the APIs
The post Track Invoice Payments in Excel Using ClickPesa Control Numbers appeared first on ClickPesa.
]]>The post Automatically Reconcile Payments Using Order BillPay Control Numbers appeared first on ClickPesa.
]]>Organizations like schools, SaaS providers, utilities, and NGOs frequently deal with the challenge of matching anonymous payments from mobile money or banks to specific customers or invoices. Manual bank statement checks, Excel spreadsheets, and phone confirmations are common, and incredibly time demanding.
ClickPesa offers a better way. Through Order BillPay Control Number, ClickPesa enables automatic, real-time reconciliation of payments tied to specific transactions. Whether you are collecting school fees or managing e-commerce payments, this solution makes it possible to track who paid what, when, and for which invoice, without manual intervention.
ClickPesa BillPay supports three types of control numbers, each designed for different payment collection needs:
In this article, we focus exclusively on the Order BillPay Control Number, how it works, how to implement it, and how it helps you automatically reconcile specific transactions in real time.
An Order BillPay Control Number is a dynamic payment reference created for a specific transaction. It is intended for one-time use and is ideal for e-commerce checkouts, unique invoices, or cases where individual customers must make specific payments.
Important to note is that there is no API endpoint to create an Order BillPay Control Number. Instead, you create it on your side by combining your Merchant BillPay-Namba (assigned by ClickPesa) with a unique order reference from your system. This combined value is what you share with the customer as the payment reference. When a customer makes a payment using that BillPay number, ClickPesa uses the BillPay-Namba to route the payment to your account and sends you a webhook notification containing the full BillPay number and payment details.
Each Order BillPay Control Number is generated by combining two components:
Order BillPay Control Number = [Merchant BillPay-Namba] + [Order Reference]
Example:
This method gives you full control over reference formatting, allowing it to reflect your internal system logic.
Once created, the customer can use the control number to pay through a wide range of payment channels, including:
This accessibility ensures customers can easily pay from anywhere using their preferred mobile money or banking option.
Here’s a step-by-step breakdown of how you would implement the Order BillPay Control Number for automated reconciliation:
IMPORTANT: Once paid, the control number is closed or fulfilled, ensuring it’s not reused or misattributed. When it is partly paid or a transaction fails, the control number is also closed.
Lets say you run a school or provide school billing software. You want each parent to pay school fees for their child without confusion or manual intervention.
Here is how you would use Order BillPay Control Numbers:
This provides a closed-loop, automated flow with no manual verification needed.
Many businesses rely on bank statements or mobile money summaries, but this method is:
With Order BillPay Control Numbers, you get:
Sign up with ClickPesa and request access to BillPay. You will receive your unique Merchant BillPay-Namba: a 4-digit code tied to your merchant account.
In your system, generate a unique Order Reference for each transaction. These should be meaningful and structured, such as:
Concatenate your BillPay-Namba with the Order Reference to create the Order BillPay Control Number, and display this prominently on your invoice, email, or SMS.
Find more information about Webhook Notifications. Webhooks only work for order and customer billpay order number.
Build a secure webhook listener to receive ClickPesa notifications when payments are completed. A good endpoint name would be /api/payments/webhook.
The webhook payload will include:
Alternative:
It is also possible to use the API query for payments using the order / customer billpay order number.
When your backend receives the webhook:
Order BillPay Control Numbers can be used across many industries:
ClickPesa’s Order BillPay Control Number system is a simple but powerful innovation for real-time, automated payment reconciliation. It helps businesses and platforms to move beyond static account numbers and vague references, replacing them with clear, structured, and automatically tracked transactions.
By combining your Merchant BillPay-Namba with custom Order References, and using ClickPesa’s webhook system, you can build a fully automated reconciliation flow, one that saves time, reduces errors, and scales with your business.Whether you’re building a school platform, invoicing tool, or payment portal, if you’re handling mobile or bank payments in Tanzania, this tool is a must.
The post Automatically Reconcile Payments Using Order BillPay Control Numbers appeared first on ClickPesa.
]]>The post How to connect ClickPesa with Google Sheet appeared first on ClickPesa.
]]>When you are a larger company and handling payments through a platform like ClickPesa, automating transaction logging is not just convenient, it is a large time-saver. This article will guide you through how to automatically receive mobile money and bank transaction confirmations in a Google Sheet. This is done setting up a Google Apps Script Web App that logs incoming payment webhooks to a Google Sheet. We will cover webhook formats, scripting and deployment.
Webhooks are HTTP callbacks triggered by an event in a third-party system (like a payment platform). When an event such as “PAYMENT RECEIVED” or “PAYMENT FAILED” occurs, the payment gateway sends a POST request to a URL you specify.
Example webhook payloads:
(Full spec: ClickPesa PAYMENT RECEIVED)
{
"event": "PAYMENT RECEIVED",
"data": {
"paymentId": "PAY123456",
"orderReference": "ORD987654",
"collectedAmount": "10000.00",
"collectedCurrency": "TZS",
"status": "SUCCESS",
"customer": {
"name": "John Doe",
"email": "[email protected]",
"phone": "255700000000"
},
"createdAt": "2024-04-10T18:22:16.949Z",
"updatedAt": "2024-04-10T18:22:56.153Z"
}
}
(Full spec: ClickPesa PAYMENT FAILED)
{
"eventType": "PAYMENT FAILED",
"data": {
"id": "0969231256LCP2C95",
"status": "FAILED",
"orderReference": "0969231256",
"message": "Insufficient balance",
"updatedAt": "2024-04-11T04:58:31.036Z",
"createdAt": "2024-04-11T04:58:31.036Z"
}
}
You can view all webhook formats here: ClickPesa Webhook Docs
Our goal is to capture these transaction events and have them automatically appear into a Google Sheet.
Open Google Sheets and create a sheet named “Sheet1” (or any other name you prefer). Set up your columns:
| Timestamp | Event Type | Payment ID | Order Reference | Amount | Currency | Status | Customer Name | Phone | Message |
You can customize this further, but this layout will allow you to track all key details. Find here the Template
Go to Extensions > Apps Script in your Google Sheet.
Paste the following code:
function doPost(e) {
if (!e || !e.postData) {
throw new Error("This function must be triggered by a POST request.");
}
const spreadsheet = SpreadsheetApp.openById("1mVIoG2LaVojwfBRkfKw1libR4KonhHYfYtlaQOZcRmo");
const logSheet = spreadsheet.getSheetByName("Webhook Log") || spreadsheet.insertSheet("Webhook Log");
const sheet = spreadsheet.getSheetByName("Sheet1");
const now = new Date();
let payload;
try {
payload = JSON.parse(e.postData.contents);
} catch (err) {
logSheet.appendRow([now, "Invalid JSON", e.postData.contents]);
return ContentService.createTextOutput("Invalid JSON").setMimeType(ContentService.MimeType.TEXT);
}
// Log the raw JSON payload
logSheet.appendRow([now, JSON.stringify(payload)]);
const event = payload.event || payload.eventType;
let row = [now];
if (event === "PAYMENT RECEIVED") {
const data = payload.data;
row.push(
event,
data.paymentId,
data.orderReference,
data.collectedAmount,
data.collectedCurrency,
data.status,
data.customer.name,
data.customer.email,
data.customer.phone,
""
);
} else if (event === "PAYMENT FAILED") {
const data = payload.data;
row.push(
event,
data.id,
data.orderReference,
"",
"",
data.status,
"",
"",
"",
data.message
);
} else {
row.push("UNKNOWN EVENT");
}
sheet.appendRow(row);
return ContentService.createTextOutput("OK").setMimeType(ContentService.MimeType.TEXT);
}
This is the URL you will provide to ClickPesa or another gateway as your webhook endpoint.
To configure your webhook with ClickPesa:
For more: ClickPesa Webhook Setup
Now it works and you are ready to receive transaction confirmations in your sheet.

The post How to connect ClickPesa with Google Sheet appeared first on ClickPesa.
]]>