glebtv-robokassa 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d92d7be6df70c58ac056421fe43885b81c2aa0db2e1e772e758259931ad5b929
4
- data.tar.gz: e86a7dccef0f9f13ccbb54107e5b71870673a8b7e3cc97995cba7b7f19925ac5
3
+ metadata.gz: f9789611e089b962f3ea1f3afd11508557cf27416c5f8dde57463bbd8f26e39f
4
+ data.tar.gz: f9fbf2ba3d5f2d5e1154764d80ad4cc51d6420bd7c85f40ddb27e9406b92ad3f
5
5
  SHA512:
6
- metadata.gz: 5fc48515bc38b9b7084b6d5d03f0e10ebef0d465f8c7ead438c0347de9dec27a7d120e861dffdb051947e1231420ae56d339e68b09fdd5d99ad01ba55f90f65b
7
- data.tar.gz: ecf7ab364e6769950c7b80ee701512d17a49f934e57ce38f8c47e6c5bcbfa56b6eeb6983273aac84f11add52d1e7b0b7636c0286055e1aafaec44021097d0874
6
+ metadata.gz: 07ce56e2beaff6179bc0bdb320d950da81286a41ee22f659cfd5896c4a542a99e122b1c539e66090ce4cdf1d31f1a35814d66f259d4feb0f53f62f1e42c295ef
7
+ data.tar.gz: c94a54eddc0060adc874bb41c7a43bcaea23e2f41e5aafcfcf05409fab148e72f09ed99b27d7f9d4c63cceca42fa8af00ddc3f1cfb55567dd4553155bab3514f
data/Gemfile CHANGED
@@ -2,3 +2,13 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in glebtv-robokassa.gemspec
4
4
  gemspec
5
+
6
+ group :test do
7
+ gem 'rspec'
8
+ gem 'combustion'
9
+ gem 'rspec-rails'
10
+ gem 'factory_bot_rails'
11
+ gem 'shoulda'
12
+ gem 'faker'
13
+ gem 'pg'
14
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+
6
+ Bundler.require :default, :development
7
+
8
+ Combustion.initialize! :all
9
+ run Combustion::Application
@@ -17,9 +17,9 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
-
20
+
21
21
  spec.add_dependency "rails", ">= 3.2.0"
22
-
23
- spec.add_development_dependency "bundler", "~> 1.3"
22
+
23
+ spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "rake"
25
25
  end
@@ -1,14 +1,16 @@
1
1
  module Robokassa::Controller
2
2
  extend ActiveSupport::Concern
3
- included do
4
- skip_before_action :verify_authenticity_token
5
- end
3
+ # included do
4
+ # if protect_against_forgery?
5
+ # skip_before_action :verify_authenticity_token, only: [:notify]
6
+ # end
7
+ # end
6
8
 
7
9
  def notify
8
10
  if params[:token] != Robokassa.interface.token
9
11
  raise Robokassa::InvalidToken.new
10
12
  end
11
- render :text => Robokassa.interface.notify(params, self)
13
+ render plain: Robokassa.interface.notify(params, self)
12
14
  end
13
15
 
14
16
  def success
@@ -135,6 +135,7 @@ module Robokassa
135
135
 
136
136
  # Maps gem parameter names, to robokassa names
137
137
  def map_params(params, map)
138
+ params = params.is_a?(Hash) ? params : params.permit!.to_hash
138
139
  parsed_params = Hash[params.map do|key, value| [(map[key] || map[key.to_sym] || key), value] end]
139
140
  parsed_params[:custom_options] = Hash[params.select{ |k,v| k.respond_to?(:starts_with?) && k.starts_with?('shp') }.sort.map{|k, v| [k[3, k.size].to_sym, v]}]
140
141
  parsed_params
@@ -152,6 +153,9 @@ module Robokassa
152
153
  :email => email,
153
154
  :language => language
154
155
  }.merge(Hash[custom_options.sort.map{|x| ["shp#{x[0]}", x[1]]}])
156
+ if @options[:test_mode]
157
+ options[:isTest] = 1
158
+ end
155
159
  map_params(options, @@params_map)
156
160
  end
157
161
 
@@ -166,9 +170,9 @@ module Robokassa
166
170
  "#{@options[:login]}:#{amount}:#{invoice_id}:#{@options[:password1]}#{custom_options_fmt.blank? ? "" : ":" + custom_options_fmt}"
