Class: PreauthBase
- Defined in:
- lib/rave_ruby/rave_objects/base/preauth_base.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#handle_capture_response(response) ⇒ Object
method to handle capture response.
-
#handle_charge_response(response) ⇒ Object
method to handle preauth charge response.
-
#handle_refund_void_response(response) ⇒ Object
method to handle refund or void response.
-
#handle_verify_response(response) ⇒ Object
method to handle verify preauth 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_capture_response(response) ⇒ Object
method to handle capture response
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rave_ruby/rave_objects/base/preauth_base.rb', line 32 def handle_capture_response(response) capture_response = response flwRef = capture_response["data"]["flwRef"] txRef = capture_response["data"]["txRef"] status = capture_response["data"]["status"] = capture_response["message"] payment_type = capture_response["data"]["paymentType"] amount = capture_response["data"]["amount"] charge_response_code = capture_response["data"]["chargeResponseCode"] = capture_response["data"]["chargeResponseMessage"] currency = capture_response["data"]["currency"] if charge_response_code == "02" res = {"error": false, "status": status, "validation_required": true, "txRef": txRef, "flwRef": flwRef, "amount": amount, "currency": currency, "chargeResponseCode": charge_response_code, "chargeResponseMessage": , "paymentType": payment_type} return JSON.parse(res.to_json) else res = {"error": false, "status": status, "message": , "validation_required": false, "txRef": txRef, "flwRef": flwRef, "amount": amount, "currency": currency, "chargeResponseCode": charge_response_code, "chargeResponseMessage": , "paymentType": payment_type} return JSON.parse(res.to_json) end end |
#handle_charge_response(response) ⇒ Object
method to handle preauth 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 |
# File 'lib/rave_ruby/rave_objects/base/preauth_base.rb', line 6 def handle_charge_response(response) charge_response = response flwRef = charge_response["data"]["flwRef"] txRef = charge_response["data"]["txRef"] status = charge_response["data"]["status"] amount = charge_response["data"]["amount"] = charge_response["message"] 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"]["validateInstruction"] if charge_response_code == "02" res = {"error": false, "status": status, "message": , "validation_required": true, "txRef": txRef, "flwRef": flwRef, "validateInstruction": validation_instruction, "amount": amount, "currency": currency, "paymentType": payment_type} return JSON.parse(res.to_json) else res = {"error": false, "status": status, "message": , "validation_required": false, "txRef": txRef, "flwRef": flwRef, "amount": amount, "currency": currency, "paymentType": payment_type} return JSON.parse(res.to_json) end end |
#handle_refund_void_response(response) ⇒ Object
method to handle refund or void response
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rave_ruby/rave_objects/base/preauth_base.rb', line 55 def handle_refund_void_response(response) refund_void_response = response status = refund_void_response["data"]["status"] charge_response_code = refund_void_response["data"]["chargeResponseCode"] if charge_response_code == "02" res = {"error": false, "status": status, "data": refund_void_response["data"]} return JSON.parse(res.to_json) else res = {"error": false, "status": status, "data": refund_void_response["data"]} return JSON.parse(res.to_json) end end |
#handle_verify_response(response) ⇒ Object
method to handle verify preauth response
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rave_ruby/rave_objects/base/preauth_base.rb', line 71 def handle_verify_response(response) verify_response = response status = verify_response["data"]["status"] charge_code = verify_response["data"]["chargecode"] if charge_code == "00" && status == "successful" res = {"error": false, "transaction_complete": true, "data": verify_response["data"]} return JSON.parse(res.to_json) else res = {"error": false, "transaction_complete": true, "data": verify_response["data"]} return JSON.parse(res.to_json) end end |