vmrose/php-clientlibrary

此包已 废弃 且不再维护。作者建议使用 crefopay/php-clientlibrary 包代替。

Crefopay API 的 PHP 客户端库

2.0.0-rc.1 2019-01-10 10:40 UTC

README

PHP 客户端库用于 CrefoPay API。基于此处找到的 API 文档:https://docs.crefopay.de/api/ 关于此库的任何问题,请发送电子邮件至 service@crefopay.de

已知问题

以下问题已知,将在未来的版本中添加

  • 尚未报告任何问题

安装库

将两个文件夹 srcvendor 复制到项目的库路径。在您的应用程序中注册库的路径,并在代码中使用 composer 自动加载器

require_once 'vendor/autoload.php';

使用库

有关详细信息,请参阅此存储库的 docs

请求

请求库分为三个部分

```Upg\Library\Request\Objects``` contains classes for the JSON objects that are documented in the API documentation.
If a request has a property that requires a JSON object please pass in the appropriately populated ```Upg\Library\Request\Objects``` class for that property.

All properties in the request and JSON objects have getters and setters. For example, to set a field called userType on the request or object you would call `setUserType` and to get it you would call `getUserType`.

### Sending requests ###
Once you have populated a request object with the appropriate values simply create an instance of a ```Upg\Library\Api```
class for the appropriate method call. Pass in a config object and the request you want to send. Then call the
`sendRequest()` method to send the response. This method might raise an Exception or provide an object of the class SuccessResponse.

The exceptions which can be raised are in ```Upg\Library\Api\Exception```.
For any parsed responses you will have access to an ```Upg\Library\Response\SuccessResponse``` or ```Upg\Library\Response\FailureResponse``` object.
The SuccessResponse object is returned if no exception is thrown.
The FailureResponse object is returned in a ```Upg\Library\Api\Exception\ApiError``` exception.

## Handling MNS notifications ##

The library provides a helper class to validate MNS notifications:
```Upg\Library\Mns\Handler```

It takes the following as a constructor:

  * $config: The config object for the integration
  * $data: The data from the post variables which should be an associated array of the MNS callback
  * $processor: An instance of a class which implements the ```Upg\Library\Mns\ProcessorInterface```, which the method will invoke after validation.

The processor object should implement `sendData` to get data from the handler and a `run` method which executes your callback after successful validation.

The processor callback should avoid processing the request, instead it should save it to a database for asynchronous processing via a cron script.

If you use the handler class to save a MNS to the database for later processing you can assume the MNS is perfectly valid with out checking the MAC.

Please note the MNS call must always return a 200 response to CrefoPay otherwise the CrefoPay system will retry to send this notification and eventually lock the MNS queue for your system.

## Working on the library ##

If you want to contribute to the library, please note that all code should be written according to the **PSR2 standard**.
There are many tools to conform to this standard, e.g. PHP-Codesniffer or PHP Coding Standards Fixer.
We will also specify a contributing guideline in the future.