Class: Mpesa::Payout

Inherits:
Resource show all
Defined in:
lib/mpesa/resources/payout.rb

Constant Summary collapse

PATH =
'mpesa/b2c/v1/paymentrequest'

Instance Attribute Summary

Attributes inherited from Resource

#args, #client

Instance Method Summary collapse

Methods inherited from Resource

#format_phone, #get_request, #handle_response, #initialize, #post_request

Constructor Details

This class inherits a constructor from Mpesa::Resource

Instance Method Details

#bodyObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/mpesa/resources/payout.rb', line 11

def body
  {
    'InitiatorName': args[:initiator_username],
    'SecurityCredential': credentials,
    'CommandID': args[:command_id],
    'Amount': args[:amount],
    'PartyA': client.shortcode || args[:shortcode],
    'PartyB': format_phone(args[:phone]),
    'Remarks': args[:remarks],
    'QueueTimeOutURL': args[:timeout_url],
    'ResultURL': args[:result_url],
    'Occasion': args[:occasion]
  }
end

#callObject



7
8
9
# File 'lib/mpesa/resources/payout.rb', line 7

def call
  Object.new post_request(url: PATH, body: body).body
end

#credentialsObject



26
27
28
# File 'lib/mpesa/resources/payout.rb', line 26

def credentials
  SecurityCred.new(args[:initiator_password], client.env).password_credential
end