167
171
  end
168
172
 
169
- # returns http://test.robokassa.ru or https://merchant.roboxchange.com in order to current mode
173
+ # returns http://auth.robokassa.ru or https://merchant.roboxchange.com in order to current mode
170
174
  def base_url
171
- test_mode? ? 'http://test.robokassa.ru' : 'https://merchant.roboxchange.com'
175
+ test_mode? ? 'http://auth.robokassa.ru/Merchant' : 'https://merchant.roboxchange.com'
172
176
  end
173
177
 
174
178
  # returns url to redirect user to payment page
@@ -1,3 +1,3 @@
1
1
  module Robokassa
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -0,0 +1,9 @@
1
+ # coding: utf-8
2
+
3
+ class RobokassaController < ActionController::Base
4
+ include Robokassa::Controller
5
+
6
+ def success
7
+ super
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ test:
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ database: robokassa_test
5
+ pool: 5
6
+ host: localhost
7
+ username: postgres
8
+ password: 123
9
+ template: template0
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.routes.draw do
4
+ # Add your own routes here, or remove this file if you don't have need for it.
5
+ mount Robokassa::Engine => '/robokassa'
6
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ ActiveRecord::Schema.define do
4
+ # Set up any tables you need to exist for your test suite that don't belong
5
+ # in migrations.
6
+ end
@@ -0,0 +1 @@
1
+ *.log
File without changes
@@ -5,11 +5,11 @@ require 'robokassa/interface'
5
5
  describe "Interface should work correct" do
6
6
  before :each do
7
7
  end
8
-
8
+
9
9
  it "Should correctly use test server" do
10
10
  i = Robokassa::Interface.new :test_mode => true
11
11
  i.should be_test_mode
12
- i.base_url.should == "http://test.robokassa.ru"
12
+ i.base_url.should == "http://auth.robokassa.ru/Merchant"
13
13
  end
14
14
 
15
15
  it "should compute correct signature string" do
@@ -18,13 +18,20 @@ describe "Interface should work correct" do
18
18
  i.init_payment_signature_string(15, 185.0, "Order #125", {:a => 15, :c => 30, :b => 20}).should == "demo:185.0:15:12345:shpa=15:shpb=20:shpc=30"
19
19
  end
20
20
 
21
- it "should create correct init payment url" do
21
+ it "should create correct init payment url for test_mode" do
22
22
  i = Robokassa::Interface.new :test_mode => true, :login => 'demo', :password1 => '12345'
23
- i = Robokassa::Interface.new :test_mode => true, :login => 'shaggyone239', :password1 => '12345asdf'
23
+ expected_url = "http://auth.robokassa.ru/Merchant/Index.aspx?MrchLogin=demo&OutSum=185.11&InvId=15&Desc=Order+125&SignatureValue=8e32c6ad194a540fe14fb97367360170&IncCurrLabel=&Email=demo%40robokassa.ru&Culture=ru&isTest=1&custom_options=%7B%7D"
24
+ generated_url = i.init_payment_url(15, 185.11, "Order 125", '', 'ru', 'demo@robokassa.ru', {})
25
+ puts generated_url
26
+ generated_url.should == expected_url
27
+ end
28
+
29
+ it "should create correct init payment url for production" do
30
+ i = Robokassa::Interface.new :login => 'shaggyone239', :password1 => '12345asdf'
24
31
  i.init_payment_signature_string(15, 185.11, "Order #125").should == "shaggyone239:185.11:15:12345asdf"
25
32
  i.init_payment_signature(15, 185.11, "Order #125").should == "55f2aee20767cde28e7fc49919cec969"
26
- i.init_payment_url(15, 185.11, "Order 125", '', 'ru', 'demo@robokassa.ru', {}).should ==
27
- "http://test.robokassa.ru/Index.aspx?MrchLogin=shaggyone239&OutSum=185.11&InvId=15&Desc=Order+125&SignatureValue=55f2aee20767cde28e7fc49919cec969&IncCurrLabel=&Email=demo%40robokassa.ru&Culture=ru"
33
+ i.init_payment_url(15, 185.11, "Order 125", '', 'ru', 'demo@robokassa.ru', {}).should ==
34
+ "ttps://merchant.roboxchange.com/Index.aspx?MrchLogin=shaggyone239&OutSum=185.11&InvId=15&Desc=Order+125&SignatureValue=55f2aee20767cde28e7fc49919cec969&IncCurrLabel=&Email=demo%40robokassa.ru&Culture=ru&isTest=1"
28
35
  i.init_payment_signature(196, 2180.0, "R602412577").should == "adeedf2afbac5eca09b44898da3ef51a"
