Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
[![Dependency Status](https://gemnasium.com/ZeroOneStudio/rubykassa.png)](https://gemnasium.com/ZeroOneStudio/rubykassa)
[![Inline docs](http://inch-ci.org/github/ZeroOneStudio/rubykassa.svg?branch=master)](http://inch-ci.org/github/ZeroOneStudio/rubykassa)

by [Zero One][]
by [Ruby Fire][] and [Zero One][]

[Zero One]: http://zeroone.st
[Ruby Fire]: http://rubyfire.ru

Yet another Ruby wrapper for [Robokassa API][]. Make Robokassa to work with your Rails project without pain. Rubykassa took the best from [robokassa gem][] and [Active Merchant Robokassa integration] but easier to use and setup.
Yet another Ruby wrapper for [Robokassa API][]. Make Robokassa to work with your Rails project without pain. Rubykassa took the best from [robokassa gem][] and [Active Merchant Robokassa integration] but easier to use and setup. Supports Rails 5.

[Robokassa API]: http://robokassa.ru/ru/Doc/Ru/Interface.aspx
[robokassa gem]: https://github.com/shaggyone/robokassa
Expand All @@ -25,7 +26,7 @@ Yet another Ruby wrapper for [Robokassa API][]. Make Robokassa to work with your

Add to your `Gemfile`:

gem "rubykassa"
gem "rubykassa", :git => "https://github.com/ElusiveSpirit/rubykassa.git"

## Usage

Expand All @@ -35,6 +36,7 @@ Run `rails g rubykassa:install`, get an initializer with the following code:
config.login = ENV["ROBOKASSA_LOGIN"]
config.first_password = ENV["ROBOKASSA_FIRST_PASSWORD"]
config.second_password = ENV["ROBOKASSA_SECOND_PASSWORD"]
config.currency = ENV["ROBOKASSA_CURRENCY"]
config.mode = :test # or :production
config.http_method = :get # or :post
config.xml_http_method = :get # or :post
Expand Down Expand Up @@ -103,17 +105,26 @@ then call whatever you need
xml_interface.get_payment_methods
xml_interface.get_rates
xml_interface.op_state
xml_interface.calc_out_summ

In test mode, `op_state` accepts hash with additional attributes you would like to get back with response, for example `{ 'StateCode' => 5 }` (more about [StateCode](http://robokassa.ru/en/Doc/En/Interface.aspx#interfeys)). Please note, that any additional parameters to `op_state` are discarded in production mode.

## How to pay fee for yout client

Run `total = xml_interface.calc_out_summ` to get summ without RoboKassa fee and then use `total` in payment_url

<%= pay_url ivoice_id, total do %>
Pay with Robokassa
<% end %>

## Supported Rubies and Rails versions

See the CI build [![Build Status](https://secure.travis-ci.org/ZeroOneStudio/rubykassa.png)](http://travis-ci.org/ZeroOneStudio/rubykassa)

## License

This project rocks and uses MIT-LICENSE
Copyright (c) 2013-2016 [Zero One][]
Copyright (c) 2013-2016 [Zero One][] 2018 [Ruby Fire][]

[ZERO.ONE]: http://www.zeroone.st

Expand Down
8 changes: 2 additions & 6 deletions app/controllers/robokassa_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
class RobokassaController < ActionController::Base
if respond_to?(:before_action)
before_action :create_notification
else
before_filter :create_notification
end
class RobokassaController < ApplicationController
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing magic comment # frozen_string_literal: true.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing magic comment # frozen_string_literal: true.

before_action :create_notification

def result
if @notification.valid_result_signature?
Expand Down
1 change: 1 addition & 0 deletions lib/generators/rubykassa/templates/rubykassa.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
config.login = ENV['ROBOKASSA_LOGIN']
config.first_password = ENV['ROBOKASSA_FIRST_PASSWORD']
config.second_password = ENV['ROBOKASSA_SECOND_PASSWORD']
config.currency = ENV['ROBOKASSA_CURRENCY']
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

config.mode = :test # or :production
config.http_method = :get # or :post
config.xml_http_method = :get # or :post
Expand Down
3 changes: 2 additions & 1 deletion lib/rubykassa/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Rubykassa
class Configuration
ATTRIBUTES = [
:login, :first_password, :second_password, :mode, :http_method,
:login, :first_password, :second_password, :currency, :mode, :http_method,
:xml_http_method, :success_callback, :fail_callback, :result_callback,
:hash_algorithm
]
Expand All @@ -13,6 +13,7 @@ def initialize
self.login = 'your_login'
self.first_password = 'first_password'
self.second_password = 'second_password'
self.currency = 'currency'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary spacing detected.
Operator = should be surrounded by a single space.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary spacing detected.
Operator = should be surrounded by a single space.
Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

self.mode = :test
self.http_method = :get
self.xml_http_method = :get
Expand Down
7 changes: 7 additions & 0 deletions lib/rubykassa/xml_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ def initialize(&block)
yield self if block_given?
end

def calc_out_summ
request transform_method_name(__method__),
'MerchantLogin' => Rubykassa.login,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

'IncCurrLabel' => Rubykassa.currency,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

'IncSum' => @total.to_s
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

end

def get_currencies
request transform_method_name(__method__),
'MerchantLogin' => Rubykassa.login,
Expand Down