crefopay / php-clientlibrary
一个用于简化CrefoPay Web-API实现的PHP库
3.0.1
2024-07-05 12:15 UTC
Requires
- ext-curl: *
- ext-json: *
- ext-openssl: *
- siriusphp/validation: ^3.1.0
Replaces
- dev-master
- 3.0.1
- 3.0.0
- 2.0.2
- 2.0.1
- 2.0.0
- 1.4.1
- 1.4.0
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-master-shopware5
- dev-master-shopware
- dev-master-magento
- dev-oxid-master
- dev-master-upg
- dev-develop-upg
- dev-develop
- dev-pipelines
- dev-featureStatus
- dev-release/2.0.1
- dev-master-standalone
This package is auto-updated.
Last update: 2024-09-23 09:21:30 UTC
README
CrefoPay API的PHP客户端库。基于以下API文档:[https://docs.crefopay.de/api/](https://docs.crefopay.de/api/)。关于此库的问题,请发送电子邮件至service@crefopay.de
已知问题
以下问题已知,将在后续版本中添加
- 未报告问题
安装库
将两个文件夹 src
和 vendor
复制到您的项目的库路径中。在您的应用程序中注册库路径,并在代码中使用composer自动加载器
require_once 'vendor/autoload.php';
使用库
有关详细信息,请参阅此存储库的文档
请求
请求库分为三个部分
```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.