husail/paystore-sdk

v1.0.0-alpha 2025-07-03 06:50 UTC

This package is auto-updated.

Last update: 2025-07-03 06:55:56 UTC


README

The PayStore PHP SDK allows integration with the PayStore API in any PHP project. It also provides Facades and a Service Provider for enhanced Laravel integration.

📦 Installation

composer require husail/paystore-sdk

🔧 Usage Example

For Non-Laravel PHP Projects:

Basic Usage:

require 'vendor/autoload.php';

use Husail\PayStore\Client;
use Husail\PayStore\Authentication;

$client = new Client(
    new Authentication(token: 'your-token')
);

$response = $client->merchant->all();
if ($response->successful()) {
    // Handle the response
}

With Logging:

require 'vendor/autoload.php';

use Monolog\Logger;
use Husail\PayStore\Client;
use Monolog\Handler\StreamHandler;
use Husail\PayStore\Authentication;
use Husail\PayStore\HttpClient\Message\Formatter\SimpleFormatter;

$logger = new Logger('my_logger');
$logger->pushHandler(new StreamHandler(__DIR__ . '/paystore.log'));

$client = new Client(
    new Authentication(token: 'your-token'),
    logger: $logger,
    formatter: new SimpleFormatter(true) // 'true' enables pretty-printed JSON logs
);

$response = $client->merchant->all();
if ($response->successful()) {
    // Handle the response
}

For Laravel:

  1. Publish the configuration:

    php artisan vendor:publish --provider="Husail\PayStore\PayStoreServiceProvider"
  2. Add environment variables in your .env file:

    PAYSTORE_TOKEN=your-token
    
    # Optional logging settings:
    PAYSTORE_LOG_ENABLED=false             # Enable or disable request/response logging
    PAYSTORE_LOG_FORMATTER_EXPANDED=false  # Pretty-print JSON in logs if enabled
  3. Use the Facade to interact with the API:

use PayStore;

$response = PayStore::client()->merchant->all();
if ($response->successful()) {
    // Handle the response
}
  1. Configure Logging

    When PAYSTORE_LOG_ENABLED is set to true, the SDK logs request and response details via Laravel's default logging channel. By default, logs output compact JSON. If you want the JSON output to be more readable (pretty-printed), set PAYSTORE_LOG_FORMATTER_EXPANDED to true.

🤝 Contributing

We welcome contributions! Feel free to submit issues or pull requests to help improve the SDK.

📜 License

Licensed under the MIT License.