Logo Lanfrica

coleYab/mpesasdk

Domain:

digital infrastructure

Record type:

software
Creator:
col
Host:
Simple sdk for mpesa # ** ⚠️ Deprecated: Use new-module instead ** **This package is now deprecated.** Please use new-module for future development. This package will no longer be maintained, and we recommend migrating to the alternative package for all new work. # MpesaSdk `mpesasdk` is a Go SDK for interacting with Safaricom's M-Pesa API. This SDK simplifies integration with M-Pesa's services, enabling operations such as B2C payments, C2B URL registration, STK Push payments, transaction status queries, account balance checks, and transaction reversals. ## Features - **B2C Payments**: Transfer funds from a business account to a customer account. - **C2B URL Registration**: Register URLs for payment notifications. - **STK Push**: Initiate USSD-based payment requests. - **Transaction Status**: Query the status of transactions. - **Account Balance**: Retrieve M-Pesa account balances. - **Transaction Reversal**: Reverse a completed M-Pesa transaction. ## Table of Contents - Installation - Quick Start - Examples - Register C2B URL - Simulate C2B Payment - Make B2C Payment - Transaction Status Query - Account Balance Query - Transaction Reversal - STK Push Payment - Contributing - License ## Installation To install the SDK, use the following command: ```bash go get github.com ``` ## Quick Start ### Initialize the MpesaClient ```go client, err := mpesasdk.NewMpesaClient( " ", " ", common.SANDBOX, service.LogLevelInfo, 10*time.Second, 3, ) if err != nil { log.Fatalf("Failed to initialize M-Pesa client: %v", err) } ``` ## Examples ### Register C2B URL ```go response, err := client.RegisterNewURL(c2b.RegisterC2BURLRequest{ ShortCode: 123456, ResponseType: c2b.CompletedResponse, ConfirmationURL: "yourdomain.com", ValidationURL: "yourdomain.com", }) ``` ### Simulate C2B Payment ```go response, err := client.SimulateCustomerInitiatedPayment(c2b.SimulateCustomerInititatedPayment{ ShortCode: "123456", BillRef …

Languages

Licenses