An open API service indexing awesome lists of open source software.

https://github.com/papihack/payexpresse-php-client

PHP SDK for PayExpresse Payment Gateway available via composer
https://github.com/papihack/payexpresse-php-client

Last synced: 14 days ago
JSON representation

PHP SDK for PayExpresse Payment Gateway available via composer

Awesome Lists containing this project

README

          

# PayExpresse - PHP API Client

[![Coverage Status](https://img.shields.io/badge/coverage-100%25-brightgreen)](https://coveralls.io/github/PapiHack/payexpresse-php-client?branch=master)
![Issues](https://img.shields.io/github/issues/PapiHack/payexpresse-php-client)
![PR](https://img.shields.io/github/issues-pr/PapiHack/payexpresse-php-client)
[![Latest Stable Version](https://poser.pugx.org/papihack/payexpresse-php-client/v)](//packagist.org/packages/papihack/payexpresse-php-client)
[![Total Downloads](https://poser.pugx.org/papihack/payexpresse-php-client/downloads)](//packagist.org/packages/papihack/payexpresse-php-client)
[![Latest Unstable Version](https://poser.pugx.org/papihack/payexpresse-php-client/v/unstable)](//packagist.org/packages/papihack/payexpresse-php-client)
[![License](https://poser.pugx.org/papihack/payexpresse-php-client/license)](//packagist.org/packages/papihack/payexpresse-php-client)
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.png?v=103)](https://github.com/ellerbrock/open-source-badges/)

This is a simple `SDK Client` or `API Client` for `PayExpresse Online Payment Gateway`.

Check out [PayExpresse Website](https://payexpresse.com/).

## How to use it

First of all, install the package or library via composer

- `composer require papihack/payexpresse-php-client`

After that, setup the API config with your parameters like this :

```php
\PayExpresse\Config::setApiKey('your_api_key');
\PayExpresse\Config::setApiSecret('your_api_secret');

/*
* you can set one of this two environment TEST or PROD
* you can just set the env mode via \PayExpresse\Enums\Env::TEST or \PayExpresse\Enums\Env::PROD
* Like the following example
* !!! By default env is PROD !!!
* You can also directly set test or prod as a string if you want
* Like \PayExpresse\Config::setEnv('test') or \PayExpresse\Config::setEnv('prod')
*/

\PayExpresse\Config::setEnv(\PayExpresse\Enums\Env::PROD);

/*
* The PayExpresse\Enums\Currency class defined authorized currencies
* You can change XOF (in the following example) by USD, CAD or another currency
* All allowed currencies are in \PayExpresse\Enums\Currency class
* !!! Notice that XOF is the default currency !!!
*/

\PayExpresse\Config::setCurrency(\PayExpresse\Enums\Currency::XOF);

/* !!! Note that if you decide to set the ipn_url, it must be in https !!! */

\PayExpresse\Config::setIpnUrl('your_ipn_url');
\PayExpresse\Config::setSuccessUrl('your_success_url');
\PayExpresse\Config::setCanceUrl('your_cancel_url');

/*
* if you want the mobile success or cancel page, you can set
* the following parameter
*/

\PayExpresse\Config::setIsMobile(true);
```

Then you can proceed with :

```php
$article_price = 15000;
$article = new \PayExpresse\Invoice\InvoiceItem('article_name', $article_price, 'command_name', 'ref_command');

/* You can also add custom data or fields like this */

\PayExpresse\CustomField::set('your_field_name', 'your_field_value');

/* Make the payment request demand to the API */

\PayExpresse\PayExpresse::send($article);

/* Get the API Response */

$response = [
'success' => \PayExpresse\ApiResponse::getSuccess(),
'errors' => \PayExpresse\ApiResponse::getErrors(),
'token' => \PayExpresse\ApiResponse::getToken(),
'redirect_url' => \PayExpresse\ApiResponse::getRedirectUrl(),
];
```

After that, if you have a success response, you can redirect your user to the `$response['redirect_url']` so that he can make the payment.
You can process the response as you wish by directly manipulating `\PayExpresse\ApiResponse`.

## TODO

- tests: cover all use cases ✅
- get the support team at [PayExpresse](https://payexpresse.com/) to clarify certain points

## Contributing

Feel free to make a PR or report an issue 😃

Regarding the tests, I use the elegant PHP Testing Framework [Pest](https://pestphp.com/) 😎

Oh, one more thing, please do not forget to put a description when you make your PR 🙂

## Contributors

- [M.B.C.M](https://itdev.herokuapp.com)
[![My Twitter Link](https://img.shields.io/twitter/follow/the_it_dev?style=social)](https://twitter.com/the_it_dev)