Class: UssdBase
- Defined in:
- lib/rave_ruby/rave_objects/base/ussd_base.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#handle_charge_response(response, request) ⇒ Object
method to handle ussd charge response.
-
#handle_verify_response(response) ⇒ Object
method to handle ussd verify response.
Methods inherited from Base
#check_passed_parameters, #get_request, #handle_list_bank, #initialize, #post_request
Constructor Details
This class inherits a constructor from Base
Instance Method Details
#handle_charge_response(response, request) ⇒ Object
method to handle ussd charge response
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rave_ruby/rave_objects/base/ussd_base.rb', line 6 def handle_charge_response(response, request) charge_response = response flwRef = charge_response["data"]["flwRef"] txRef = charge_response["data"]["txRef"] status = charge_response["data"]["status"] amount = charge_response["data"]["amount"] charged_amount = charge_response["data"]["charged_amount"] currency = charge_response["data"]["currency"] payment_type = charge_response["data"]["paymentType"] charge_response_code = charge_response["data"]["chargeResponseCode"] = charge_response["data"]["chargeResponseMessage"] validation_instruction = charge_response["data"]["validateInstructions"] bank_list = {"gtb" => "058", "zenith" => "057"} gtb_response_text = "To complete this transaction, please dial *737*50*#{charged_amount.ceil}*159#" if charge_response_code == "02" if request["accountbank"] == bank_list["gtb"] res = {"error": false, "status": status, "validation_required": true, "txRef": txRef, "flwRef": flwRef, "validateInstruction": gtb_response_text, "amount": amount, "currency": currency, "paymentType": payment_type} return JSON.parse(res.to_json) else res = {"error": false, "status": status, "validation_required": true, "txRef": txRef, "flwRef": flwRef, "validateInstruction": validation_instruction, "amount": amount, "currency": currency, "paymentType": payment_type} return JSON.parse(res.to_json) end else res = {"error": false, "status": status, "validation_required": false, "txRef": txRef, "flwRef": flwRef, "amount": amount, "currency": currency, "paymentType": payment_type} return JSON.parse(res.to_json) end end |
#handle_verify_response(response) ⇒ Object
method to handle ussd verify response
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/rave_ruby/rave_objects/base/ussd_base.rb', line 39 def handle_verify_response(response) verify_response = response flwref = verify_response["data"]["flwref"] txref = verify_response["data"]["txref"] status = verify_response["data"]["status"] charged_amount = verify_response["data"]["chargedamount"] amount = verify_response["data"]["amount"] = verify_response["data"]["vbvmessage"] vbvcode = verify_response["data"]["vbvcode"] currency = verify_response["data"]["currency"] charge_code = verify_response["data"]["chargecode"] = verify_response["data"]["chargemessage"] if charge_code == "00" && status == "successful" res = {"error": false, "status": status, "transaction_complete": true, "txref": txref, "flwref": flwref, "amount": amount, "chargedamount": charged_amount, "vbvmessage": , "vbvcode": vbvcode, "currency": currency, "chargecode": charge_code, "chargemessage": } return JSON.parse(res.to_json) else res = {"error": false, "status": status, "transaction_complete": false, "txref": txref, "flwef": flwref, "amount": amount, "chargedamount": charged_amount, "vbvmessage": , "vbvcode": vbvcode, "currency": currency, "charge_code": charge_code, "chargemessage": } return JSON.parse(res.to_json) end end |