Sha256: 0250e9b1ab61a86e881224909a751ebc0dfda857279202c33da48f928bad2afd
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
module Cardflex class TransactionGateway attr_reader :config def initialize(gateway) @gateway = gateway @config = gateway.config end # Three Step API def request(attributes) res = @config.http.post(attributes) _handle_response(res) end # Query API def query(attributes) unless username = @config.username && password = @config.password raise ArgumentError, 'missing username and/or password' end res = @config.http.get(attributes.merge(:username => username, :password => password)) _handle_query_response(res) end def _handle_response(res) if res[:response][:result] == '1' SuccessResponse.new(:transaction => Transaction.new(@gateway, res[:response])) else ErrorResponse.new(@gateway, res[:response]) end end def _handle_query_response(res) if res[:nm_response].keys.include?(:error_response) ErrorResponse.new(@gateway, :result => 3, :result_text => res[:nm_response][:error_response]) else SuccessResponse.new(:transaction => Transaction.new(@gateway, res[:nm_response][:transaction])) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cardflex-ruby-0.1.2 | lib/cardflex/transaction_gateway.rb |
cardflex-ruby-0.1.1 | lib/cardflex/transaction_gateway.rb |