ziyoren/pay-sdk

Ziyoren Pay SDK for payment integration

Maintainers

Package info

github.com/ziyoren/pay-sdk

pkg:composer/ziyoren/pay-sdk

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-03-24 17:33 UTC

This package is auto-updated.

Last update: 2026-03-25 00:44:32 UTC


README

A PHP SDK for integrating with Ziyoren Pay payment gateway.

English Version | 中文版本

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.