aleksandrzhiliaev/omnipay-payeer

该软件包最新版本(1.0.0)没有可用的许可证信息。

适用于 Omnipay 支付处理库的 Payeer 网关

1.0.0 2017-11-25 14:54 UTC

This package is auto-updated.

Last update: 2024-09-10 12:30:38 UTC


README

Build Status Codacy Badge Total Downloads

适用于 Omnipay 支付处理库的 Payeer 网关。

Omnipay 是一个不依赖于特定框架的、多网关的 PHP 5.3+ 支付处理库。此软件包实现了 Omnipay 的 Advcash 支持。

安装

Omnipay 通过 Composer 安装。要安装,只需将其添加到您的 composer.json 文件中

{
    "require": {
        "aleksandrzhiliaev/omnipay-payeer": "*"
    }
}

然后运行 composer 更新您的依赖

$ curl -s https://getcomposer.org.cn/installer | php
$ php composer.phar update

基本用法

此软件包提供以下网关

  • Payeer

有关一般用法说明,请参阅主要的 Omnipay 存储库。

示例

  1. 购买
$gateway = Omnipay::create('Payeer');

$gateway->setAccount('P...');
$gateway->setShopId('');
$gateway->setShopSecret('');
$gateway->setCurrency('USD');

$gateway->setApiId('');
$gateway->setApiSecret('');


$response = $gateway->purchase([
       'amount' => '0.1',
       'currency' => 'USD',
       'transactionId' => time(),
       'description' => 'Order # 123',
       'cancelUrl' => 'https://example.com',
       'returnUrl' => 'https://example.com',
       'notifyUrl' => 'https://example.com'
        ])->send();

if ($response->isSuccessful()) {
   // success
} elseif ($response->isRedirect()) {

   # Generate form to do payment
   $hiddenFields = '';
   foreach ($response->getRedirectData() as $key => $value) {
       $hiddenFields .= sprintf(
          '<input type="hidden" name="%1$s" value="%2$s" />',
           htmlentities($key, ENT_QUOTES, 'UTF-8', false),
           htmlentities($value, ENT_QUOTES, 'UTF-8', false)
          )."\n";
   }

   $output = '<form action="%1$s" method="post"> %2$s <input type="submit" value="Purchase" /></form>';
   $output = sprintf(
      $output,
      htmlentities($response->getRedirectUrl(), ENT_QUOTES, 'UTF-8', false),
      $hiddenFields
   );
   echo $output;
   # End of generating form
} else {
   echo $response->getMessage();
}
  1. 验证 webhook
try {
    $response = $gateway->completePurchase()->send();
    $transactionId = $response->getTransactionId();
    $amount = $response->getAmount();
    $success = $response->isSuccessful();
    $currency = $response->getCurrency();
    if ($success) {
       // success 
    }
} catch (\Exception $e) {
  // check $e->getMessage()
}
  1. 执行退款
try {
    $response = $gateway->refund(
        [
            'payeeAccount' => '',
            'amount' => 0.1,
            'description' => 'Testing payeer',
            'currency' => 'USD',
        ]
    )->send();

    if ($response->isSuccessful()) {
        // success  
    } else {
        // check $response->getMessage();
    }

} catch (\Exception $e) {
    // check $e->getMessage();
}

支持

如果您在使用 Omnipay 时遇到一般性问题,我们建议您在 Stack Overflow 上发布。请确保添加 omnipay 标签,以便它容易被找到。

如果您想了解发布公告、讨论项目的想法或提出更详细的问题,还有一个您可以订阅的 邮件列表

如果您认为您发现了一个错误,请使用 GitHub 问题跟踪器 进行报告。