sonicpesa/sonicpesa-php
最新稳定版本:v1.0.2
Composer 安装命令:
composer require sonicpesa/sonicpesa-php
包简介
Official SonicPesa PHP SDK
README 文档
README
Official SonicPesa PHP SDK for integrating SonicPesa payment gateway in PHP applications.
Fully ready-to-use with Composer, no extra setup required.
Features
- Create payment orders
- Check order status
- Simple and flexible API
- Composer ready with Guzzle included
Requirements
- PHP >= 8.0
- cURL enabled (required by Guzzle)
Installation
Install via Composer:
composer require sonicpesa/sonicpesa-php
No additional dependencies required. Guzzle is installed automatically.
Usage
- Create order
<?php // 1. Initialize SonicPesa require 'vendor/autoload.php'; use SonicPesa\SonicPesa; $sonic = new SonicPesa("sonicpesa_api_key", "sonicpesa_secrete_key"); // Replace with your SonicPesa API key and secrete key $payment = $sonic->payment(); // 2. Create an order // You can pass an array with all details: $orderData = [ "buyer_email" => "sam@example.com", "buyer_name" => "SAM OCHU", "buyer_phone" => "255657779003", "amount" => 5000, "currency" => "TZS" ]; $order = $payment->create_order($orderData); print_r($order); // 3. Check order status $orderId = $order['order_id'] ?? ''; if ($orderId) { $status = $payment->order_status($orderId); print_r($status); } else { echo "Order ID not found!"; } // Example Response { "status": "success", "order_id": "sp_xxxxxxxx", "status": "pending", "amount": 5000, "currency": "TZS", "buyer_name": "SAM OCHU", "buyer_email": "sam@example.com", "buyer_phone": "255657779003" }
Notes
-
All amounts should be in Tanzanian Shillings (TZS) by default.
-
Phone numbers should include the country code (e.g., 255657779003).
-
Exceptions are returned as structured arrays with success and error keys.
License
- MIT License.
Give the repo star if you found helpfull.
Developd by Sam Software.
统计信息
- 总下载量: 62
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-01