active_merchant_webpay 0.0.5 → 0.0.6
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.
@@ -81,8 +81,9 @@ module ActiveMerchant #:nodoc:
|
|
81
81
|
params['TBK_ORDEN_COMPRA']
|
82
82
|
end
|
83
83
|
|
84
|
-
def fail!
|
84
|
+
def fail!(message=nil)
|
85
85
|
@error = true
|
86
|
+
@message = message
|
86
87
|
end
|
87
88
|
|
88
89
|
def success?
|
@@ -94,7 +95,7 @@ module ActiveMerchant #:nodoc:
|
|
94
95
|
end
|
95
96
|
|
96
97
|
def message
|
97
|
-
RESPONSE_CODES[params['TBK_RESPUESTA']]
|
98
|
+
@message || RESPONSE_CODES[params['TBK_RESPUESTA']]
|
98
99
|
end
|
99
100
|
|
100
101
|
# Check the transaction's validity. This method has to be called after a new
|
@@ -106,30 +107,23 @@ module ActiveMerchant #:nodoc:
|
|
106
107
|
# notify = Webpay::Notification.new(request.raw_post)
|
107
108
|
#
|
108
109
|
# if notify.valid?
|
109
|
-
#
|
110
|
+
# if check order & ammount
|
111
|
+
# # Process Order
|
112
|
+
# else
|
113
|
+
# notify.fail!
|
114
|
+
# end
|
110
115
|
# else
|
111
116
|
# ... log possible hacking attempt ...
|
112
117
|
# end
|
113
118
|
#
|
114
119
|
# render :text => notify.acknowledge
|
115
120
|
# end
|
116
|
-
def valid?
|
117
|
-
|
118
|
-
|
119
|
-
if @valid.nil?
|
120
|
-
file = Tempfile.new 'webpay-mac-check'
|
121
|
-
file.write raw
|
122
|
-
file.close
|
123
|
-
executable = Webpay.cgis_root + '/tbk_check_mac.cgi'
|
124
|
-
@valid = ( `#{executable} #{file.path}`.strip == VALID_MAC_RESPONSE )
|
125
|
-
file.unlink
|
126
|
-
end
|
127
|
-
|
128
|
-
@valid
|
121
|
+
def valid?
|
122
|
+
valid_mac && params['TBK_RESPUESTA'] == '0'
|
129
123
|
end
|
130
124
|
|
131
125
|
def acknowledge
|
132
|
-
|
126
|
+
@error ? FAILURE_RESPONSE : SUCCESS_RESPONSE
|
133
127
|
end
|
134
128
|
|
135
129
|
private
|
@@ -141,6 +135,21 @@ module ActiveMerchant #:nodoc:
|
|
141
135
|
params[key] = value
|
142
136
|
end
|
143
137
|
end
|
138
|
+
|
139
|
+
def valid_mac
|
140
|
+
if @valid_mac.nil?
|
141
|
+
file = Tempfile.new 'webpay-mac-check'
|
142
|
+
file.write raw
|
143
|
+
file.close
|
144
|
+
executable = Webpay.cgis_root + '/tbk_check_mac.cgi'
|
145
|
+
@valid_mac = ( `#{executable} #{file.path}`.strip == VALID_MAC_RESPONSE )
|
146
|
+
file.unlink
|
147
|
+
|
148
|
+
fail! 'Mac Invalido' unless @valid_mac
|
149
|
+
end
|
150
|
+
|
151
|
+
@valid_mac
|
152
|
+
end
|
144
153
|
end
|
145
154
|
end
|
146
155
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 6
|
9
|
+
version: 0.0.6
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- "Sebasti\xC3\xA1n Gamboa"
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-16 00:00:00 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|