Created
July 31, 2023 14:28
-
-
Save levizwannah/f366c63822f0a3c44fd22b5fc8ac5df4 to your computer and use it in GitHub Desktop.
mpesa-sdk-reversal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// initialize Mpesa | |
// ...autoloading | |
$mpesa = Mpesa::new()->configure([ | |
"key" => "consumer key", | |
"secret" => "consumer secret", | |
"code" => "business short code", | |
"till" => "business till if necessary", | |
"initiator" => "initiator name", | |
"credential" => "security credential" | |
]); | |
$reversal = $mpesa->reversal(); | |
$reversal->transId("TRANACTION-ID") | |
->amount(1000) | |
->timeoutUrl("https://your-domain.com/your/path") | |
->resultUrl("https://your-domain.com/your/path") | |
->remarks('Any remarks') // optional | |
->occasion('Any occasion') // optional | |
->type('11'); // optional | |
$reversal->make(); | |
if(!$reversal->accepted()){ | |
echo "Reversal was not accepted"; | |
print_r($reversal->error()); | |
exit; | |
} | |
$response = $reversal->response(); | |
// do something with the response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment