fei / payment-common
Payment - common components
Installs: 20 672
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 25
Forks: 0
Open Issues: 4
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-12-21 22:58:45 UTC
README
Table of contents
Entities
Payment entity
In addition to traditional id
and createdAt
fields, Payment entity has eleven important properties:
uuid
is a string representing a unique identifier of the payment entitycreatedAt
represent the creation datepayedAt
represent the date when the payment has been madeexpirationDate
represent the date when the payment expiresstatus
indicate in which status the payment currently iscancellationReason
is a string representing the reason of the cancellation of the paymentrequiredPrice
is a float representing the price requiredcapturedPrice
is a float representing the price capturedauthorizedPayment
is an int that represent the list of the payment authorised (used like binary flags)selectedPayment
is an integer representing the payment method that has been chosencontexts
is an ArrayCollection of all the contexts for the entitycallbackUrl
is an array of callbacks url that will be used is some events in the application (when the payment is saved for example). Here are the possible value and purpose of the callback url:succeeded
: the url that will be called when an payment authorization successesfailed
: the url that will be called when an payment authorization failedcancelled
: the url that will be called when an payment is cancelled
Context entity
In addition to traditional id
field, Context entity has three important properties:
key
is a string representing the key of the contextvalue
is a string representing the value attach to this contextpayment
is a Payment entity representing the Payment related to this context
Validators
You have the possibility to validate a Payment
entity with PaymentValidator
class:
<?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();
By default, only uuid
, createdAt
, expirationDate
, status
, requiredPrice
, authorizedPayment
and callbackUrl
properties must not be empty,
but you're also able to validate only a few properties of your entity, using validate
methods:
<?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' * ) * ) **/
Contribution
As FEI Service, designed and made by OpCoding. The contribution workflow will involve both technical teams. Feel free to contribute, to improve features and apply patches, but keep in mind to carefully deal with pull request. Merging must be the product of complete discussions between Flash and OpCoding teams :)