定制 lexty/robokassa 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lexty/robokassa

Composer 安装命令:

composer require lexty/robokassa

包简介

PHP library for Robokassa payment system

README 文档

README

Build Status Latest Stable Version Latest Unstable Version Total Downloads License SensioLabsInsight

Installation

$ composer require lexty/robokassa

Examples

Create payment:

$payment = new \Lexty\Robokassa\Payment(
    new \Lexty\Robokassa\Auth('your_login', 'password1', 'password2', true)
);

$payment
    ->setInvoiceId($orderId)
    ->setSum($orderAmount)
    ->setCulture(Payment::CULTURE_EN)
    ->setDescription('Payment for some goods');

// redirect to payment url
header("Location: {$payment->getPaymentUrl()}");

// or show payment button on page
// <script src="<?php echo $payment->getFormUrl(Payment::FORM_TYPE_L); ?>"></script>

Check payment result:

// somewhere in result url handler...
...
$payment = new \Lexty\Robokassa\Payment(
    new \Lexty\Robokassa\Auth('your_login', 'password1', 'password2', true)
);

if ($payment->validateResult($_GET) {

    // send answer
    echo $payment->getSuccessAnswer(); // "OK123\n"
}
...

Check payment on Success page:

...
$payment = new \Lexty\Robokassa\Payment(
    new \Lexty\Robokassa\Auth('your_login', 'password1', 'password2', true)
);

if ($payment->validateSuccess($_GET) {
    // payment is valid
}
...

Pay a commission for the buyer

For paying comission for the buyer is sufficient to simply call $payment->setShopCommission(true)

Please bear in mind that a user who is on the payment page ROBOKASSA can change the payment method with another commission. In this case, he will pay a different amount.

Getting list of currency

Robokassa API

Returns the list of currencies available to pay for the orders from a particular store/website.

It is used to specify the value of $payment->setPaymentMethod($method) and to display the available payment options right on your website, if you wish to give more information to your clients.

use Lexty\Robokassa\Auth;
use Lexty\Robokassa\Client;

$client = new Client(
    new Auth('your_login', 'password1', 'password2', true)
);

$currencies = $client
	->setCulture(Client::CULTURE_EN)
	->getCurrencies();

Returns

array (
  array (
    'Code' => 'Terminals',
    'Description' => 'terminal ',
    'Items' => 
    array (
      array (
        'Label' => 'TerminalsElecsnetOceanR',
        'Alias' => 'Elecsnet',
        'Name' => 'Elecsnet',
        'MaxValue' => '15000',
      ),
    ),
  ),
  array (
    'Code' => 'EMoney',
    'Description' => 'e-wallet',
    'Items' => 
    array (
      array (
        'Label' => 'W1OceanR',
        'Alias' => 'W1',
        'Name' => 'RUR W1',
        'MaxValue' => '14999',
      ),
      array (
        'Label' => 'ElecsnetWalletR',
        'Alias' => 'ElecsnetWallet',
        'Name' => 'ElecsnetWallet',
        'MaxValue' => '14999',
      ),
    ),
  ),
)

Getting list of available payment method groups

Robokassa API

Returns the list of payment methods available to pay for the orders from a particular store/website. It is used to display the available payment methods right on your website, if you wish to give more information to your clients. The key difference from the $payment->getCurrencies() – is that no detailed information is shown here for all payment options, while only payment groups/methods are displayed.

use Lexty\Robokassa\Auth;
use Lexty\Robokassa\Client;

$client = new Client(
    new Auth('your_login', 'password1', 'password2', true)
);

$paymentMethodGroups = $client
	->setCulture(Client::CULTURE_EN)
	->getPaymentMethodGroups();

Returns

array (
  'Terminals' => 'terminal ',
  'EMoney' => 'e-wallet',
  'BankCard' => 'Bank card',
  'Bank' => 'Internet Banking',
  'Other' => 'other methods ',
)

Calculating the amount payable including ROBOKASSA’s charge

Robokassa API

Helps calculate the amount payable by the buyer including ROBOKASSA’s charge (according to the service plan) and charges of other systems through which the buyer decided to pay for the order. It may be used both for your internal payments and to provide additional information to the clients on your website.

use Lexty\Robokassa\Auth;
use Lexty\Robokassa\Client;

$client = new Client(
    new Auth('your_login', 'password1', 'password2', true)
);

$rates = $client
	->setCulture(Client::CULTURE_EN)
	->getRates(500);

Returns

array (
  array (
    'Code' => 'Terminals',
    'Description' => 'terminal ',
    'Items' => 
    array (
      array (
        'Label' => 'TerminalsElecsnetOceanR',
        'Alias' => 'Elecsnet',
        'Name' => 'Elecsnet',
        'MaxValue' => '15000',
        'ClientSum' => 534.76,
      ),
    ),
  ),
  array (
    'Code' => 'EMoney',
    'Description' => 'e-wallet',
    'Items' => 
    array (
      array (
        'Label' => 'W1OceanR',
        'Alias' => 'W1',
        'Name' => 'RUR W1',
        'MaxValue' => '14999',
        'ClientSum' => 537.63,
      ),
      array (
        'Label' => 'ElecsnetWalletR',
        'Alias' => 'ElecsnetWallet',
        'Name' => 'ElecsnetWallet',
        'MaxValue' => '14999',
        'ClientSum' => 535,
      ),
    ),
  ),
)

Outgoing summ calculation

Robokassa API

Helps calculate the amount receivable on the basis of ROBOKASSA prevailing exchange rates from the amount payable by the user.

use Lexty\Robokassa\Auth;
use Lexty\Robokassa\Client;

$client = new Client(
    new Auth('your_login', 'password1', 'password2', true)
);

$sum = $client->calculateClientSum(500, 'TerminalsElecsnetOceanR'); // 534.76

Operation State

Robokassa API

Returns detailed information on the current status and payment details.

Please bear in mind that the transaction is initiated not when the user is redirected to the payment page, but later – once his payment details are confirmed, i.e. you may well see no transaction, which you believe should have been started already.

use Lexty\Robokassa\Auth;
use Lexty\Robokassa\Client;

$client = new Client(
    new Auth('your_login', 'password1', 'password2', true)
);

$invoice = $client
    ->setCulture(Client::CULTURE_EN)
    ->getInvoice(1);

Returns

array (
  'InvoiceId' => 1,
  'StateCode' => 100,
  'RequestDate' => \DateTime object,
  'StateDate' => \DateTime object,
  'PaymentMethod' => 'HandyBankKB',
  'ClientSum' => 100,
  'ClientAccount' => 'Test account',
  'PaymentMethodCode' => 'eInvoicing',
  'PaymentMethodDescription' => 'Internet bank',
  'Currency' => 'MerchantR',
  'ShopSum' => 94.5,
)

License

MIT

lexty/robokassa 适用场景与选型建议

lexty/robokassa 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 38.3k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2016 年 01 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「payment」 「robokassa」 「lexty」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 lexty/robokassa 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 lexty/robokassa 我们能提供哪些服务?
定制开发 / 二次开发

基于 lexty/robokassa 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 38.3k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 15
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 13
  • Watchers: 3
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-01-29