glebtv-robokassa 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d92d7be6df70c58ac056421fe43885b81c2aa0db2e1e772e758259931ad5b929
4
- data.tar.gz: e86a7dccef0f9f13ccbb54107e5b71870673a8b7e3cc97995cba7b7f19925ac5
3
+ metadata.gz: 6fedb197f06db0d9de2ea9c45443d930fe72c9db63ebb654980c7b8fe03c5075
4
+ data.tar.gz: 12e61a86e160877ddfef80dba62abf4ad8c5fbe9b36df71f1a8c291ce79cc0ae
5
5
  SHA512:
6
- metadata.gz: 5fc48515bc38b9b7084b6d5d03f0e10ebef0d465f8c7ead438c0347de9dec27a7d120e861dffdb051947e1231420ae56d339e68b09fdd5d99ad01ba55f90f65b
7
- data.tar.gz: ecf7ab364e6769950c7b80ee701512d17a49f934e57ce38f8c47e6c5bcbfa56b6eeb6983273aac84f11add52d1e7b0b7636c0286055e1aafaec44021097d0874
6
+ metadata.gz: 38039f60292196d6f4355b28f8b386f424dc8e28045a0dd71a16934af52a91fe601f25d73d3e52de850d50a41c1998433ea0a9986e7a75abd67f9b44930b61b3
7
+ data.tar.gz: 95cadb21a09164119da05d6229b67a7e3211bc5e38a2ba9d401fe2c3d7a9803d651b3a9bdac8ef7e522d70aebd910cb023ea4b0f5deafe00b635468b6c56fff7
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.3.1
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
data/config.ru ADDED
@@ -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
@@ -0,0 +1 @@
1
+ require 'robokassa'
@@ -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.3.0"
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
-
data/spec/spec_helper.rb CHANGED
@@ -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.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - glebtv
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-05 00:00:00.000000000 Z
11
+ date: 2024-05-16 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
@@ -60,21 +60,29 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
+ - ".ruby-version"
63
64
  - Gemfile
64
65
  - LICENSE.txt
65
66
  - README.md
66
67
  - Rakefile
67
68
  - app/controllers/robokassa_controller.rb
69
+ - config.ru
68
70
  - config/locales/en.yml
69
71
  - config/locales/ru.yml
70
72
  - config/routes.rb
71
73
  - glebtv-robokassa.gemspec
72
- - lib/glebtv-robokassa.rb
74
+ - lib/glebtv/robokassa.rb
73
75
  - lib/robokassa.rb
74
76
  - lib/robokassa/controller.rb
75
77
  - lib/robokassa/engine.rb
76
78
  - lib/robokassa/interface.rb
77
79
  - lib/robokassa/version.rb
80
+ - spec/internal/app/controllers/robokassa_controller.rb
81
+ - spec/internal/config/database.yml
82
+ - spec/internal/config/routes.rb
83
+ - spec/internal/db/schema.rb
84
+ - spec/internal/log/.gitignore
85
+ - spec/internal/public/favicon.ico
78
86
  - spec/lib/interface_spec.rb
79
87
  - spec/routing/routes_spec.rb
80
88
  - spec/spec_helper.rb
@@ -82,7 +90,7 @@ homepage: ''
82
90
  licenses:
83
91
  - MIT
84
92
  metadata: {}
85
- post_install_message:
93
+ post_install_message:
86
94
  rdoc_options: []
87
95
  require_paths:
88
96
  - lib
@@ -97,11 +105,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
105
  - !ruby/object:Gem::Version
98
106
  version: '0'
99
107
  requirements: []
100
- rubygems_version: 3.0.2
101
- signing_key:
108
+ rubygems_version: 3.5.9
109
+ signing_key:
102
110
  specification_version: 4
103
111
  summary: This gem adds robokassa support to your app.
104
112
  test_files:
113
+ - spec/internal/app/controllers/robokassa_controller.rb
114
+ - spec/internal/config/database.yml
115
+ - spec/internal/config/routes.rb
116
+ - spec/internal/db/schema.rb
117
+ - spec/internal/log/.gitignore
118
+ - spec/internal/public/favicon.ico
105
119
  - spec/lib/interface_spec.rb
106
120
  - spec/routing/routes_spec.rb
107
121
  - spec/spec_helper.rb
@@ -1 +0,0 @@
1
- require 'robokassa'