jrodella / payment-ws-api
SOAP WS API,用于在PHP网站中调用Lyra支付服务。
v1.0.1
2018-03-06 20:04 UTC
Requires
- php: >=5.3.0
- ext-curl: *
This package is auto-updated.
Last update: 2024-09-16 07:39:19 UTC
README
Lyra支付WS API是一个开源的PHP API,允许在电子商务网站内部通过SOAP WS调用由Lyra Network开发的受保护支付服务。
要求
PHP 5.3.0及更高版本。
安装
Composer
您可以通过Composer安装API。运行以下命令
composer require lyranetwork/payment-ws-api
要使用API,请使用Composer的自动加载
require_once('vendor/autoload.php');
手动安装
如果您不想使用Composer,您可以下载最新版本。然后,要使用API,请包含init.php文件。
require_once('/path/to/payment-ws-api/init.php');
用法
try { $ctxMode = 'TEST'; $keyTest = '1111111111111111'; $keyProd = '2222222222222222'; $shopId = '12345678'; // proxy options if any $options = array( 'proxy_host' => 'host', 'proxy_port' => '3128', 'proxy_login' => 'login', 'proxy_password' => 'password' ); $wsApi = new \Lyranetwork\WsApi($options, $url); $wsApi->init($shopId, $ctxMode, $keyTest, $keyProd); // example of getPaymentDetails call $queryRequest = new \Lyranetwork\QueryRequest(); $queryRequest->setUuid($uuid); // a known transaction UUID $getPaymentDetails = new \Lyranetwork\GetPaymentDetails($queryRequest); $getPaymentDetails->setQueryRequest($queryRequest); $requestId = $wsApi->setHeaders(); $getPaymentDetailsResponse = $wsApi->getPaymentDetails($getPaymentDetails); $wsApi->checkAuthenticity(); $wsApi->checkResult( $getPaymentDetailsResponse->getGetPaymentDetailsResult()->getCommonResponse(), array( 'INITIAL', 'WAITING_AUTHORISATION', 'WAITING_AUTHORISATION_TO_VALIDATE', 'UNDER_VERIFICATION', 'AUTHORISED', 'AUTHORISED_TO_VALIDATE', 'CAPTURED', 'CAPTURE_FAILED' ) // pending or accepted payment ); } catch(\SoapFault $f) { log("[$requestId] SoapFault with code {$f->faultcode}: {$f->faultstring}.", Zend_Log::WARN); // friendly message here } catch(\UnexpectedValueException $e) { log("[$requestId] getPaymentDetails error with code {$e->getCode()}: {$e->getMessage()}.", Zend_Log::ERR); if ($e->getCode() === -1) { // manage authentication error here } elseif ($e->getCode() === 1) { // merchant does not subscribe to WS option } else { // manage other unexpected response here } } catch (Exception $e) { log("[$requestId] Exception with code {$e->getCode()}: {$e->getMessage()}", Zend_Log::ERR); // friendly message here }
许可证
本分布中包含的每个Lyra支付WS API源代码文件都受GNU通用公共许可证(GPL 3.0)许可。
请参阅LICENSE.txt以获取GPL 3.0许可证的完整文本。它也可通过以下网址在全球范围内通过互联网获得:https://gnu.ac.cn/licenses/。