Download the PHP package alsharie/jawali-payment without Composer
On this page you can find all versions of the php package alsharie/jawali-payment. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alsharie/jawali-payment
More information about alsharie/jawali-payment
Files in alsharie/jawali-payment
Package jawali-payment
Short Description Laravel package to integrate with Jawali APIs.
License MIT
Informations about the package jawali-payment
Laravel Jawali API Client
Jawali Payment is a Laravel package for interacting with the Jawali payment gateway. It provides a simple API to perform operations like ecommerce inquiry and cash out, with automatic token management and structured responses.
Installation
-
Require the package using Composer:
(Replace
alsharie/jawali-payment
with your actual package name on Packagist if you publish it, or use a local path repository for development). -
Publish the configuration file (optional, but recommended):
This will create a
config/jawali.php
file. - Add the following environment variables to your
.env
file and configure them:
Configuration
The package uses Laravel's configuration system. After publishing the config file, you can find it at config/jawali.php
. The configuration is structured as follows:
The disable_ssl_verification
option is particularly useful when working with development environments or self-signed certificates.
Logging Configuration
The package includes built-in logging capabilities for debugging API requests and responses. To enable logging:
-
Enable logging in your
.env
file: - Ensure the logs directory is writable:
The package will log all API interactions using Laravel's default logging system. Log entries include:
- Request method, URL, and payload (with sensitive data redacted)
- Response status and data
- Error details with context
Note: Logging errors are silently ignored to prevent them from breaking the main application functionality.
Features
This package provides the following features:
- Structured Response Classes: Each API response is wrapped in a dedicated response class that provides methods to access the data in a type-safe way.
- Automatic Token Management: The package automatically manages authentication and wallet tokens, refreshing them when needed.
- Retry Mechanism: Failed requests due to token expiration or certain HTTP status codes are automatically retried.
- SSL Verification Control: Option to disable SSL verification for development or when working with self-signed certificates.
- Simplified API: The API is simplified to focus on the essential parameters, with tokens managed automatically.
- Enhanced Error Handling: Comprehensive error information with API response preservation and user-friendly error messages.
- Optional Logging: Built-in request/response logging for debugging purposes.
- Input Validation: Automatic validation of request parameters to prevent common errors.
Usage
You can use the Jawali
facade or inject the Alsharie\Jawali\Services\JawaliService
class.
Enhanced Error Handling
The package now provides comprehensive error handling with detailed API response information and standardized method names that match successful responses:
Standardized Method Names
Both successful responses and exceptions now use the same method names for consistency:
Purpose | Method Name | Available On | Description |
---|---|---|---|
Get raw data | getData() |
✅ Success & Exception | Returns the complete response data array |
Get response body | getResponseBody($attribute?) |
✅ Success & Exception | Gets response body or specific attribute |
Get response value | getResponse($attribute?) |
✅ Success & Exception | Gets response data or specific attribute |
Get error message | getErrorMessage() |
✅ Success & Exception | Gets API error message if available |
Check success | isSuccess() |
✅ Success only | Not applicable for exceptions |
Example - Same methods work for both success and error:
Breaking Change: Old method names (getApiResponse()
, getApiResponseBody()
, getApiResponseHeaders()
) have been removed. Use the standardized method names instead.
Debugging and Logging
Enable logging to debug API requests and responses:
The package automatically logs:
- API requests (with sensitive data redacted)
- API responses
- Error details and context
- Token refresh attempts
Explanation
-
loginToSystem()
This method authenticates with the Jawali system using the credentials from your configuration. The response is an instance ofJawaliLoginResponse
which provides access to the authentication token. -
walletAuthentication()
After system login, this method authenticates your wallet. The response is an instance ofJawaliWalletAuthResponse
which provides access to the wallet token. -
ecommerceInquiry()
This method contacts the gateway to verify payment details. The response is an instance ofJawaliEcommerceInquiryResponse
which provides methods likegetAmount()
,getCurrency()
, andgetState()
. -
ecommerceCashout()
When the inquiry indicates a pending state with the correct amount and currency, this method is called to complete the cash-out. Its response is wrapped in theJawaliEcommerceCashoutResponse
class. - Response Handling
All response classes extend the baseJawaliResponse
class (exceptJawaliLoginResponse
). They provide methods likeisSuccess()
,getErrorMessage()
, andgetData()
for consistent response handling.
License
This package is open-sourced software licensed under the MIT license.
All versions of jawali-payment with dependencies
illuminate/support Version ^8.0|^9.0|^10.0|^11.0
illuminate/http Version ^8.0|^9.0|^10.0|^11.0
nesbot/carbon Version ^2.0|^3.0