Configuration
Set the following environment variables in your Laravel application.
env
PAYSTACK_SECRET_KEY=sk_test_xxx
PAYSTACK_PUBLIC_KEY=pk_test_xxx
PAYSTACK_BASE_URL=https://api.paystack.co
PAYSTACK_TIMEOUT=30
PAYSTACK_CONNECT_TIMEOUT=10
PAYSTACK_RETRY_TIMES=2
PAYSTACK_RETRY_SLEEP_MS=250
PAYSTACK_THROW_ON_API_ERROR=true
PAYSTACK_WEBHOOK_DELETE_AFTER_DAYS=30
PAYSTACK_WEBHOOK_QUEUE=
PAYSTACK_WEBHOOK_CONNECTION=Required environment variables
PAYSTACK_SECRET_KEY: required for authenticated Paystack API requests and Paystack webhook signature verification
Optional environment variables
PAYSTACK_PUBLIC_KEY: optional; not used directly by this package, but needed if your application also integrates Paystack frontend tooling such as Paystack Inline or mobile SDKsPAYSTACK_BASE_URL: override only if you need a non-default Paystack API hostPAYSTACK_TIMEOUT: overall request timeout in secondsPAYSTACK_CONNECT_TIMEOUT: connect timeout in secondsPAYSTACK_RETRY_TIMES: retry count applied by the connectorPAYSTACK_RETRY_SLEEP_MS: delay between retries in millisecondsPAYSTACK_THROW_ON_API_ERROR: whether API failures are promoted to package exceptionsPAYSTACK_WEBHOOK_DELETE_AFTER_DAYS: retention period for storedwebhook_callsPAYSTACK_WEBHOOK_QUEUE: optional queue name for webhook processing jobs; if omitted, the package uses Laravel's default queue namePAYSTACK_WEBHOOK_CONNECTION: optional queue connection for webhook processing jobs; if omitted, the package uses Laravel's default queue connection
Connector behavior
PaystackConnector is responsible for:
- base URL selection
- bearer authentication
- timeout configuration
- retry behavior
- API error handling
Next step
Choose a feature area:
Webhook infrastructure
Webhook handling is endpoint-first and asynchronous:
- register the endpoint with
Route::webhooks('paystack/webhook', 'paystack') - publish the webhook client migration with
php artisan vendor:publish --provider="Spatie\WebhookClient\WebhookClientServiceProvider" --tag="webhook-client-migrations" - run
php artisan migrateso thewebhook_callstable exists - run a queue worker so
ProcessPaystackWebhookJobcan dispatchPaystackWebhookReceived