globee / payment-api
一个用于将您的网站与GloBee支付API集成的PHP客户端
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: 2024-09-11 10:49:57 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或更高版本