quellabs/canvas-payments
最新稳定版本:1.0.3
Composer 安装命令:
composer require quellabs/canvas-payments
包简介
Payment router for the Canvas PHP framework. Discovers and routes payment operations to installed provider packages.
README 文档
README
Payment router for the Canvas framework. Discovers installed payment provider packages automatically via composer metadata and routes payment operations to the correct provider.
Installation
composer require quellabs/canvas-payments
How it works
PaymentRouter scans installed packages for composer metadata declaring a provider class under the payments discovery key. Any package that declares one and implements PaymentProviderInterface is registered automatically — no manual configuration required.
The provider class must implement a static getMetadata() method returning a modules array. Each entry becomes a routable module identifier.
"extra": { "discover": { "canvas": { "controller": "Quellabs\\Payments\\Mollie\\MollieController" }, "payments": { "provider": "Quellabs\\Payments\\Mollie\\Driver", "config": "config/mollie.php" } } }
At runtime, PaymentRouter uses the paymentModule field on the request to route calls to the correct provider.
Configuration
After composer install, the package publishes a default config file to config/mollie.php via a post-autoload-dump script. Edit this file to set your API key, webhook URL, redirect URL, and cancel URL.
Usage
Inject PaymentRouter via Canvas DI:
use Quellabs\Payments\PaymentRouter; use Quellabs\Payments\Contracts\PaymentRequest; use Quellabs\Payments\Contracts\RefundRequest; class CheckoutService { public function __construct(private PaymentRouter $router) {} public function pay(): string { $response = $this->router->initiate(new PaymentRequest( paymentModule: 'mollie_ideal', amount: 999, // in minor units — €9.99 currency: 'EUR', description: 'Order #12345', )); if (!$response->success) { throw new \RuntimeException($response->errorMessage); } return $response->redirectUrl; } }
Available methods
| Method | Description |
|---|---|
initiate(PaymentRequest) |
Start a payment session, returns redirect URL and transaction ID |
refund(RefundRequest) |
Issue a refund for a completed payment |
exchange(string $transactionId) |
Fetch current payment state (call from webhook handler) |
getRefunds(string $transactionId) |
Returns all refunds for a given transaction |
getPaymentOptions(string $module) |
Fetch available issuers or options for a payment module |
getRegisteredModules() |
Returns all discovered module identifiers |
Requirements
- PHP 8.2+
- Quellabs Canvas framework
License
MIT
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-17