fei / payment-common
该软件包最新版本(v2.6.0)没有提供许可证信息。
支付 - 公共组件
v2.6.0
2018-12-28 16:29 UTC
Requires
- php: >=7.0
- doctrine/common: ~2.6.0
- fei/entities: ^1.0.3
- ramsey/uuid: ~3.6
Requires (Dev)
- codeception/codeception: ^2.2
- fei/api-server: ^1.0.0
- jakub-onderka/php-parallel-lint: ^0.9.2
- phpmd/phpmd: ^2.6
- sebastian/phpcpd: ^2.0
- squizlabs/php_codesniffer: ^2.7
- dev-master
- v2.6.0
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.8
- v2.4.7
- v2.4.6
- v2.4.5
- v2.4.4
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.0
- v1.0.6
- v1.0.5
- V1.0.4
- V1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-dependabot/composer/guzzlehttp/guzzle-6.5.8
- dev-dependabot/composer/guzzlehttp/psr7-1.8.5
- dev-dependabot/composer/erusev/parsedown-1.7.4
- dev-dependabot/composer/codeception/codeception-3.1.3
- dev-develop
- dev-feature/lav_add_payzen_payment
This package is auto-updated.
Last update: 2024-09-21 22:25:34 UTC
README
目录
实体
支付实体
除了传统的 id
和 createdAt
字段外,支付实体还有十一个重要属性
uuid
是表示支付实体唯一标识符的字符串createdAt
表示创建日期payedAt
表示支付完成日期expirationDate
表示支付过期日期status
表示支付当前状态cancellationReason
表示支付取消原因的字符串requiredPrice
表示所需价格的浮点数capturedPrice
表示已捕获价格的浮点数authorizedPayment
是一个整数,表示已授权支付的列表(用作二进制标志)selectedPayment
是一个整数,表示已选择的支付方式contexts
是实体所有上下文的 ArrayCollectioncallbackUrl
是回调 URL 数组,在应用的一些事件中将被使用(例如,当支付保存时)。以下是可能的值和回调 URL 的用途succeeded
: 当支付授权成功时将调用的 URLfailed
: 当支付授权失败时将调用的 URLcancelled
: 当支付被取消时将调用的 URL
上下文实体
除了传统的 id
字段外,上下文实体有三个重要属性
key
是表示上下文键的字符串value
是表示附加到此上下文的值的字符串payment
是表示与该上下文相关的支付实体的支付实体
验证器
您可以使用 PaymentValidator
类验证 Payment
实体
<?php use Fei\Service\Payment\Validator\PaymentValidator; use Fei\Service\Payment\Entity\Payment; $paymentValidator = new PaymentValidator('create'); $payment = new Payment(); //validate returns true if your Payment instance is valid, or false in the other case $isPaymentValid = $paymentValidator->validate($payment); //getErrors() allows you to get an array of errors if there are some, or an empty array in the other case $errors = $paymentValidator->getErrors();
默认情况下,只有 uuid
、createdAt
、expirationDate
、status
、requiredPrice
、authorizedPayment
和 callbackUrl
属性不能为空,但您还可以使用 validate
方法仅验证实体的一些属性
<?php use Fei\Service\Payment\Validator\PaymentValidator; use Fei\Service\Payment\Entity\Payment; $paymentValidator = new PaymentValidator('create'); $payment = new Payment(); $payment->setUuid('uuid'); $paymentValidator->validateUuid($payment->getUuid()); // will return an empty array : all of our definitions are correct $errors = $paymentValidator->getErrors(); echo empty($errors); // true // callbackUel can not be empty, let's try to set it as an empty string $payment->setCallbackUrl([]); $paymentValidator->validateCallbackUrl($payment->getCallbackUrl()); // this time you'll get a non-empty array $errors = $paymentValidator->getErrors(); echo empty($errors); // false print_r($errors); /** * print_r will return: * * Array * ( * ['callbackUrl'] => Array * ( * 'The callback URL cannot be empty' * ) * ) **/
贡献
作为 OpCoding 设计和制作的 FEI 服务。贡献工作流程将涉及技术团队。欢迎贡献,改进功能和应用补丁,但请记住要仔细处理拉取请求。合并必须是 Flash 和 OpCoding 团队之间完全讨论的结果:)