yarcode/yii2-payeer

Yii2 Payeer 组件

安装次数: 8,531

依赖关系: 0

建议者: 0

安全: 0

星星: 3

关注者: 4

分支: 8

开放性问题: 0

类型:yii2-extension

2.0.2 2017-04-03 10:18 UTC

This package is not auto-updated.

Last update: 2024-09-15 01:57:43 UTC


README

为 Payeer 服务提供的支付网关和 API 客户端。

该包包含 2 个主要组件

  • Api 执行各种 API 调用。例如:获取余额、发送资金、获取账户历史等。
  • Merchant 连接商户 API 并处理支付

安装

安装此扩展的首选方式是通过 composer

运行以下命令

php composer.phar require --prefer-dist yarcode/yii2-payeer "~1.0"

或将以下内容添加到您的 composer.json 文件的 require 部分。

"yarcode/yii2-payeer": "~1.0"

API

配置

在应用程序的 components 部分配置 payeerApi 组件。

'payeerApi' => [
    'class' => \yarcode\payeer\Api::class,
    'accountNumber' => '<account number>',
    'apiId' => '<api ID>',
    'apiSecret' => '<your secret>'
],

用法

您应该使用 try {} catch() {} 将 API 调用包装起来以处理任何错误。

/** @var \yarcode\payeer\Api $api */
$api = Yii::$app->get('payeerApi');

try {
    $result = $api->balance();    
} catch(ApiException $e) {
    // handle API errors here, for instance:
     $error = $e->getMessage();
     $result = null;
}

可用方法

$api->isAuth();
$api->balance();
$api->transfer($to, $sum, $curIn, $curOut = null, array $restParams = [])
$api->checkUser('P1234567')
$api->getExchangeRate();
$api->initOutput($psId, $sumIn, $accountNumber, $curIn = self::CURRENCY_USD, $curOut = null);
$api->output($psId, $sumIn, $accountNumber, $curIn = self::CURRENCY_USD, $curOut = null);
$api->getPaySystems();
$api->historyInfo($historyId);
$api->shopOrderInfo($shopId, $orderId);
$api->history(array $params = []);
$api->merchant($shop, $ps, $form, array $restParams = []);

商户

配置

在应用程序的 components 部分配置 payeer 组件。

'payeer' => [
    'class' => \yarcode\payeer\Merchant::class,
    'shopId' => '<shop ID>',
    'secret' => '<merchant secret>',
    'currency' => '<default shop currency>' // by default Merchant::CURRENCY_USD
],

重定向到支付系统

要将用户重定向到 Payeer 网站,您需要创建带有 RedirectForm 小部件的页面。用户将在页面加载后立即被重定向。

<?= \yarcode\payeer\RedirectForm::widget([
    'merchant' => Yii::$app->get('payeer'),
    'invoiceId' => $invoiceId,
    'amount' => $amount,
    'description' => $description,
    'currency' => \yarcode\payeer\Merchant::CURRENCY_USD // By default Merchant component currency
]); ?>

网关控制器

您需要创建一个控制器来处理来自 PerfectMoney 服务的请求结果。示例控制器代码

// TODO: Finish gateway controller example

许可证

MIT

链接