承接 tzsmm/tzsmmpay 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tzsmm/tzsmmpay

最新稳定版本:v1.0.0

Composer 安装命令:

composer require tzsmm/tzsmmpay

包简介

PHP library for TZSMM PAY Gateway

README 文档

README

License Version

PHP Library for TZSMM PAY Gateway

The TZSMM Pay PHP library allows you to integrate the TZSMM Pay payment gateway into your PHP-based applications. It provides easy-to-use methods for creating and verifying payments with the TZSMM Pay API.

Features

  • Create Payments: Create payments directly via the TZSMM Pay API.
  • Verify Payments: Check payment status in real-time.
  • Supports PHP 7.2 and above.
  • Secure and Easy Integration.

Installation

You can install the TZSMM Pay library via Composer.

Step 1: Install the Package

Run the following command in your terminal:

composer require tzsmm/tzsmmpay

Step 2: Autoload the Package

Once installed, Composer will automatically load the library. If you're using a custom autoloader, ensure that the Tzsmmpay class is included properly.

API Documentation

This section explains how to use the API to create a payment via the TZSMM Pay gateway.

API Endpoint: /api/payment/create

URL: https://tzsmmpay.com/api/payment/create

Method: GET

Required Parameters

To create a payment, send the following parameters in the API request:

  • api_key: Your TZSMM Pay API key.
  • cus_name: The name of the customer (e.g., "Demo User").
  • cus_email: The email of the customer (e.g., "demo@demo.com").
  • cus_number: The phone number of the customer (e.g., "01700000000").
  • amount: The payment amount (e.g., "1" for 1 unit of currency).
  • success_url: The URL to redirect the user to after a successful payment (e.g., https://domain.com/success-url).
  • cancel_url: The URL to redirect the user to if they cancel the payment (e.g., https://domain.com/cancel-url/dashboard).
  • callback_url: The URL where payment status will be sent (e.g., https://domain.com/callback-url).

Example Request

use Tzsmmpay\TzsmmpayClient;
use Tzsmmpay\TzsmmpayResponse;

$apiKey = 'xOevYGbzFmJCm1rkzDrf';  // Your API key

$tzsmm = new TzsmmpayClient($apiKey);

$paymentData = [
    'cus_name' => 'Demo User',
    'cus_email' => 'demo@demo.com',
    'cus_number' => '01700000000',
    'amount' => 1,
    'success_url' => 'https://domain.com/success-url',
    'cancel_url' => 'https://domain.com/cancel-url/dashboard',
    'callback_url' => 'https://domain.com/callback-url',
];

$response = $tzsmm->createPayment($paymentData);

if ($response->isSuccess()) {
    echo "Payment created successfully!";
    echo "Transaction ID: " . $response->getData()['transaction_id'];
    echo "Payment URL: " . $response->getData()['payment_url'];
} else {
    echo "Error: " . $response->getMessage();
}

Example Response

{
    "success": true,
    "data": {
        "transaction_id": "trx_123456",
        "payment_url": "https://tzsmmpay.com/payment/trx_123456"
    },
    "message": null
}

Verify Payment

After a customer has completed their payment, you can verify the payment using the verifyPayment method.

API Endpoint: /api/payment/verify

URL: https://tzsmmpay.com/api/payment/verify

Method: GET

Example Verification Request

$transactionId = 'trx_123456';  // Replace with actual transaction ID

$response = $tzsmm->verifyPayment($transactionId);

if ($response->isSuccess()) {
    if ($response->getData()['status'] == 'Completed') {
        echo "Payment verified successfully!";
    } else {
        echo 'Your Payment is ' . $response->getData()['status'];
    }
} else {
    echo "Verification failed: " . $response->getMessage();
}

Example Verification Response

{
    "success": true,
    "data": {
        "status": "Completed",
        "amount": 1,
        "cus_name": "Demo User",
        "cus_email": "demo@demo.com",
        "cus_number": "01700000000"
    },
    "message": null
}

Error Handling

In case of an error, the API will return an error message in the message field of the response. Handle errors accordingly in your application:

if (!$response->isSuccess()) {
    echo "Error: " . $response->getMessage();
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please fork the repository, create a branch, and submit a pull request.

Steps to Contribute:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-name).
  3. Commit your changes (git commit -am 'Add new feature').
  4. Push to the branch (git push origin feature-name).
  5. Open a pull request.

Support

For support or questions, please visit TZSMM Pay Support.

Authors

Changelog

v1.0.0

  • Initial release with core functionality to create and verify payments.

Acknowledgements

  • TZSMM Pay for providing the API and gateway.
  • Composer for managing PHP dependencies.

Happy coding! 🚀

统计信息

  • 总下载量: 29
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-21