rubykassa 0.2.6 → 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
  SHA1:
3
- metadata.gz: e32aed2ec5fcba1f0a2da295982531f30bc09639
4
- data.tar.gz: 97b7a4036c09d345cd29becd995e259642786e37
3
+ metadata.gz: 3ade0bc62aef80b744ba0986070c235d5f984bb6
4
+ data.tar.gz: 04c7e176126113ec11c16cad12b83aee1a95b5ba
5
5
  SHA512:
6
- metadata.gz: 780f5632372166c33f2eef59a63308a46ac87ad36a1f9db16e764763e42bf8acd7e1efeda195679435e45737cbd2972bad21e6ada74bdceec34114476d8102f2
7
- data.tar.gz: 3402f01d6f369a09c850d5514941681367134c172516cf2f776d7c472cb6a99bf63446dcf67c010c80d0118a47e65005ed92bd93604d3b8d3b683dda5bd8ad3a
6
+ metadata.gz: b3fc71559975f76cd9c406a0a05c8d31cef8633810491c0ea23afc9175ecd1c1171f69226445d01514a823d47d74e5e172069388476c72fbb5636c2aadea7ab6
7
+ data.tar.gz: 15daf1b2eb84e87fb8538800874dc97d52bedf791c33487e46f440fa4e56cd8a8a40b2ffef0ddacd1c6933c9cfda0e882e742b6872f78dc42886c817edb7ef3b
data/.travis.yml CHANGED
@@ -4,10 +4,9 @@ rvm:
4
4
  - 2.0.0
5
5
  - 2.1.0
6
6
  env:
7
- - "RAILS_VERSION=3.0.0"
8
- - "RAILS_VERSION=3.1.0"
9
- - "RAILS_VERSION=3.2.0"
7
+ - "RAILS_VERSION=3.2.18"
10
8
  - "RAILS_VERSION=4.0.0"
9
+ - "RAILS_VERSION=4.1.0"
11
10
  - "RAILS_VERSION=master"
12
11
  matrix:
13
12
  allow_failures:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## Edge (not released)
2
2
 
3
+ ## 0.3.0
4
+
5
+ * Add confugurable success and fail callbacks
6
+
7
+ ## 0.2.6
8
+
3
9
  * Fix bug with wrong signature generating with custom user params
4
10
 
5
11
  ## 0.2.5
@@ -22,4 +28,4 @@
22
28
 
