Download the PHP package wajub/wajub-php without Composer
On this page you can find all versions of the php package wajub/wajub-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wajub/wajub-php
More information about wajub/wajub-php
Files in wajub/wajub-php
Package wajub-php
Short Description Official Wajub PHP SDK server-side payments, and merchant API
License MIT
Homepage https://docs.wajub.com/libraries/sdks/php
Informations about the package wajub-php
Introduction
Official server-side SDK for the Wajub API: create payments, confirm them, pay out and verify webhooks from any PHP application, Laravel included.
It runs on your server with a secret (sk.…, sk_test.…) or restricted (rk.…, rk_test.…) API key. Never expose these keys in client-side code: in the browser, use Wajub.js with your publishable key (pk.…, pk_test.…).
Requirements
| Requirement | Version |
|---|---|
| PHP | 8.4 or later |
| Extension | ext-json |
Installation
Quick start
Amounts are in the currency's main unit: 12.50 for GHS 12.50, 15000 for XAF 15,000.
Then confirm the result on your server: handle the payment.succeeded webhook, or call $wajub->payments->retrieve($payment->id).
Parameters take the API's field names. What comes back is an object: read a field as a property ($payment->status) or as an array key ($payment['status']).
Configuration
| Key | Description |
|---|---|
api_key |
Secret or restricted API key (sk.…, sk_test.…, rk.…, rk_test.…). Required. |
webhook_secret |
Webhook signing secret (whsec_…), needed only for webhooks->constructEvent(). Falls back to WAJUB_WEBHOOK_SECRET. |
timeout |
Request timeout in seconds. |
The SDK does not read the API key from the environment: read WAJUB_API_KEY yourself and pass it as api_key, as above.
Laravel
Add the keys to config/services.php, then bind the client once:
Resources
| Purpose | Property | Methods |
|---|---|---|
| Payments | $wajub->payments |
create, retrieve, list, cancel, process, processSplit, listRefunds |
| Refunds | $wajub->refunds |
create, retrieve, list |
| Customers | $wajub->customers |
create, retrieve, update, delete, list, block, unblock, activate, deactivate, listTaxIds, createTaxId, deleteTaxId |
| Payment links | $wajub->links |
create, retrieve, update, delete, list |
| Invoices | $wajub->invoices |
create, retrieve, update, delete, list, send, markPaid, cancel |
| Payouts | $wajub->transfers |
create, retrieve, list |
| Payout recipients | $wajub->beneficiaries |
create, retrieve, update, delete, list |
| Destination checks | $wajub->identity |
resolve, validate |
| Balance | $wajub->balance |
retrieve |
| Disputes | $wajub->disputes |
list, retrieve, submitEvidence, accept, close, sendMessage |
| Events | $wajub->events |
list, retrieve, resend |
| Webhook endpoints | $wajub->webhookEndpoints |
create, retrieve, update, delete, list, rotateSecret |
| Webhook verification | $wajub->webhooks |
constructEvent |
| Connected accounts (Sync) | $wajub->accounts |
create, retrieve, update, delete, list, regenerateToken |
| Tax | $wajub->tax |
getSettings, updateSettings, rates, calculate, reports, listCodes, retrieveCode, listRegistrations, createRegistration, retrieveRegistration, updateRegistration, deleteRegistration, jurisdictions, thresholds, thresholdAlerts |
| Fraud (Shield) | $wajub->shield |
getSettings, updateSettings, stats, listBlocklist, addToBlocklist, removeFromBlocklist |
| Reference data | $wajub->global |
ping, channels, countries, currencies |
Acting for a connected account
Pass the connected account with sync on the call:
Webhooks
Pass the raw request body, not parsed JSON, with the X-Wajub-Signature and X-Wajub-Timestamp headers. In a Laravel controller:
The event is an array; its type is in event. A delivery that does not verify throws WebhookSignatureVerificationError. If your server's clock drifts, pass a tolerance in seconds as a fourth argument. In Laravel, exempt the webhook route from CSRF verification.
Pagination
list() returns a page you can walk one page at a time, or iterate across all pages; rows are arrays:
Idempotency
Temporary failures are retried for you. To make a create safe to repeat on your side too, after a restart or in a queued job's retry, pass your own key:
Error handling
API errors throw a subclass of Wajub\Exception\WajubError:
Class in Wajub\Exception |
Raised on |
|---|---|
AuthenticationException |
401 |
PermissionException |
403 |
NotFoundException |
404 |
InvalidRequestException |
400, 422 |
RateLimitException |
429, with retryAfter in seconds |
WajubError |
Any other error status, and the parent of the classes above |
ApiConnectionException |
No response: network error or timeout |
Every error carries getMessage(), errorCode, httpStatus, errors (the first message of each field) and raw (the response body). getCode() is always 0: read errorCode.
Testing
Use a sandbox key (sk_test.…): the key chooses the environment, and no real money moves. The test phone numbers and cards are on Test scenarios. To receive webhooks on your machine, forward them with the Wajub CLI.
Documentation & support
- Documentation: docs.wajub.com/libraries/sdks/php
- Report issues: github.com/wajubhq/wajub-php/issues
- Report a security vulnerability: security policy
License
The Wajub PHP SDK is open-sourced software licensed under the MIT license.