定制 sonicpesa/sonicpesa-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固