Class: Paylense::Disbursements

Inherits:
Client
  • Object
show all
Defined in:
lib/paylense-sdk/disbursements.rb

Instance Method Summary collapse

Methods inherited from Client

#create_connection, #get_credentials, #get_transaction_status, #handle_error, #interpret_response, #send_request

Instance Method Details

#transfer(api_key, account_number, amount, merchant_reference, payment_method, provider, currency, narration = '', account_name = '', account_email = '', redirect_url = '', callback_url = '', extra_provider_detail = {}) ⇒ Object

The transfer operation is used to transfer an amount from the payer’s account to a payee account. The status of the transaction can be validated by using ‘get_transation_status`



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/paylense-sdk/disbursements.rb', line 14

def transfer(api_key, , amount, merchant_reference, payment_method, provider, currency,
             narration = '',  = '',  ='', redirect_url = '', callback_url = '',
             extra_provider_detail = {})
  Paylense::Validate.new.validate(, amount)
  merchant_reference = SecureRandom.uuid unless merchant_reference.blank?

  body = {
    "account_number": ,
    "narration": narration,
    "merchant_reference": merchant_reference,
    "amount": amount.to_i,
    "api_key": api_key,
    "payment_method": payment_method,
    "provider": provider,
    "currency": currency,
    "account_name": ,
    "account_email": ,
    "redirect_url": redirect_url,
    "callback_url": callback_url,
    "extra_provider_detail": extra_provider_detail
  }
  path = '/transfer'

  send_request('post', path, body)
  { merchant_reference: merchant_reference }
end