Artisan commands
daraja:token
Section titled “daraja:token”Fetches an access token, which verifies your consumer key and secret against the configured mode.
php artisan daraja:tokenphp artisan daraja:token --fresh # discard the cached token firstMode ............................................................... sandboxAccess token ..................................... c9SQxWWhmdVRlyh0zh8gZDTkubVFThe first thing to run after installing. A failure here names the cause rather than surfacing later as a confusing 404.
daraja:credential
Section titled “daraja:credential”Encrypts an initiator password into a SecurityCredential, for comparing
against the portal’s own tool.
php artisan daraja:credentialphp artisan daraja:credential "some-other-password"Mode ................................................................. liveCertificate ................... /app/vendor/starnerz/laravel-daraja/certs/production.cerIt prints the certificate path, which is how you confirm you are encrypting for
the right environment — the usual cause of 2001 The initiator information is invalid.
The output differs every run. PKCS #1 v1.5 padding is randomised, so that is expected.
daraja:register-urls
Section titled “daraja:register-urls”Registers your C2B confirmation and validation URLs.
php artisan daraja:register-urls
php artisan daraja:register-urls \ --confirmation=https://example.com/confirm \ --validation=https://example.com/validate \ --short-code=600000 \ --response-type=CancelledWithout options it uses urls.c2b.confirmation and urls.c2b.validation from
configuration.
--response-type decides what M-Pesa does when your validation URL is
unreachable: Completed accepts the payment anyway, Cancelled rejects it.