quellabs/canvas-payments-contracts
Composer 安装命令:
composer require quellabs/canvas-payments-contracts
包简介
Payment gateway contracts and interfaces for the Canvas PHP framework
README 文档
README
Shared contracts for the Canvas payments ecosystem. Contains the interfaces and value objects that connect payment provider packages to your application.
Installation
composer require quellabs/canvas-payments-contracts
What's in this package
| Class / Interface | Description |
|---|---|
PaymentInterface |
Interface for application code — exposes initiate, refund, getRefunds, getPaymentOptions |
PaymentProviderInterface |
Interface all driver packages must implement — extends PaymentInterface, adds discovery methods |
PaymentRequest |
Input for initiating a payment |
InitiateResult |
Result of a successful payment initiation |
PaymentState |
Payment snapshot delivered via the payment_exchange signal |
PaymentStatus |
Enum of possible payment states |
RefundRequest |
Input for issuing a refund |
RefundResult |
Result of a successful refund |
PaymentAddress |
Billing or shipping address attached to a payment |
PaymentException |
Base exception for all payment failures |
PaymentInitiationException |
Thrown when initiate() fails |
PaymentRefundException |
Thrown when refund() or getRefunds() fails |
PaymentExchangeException |
Thrown internally by the controller layer |
All amounts are in minor units (e.g. 999 for €9.99). All classes are in the Quellabs\Payments\Contracts namespace.
Usage
use Quellabs\Payments\Contracts\PaymentInterface; use Quellabs\Payments\Contracts\PaymentRequest; use Quellabs\Payments\Contracts\PaymentInitiationException; class CheckoutService { public function __construct(private PaymentInterface $payment) {} public function pay(): string { try { $result = $this->payment->initiate(new PaymentRequest( paymentModule: 'mollie_ideal', amount: 999, currency: 'EUR', description: 'Order #12345', )); return $result->redirectUrl; } catch (PaymentInitiationException $e) { // handle error } } }
PaymentState
PaymentState is an immutable snapshot of a payment's current status. Your application receives it by subscribing
to the payment_exchange signal, which is emitted by the controller layer after a return URL visit or webhook.
| Property | Type | Description |
|---|---|---|
$provider |
string |
Provider identifier, e.g. 'mollie', 'paypal' |
$transactionId |
string |
Provider's unique identifier for this payment |
$state |
PaymentStatus |
Normalised payment status |
$currency |
string |
ISO 4217 currency code, e.g. 'EUR' |
$valuePaid |
int |
Amount actually captured, in minor units. 0 if not yet paid |
$valueRefunded |
int |
Total amount refunded so far, in minor units |
$internalState |
?string |
Raw status string from the provider, before normalisation |
$metadata |
array |
Provider-specific data, e.g. captureId required for refunds |
$valuePaid is only non-zero when $state is PaymentStatus::Paid or PaymentStatus::Refunded. For all other
states — including Pending — it is 0. Use $state to determine whether funds have actually moved, and
$valuePaid to know how much.
To issue a refund after a successful payment, persist $metadata['paymentReference'] from the PaymentState — it is
required as RefundRequest::$paymentReference.
Exceptions
All exceptions extend PaymentException, which exposes getProvider(): string and getErrorId(): int. Catch the base
class to handle any payment failure, or catch a specific subclass to handle a particular operation.
use Quellabs\Payments\Contracts\PaymentException; use Quellabs\Payments\Contracts\PaymentInitiationException; use Quellabs\Payments\Contracts\PaymentRefundException; // Catch all payment failures } catch (PaymentException $e) { $e->getProvider(); // e.g. 'mollie' $e->getErrorId(); // provider error ID $e->getMessage(); // human-readable message } // Or catch specific failures } catch (PaymentInitiationException $e) { ... } // initiate() failed } catch (PaymentRefundException $e) { ... } // refund() or getRefunds() failed
PaymentStatus values
| Case | Description |
|---|---|
PaymentStatus::Pending |
Payment is open or pending |
PaymentStatus::Paid |
Payment completed successfully |
PaymentStatus::Canceled |
Customer canceled — definitive |
PaymentStatus::Expired |
Customer abandoned, or bank transfer timed out |
PaymentStatus::Failed |
Payment failed and cannot be retried |
PaymentStatus::Refunded |
Payment was refunded |
PaymentStatus::Redirect |
Redirect user back to provider. Internally handled. |
PaymentStatus::Unknown |
Unrecognised status from provider |
License
MIT
quellabs/canvas-payments-contracts 适用场景与选型建议
quellabs/canvas-payments-contracts 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「payments」 「interfaces」 「canvas」 「contracts」 「abstractions」 「canvas-payments」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 quellabs/canvas-payments-contracts 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 quellabs/canvas-payments-contracts 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 quellabs/canvas-payments-contracts 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
O2System PSR it's build based on PHP Framework Interop Group (PHP-FIG) standards recommendations. This repository contains a collection of PHP interfaces based on the PSR-0 until the PSR-7.
Limoncello PHP Framework Contracts (interfaces) required for components integration.
Dealing with payments through the Egyptian payment gateway PayMob
Librería para la gestión sencilla de pagos mediante TPV Redsys y Paypal
Transforms Laravel Models to Typescript Interfaces/Types
Visual marketing automation with node-based canvas for Sylius 2.x
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 35
- 依赖项目数: 11
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-17