Customer to bussiness (C2B)
The C2B API call is used as a standard customer-to-business transaction. Funds from the customer’s mobile money wallet will be deducted and be transferred to the mobile money wallet of the business.
To authenticate and authorize this transaction, M-Pesa Payments Gateway will initiate a USSD Push message to the customer to gather and verify the mobile money PIN number.
This number is not stored and is used only to authorize the transaction.
Use customer_to_bussiness() method to process these kind of payments in Pypesa
As explained at the top, the journey to integrate is made smooth as possible, what you have to do is to prepare a transaction_query{} dictionary of the payment to be made and then do your transaction, just as illustrated in the example below;
#
ExampleGood news !! As we can see above, our payments was sucessfully processed by the sandbox
But you have to be carefully while writing your transaction_query by making sure all the neccessary keys are specified with their correct type.
#
Pre-validationPypesa do pre-validation before sending a request to vodacom openapi to ensure all the keys for particular transaction are present and it will raise keyError if any of the neccessary key is missing.
For instance let's repeat doing the previous transaction but with a a missing input_PurchasedItemsDesc field.
#
Authentication ErrorPypesa will does not verify your authentication instantly as you create a pypesa instance, instead it will verify them while submitting a request of particular transaction, so that means if you have put invalid api-key or public-key you will experience an Authentication Error
#
MpesaConnectionErrorWhen you try to do a transaction without internet connection, pypesa will raise MpesaConnectionError, So make sure you have an active intenet connection when doing it so