fbiego / MpesaSTK

An Arduino Library implementing MPESA Daraja on microcontrollers
MIT License
19 stars 6 forks source link
daraja daraja-api mpesa mpesa-api safaricom stk stkpush

MpesaSTK

An Arduino Library implementing MPESA Daraja on microcontrollers

arduino-library-badge

Usage

Initialize

//MpesaSTK mpesa(consumer_key, consumer_secret, pass_key);  //defaults to SANDBOX environment
MpesaSTK mpesa(consumer_key, consumer_secret, pass_key, SANDBOX);   //environment can be SANDBOX(default) or PRODUCTION

Details

//TEST_CODE = 174379 
mpesa.begin(TEST_CODE, PAYBILL, "https://mycallbackurl.com/checkout.php"); //business code, type(PAYBILL or BUY_GOODS), callback url

StkPush

mpesa.pay("2547XXXX__", 20, "Arduino", "Test");     //phone number, amount, reference, description
//String result = mpesa.pay("2547XXXX__", 20, "Arduino", "Test");   //get the result (json string)