Class: SisowIdeal::Client
- Inherits:
-
Object
- Object
- SisowIdeal::Client
- Includes:
- HTTParty
- Defined in:
- lib/sisow_ideal/client.rb
Instance Method Summary collapse
-
#banklist ⇒ Object
Get the banklist.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#setup_transaction(options = {}) ⇒ Object
Setup a transaction.
- #status_request(options = {}) ⇒ Object
- #valid_response?(params) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
6 7 8 9 10 |
# File 'lib/sisow_ideal/client.rb', line 6 def initialize( = {}) (, :merchantid, :merchantkey) @options = end |
Instance Method Details
#banklist ⇒ Object
Get the banklist
13 14 15 16 17 18 19 20 21 |
# File 'lib/sisow_ideal/client.rb', line 13 def banklist response = Hashie::Mash.new( self.class.get('/DirectoryRequest', :query => @options, :format => :xml ).parsed_response).directoryresponse.directory.issuer response.kind_of?(Array) ? response.map { |b| [b.issuername, b.issuerid] } : [[response.issuername, response.issuerid]] end |
#setup_transaction(options = {}) ⇒ Object
Setup a transaction
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sisow_ideal/client.rb', line 24 def setup_transaction( = {}) (, :issuerid, :amount, :description, :returnurl, :callbackurl, :notifyurl, :purchaseid) sha1 = [ .fetch(:purchaseid), .fetch(:entrancecode), .fetch(:amount), .fetch(:shopid), @options.fetch(:merchantid), @options.fetch(:merchantkey) ].join response = Hashie::Mash.new( self.class.get('/TransactionRequest', :query => (, sha1), :format => :xml ).parsed_response) begin return Hashie::Mash.new( :url => CGI.unescape(response.transactionrequest.transaction.issuerurl), :trxid => response.transactionrequest.transaction.trxid ) rescue raise SisowIdeal::SisowException.new(response.errorresponse.error.errorcode, CGI.unescape(response.errorresponse.error.)) end end |
#status_request(options = {}) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/sisow_ideal/client.rb', line 52 def status_request( = {}) (, :trxid, :shopid) sha1 = [ .fetch(:trxid), .fetch(:shopid), @options.fetch(:merchantid), @options.fetch(:merchantkey) ].join response = Hashie::Mash.new( self.class.get('/StatusRequest', :query => (, sha1), :format => :xml ).parsed_response) begin return response.statusresponse.transaction rescue raise SisowIdeal::SisowException.new(response.errorresponse.error.errorcode, CGI.unescape(response.errorresponse.error.)) end end |
#valid_response?(params) ⇒ Boolean
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/sisow_ideal/client.rb', line 75 def valid_response?(params) sha1 = [ params.fetch(:trxid), params.fetch(:ec), params.fetch(:status), @options.fetch(:merchantid), @options.fetch(:merchantkey) ].join Digest::SHA1.hexdigest(sha1) == params[:sha1] end |