Class: Twocheckout::ValidateResponse
- Inherits:
-
Object
- Object
- Twocheckout::ValidateResponse
- Defined in:
- lib/twocheckout/validate_response.rb
Class Method Summary collapse
- .notification(options) ⇒ Object
- .purchase(options) ⇒ Object
-
.valid?(arg1, arg2, arg3, arg4, key) ⇒ Boolean
Checks against MD5 Hash.
Class Method Details
.notification(options) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/twocheckout/validate_response.rb', line 20 def self.notification() if valid?([:sale_id], [:vendor_id], [:invoice_id], [:secret], [:md5_hash]) {:code => "PASS", :message => "Hash Matched"} else {:code => "FAIL", :message => "Hash Mismatch"} end end |
.purchase(options) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/twocheckout/validate_response.rb', line 11 def self.purchase() oid = [:demo] == 'Y' ? 1 : [:order_number] if valid?([:secret], [:sid], oid, [:total], [:key]) {:code => "PASS", :message => "Hash Matched"} else {:code => "FAIL", :message => "Hash Mismatch"} end end |
.valid?(arg1, arg2, arg3, arg4, key) ⇒ Boolean
Checks against MD5 Hash
7 8 9 |
# File 'lib/twocheckout/validate_response.rb', line 7 def self.valid?(arg1, arg2, arg3, arg4, key) Digest::MD5.hexdigest("#{arg1}#{arg2}#{arg3}#{arg4}").upcase == key end |