lolita-bank-link 1.0.2 → 1.0.3

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: 9d3c12e9a0e2abad36809a9bb092c979b62b9d51
4
- data.tar.gz: 1e97787930fa2c2f8413179e67af45aa5e37958d
3
+ metadata.gz: a692e64cc9e5773bc38865d2ac516ff0592e3d6f
4
+ data.tar.gz: b4941495e06c5ade39bf4038acaadfba9bd18b81
5
5
  SHA512:
6
- metadata.gz: 2c8d9f51bd48bd3636d3d4bcaf71e91315a0737eaa74b37bb0fb1cc2e98a4b7580f632e7df8e82ab9a836e062ca31f1f4cfd850f3e811e69afdbe4247130cb71
7
- data.tar.gz: 26308a49920440c8a551d1afaacd748710f09a8ecd363ce619efa427161dce58161dd5ddd23f7ec0c5f296009551b760b6a3d22be7133cddf08f1d6de33c1603
6
+ metadata.gz: 8d65e3d8802ab780ea76f1eb9ed2d967f242e054cea5d2b304f65ed739d5e8c33bd8d3ae39d7880860567a459e810ed13c4ca611e2eacb3753cb5ad1cb36344c
7
+ data.tar.gz: 4db446892acaf63ae7ed3f81c370e0232efbbd814dc5f8c4d67625a0f029fdd32325f7488915ce46b2b875c9222762e1aca56c332099069a3181c56398c82a24
@@ -18,19 +18,13 @@ module LolitaBankLink
18
18
  # - bank sends another confirmation and add's VK_AUTO=Y to params
19
19
  def answer
20
20
  response = LolitaBankLink::Response.new(response_params)
21
- if response.update_transaction
22
- if bank_auto_response?
23
- render nothing: true
24
- else
25
- redirect_to response.return_path
26
- end
21
+ response.update_transaction
22
+ if response.success_redirect?
23
+ redirect_to response.return_path
24
+ elsif response.success_response?
25
+ render nothing: true
27
26
  else
28
- if !bank_auto_response? && response.transaction_completed?
29
- redirect_to response.return_path
30
- else
31
- LolitaBankLink.logger.error("[#{session_id}][#{response.paymentable_id}][answer] #{response.error}")
32
- render text: I18n.t("bank_link.wrong_request"), status: 400
33
- end
27
+ render text: I18n.t("bank_link.wrong_request"), status: 400
34
28
  end
35
29
  ensure
36
30
  if response
@@ -40,10 +34,6 @@ module LolitaBankLink
40
34
 
41
35
  private
42
36
 
43
- def bank_auto_response?
44
- params["VK_AUTO"] == "Y"
45
- end
46
-
47
37
  # returns current payment instance from session
48
38
  def set_active_payment
49
39
  if session && session[:payment_data]
@@ -1,9 +1,10 @@
1
1
  module LolitaBankLink
2
2
  class Response
3
- attr_reader :params, :required_params, :crypt, :signature
3
+ attr_reader :params, :required_params, :crypt, :signature, :bank_auto_response
4
4
  attr_accessor :error
5
5
 
6
6
  def initialize params
7
+ @bank_auto_response = params["VK_AUTO"] == "Y"
7
8
  @params = read_required_params(params)
8
9
  @signature = read_signature(params)
9
10
  @crypt = LolitaBankLink::Crypt.new
@@ -47,6 +48,14 @@ module LolitaBankLink
47
48
  transaction && transaction.completed?
48
49
  end
49
50
 
51
+ def success_redirect?
52
+ !bank_auto_response && transaction_completed?
53
+ end
54
+
55
+ def success_response?
56
+ bank_auto_response && transaction_completed?
57
+ end
58
+
50
59
  private
51
60
 
52
61
  def read_signature(params)
@@ -1,3 +1,3 @@
1
1
  module LolitaBankLink
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolita-bank-link
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gatis Tomsons