blesta/coingate

CoinGate

安装: 364

依赖项: 0

建议者: 0

安全性: 0

星标: 0

关注者: 6

分支: 0

公开问题: 0

类型:blesta-gateway-nonmerchant

1.4.0 2022-01-25 00:10 UTC

This package is auto-updated.

Last update: 2024-08-25 22:41:35 UTC


README

Build Status Coverage Status

这是一个为Blesta提供的非商户网关,与CoinGate集成。

安装网关

  1. 您可以通过Composer安装网关

    composer require blesta/coingate
    
  2. 将源代码上传到Blesta安装路径中的/components/gateways/nonmerchant/coingate/目录。

    例如

    /var/www/html/blesta/components/nonmerchant/coingate/
    
  3. 登录到您的管理员Blesta账户,然后导航到

设置 > 支付网关

  1. 找到CoinGate网关并点击“安装”按钮进行安装

  2. 完成!

Blesta 兼容性

CoinGate PHP库

CoinGate API的PHP库。

您可以在https://coingate.com注册CoinGate账户用于生产,并在https://sandbox.coingate.com(沙箱)进行测试。

请注意,对于沙箱,您必须在https://sandbox.coingate.com上生成单独的API凭证。在https://coingate.com上生成的API凭证在沙箱模式下将不会工作。

Composer

您可以通过Composer安装库。在您的终端中运行以下命令

composer require blesta/coingate

手动安装

下载最新版本并包含init.php文件。

require_once('/path/to/coingate/init.php');

入门

CoinGate库的使用

设置CoinGate库

设置默认认证

use CoinGate\CoinGate;

\CoinGate\CoinGate::config(array(
  'environment' => 'sandbox', // sandbox OR live
  'app_id'      => 'YOUR_APP_ID',
  'api_key'     => 'YOUR_API_KEY',
  'api_secret'  => 'YOUR_API_SECRET'
));

// $order = \CoinGate\Merchant\Order::find(7294);

单独设置认证

use CoinGate\CoinGate;

# \CoinGate\Merchant\Order::find($orderId, $options = array(), $authentication = array())

$order = \CoinGate\Merchant\Order::find(1087999, array(), array(
    'environment' => 'sandbox', // sandbox OR live
    'app_id' => 'YOUR_APP_ID',
    'api_key' => 'YOUR_API_KEY',
    'api_secret' => 'YOUR_API_SECRET'));

创建商户订单

https://developer.coingate.com/docs/create-order

use CoinGate\CoinGate;

$post_params = array(
                   'order_id'          => 'YOUR-CUSTOM-ORDER-ID-115',
                   'price'             => 1050.99,
                   'currency'          => 'USD',
                   'receive_currency'  => 'EUR',
                   'callback_url'      => 'https://example.com/payments/callback?token=6tCENGUYI62ojkuzDPX7Jg',
                   'cancel_url'        => 'https://example.com/cart',
                   'success_url'       => 'https://example.com/account/orders',
                   'title'             => 'Order #112',
                   'description'       => 'Apple Iphone 6'
               );

$order = \CoinGate\Merchant\Order::create($post_params);

if ($order) {
    echo $order->status;
} else {
    # Order Is Not Valid
}

获取商户订单

https://developer.coingate.com/docs/get-order

use CoinGate\CoinGate;

try {
    $order = \CoinGate\Merchant\Order::find(7294);

    if ($order) {
      var_dump($order);
    }
    else {
      echo 'Order not found';
    }
} catch (Exception $e) {
  echo $e->getMessage(); // BadCredentials Not found App by Access-Key
}

测试API凭证

$testConnection = \CoinGate\CoinGate::testConnection(array(
  'environment'   => 'sandbox',
  'app_id'        => 'APP_ID',
  'api_key'       => 'APP_KEY',
  'api_secret'    => 'APP_SECRET'
));

if ($testConnection !== true) {
  echo $testConnection; // CoinGate\BadCredentials: BadCredentials Not found App by Access-Key
}