rubykassa 0.3.1 → 0.3.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
  SHA1:
3
- metadata.gz: c52a778739e02a0c460779e56ef5aa8f1551a341
4
- data.tar.gz: a8c7956dad7f2320f9c53edf8b159348a931b75b
3
+ metadata.gz: dd92e78dd2880fad505c7e4bcf561a011c0ebabd
4
+ data.tar.gz: 7075c5b4b5a8b7d5852f2de6e985bba652e23455
5
5
  SHA512:
6
- metadata.gz: 21cc076fa77de32594bf1e7ee3e13874ff1853a8c14dbc58ef8d3a51fd8c8a4fdb984f22ab17183b0c0746add7a34602319914b4b6bb8eacb168c8d2e8dc40a4
7
- data.tar.gz: 4c18a84c4d1153f1a71ed7fc416958f2f1557a5b06868cabd2c23ed447b106f84ce712fee9be7f7a6281d4f2e8ae180d678195ec6e3e85ab6fba48fda2bc5929
6
+ metadata.gz: a1800cc9729f3a985d9aabf204b3199c251f5b2bdfc6bbe7425256a5e797fb54c148b16f9f3d71ccbcf81bc6b5cf1606588501690b7863b3f21e7a609994f5c3
7
+ data.tar.gz: 71a029822a6eaf978bd1cd0b950ca9c1ae3a231f556d177188795bdb823f61b7b8b837873ef3e7169ba065b56f9779906307f8e88e87e8ec5f29b16c243666ed
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## Edge (not released)
2
2
 
3
+ ## 0.3.2
4
+
5
+ * Add confugurable result callback [#14][]
6
+
7
+ [#14]:https://github.com/ZeroOneStudio/rubykassa/pull/14
8
+
3
9
  ## 0.3.1
4
10
 
5
11
  * Pass `controller` and `notification` variables to callback block by @1um [#12][]
data/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  [![Coverage Status](https://coveralls.io/repos/ZeroOneStudio/rubykassa/badge.png)](https://coveralls.io/r/ZeroOneStudio/rubykassa)
6
6
  [![Code Climate](https://codeclimate.com/github/ZeroOneStudio/rubykassa.png)](https://codeclimate.com/github/ZeroOneStudio/rubykassa)
7
7
  [![Dependency Status](https://gemnasium.com/ZeroOneStudio/rubykassa.png)](https://gemnasium.com/ZeroOneStudio/rubykassa)
8
+ [![Inline docs](http://inch-ci.org/github/ZeroOneStudio/rubykassa.svg?branch=master)](http://inch-ci.org/github/ZeroOneStudio/rubykassa)
8
9
 
9
10
  by [Zero One][]
10
11
 
@@ -47,11 +48,14 @@ To define custom success/fail callbacks you can also use the initializer:
47
48
 
48
49
  Rubykassa.configure do |config|
49
50
  ...
50
- config.success_callback = -> (controller, notification){ render text: 'success' }
51
- config.fail_callback = -> (controller, notification){ redirect_to root_path }
51
+ config.success_callback = -> (controller, notification) { controller.render text: 'success' }
52
+ config.fail_callback = -> (controller, notification) { controller.redirect_to controller.root_path }
53
+ config.result_callback = -> (controller, notification) { controller.render text: notification.success }
52
54
  end
53
55
 
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)
56
+ 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) calling it on the `controller` variable.
57
+
58
+ NOTE: `result_callback` should always return `"OK#{ invoice_id }"` string. So, implement your custom logic above `render text: notification.success` line.
55
59
 
56
60
  Mode is `:test` by default. For production you have to use `:production`.
57
61
  `http_method` and `xml_http_method` are `:get` by default but can be configured as `:post`
@@ -103,4 +107,4 @@ Copyright (c) 2013-2014 [Zero One][]
103
107
  [ZERO.ONE]: http://www.zeroone.st
104
108
 
105
109
 
106
- [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ZeroOneStudio/rubykassa/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
110
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ZeroOneStudio/rubykassa/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
@@ -4,7 +4,7 @@ class RobokassaController < ApplicationController
4
4
 
5
5
  def paid
6
6
  if @notification.valid_result_signature?
7
- render text: @notification.success
7
+ Rubykassa.result_callback.call(self, @notification)
8
8
  else
9
9
  Rubykassa.fail_callback.call(self, @notification)
10
10
  end
@@ -1,14 +1,21 @@
1
1
  # -*- encoding : utf-8 -*-
2
- Rubykassa.configure do |c|
3
- c.login = ENV["ROBOKASSA_LOGIN"]
4
- c.first_password = ENV["ROBOKASSA_FIRST_PASSWORD"]
5
- c.second_password = ENV["ROBOKASSA_SECOND_PASSWORD"]
6
- c.mode = :test # or :production
7
- c.http_method = :get # or :post
8
- c.xml_http_method = :get # or :post
2
+ Rubykassa.configure do |config|
3
+ config.login = ENV["ROBOKASSA_LOGIN"]
4
+ config.first_password = ENV["ROBOKASSA_FIRST_PASSWORD"]
5
+ config.second_password = ENV["ROBOKASSA_SECOND_PASSWORD"]
6
+ config.mode = :test # or :production
7
+ config.http_method = :get # or :post
8
+ config.xml_http_method = :get # or :post
9
+
10
+
11
+ # Result callback is called in RobokassaController#paid action if valid signature
12
+ # was generated. It should always return "OK#{ invoice_id }" string, so implement
13
+ # your custom logic above `controller.render text: notification.success` line
14
+
15
+ config.result_callback = -> (controller, notification) { controller.render text: notification.success }
9
16
 
10
17
  # Define success or failure callbacks here like:
11
18
 
12
- # config.success_callback = -> (controller, notification){ render text: 'success' }
13
- # config.fail_callback = -> (controller, notification){ redirect_to root_path }
19
+ # config.success_callback = -> (controller, notification) { controller.render text: 'success' }
20
+ # config.fail_callback = -> (controller, notification) { controller.redirect_to controller.root_path }
14
21
  end
@@ -4,6 +4,7 @@ module Rubykassa
4
4
  attr_accessor :login, :first_password, :second_password, :mode, :http_method, :xml_http_method
5
5
  attr_accessor :success_callback
6
6
  attr_accessor :fail_callback
7
+ attr_accessor :result_callback
7
8
 
8
9
  def initialize
9
10
  self.login = "your_login"
@@ -18,6 +19,9 @@ module Rubykassa
18
19
  self.fail_callback = Proc.new do |controller, notification|
19
20
  render text: 'fail'
20
21
  end
22
+ self.result_callback = Proc.new do |controller, notification|
23
+ render text: notification.success
24
+ end
21
25
  end
22
26
  end
23
- end
27
+ end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Rubykassa
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
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 success_callback fail_callback).map do |name|
15
+ %w(login first_password second_password mode http_method xml_http_method success_callback fail_callback result_callback).map do |name|
16
16
  define_method name do
17
17
  Rubykassa::Client.configuration.send(name)
18
18
  end
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.3.1
4
+ version: 0.3.2
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-07-21 00:00:00.000000000 Z
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails