Fund Wallet

How to fund a wallet using M-Pesa and Card

How to Fund Wallet with M-Pesa STK Push

The collection M-Pesa STK Push API enables you to directly bill a client and have the funds deposited to the specified wallet_id. To implement this, simply provide a wallet_id as one of the fields options in the M-Pesa STK Push API.

Below is an example of direct wallet funding with the M-Pesa STK Push API in Python. The same can be implemented in other language by simply parsing a wallet_id field in the request payload. See the M-Pesa STK Push for more details.

from intasend import APIService

publishable_key = "INTASEND_PUBLISHABLE_KEY"

service = APIService(publishable_key=publishable_key, test=True)

response = service.collect.mpesa_stk_push(wallet_id="<TARGETED-WALLET-ID>", phone_number=2547...,
                                  email="[email protected]", amount=10, narrative="Purchase")

How to Fund Wallet Using the Checkout API

The Checkout Link API can be used to directly fund a wallet. To do this, you simply provide a wallet_id of the wallet you would like to fund during the Checkout API request. The API will generate a secure payment URL where you can redirect the user to complete payment. This option provide support for both M-Pesa and Card payments.

Here is an example of the Checkout Link API with the targeted wallet_id added as one of the fields.

from intasend import APIService

publishable_key = "INTASEND_PUBLISHABLE_KEY"
service = APIService(publishable_key=publishable_key)

response = service.collect.checkout(wallet_id="<TARGETED-WALLET-ID>", phone_number=2547...,
                                    email="[email protected]", amount=1000, currency="KES", comment="Deposit")

The successful response contains a payment URL. Redirect the user to the URL to complete payment. On successful payment, the funds will be deposited in the targeted wallet_id instead of the default SETTLEMENT wallet.