23
29
  * Fix description param name from `'InvDesc'` to `'Desc'`. Closes [#2][]
24
30
 
25
- [#2]: https://github.com/ZeroOneStudio/rubykassa/issues/2
31
+ [#2]: https://github.com/ZeroOneStudio/rubykassa/issues/2
data/README.md CHANGED
@@ -37,6 +37,22 @@ Run `rails g rubykassa:install`, get an initializer with the following code:
37
37
 
38
38
  and configure it with your credentials.
39
39
 
40
+ Also, you need to specify Result URL, Success URL and Fail URL at the "Technical Settings" (Технические настройки) in your Robokassa dashboard:
41
+
42
+ * Result URL: `http://<your_domain>/robokassa/paid`
43
+ * Success URL: `http://<your_domain>/robokassa/success`
44
+ * Fail URL: `http://<your_domain>/robokassa/fail`
45
+
46
+ To define custom success/fail callbacks you can also use the initializer:
47
+
48
+ Rubykassa.configure do |config|
49
+ ...
50
+ config.success_callback = -> { render text: 'success' }
51
+ config.fail_callback = -> { redirect_to root_path }
52
+ end
53
+
54
+ Lambdas are called in RobokassaController so you can respond with [any kind that is supported by Rails](http://guides.rubyonrails.org/layouts_and_rendering.html#creating-responses)
55
+
40
56
  Mode is `:test` by default. For production you have to use `:production`.
41
57
  `http_method` and `xml_http_method` are `:get` by default but can be configured as `:post`
42
58
 
@@ -75,10 +91,9 @@ Rubies:
75
91
  * 2.1.0
76
92
 
77
93
  Rails:
78
- * ~> 3.0.0
79
- * ~> 3.1.0
80
- * ~> 3.2.0
94
+ * ~> 3.2.18
81
95
  * ~> 4.0.0
96
+ * ~> 4.1.0
82
97
 
83
98
  ## License
84
99
 
@@ -88,5 +103,4 @@ Copyright (c) 2013-2014 [Zero One][]
88
103
  [ZERO.ONE]: http://www.zeroone.st
89
104
 
90
105
 
91
- [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ZeroOneStudio/rubykassa/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
92
-
106
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ZeroOneStudio/rubykassa/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
@@ -6,20 +6,20 @@ class RobokassaController < ApplicationController
6
6
  if @notification.valid_result_signature?
7
7
  render text: @notification.success
8
8
  else
9
- render text: "fail"
9
+ Rubykassa.fail_callback.call
10
10
  end
11
11
  end
12
12
 
13
13
  def success
14
14
  if @notification.valid_success_signature?
15
- render text: "success"
15
+ Rubykassa.success_callback.call
16
16
  else
17
- render text: "fail"
17
+ Rubykassa.fail_callback.call
18
18
  end
19
19
  end
20
20
 
21
21
  def fail
22
- render text: "fail"
22
+ Rubykassa.fail_callback.call
23
23
  end
24
24
 
25
25
  private
@@ -2,6 +2,8 @@
2
2
  module Rubykassa
3
3
  class Configuration
4
4
  attr_accessor :login, :first_password, :second_password, :mode, :http_method, :xml_http_method
5
+ attr_accessor :success_callback
6
+ attr_accessor :fail_callback
5
7
 
6
8
  def initialize
7
9
  self.login = "your_login"
@@ -9,7 +11,13 @@ module Rubykassa
9
11
  self.second_password = "second_password"
10
12
  self.mode = :test
11
13
  self.http_method = :get
12
- self.xml_http_method = :get
14
+ self.xml_http_method = :get
15
+ self.success_callback = -> {
16
+ render text: 'success'
17
+ }
18
+ self.fail_callback = -> {
19
+ render text: 'fail'
20
+ }
13
21
  end
14
22
  end
15
23
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Rubykassa
3
- VERSION = "0.2.6"
3
+ VERSION = "0.3.0"
4
4
  end
data/lib/rubykassa.rb CHANGED
@@ -12,7 +12,7 @@ module Rubykassa
12
12
  Rubykassa::Client.configure &block
13
13
  end
14
14
 
15
- %w(login first_password second_password mode http_method xml_http_method).map do |name|
15
+ %w(login first_password second_password mode http_method xml_http_method success_callback fail_callback).map do |name|
16
16
  define_method name do
17
17
  Rubykassa::Client.configuration.send(name)
18
18
  end
@@ -20,9 +20,9 @@ module Rubykassa
20
20
 
21
21
  def pay_url invoice_id, total, custom_params, extra_params = {}
22
22
  Rubykassa::PaymentInterface.new do
23
- self.total = total
24
- self.invoice_id = invoice_id
25
- self.params = custom_params
23
+ self.total = total
24
+ self.invoice_id = invoice_id
25
+ self.params = custom_params
26
26
  end.pay_url(extra_params)
27
27
  end
28
28
  end
data/rubykassa.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.files = `git ls-files`.split("\n")
19
19
  s.test_files = `git ls-files -- spec/rubykassa/*`.split("\n")
20
20
 
21
- s.add_dependency "rails", ">= 3.0"
21
+ s.add_dependency "rails", ">= 3.2.18"
22
22
  s.add_dependency "multi_xml"
23
23
 
24
24
  s.add_development_dependency "sqlite3"
@@ -32,6 +32,18 @@ describe Rubykassa::Client do
32
32
  Rubykassa.mode.should == :test
33
33
  Rubykassa.http_method.should == :get
34
34
  Rubykassa.http_method.should == :get
35
+ expect(Rubykassa.success_callback).to be_instance_of(Proc)
36
+ expect(Rubykassa.fail_callback).to be_instance_of(Proc)
37
+ end
38
+
39
+ it "should set success_callback" do
40
+ Rubykassa.configure do |config|
41
+ config.success_callback = -> {
42
+ 2 + 5
43
+ }
44
+ end
45
+
46
+ expect(Rubykassa.success_callback.call).to eq(7)
35
47
  end
36
48
 
37
49
  it "should raise error when wrong mode is set" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubykassa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Kishenin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-06 00:00:00.000000000 Z
11
+ date: 2014-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.0'
19
+ version: 3.2.18
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '3.0'
26
+ version: 3.2.18
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: multi_xml
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -206,3 +206,4 @@ test_files:
206
206
  - spec/rubykassa/notification_spec.rb
207
207
  - spec/rubykassa/payment_interface_spec.rb
208
208
  - spec/rubykassa/xml_interface_spec.rb
209
+ has_rdoc: