class WebpayInterswitch::TransactionQuery
This class can be used to fetch transaction details Initialization Parameters:
post_params: Parameters sent via POST by the gateway at the redirect_url amount: This is needed to detect the masquerading or parameter tampering to alter the amount. WebpayInterswitch::TransactionQuery.new
(params, amount)
Constants
- LIVE_URL
- TEST_URL
Attributes
resp and desc are empty when transaction is successful txnref is the unique number sent in request. cardNum is always zero apprAmt is always zero response is populated when a transactions search query is sent.
resp and desc are empty when transaction is successful txnref is the unique number sent in request. cardNum is always zero apprAmt is always zero response is populated when a transactions search query is sent.
resp and desc are empty when transaction is successful txnref is the unique number sent in request. cardNum is always zero apprAmt is always zero response is populated when a transactions search query is sent.
resp and desc are empty when transaction is successful txnref is the unique number sent in request. cardNum is always zero apprAmt is always zero response is populated when a transactions search query is sent.
resp and desc are empty when transaction is successful txnref is the unique number sent in request. cardNum is always zero apprAmt is always zero response is populated when a transactions search query is sent.
resp and desc are empty when transaction is successful txnref is the unique number sent in request. cardNum is always zero apprAmt is always zero response is populated when a transactions search query is sent.
resp and desc are empty when transaction is successful txnref is the unique number sent in request. cardNum is always zero apprAmt is always zero response is populated when a transactions search query is sent.
resp and desc are empty when transaction is successful txnref is the unique number sent in request. cardNum is always zero apprAmt is always zero response is populated when a transactions search query is sent.
Public Class Methods
# File lib/webpay_interswitch/transaction_query.rb, line 29 def initialize(post_params={}, amount) post_params.to_hash.symbolize_keys! post_params.each_pair do |key, val| instance_variable_set("@#{key}", val) end @amount = amount fetch_response end
Public Instance Methods
Returns error message if present. Else returns a blank string. This is generally due to incorrect parameters such as product_id, pay_item_id etc.
# File lib/webpay_interswitch/transaction_query.rb, line 59 def error_message @desc.strip.gsub(',', '') end
fetches a returns a transaction as json
# File lib/webpay_interswitch/transaction_query.rb, line 39 def fetch_response uri = URI.parse(make_request) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE @response = JSON.parse http.get(uri.request_uri, { 'Hash' => sha_hash(string_for_get_query) }).body end
# File lib/webpay_interswitch/transaction_query.rb, line 53 def full_error_message "#{ error_message }. #{ query_error_message }" end
Returns error message recd from the gateway if the txn query was failed. else, returns nil This is due to: incorrect amount, invalid card number etc.
# File lib/webpay_interswitch/transaction_query.rb, line 66 def query_error_message @response['ResponseDescription'] unless success? end
Returns true or false
# File lib/webpay_interswitch/transaction_query.rb, line 49 def success? @response['ResponseCode'] == '00' end
# File lib/webpay_interswitch/transaction_query.rb, line 70 def transaction_url WebpayInterswitch::Gateway.test ? TEST_URL : LIVE_URL end
Private Instance Methods
# File lib/webpay_interswitch/transaction_query.rb, line 76 def make_request url = transaction_url url += "?productid=#{WebpayInterswitch::Gateway.product_id}" url += "&transactionreference=#{@txnref}" url += "&amount=#{@amount}" end
Returns a string that is used to compute the sha hash for get transaction query on webpay.
# File lib/webpay_interswitch/transaction_query.rb, line 84 def string_for_get_query WebpayInterswitch::Gateway.product_id + @txnref.to_s + WebpayInterswitch::Gateway.mac_key end