globee / payment_api
0.5.0
2020-04-14 12:19 UTC
Requires
- php: >=5.5
- ext-curl: *
- ext-json: *
Requires (Dev)
- mockery/mockery: 0.9.9|^1.0
- phpunit/phpunit: ~5.7|~7.5
This package is not auto-updated.
Last update: 2022-02-01 13:12:41 UTC
README
这是一个库,用于将您的系统与 GloBee 支付 API 集成,以管理和接受通过我们的系统进行的加密货币支付。
####注意:如果使用 PHP 7.0 或更低版本,请使用 0.4.0 或更低版本。
使用 Composer 安装
在您的项目中运行以下命令以添加此包
composer require globee/payment-api
通过 GloBee 进行认证
要接收有效的 X-AUTH-ID,请完成以下步骤
- 登录 GloBee,并在后端面板中导航到支付 API 部分。
- 复制“支付 API 密钥”并将其存储在您的代码中某个位置。
使用示例
要创建 GloBee 上的发票并接收重定向到支付中继页,您可以复制并修改以下代码。
创建新的支付请求
<?php include 'vendor/autoload.php'; $connector = new \GloBee\PaymentApi\Connectors\GloBeeCurlConnector('YOUR_UNIQUE_API_KEY'); $paymentApi = new \GloBee\PaymentApi\PaymentApi($connector); $paymentRequest = new \GloBee\PaymentApi\Models\PaymentRequest(123.45, 'example@email.com'); $response = $paymentApi->createPaymentRequest($paymentRequest); $paymentRequestId = $response->id; // Save this ID to know when payment has been made $redirectUrl = $response->redirectUrl; // Redirect your client to this URL to make payment
获取现有的支付请求
<?php include 'vendor/autoload.php'; $connector = new \GloBee\PaymentApi\Connectors\GloBeeCurlConnector( 'YOUR_UNIQUE_API_KEY' ); $paymentApi = new \GloBee\PaymentApi\PaymentApi($connector); $response = $paymentApi->getPaymentRequest($paymentRequestId);
将 IPN 的响应转换为 PaymentRequest 对象
<?php include 'vendor/autoload.php'; $requestBody = file_get_contents('php://input'); // Get post body $input = json_decode($requestBody, true); // convert JSON text into array $data = $input['data']; // Get the data // Create new Payment Request from the request $paymentRequest = \GloBee\PaymentApi\Models\PaymentRequest::fromResponse($data);
文档
有关更多信息,请查看以下文档:https://globee.com/docs/payment-api/v1
许可证
本软件是开源软件,根据 GNU 通用公共许可证版本 3 或更高版本授权。