fdm / netaxept
此包已被弃用且不再维护。未建议替代包。
Netaxept API 集成包
v1.1.0
2018-06-21 08:26 UTC
Requires
- guzzlehttp/guzzle: ^6.3
- webmozart/assert: ^1.3
Requires (Dev)
- phpstan/phpstan: ^0.9.2
- phpunit/phpunit: ^7.2
- symplify/easy-coding-standard: ^4.4
This package is auto-updated.
Last update: 2021-07-06 03:00:02 UTC
README
此项目提供了一个简单接口用于NETS的Netaxept支付网关。
使用库
使用composer安装
composer require fdm/netaxept
<?php require 'vendor/autoload.php'; // Instantiate the API with the required merchantId and token $api = new \FDM\Netaxept\Api('merchantId', 'token'); // Get a response object from the API, in this example, get a transaction. $response = $api->getTransaction('transactionId'); // Retrieve properties on the transaction. $status = $response->getTransactionStatus(); print_r($response->getOrderInformation());
自定义响应工厂
提供的响应类仅包含用于公开最常见数据的公共方法。如果您需要检索其他数据,则只需创建一个扩展现有之一(或实现适当接口的全新类)的响应类,并实现您的公共方法。然后,将这些完全限定类名提供给 Factory() 类的构造函数。
// Acme/Netaxept/Response/MyCustomQuery.php use FDM\Netaxept\Response\Query; class MyCustomQuery extends Query { public function getQueryFinished() { return (string)$this->xml->QueryFinished; } } ... // In your file that instantiates the API object $responseFactory = new Factory(Acme\Netaxept\Response\MyCustomQuery::class); $api = new Api('merch', 'token', $responseFactory); $response = $api->getTransaction('transactionid'); $finished = $response->getQueryFinished();
自定义异常工厂
与响应工厂一样,您也可以提供自己的工厂类来处理抛出适当的异常,从而允许您自定义异常处理。
// In your file that instantiates the API object use FDM\Netaxept\Exception\Factory; $exceptionFactory = new Factory(Acme\Netaxept\Exception\MyCustomException::class ... [etc]); $api = new Api('merch', 'token', null, $exceptionFactory); try { $response = $api->getTransaction('transactionid'); } catch (MyCustomException $e) { $e->doSomethingCustom(); }
有关支持的异常,请参阅 异常工厂构造函数。
贡献
提供了一些工具以简化开发。克隆项目并运行 make docker-start
来启动PHP Docker容器。运行 make docker-shell
在容器内部获得一个shell。运行 composer install
安装依赖项。在容器内部运行 make test
以运行测试,并运行 make codecheck
确保您的代码遵循标准。
许可证
版权所有 © 联合丹麦汽车制造商 (FDM)。保留所有权利。
在MIT许可证下授权。