Class: Momoapi::Disbursement
- Defined in:
- lib/momoapi-ruby/disbursement.rb
Instance Method Summary collapse
- #get_auth_token ⇒ Object
- #get_balance ⇒ Object
- #get_transaction_status(transaction_id) ⇒ Object
- #is_user_active(phone_number) ⇒ Object
-
#transfer(phone_number, amount, external_id, payee_note = '', payer_message = '', currency = 'EUR', callback_url = '') ⇒ Object
The transfer operation is used to transfer an amount from the owner’s account to a payee account.
Methods inherited from Client
#get_credentials, #handle_error, #interpret_response, #prepare_get_request, #send_request
Instance Method Details
#get_auth_token ⇒ Object
10 11 12 13 |
# File 'lib/momoapi-ruby/disbursement.rb', line 10 def get_auth_token path = 'disbursement/token/' super(path, Momoapi.config.disbursement_primary_key) end |
#get_balance ⇒ Object
15 16 17 18 |
# File 'lib/momoapi-ruby/disbursement.rb', line 15 def get_balance path = '/disbursement/v1_0/account/balance' super(path, Momoapi.config.disbursement_primary_key) end |
#get_transaction_status(transaction_id) ⇒ Object
20 21 22 23 |
# File 'lib/momoapi-ruby/disbursement.rb', line 20 def get_transaction_status(transaction_id) path = "/disbursement/v1_0/transfer/#{transaction_id}" super(path, Momoapi.config.disbursement_primary_key) end |
#is_user_active(phone_number) ⇒ Object
57 58 59 60 |
# File 'lib/momoapi-ruby/disbursement.rb', line 57 def is_user_active(phone_number) path = "/disbursement/v1_0/accountholder/msisdn/#{phone_number}/active" super(path, Momoapi.config.disbursement_primary_key) end |
#transfer(phone_number, amount, external_id, payee_note = '', payer_message = '', currency = 'EUR', callback_url = '') ⇒ Object
The transfer operation is used to transfer an amount from the owner’s account to a payee account. The status of the transaction can be validated by using ‘get_transation_status`
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/momoapi-ruby/disbursement.rb', line 29 def transfer(phone_number, amount, external_id, payee_note = '', = '', currency = 'EUR', callback_url = '') Momoapi::Validate.new.validate(phone_number, amount, currency) uuid = SecureRandom.uuid headers = { "X-Target-Environment": Momoapi.config.environment || 'sandbox', "Content-Type": 'application/json', "X-Reference-Id": uuid, "Ocp-Apim-Subscription-Key": Momoapi.config.disbursement_primary_key } headers['X-Callback-Url'] = callback_url unless callback_url.empty? body = { "payee": { "partyIdType": 'MSISDN', "partyId": phone_number }, "payeeNote": payee_note, "payerMessage": , "externalId": external_id, "currency": currency, "amount": amount.to_s } path = '/disbursement/v1_0/transfer' send_request('post', path, headers, body) { transaction_reference: uuid } end |