cmpayments / guzzle-psp-authentication-middleware
添加认证头到 Guzzle 请求的 Guzzle 中间件。
1.0.1
2020-07-07 09:20 UTC
Requires
- php: >=5.5.0
- guzzlehttp/guzzle: ^6.0 || ^7.0
Requires (Dev)
- jakub-onderka/php-parallel-lint: ^0.9.0
- phpunit/phpunit: ^4.7|>=5.0 <5.4
- squizlabs/php_codesniffer: ^2.3
This package is auto-updated.
Last update: 2024-09-07 18:17:21 UTC
README
此中间件实现了向 CM Payments PSP-api 发送 Guzzle 请求的认证部分。
此库兼容 PHP 5.5+ 和 PHP 7.0,但需要 Guzzle、PHP HTTP 客户端版本 ^6.0 或 ^7.0
安装
要安装 cmpayments/guzzle-psp-authentication-middleware,只需使用 composer 进行要求
# composer require cmpayments/guzzle-psp-authentication-middleware
使用示例
以下是一个通过 POST 请求请求 iDEAL 交易的示例。
<?php $key = 'Your-OAuth-Consumer-Key'; $secret = 'Your-OAuth-Consumer-Secret'; $body = [ 'amount' => 15.95, 'currency' => 'EUR', 'payments' => [ [ 'amount' => 15.95, 'currency' => 'EUR', 'payment_method' => 'iDEAL', 'payment_details' => [ 'issuer_id' => 'RABONL2U', 'purchase_id' => 'unqiue' . (new \DateTime())->format('YmdHis'), 'description' => 'Transaction description', 'success_url' => 'http://www.yourdomain.com/ideal/success', 'failed_url' => 'http://www.yourdomain.com/ideal/failed', 'cancelled_url' => 'http://www.yourdomain.com/ideal/cancelled', 'expired_url' => 'http://www.yourdomain.com/ideal/expired' ] ], ], ]; $stack = HandlerStack::create(); $authenticationMiddleware = new AuthenticationMiddleware($key, $secret); $stack->push($authenticationMiddleware); $client = new Client(['base_uri' => 'https://api.cmpayments.com/', 'handler' => $stack]); $response = $client->request('POST', 'charges/v1', [ 'json' => $body ]);
以下是一个通过 GET 请求请求 iDEAL 发行商列表的示例。
<?php $key = 'Your-OAuth-Consumer-Key'; $secret = 'Your-OAuth-Consumer-Secret'; $stack = HandlerStack::create(); $authenticationMiddleware = new AuthenticationMiddleware($key, $secret); $stack->push($authenticationMiddleware); $client = new Client(['base_uri' => 'https://api.cmpayments.com/', 'handler' => $stack]); $response = $client->request('GET', 'issuers/v1/ideal', []);
提交错误和功能请求
错误和功能请求在 GitHub 上跟踪
版权和许可
cmpayment/guzzle-psp-authentication-middleware 库版权所有 © CM Payments,许可协议为 MIT 许可证(MIT)。有关更多信息,请参阅 LICENSE。