Class: MPower::DirectMobile
- Inherits:
-
Checkout::Core
- Object
- Checkout::Core
- MPower::DirectMobile
- Defined in:
- lib/mpower/direct_mobile.rb
Instance Attribute Summary collapse
-
#cancel_reason ⇒ Object
Returns the value of attribute cancel_reason.
-
#mobile_invoice_no ⇒ Object
Returns the value of attribute mobile_invoice_no.
-
#tx_status ⇒ Object
Returns the value of attribute tx_status.
Attributes inherited from Checkout::Core
#description, #invoice_token, #response_code, #response_text, #result, #status, #token, #transaction_id
Instance Method Summary collapse
- #charge(amount, customer_details = {}) ⇒ Object
-
#transaction_status(token) ⇒ Object
Poll this method for completed / pending / failed / cancelled status.
Methods inherited from Checkout::Core
Methods included from Utilities
#hash_to_json, #http_get_request, #http_json_request, #json_to_hash
Instance Attribute Details
#cancel_reason ⇒ Object
Returns the value of attribute cancel_reason.
4 5 6 |
# File 'lib/mpower/direct_mobile.rb', line 4 def cancel_reason @cancel_reason end |
#mobile_invoice_no ⇒ Object
Returns the value of attribute mobile_invoice_no.
4 5 6 |
# File 'lib/mpower/direct_mobile.rb', line 4 def mobile_invoice_no @mobile_invoice_no end |
#tx_status ⇒ Object
Returns the value of attribute tx_status.
4 5 6 |
# File 'lib/mpower/direct_mobile.rb', line 4 def tx_status @tx_status end |
Instance Method Details
#charge(amount, customer_details = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/mpower/direct_mobile.rb', line 5 def charge(amount,customer_details={}) customer_details[:amount] = amount result = http_json_request(MPower::Setup.direct_mobile_charge_base_url,customer_details) if result["response_code"] == "00" @mobile_invoice_no = result["mobile_invoice_no"] push_results(result) true else push_results(result) false end end |
#transaction_status(token) ⇒ Object
Poll this method for completed / pending / failed / cancelled status
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mpower/direct_mobile.rb', line 20 def transaction_status(token) payload = { :token => token } result = http_json_request(MPower::Setup.direct_mobile_tx_status_base_url,payload) if result["response_code"] == "00" @tx_status = result["tx_status"] @mobile_invoice_no = result["mobile_invoice_no"] @cancel_reason = result["cancel_reason"] push_results(result) true else push_results(result) false end end |