Open KerollesFathy opened 2 weeks ago
The Mpesa Express integration on Frappe Cloud enables seamless payment processing via the Mpesa platform. This guide outlines the configuration process, focusing on the Mpesa Settings doctype, which serves as the foundation for setting up and managing Mpesa payment credentials.
The Mpesa Settings doctype is where you configure and manage the credentials and details necessary for Mpesa integration. These settings are specific to your Mpesa account and are provided by Mpesa after registering on their portal.
Consumer Secret
Till Number
Business Number
Online Passkey
The Payment Gateway doctype is used to configure the integration between Frappe Cloud and external payment providers, like Mpesa. It contains key fields and sections essential for selecting the appropriate configuration, setting up API credentials, and specifying taxes or charges for the integration.
Team
Gateway Setting
URL
API Key
API Secret
This section allows partners to specify the tax and fee percentages applicable to transactions processed through the gateway.
Tax ID
Phone Number
The Mpesa Request Log stores transaction request data after the STK push is made to the customer's phone. It tracks the progress of the transaction, from the initial request to the final status update. The log is crucial for monitoring and updating the transaction's lifecycle and integrates with the Mpesa Payment Record once the transaction is complete.
Service
Status
Request Headers
Request Data
Response Output
Error
The Mpesa Payment Record doctype logs successful payment transactions processed via Mpesa. This doctype is created automatically upon the completion of a successful transaction, allowing for comprehensive tracking and audit trails within Frappe.
Administrator
Transaction Type
Trans Time
YYYYMMDDHHMMSS
format (e.g., 20240916181019
).Grand Total (Ksh)
Trans Amount (Ksh)
Amount (USD)
Exchange Rate
Submitted to Frappe
254740743521
for a Kenyan number).13-11-2024
).HH:MM:SS
format.BT-2024-00129
).https://demo.navari.co.ke/api/...
).On the Billing section of the sidebar, when the user selects Add on Credit Available, the system checks if the partner is located in Kenya. If so, Mpesa becomes visible as a payment option.
Select Partner:
Enter Amount:
Initiate Payment:
Dialog Interface:
The workflow ensures seamless payment initiation via Mpesa, with a straightforward process for users in Kenya.
On the Mpesa Invoices tab, users can view all invoices associated with a specific Team (Customer), displaying all transactions that have ever been processed through Mpesa. This provides a comprehensive history of payments made by the team.
Invoice Display:
Payment History:
Download Option:
On the left sidebar, just below the Billing section, there is a Partner option. By clicking on it, users are directed to a section where they can configure their payment settings, particularly for Mpesa or other payment gateways.
Select Local Payment Setup:
- On clicking **Add**, a dialog box appears where the user can fill in all the necessary **Mpesa details**, such as:
- **Consumer Key**
- **Consumer Secret**
- **Till Number**
- **Business Number**
- **Online Passkey**
- These details are provided by Mpesa when the user has an active account on their platform.
Proceed to Payment Gateway Setup:
Partner Payment Payout On the Local setup, partners can also create transactions from all the available payments they received from clients through their payment gateway, and submit them. Upon submission, it creates a Partner Payment POayout transaction and calculates the commission. Then it goes to the partner site and creates a related purchase invoice with the total net amount after commission.
ποΈ Paymob Log:
event_type
: Event type of the payment (e.g., intention). payment_partner
: Link to the associated payment partner . amount
and actual_amount
: Payment amount in different currencies, with exchange rate handling. payload
: JSON field to store payload from Paymob's response. π Paymob Callback Log:
event_type
: Type of event triggering the callback. payment_partner
: Associated payment partner (read-only).
transaction_id
and Order ID
: Unique identifiers for the payment transaction that comes from Paymob side. payload
: JSON field to store raw callback data. β‘οΈ Payment Partner Transaction:
Purpose: Maintains detailed transaction records, ensuring accountability and automated allocation.
Fields:
payment_partner
and payment_gateway
: Links to the payment partner and gateway used. team
: who buys the creditsamount
and actual_amount
: Transaction amount, with currency and exchange rate details. payment_transaction_details
: JSON field storing detailed transaction metadata. On Submit: Allocate the amount to the Team
π¦ Payment Gateway:
gateway
: Unique identifier for the payment gateway. url
, api_key
, and api_secret
: Core credentials for gateway communication. team
and team_name
: Links to the responsible team managing the gateway. currency
: Associated currency for transactions via the gateway. gateway_settings
and gateway_controller
integration_logo
and ui_configuration_section
: Support for branding and UI enhancements. taxes_and_charges
: Option to define applicable taxes and charges (percentage). π Paymob Settings:
api_key
, public_key
, hmac
, token
, and secret_key
: Securely store credentials for API communication. iframe
: IFRAME URL for embedding the Paymob payment page. payment_integration
: Integer value for Integration Number. User Initiation:
Payment Processing:
Callback Handling and Allocation:
Gateway Configuration:
Success Feedback:
Too big PR, maybe get MVP merged as soon as possible and then iterate with smaller PRs (for example, reports etc. can come in later).
@shadrak98 @BreadGenie