Accept Mpesa payments on your Vendure store.
yarn add vendure-mpesa-plugin
- Add the MpesaPlugin to your
VendureConfig
plugins array.
import { MpesaPlugin } from "vendure-mpesa-plugin"
export const config: VendureConfig = {
// ...
plugins: [
// ...
MpesaPlugin.init({
consumerKey: "YOUR_CONSUMER_KEY",
consumerSecret: "YOUR_CONSUMER_SECRET",
shortCode: "YOUR_SHORT_CODE",
shortCodeType: "SHORTCODE_TYPE",
passkey: "YOUR_PASSKEY",
environment: "APP_ENVIRONMENT",
vendureHost: "https://yourvendureserver.com",
}),
],
}
- Start the server and navigate to
Settings > Payment methods
. Add a new payment method, selectingLipa na Mpesa Online
as the handler.
Be sure to select the 'Check whether Mpesa supports the payment' eligibility checker when creating the payment method. This plugin consumes the Mpesa Daraja API which currently only supports Safaricom numbers in Kenya.
-
Calling the
addPaymentToOrder
mutation on the storefront with the corresponing payment method code will initiate an STK push to the customer's phone. -
Call the
verifyMpesaTransaction
mutation periodically on the storefront to verify the transaction status.