PHPackages                             fei/payment-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. fei/payment-client

ActiveProject[Payment Processing](/categories/payments)

fei/payment-client
==================

Payment - client component

v1.2.0(7y ago)010.6k1proprietaryPHPPHP &gt;=5.5CI failing

Since May 23Pushed 7y ago22 watchersCompare

[ Source](https://github.com/flash-global/payment-client)[ Packagist](https://packagist.org/packages/fei/payment-client)[ RSS](/packages/fei-payment-client/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (5)Dependencies (8)Versions (14)Used By (1)

Payment Client
==============

[](#payment-client)

You can use this client to consume the Payment service.

With this client you can use two kind of transports to send the requests :

- Asynchronous transport implemented by `BeanstalkProxyTransport`
- Synchronous transport implemented by `BasicTransport`

`BeanstalkProxyTransport` delegates the API consumption to workers by sending payments entities to a Beanstalkd queue.

`BasicTransport` uses the classic HTTP layer to send payments synchronously.

You can find examples of how to use payment client methods in the examples folder.

Installation
============

[](#installation)

Payer client needs at least PHP 5.5 to work properly.

Add this requirement to your composer.json: "fei/payment-client": : "^1.0"

Or execute composer.phar require fei/payment-client in your terminal.

If you want use the asynchronous functionality of the Payer client (and we know you want), you need an instance of Beanstalkd which running properly and an instance of api-client-worker.php which will consume the Beanstalk's pipe and forward messages payload to the Payment API:

```
Payer Client -> Beanstalkd -> api-client-worker.php -> Payment API server

```

Beanstalkd configuration
------------------------

[](#beanstalkd-configuration)

Running Beanstalkd is very simple. However, you must pay attention to the z option which set the maximum job (or message) size in bytes.

Run `api-client-worker.php`
---------------------------

[](#run-api-client-workerphp)

You could see below an example of running `api-client-worker.php`:

```
php /path/to/payment-client/vendor/bin/api-client-worker.php --host 127.0.0.1 --port 11300 --delay 3
```

OptionsShortcutDescriptionDefaulthost`-h`The host of Beanstalkd instance`localhost`port`-p`The port which Beanstalkd instance listening`11300`delay`-d`The delay between two treatment of the worker3 secondsverbose`-v`Print verbose information-You can control the api-client-worker.php process by using Supervisor.

Entities and classes
====================

[](#entities-and-classes)

Payment entity
--------------

[](#payment-entity)

In addition to traditional `id` and `createdAt` fields, Payment entity has eleven important properties:

PropertiesTypeid`integer`uuid`string`createdAt`datetime`payedAt`datetime`expirationDate`datetime`status`integer`cancellationReason`string`requiredPrice`float`capturedPrice`float`authorizedPayment`integer`selectedPayment`integer`contexts`ArrayCollection`callbackUrl`ArrayCollection`orderId`string`paymentMethod`string`- `uuid` is a string representing a unique identifier of the payment entity
- `createdAt' represent the creation date
- `payedAt' represent the date when the payment has been made
- `expirationDate' represent the date when the payment expires
- `status` indicate in which status the payment currently is
- `orderId` Store your OrderId from your application
- `paymentMethod` Payment method to be used on the platform (example: VISA in payzen)
- `cancellationReason` is a string representing the reason of the cancellation of the payment
- `requiredPrice` is a float representing the price required
- `capturedPrice` is a float representing the price captured
- `authorizedPayment` 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 chosen
- `contexts` is an ArrayCollection of all the contexts for the entity
- `callbackUrl` 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 successes
    - `failed` : the url that will be called when an payment authorization failed
    - `cancelled` : the url that will be called when an payment is cancelled

Context entity
--------------

[](#context-entity)

In addition to traditional `id` field, Context entity has three important properties:

PropertiesTypeid`integer`key`string`value`string`payment`Payment`- `key` is a string representing the key of the context
- `value` is a string representing the value attach to this context
- `payment` is a Payment entity representing the Payment related to this context

Basic usage
===========

[](#basic-usage)

In order to consume `Payer` methods, you have to define a new `Payer` instance and set the right transport (Asynchronously or Synchronously).

```
