Class: MobileMoneyBase

Inherits:
Base
  • Object
show all
Defined in:
lib/rave_ruby/rave_objects/base/mobile_money_base.rb

Direct Known Subclasses

MobileMoney, UgandaMobileMoney, ZambiaMobileMoney

Instance Attribute Summary

Attributes inherited from Base

#get_hashed_key, #rave_object

Instance Method Summary collapse

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) ⇒ Object

method to handle mobile money charge response



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rave_ruby/rave_objects/base/mobile_money_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"]
    currency = charge_response["data"]["currency"]
    payment_type = charge_response["data"]["paymentType"]
    validate_instruction = charge_response["data"]["validateInstruction"]
    auth_model_used = charge_response["data"]["authModelUsed"]
    charge_response_code = charge_response["data"]["chargeResponseCode"]
    charge_response_message = charge_response["data"]["chargeResponseMessage"]


    if charge_response_code == "00"
        res = {"error": false, "status": status, "validation_required": false, "txRef": txRef, "flwRef": flwRef, "amount": amount, "currency": currency, "validateInstruction": validate_instruction, "authModelUsed": auth_model_used, "paymentType": payment_type}
        return JSON.parse(res.to_json)
    else
        res = {"error": false, "status": status, "validation_required": true, "txRef": txRef, "flwRef": flwRef, "amount": amount, "currency": currency, "validateInstruction": validate_instruction, "authModelUsed": auth_model_used, "paymentType": payment_type}
        return JSON.parse(res.to_json)
    end
end

#handle_verify_response(response) ⇒ Object

method to handle mobile money verify response



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rave_ruby/rave_objects/base/mobile_money_base.rb', line 31

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": false, "data": verify_response["data"]}
        return JSON.parse(res.to_json)
    end
end