afconwave/afconwave-php
Composer 安装命令:
composer require afconwave/afconwave-php
包简介
Official AfconWave PHP SDK — Global payments, payouts, crypto, refunds & disputes.
README 文档
README
The official PHP client library for the AfconWave Payments API.
Features
- ✅ PHP 7.4+ and PHP 8.x compatible
- 🌍 Payments, Payouts, and Refunds
- 🔒 Secure, server-side only API key handling
- 🔔 Webhook HMAC-SHA256 signature verification
- 🧪 Sandbox-ready with test keys
- 📦 PSR-4 autoloaded via Composer
Requirements
- PHP 7.4 or higher
- Composer
guzzlehttp/guzzle(auto-installed)
Installation
composer require afconwave/sdk
Quick Start
<?php require "vendor/autoload.php"; use AfconWave\AfconWave; $afw = new AfconWave('afw_sk_test_your_key_here');
Usage Guide
Create a Payment
$payment = $afw->createPayment([ 'amount' => 5000, // Amount in minor units (5000 = 50 XAF) 'currency' => 'XAF', 'description' => 'Order #1234', 'callback_url' => 'https://yoursite.com/payment/callback', 'customer' => [ 'name' => 'Jean Dupont', 'email' => 'jean@example.com', 'phone' => '+237600000000', ], 'metadata' => [ 'order_id' => 'ORD-1234', ], ]); echo $payment['checkout_url']; // Redirect user here echo $payment['id']; // e.g., pay_507f191e8180f
Retrieve a Payment
$payment = $afw->retrievePayment('pay_507f191e8180f'); echo $payment['status']; // "pending" | "success" | "failed" echo $payment['amount']; echo $payment['paid_at'];
Create a Payout
$payout = $afw->createPayout([ 'amount' => 10000, 'currency' => 'XAF', 'recipient' => [ 'phone' => '+237600000001', 'network' => 'MTN', // "MTN" | "ORANGE" | "MOOV" | "WAVE" 'name' => 'Marie Kamga', ], 'reference' => 'PAYOUT-REF-001', ]); echo $payout['status']; // "pending" | "success" | "failed"
List Payments
$result = $afw->listPayments([ 'limit' => 20, 'status' => 'success', ]); foreach ($result['data'] as $payment) { echo $payment['id'] . ' — ' . $payment['status'] . PHP_EOL; }
Webhook Verification
Always verify that incoming webhooks are genuinely from AfconWave.
<?php // Your webhook endpoint (e.g., yoursite.com/webhooks/afconwave) $webhookSecret = 'your_webhook_secret_here'; $payload = file_get_contents('php://input'); $signature = $_SERVER['HTTP_X_AFCONWAVE_SIGNATURE'] ?? ''; $expected = hash_hmac('sha256', $payload, $webhookSecret); if (!hash_equals($expected, $signature)) { http_response_code(400); echo 'Invalid signature'; exit; } $event = json_decode($payload, true); switch ($event['event']) { case 'payment.success': // Fulfill the order error_log('Payment received: ' . $event['data']['id']); break; case 'payment.failed': // Notify the customer break; case 'payout.success': // Update your records break; } http_response_code(200); echo 'OK';
Error Handling
use AfconWave\AfconWave; use AfconWave\Exceptions\AfconWaveException; use AfconWave\Exceptions\AuthException; try { $payment = $afw->createPayment([...]); } catch (AuthException $e) { echo 'Invalid API Key: ' . $e->getMessage(); } catch (AfconWaveException $e) { echo 'API Error ' . $e->getStatusCode() . ': ' . $e->getMessage(); } catch (\Exception $e) { echo 'Unexpected error: ' . $e->getMessage(); }
Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
$secretKey |
string |
required | Your AfconWave secret API key |
$baseUrl |
string |
https://api.afconwave.com/v1 |
API base URL |
Sandbox / Testing
Use test keys prefixed with afw_sk_test_ to run inside sandbox mode.
$afw = new AfconWave('afw_sk_test_...');
Laravel Integration (Example)
Create a service and bind it in your AppServiceProvider:
// config/services.php 'afconwave' => [ 'secret_key' => env('AFCONWAVE_SECRET_KEY'), ], // AppServiceProvider.php use AfconWave\AfconWave; $this->app->singleton(AfconWave::class, function () { return new AfconWave(config('services.afconwave.secret_key')); }); // In a controller class PaymentController extends Controller { public function __construct(private AfconWave $afw) {} public function checkout(Request $request) { $payment = $this->afw->createPayment([ 'amount' => $request->amount, 'currency' => 'XAF', 'callback_url' => route('payment.callback'), ]); return redirect($payment['checkout_url']); } }
Documentation
Full API documentation: docs.afconwave.com
License
MIT © AfconWave
afconwave/afconwave-php 适用场景与选型建议
afconwave/afconwave-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 05 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payments」 「global」 「africa」 「cross-border」 「fintech」 「payouts」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 afconwave/afconwave-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 afconwave/afconwave-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 afconwave/afconwave-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dealing with payments through the Egyptian payment gateway PayMob
Librería para la gestión sencilla de pagos mediante TPV Redsys y Paypal
A global CDN and reverse proxy cache warmer.
Validation rules and an Eloquent Model attribute cast to value object encapsulating a South African government-issued personal identification number, for Laravel.
Feature-based billing for Laravel with African payment provider support (M-Pesa, Paystack, Flutterwave, Pesapal). Plans, feature gating, usage metering, subscriptions, and invoicing.
A global command line tool for Laravel's Artisan.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 49
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-11