ziyoren / pay-sdk
Ziyoren Pay SDK for payment integration
v1.0.0
2026-03-24 17:33 UTC
Requires
- php: >=8.1
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^12.5
README
A PHP SDK for integrating with Ziyoren Pay payment gateway.
Installation
You can install the package via composer:
composer require ziyoren/pay-sdk
Usage
Initialize Client
use Ziyoren\PaySdk\Client; $client = new Client('your-api-key', 'your-secret-key', 'https://api.ziyoren.com');
Create Payment Order
$orderData = [ 'out_trade_no' => 'ORDER-' . time(), 'total_amount' => 100.00, 'subject' => 'Product Name', 'notify_url' => 'https://your-domain.com/notify' ]; try { $result = $client->createPaymentOrder($orderData); // Handle result var_dump($result); } catch (\Ziyoren\PaySdk\Exceptions\ApiException $e) { // Handle API error echo "API Error: " . $e->getMessage(); }
Get Payment Status
try { $result = $client->getPaymentStatus('ORDER-123456789'); // Handle result var_dump($result); } catch (\Ziyoren\PaySdk\Exceptions\ApiException $e) { // Handle API error echo "API Error: " . $e->getMessage(); }
Verify Payment Notification
// Example: in your notification endpoint $notificationData = $_POST; // or however you receive the data if ($client->verifyNotification($notificationData)) { // Signature is valid, process the notification echo "Valid notification"; } else { // Invalid signature, reject http_response_code(400); echo "Invalid signature"; }
Testing
Run the tests using PHPUnit:
composer test
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.