In order to implement Customer Online Shopping by M-Pesa, the eCommerce merchant needs to integration the merchant system to use the following M-Pesa API functions: C2BPayment_2Stage, Reversal and Query.
Customer Online Payment service flow
To submit a 2 stage payment by M-Pesa request, the merchant website can call the M-Pesa OpenAPI server using C2BPayment_2Stage API to send <customer’s M-Pesa MSISDN> and Order details and Amount to request the reservation of customer’s funds for future payment to the Merchant. To confirm the payment reservation, the M-Pesa customer will be asked to enter his/her M-Pesa PIN through a USSD push mechanism.
Upon goods deliver, the merchant website can call the M-Pesa OpenAPI server again using C2BPayment_2Stage API to request the completion of the payment. To confirm the payment completion, the M-Pesa customer will be asked to enter his/her M-Pesa PIN again through a USSD push mechanism.
For more details on the API, its parameters and error codes, please see C2BPayment_2Stage.
Reversal service flow
If customer wants to request a refund after a successful transaction, the customer will need to discuss and agree with the merchant. The merchant can call the Reversal API to refund the customer.
Query service flow
Merchant can query M-Pesa to check the status of the transaction by using the Query Txn API.