Configuration
Every value in config/laravel-daraja.php reads from an environment variable,
so publishing the config file is optional.
Mode and credentials
Section titled “Mode and credentials”DARAJA_MODE=sandbox # sandbox or liveDARAJA_CONSUMER_KEY=DARAJA_CONSUMER_SECRET=mode selects the API host and the bundled certificate. Anything other than
sandbox or live raises a ConfigurationException rather than silently
falling back.
| Mode | Host |
|---|---|
sandbox |
https://sandbox.safaricom.co.ke |
live |
https://api.safaricom.co.ke |
Initiator
Section titled “Initiator”Required by B2C, B2B, Reversal, Account Balance and Transaction Status.
DARAJA_INITIATOR_NAME=testapiDARAJA_INITIATOR_CREDENTIAL=your-plaintext-passwordDARAJA_INITIATOR_SHORTCODE=600000DARAJA_INITIATOR_TYPE=paybill # paybill, till or msisdncredential is the plaintext operator password. The package encrypts it per
request; you never store the encrypted form.
M-Pesa Express
Section titled “M-Pesa Express”DARAJA_STK_SHORTCODE=174379DARAJA_STK_PASS_KEY=DARAJA_STK_CALLBACK_URL=https://your-domain/daraja/stkCallback URLs
Section titled “Callback URLs”Each accepts either an absolute URL or the name of a route in your
application, which the package resolves with route().
DARAJA_C2B_CONFIRMATION_URL=DARAJA_C2B_VALIDATION_URL=
DARAJA_B2C_RESULT_URL=DARAJA_B2C_TIMEOUT_URL=DARAJA_B2B_RESULT_URL=DARAJA_B2B_TIMEOUT_URL=DARAJA_BALANCE_RESULT_URL=DARAJA_BALANCE_TIMEOUT_URL=DARAJA_TRANSACTION_STATUS_RESULT_URL=DARAJA_TRANSACTION_STATUS_TIMEOUT_URL=DARAJA_REVERSAL_RESULT_URL=DARAJA_REVERSAL_TIMEOUT_URL=Per-API settings
Section titled “Per-API settings”DARAJA_PARTNER_NAME= # shown in the B2B Express promptDARAJA_PULL_NOMINATED_NUMBER= # MSISDN on the short code's KYC recordDARAJA_BILL_MANAGER_APP_KEY= # returned once, at Bill Manager opt-inDARAJA_B2B_EXPRESS_RESULT_URL=DARAJA_PULL_CALLBACK_URL=DARAJA_BILL_MANAGER_CALLBACK_URL=DARAJA_STANDING_ORDER_CALLBACK_URL=HTTP client
Section titled “HTTP client”DARAJA_HTTP_TIMEOUT=30DARAJA_HTTP_CONNECT_TIMEOUT=10DARAJA_HTTP_RETRIES=2DARAJA_HTTP_RETRY_DELAY=250Retries apply only to connection failures. A 4xx from Daraja means the request itself was rejected, so retrying it would just repeat the rejection.
Token cache
Section titled “Token cache”DARAJA_CACHE_STORE= # blank uses the default storeDARAJA_TOKEN_TTL=3540Tokens are cached per consumer key and mode, so multiple short codes in one application never share a token.
Logging
Section titled “Logging”DARAJA_LOGGING_ENABLED=falseDARAJA_LOG_CHANNEL= # blank uses the default channelSecurityCredential, Password, InitiatorPassword, consumer_key and
consumer_secret are replaced with [redacted] before anything is written.
Callback routes
Section titled “Callback routes”DARAJA_ROUTES_ENABLED=falseDARAJA_ROUTES_PREFIX=darajaDARAJA_ALLOWED_IPS= # comma separated, plain or CIDRSee Handling callbacks.
Certificate
Section titled “Certificate”DARAJA_CERTIFICATE_PATH= # blank uses the bundled certificate for the mode