mboateng/sppay-laravel
Composer 安装命令:
composer require mboateng/sppay-laravel
包简介
Laravel integration for the SPPay public API (payments, transfers, transactions, institutions, SMS).
README 文档
README
Laravel client for the SPPay public API: OAuth, payments, transfers, transactions, institutions, and SMS.
Package: mboateng/sppay-laravel
PHP: 8.1+
Laravel: 10, 11, or 12
Installation
composer require mboateng/sppay-laravel
The service provider and Sppay facade are registered automatically via Laravel package discovery.
Publish the configuration (optional):
php artisan vendor:publish --tag=sppay-config
Configuration
Values are read from .env through config/sppay.php (use config('sppay.*') in code).
Environment variables
| Variable | Description | Default |
|---|---|---|
SPPAY_BASE_URL |
API host, no trailing slash | https://engine.sppay.dev |
SPPAY_OAUTH_URL |
Full URL for token endpoint (optional) | — (uses {SPPAY_BASE_URL}/oauth/token) |
SPPAY_CLIENT_ID |
OAuth client id | — |
SPPAY_CLIENT_SECRET |
OAuth client secret | — |
SPPAY_USERNAME |
OAuth username | — |
SPPAY_PASSWORD |
OAuth password | — |
SPPAY_ACCESS_TOKEN |
Bearer token (if you already have one) | — |
SPPAY_TIMEOUT |
Request timeout (seconds) | 30 |
SPPAY_CONNECT_TIMEOUT |
Connect timeout (seconds) | 10 |
Example .env (use your own secrets; do not commit real credentials):
SPPAY_BASE_URL=https://engine.sppay.dev SPPAY_OAUTH_URL=https://engine.sppay.dev/oauth/token SPPAY_CLIENT_ID=your-client-id SPPAY_CLIENT_SECRET=your-client-secret SPPAY_USERNAME=your@email.com SPPAY_PASSWORD=your-password
Laravel loads these into config('sppay.base_url'), config('sppay.oauth_url'), config('sppay.client_id'), etc. You do not need a separate services.php entry unless you prefer to duplicate keys there.
Usage
Facade
Option A — password grant using .env (recommended when credentials live in config):
use Mboateng\Sppay\Facades\Sppay; $response = Sppay::oauthPasswordGrant(); Sppay::setAccessToken($response['access_token']); $transactions = Sppay::listTransactions(['page_size' => 10]);
Option B — build the payload yourself:
use Mboateng\Sppay\Facades\Sppay; $token = Sppay::oauthToken([ 'grant_type' => 'password', 'client_id' => config('sppay.client_id'), 'client_secret' => config('sppay.client_secret'), 'username' => config('sppay.username'), 'password' => config('sppay.password'), ]); Sppay::setAccessToken($token['access_token']); $transactions = Sppay::listTransactions(['page_size' => 10]);
Dependency injection
use Mboateng\Sppay\Contracts\SppayClientContract; public function __construct( private SppayClientContract $sppay ) {} public function example(): void { $this->sppay->setAccessToken($token); $this->sppay->getTransaction('REFERENCE'); }
Manual client
use Mboateng\Sppay\SppayClient; $client = new SppayClient( baseUrl: 'https://engine.sppay.dev', accessToken: $token, ); $client->initiatePayment([/* ... */]);
Public endpoints (no Bearer)
oauthToken() and validatePublicKey() do not send an Authorization header. All other methods require a Bearer token (setAccessToken() or SPPAY_ACCESS_TOKEN).
API methods
| Method | Endpoint |
|---|---|
oauthToken(array $payload) |
POST /oauth/token |
oauthPasswordGrant() |
POST /oauth/token (uses SPPAY_* credentials from config) |
validatePublicKey(array $body) |
POST /v1/key/validate |
validatePayment(array $body) |
POST /v1/api/payments/validate |
initiatePayment(array $body) |
POST /v1/api/payments/initiate |
submitPaymentOtp(array $body) |
POST /v1/api/payments/otp/submit |
validateTransferAccount(array $body) |
POST /v1/api/transfers/validate-account |
validateTransfer(array $body) |
POST /v1/api/transfers/validate |
submitTransfer(array $body) |
POST /v1/api/transfers/submit |
listTransactions(array $query) |
GET /v1/api/transactions |
getTransaction(string $reference) |
GET /v1/api/transactions/{reference} |
getTransactionStatus(string $reference) |
GET /v1/api/transactions/{reference}/status |
postSpPayWebhook(array $body) |
POST /v1/sp-pay/webhook |
getInstitutions(array $body) |
POST /v1/api/institutions |
getInstitution(string $code) |
GET /v1/api/institutions/{code} |
sendSms(array $body) |
POST /v1/api/sms/send |
listTransactions() accepts query parameters such as account_no, reference, amount, date_from, date_to, type_code, status_id, page_size, page, etc.
Errors
Failed HTTP calls throw Mboateng\Sppay\Exceptions\SppayRequestException. Use getResponseBody() for the raw API error body when available.
Testing
composer test
License
MIT
mboateng/sppay-laravel 适用场景与选型建议
mboateng/sppay-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payments」 「laravel」 「API-Client」 「Ghana」 「mobile-money」 「sppay」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mboateng/sppay-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mboateng/sppay-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mboateng/sppay-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Skolkovo API Client
Dealing with payments through the Egyptian payment gateway PayMob
Librería para la gestión sencilla de pagos mediante TPV Redsys y Paypal
A client library for the OpenPLZ API project
Alfabank REST API integration
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-28