small/swoole-payment
最新稳定版本:1.0.0
Composer 安装命令:
composer require small/swoole-payment
包简介
README 文档
README
small/swoole-payment

Modular payment abstraction layer with support for Stripe, manual payments, and billing logic. Designed to run with high-performance Swoole environments using PSR-18 HTTP clients.
Features
- Stripe and manual payment drivers
- PSR-18 HTTP client integration
- Full or partial payments
- Payment notifications
- Billing builder with sold-out detection
- Seamless adaptation of PaymentInterface objects
Installation
composer require small/swoole-payment
Usage
1. Manual Payment
use Small\SwoolePayment\Payment\Driver\Concrete\PaymentManualDriver;
$driver = new PaymentManualDriver();
$payment = $driver->payOrder($order);
2. Stripe Payment
use Small\SwoolePayment\Payment\Driver\Concrete\PaymentStripeDriver;
$driver = new PaymentStripeDriver($stripeSecretKey, 'https://app.example.com/payment-return');
$payment = $driver->payOrder($order);
3. Confirm 3D Secure (Stripe)
try {
$driver->confirm3DSecure($payment);
} catch (RedirectException $e) {
header('Location: ' . $e->getRedirectUrl());
exit;
}
4. Partial Payment
$partial = $driver->partialPayOrder($order, 50.0);
5. Notification ingestion
$updated = $driver->ingestNotification($order, 'ext_123', PaymentInterface::PAYMENT_STATUS_AUTHORIZED);
6. Bill Generation
use Small\SwoolePayment\Bill\Builder\BillFromOrderBuilder;
$builder = new BillFromOrderBuilder();
$bill = $builder($order);
7. Adapt to Another Payment Class
use Small\SwoolePayment\Payment\Adapter\PaymentAdapter;
$adapter = new PaymentAdapter(MyCustomPayment::class);
$new = $adapter($oldPayment);
Tests
Run unit tests with Pest:
vendor/bin/pest
License
GPL V3 License
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-only
- 更新时间: 2025-06-30