29
36
  end
30
37
 
@@ -52,4 +59,3 @@ describe "Interface should work correct" do
52
59
  expect { i.success_validate_signature( params ) }.not_to raise_error
53
60
  end
54
61
  end
55
-
@@ -1,23 +1,26 @@
1
1
  require 'spec_helper'
2
2
 
3
3
 
4
- describe 'routes' do
4
+ describe 'routes', type: :routing do
5
5
  context "robokassa" do
6
- specify { get('/robokassa/notify/some-secure-notification-key').should route_to(
7
- controller: 'robokassa',
8
- action: 'notify',
9
- token: 'some-secure-notification-key'
10
- )}
11
-
12
- specify { get('/robokassa/success').should route_to(
13
- controller: 'robokassa',
14
- action: 'success'
15
- )}
16
-
17
- specify { get('/robokassa/fail').should route_to(
18
- controller: 'robokassa',
19
- action: 'fail'
20
- )}
6
+ it "routes robokassa notify" do
7
+ expect(:get => '/robokassa/notify/some-secure-notification-key').to route_to(
8
+ controller: 'robokassa',
9
+ action: 'notify',
10
+ token: 'some-secure-notification-key'
11
+ )
12
+ end
13
+ it "routes robokassa success" do
14
+ expect(:get => '/robokassa/success').to route_to(
15
+ controller: 'robokassa',
16
+ action: 'success'
17
+ )
18
+ end
19
+ it "routes robokassa fail" do
20
+ expect(:get => '/robokassa/fail').to route_to(
21
+ controller: 'robokassa',
22
+ action: 'fail'
23
+ )
24
+ end
21
25
  end
22
26
  end
23
-
@@ -1,11 +1,12 @@
1
1
  require 'rubygems'
2
2
  require 'bundler'
3
-
3
+ require 'combustion'
4
4
  require 'rails'
5
5
 
6
6
  Bundler.require :default, :development
7
7
 
8
- Combustion.initialize! :active_record, :action_controller
8
+ # :active_record,
9
+ Combustion.initialize! :action_controller
9
10
 
10
11
  require 'rspec/rails'
11
12
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glebtv-robokassa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-05 00:00:00.000000000 Z
11
+ date: 2019-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.3'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -65,6 +65,7 @@ files:
65
65
  - README.md
66
66
  - Rakefile
67
67
  - app/controllers/robokassa_controller.rb
68
+ - config.ru
68
69
  - config/locales/en.yml
69
70
  - config/locales/ru.yml
70
71
  - config/routes.rb
@@ -75,6 +76,12 @@ files:
75
76
  - lib/robokassa/engine.rb
76
77
  - lib/robokassa/interface.rb
77
78
  - lib/robokassa/version.rb
79
+ - spec/internal/app/controllers/robokassa_controller.rb
80
+ - spec/internal/config/database.yml
81
+ - spec/internal/config/routes.rb
82
+ - spec/internal/db/schema.rb
83
+ - spec/internal/log/.gitignore
84
+ - spec/internal/public/favicon.ico
78
85
  - spec/lib/interface_spec.rb
79
86
  - spec/routing/routes_spec.rb
80
87
  - spec/spec_helper.rb
@@ -102,6 +109,12 @@ signing_key:
102
109
  specification_version: 4
103
110
  summary: This gem adds robokassa support to your app.
104
111
  test_files:
112
+ - spec/internal/app/controllers/robokassa_controller.rb
113
+ - spec/internal/config/database.yml
114
+ - spec/internal/config/routes.rb
115
+ - spec/internal/db/schema.rb
116
+ - spec/internal/log/.gitignore
117
+ - spec/internal/public/favicon.ico
105
118
  - spec/lib/interface_spec.rb
106
119
  - spec/routing/routes_spec.rb
107
120
  - spec/spec_helper.rb