Class: WebpayInterswitch::TransactionQuery
- Inherits:
-
Object
- Object
- WebpayInterswitch::TransactionQuery
- Includes:
- Core
- Defined in:
- lib/webpay_interswitch/transaction_query.rb
Constant Summary collapse
- TEST_URL =
'https://sandbox.interswitchng.com/webpay/api/v1/gettransaction.json'
- LIVE_URL =
'https://webpay.interswitchng.com/paydirect/api/v1/gettransaction.json'
Instance Attribute Summary collapse
-
#amount ⇒ Object
resp and desc are empty when transaction is successful txnref is the unique number sent in request.
-
#cardNum ⇒ Object
resp and desc are empty when transaction is successful txnref is the unique number sent in request.
-
#desc ⇒ Object
resp and desc are empty when transaction is successful txnref is the unique number sent in request.
-
#payRef ⇒ Object
resp and desc are empty when transaction is successful txnref is the unique number sent in request.
-
#resp ⇒ Object
resp and desc are empty when transaction is successful txnref is the unique number sent in request.
-
#response ⇒ Object
resp and desc are empty when transaction is successful txnref is the unique number sent in request.
-
#retRef ⇒ Object
resp and desc are empty when transaction is successful txnref is the unique number sent in request.
-
#txnref ⇒ Object
resp and desc are empty when transaction is successful txnref is the unique number sent in request.
Instance Method Summary collapse
-
#error_message ⇒ Object
Returns error message if present.
-
#fetch_response ⇒ Object
fetches a returns a transaction as json.
- #full_error_message ⇒ Object
-
#initialize(post_params = {}, amount) ⇒ TransactionQuery
constructor
A new instance of TransactionQuery.
-
#query_error_message ⇒ Object
Returns error message recd from the gateway if the txn query was failed.
-
#success? ⇒ Boolean
Returns true or false.
- #transaction_url ⇒ Object
Methods included from Core
Constructor Details
#initialize(post_params = {}, amount) ⇒ TransactionQuery
Returns a new instance of TransactionQuery.
29 30 31 32 33 34 35 36 |
# 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 |
Instance Attribute Details
#amount ⇒ Object
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.
23 24 25 |
# File 'lib/webpay_interswitch/transaction_query.rb', line 23 def amount @amount end |
#cardNum ⇒ Object
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.
23 24 25 |
# File 'lib/webpay_interswitch/transaction_query.rb', line 23 def cardNum @cardNum end |
#desc ⇒ Object
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.
23 24 25 |
# File 'lib/webpay_interswitch/transaction_query.rb', line 23 def desc @desc end |
#payRef ⇒ Object
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.
23 24 25 |
# File 'lib/webpay_interswitch/transaction_query.rb', line 23 def payRef @payRef end |
#resp ⇒ Object
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.
23 24 25 |
# File 'lib/webpay_interswitch/transaction_query.rb', line 23 def resp @resp end |
#response ⇒ Object
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.
23 24 25 |
# File 'lib/webpay_interswitch/transaction_query.rb', line 23 def response @response end |
#retRef ⇒ Object
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.
23 24 25 |
# File 'lib/webpay_interswitch/transaction_query.rb', line 23 def retRef @retRef end |
#txnref ⇒ Object
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.
23 24 25 |
# File 'lib/webpay_interswitch/transaction_query.rb', line 23 def txnref @txnref end |
Instance Method Details
#error_message ⇒ Object
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.
59 60 61 |
# File 'lib/webpay_interswitch/transaction_query.rb', line 59 def @desc.strip.gsub(',', '') end |
#fetch_response ⇒ Object
fetches a returns a transaction as json
39 40 41 42 43 44 45 46 |
# 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 |
#full_error_message ⇒ Object
53 54 55 |
# File 'lib/webpay_interswitch/transaction_query.rb', line 53 def "#{ }. #{ }" end |
#query_error_message ⇒ Object
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.
66 67 68 |
# File 'lib/webpay_interswitch/transaction_query.rb', line 66 def @response['ResponseDescription'] unless success? end |
#success? ⇒ Boolean
Returns true or false
49 50 51 |
# File 'lib/webpay_interswitch/transaction_query.rb', line 49 def success? @response['ResponseCode'] == '00' end |
#transaction_url ⇒ Object
70 71 72 |
# File 'lib/webpay_interswitch/transaction_query.rb', line 70 def transaction_url WebpayInterswitch::Gateway.test ? TEST_URL : LIVE_URL end |