class Flutterwave::ACH

Attributes

client[RW]
options[RW]

Public Class Methods

new(client) click to toggle source
# File lib/flutterwave/ach.rb, line 6
def initialize(client)
  @client = client
end

Public Instance Methods

add_user(options = {}) click to toggle source

www.flutterwave.com/documentation/ach-payments/#add-user

# File lib/flutterwave/ach.rb, line 34
def add_user(options = {})
  @options = options

  request_params = {
    username: encrypt(:username),
    password: encrypt(:password),
    email: encrypt(:email),
    institution: encrypt(:institution),
    merchantid: client.merchant_key
  }

  request_params[:pin] = encrypt(:pin) if options[:pin]

  response = post(
    Flutterwave::Utils::Constants::ACH[:add_user_url],
    request_params
  )

  Flutterwave::Response.new(response)
end
charge(options = {}) click to toggle source

www.flutterwave.com/documentation/ach-payments/#charge

# File lib/flutterwave/ach.rb, line 56
def charge(options = {})
  @options = options

  response = post(
    Flutterwave::Utils::Constants::ACH[:charge_url],
    publictoken: encrypt(:publictoken),
    accountid: encrypt(:accountid),
    custid: encrypt(:custid),
    narration: encrypt(:narration),
    trxreference: encrypt(:trxreference),
    amount: encrypt(:amount),
    currency: encrypt(:currency),
    merchantid: client.merchant_key
  )

  Flutterwave::Response.new(response)
end
encrypt(key) click to toggle source
# File lib/flutterwave/ach.rb, line 74
def encrypt(key)
  plain_text = options[key].to_s
  raise Flutterwave::Utils::MissingKeyError.new(
    "#{key.capitalize} key required!"
  ) if plain_text.empty?

  encrypt_data(plain_text, client.api_key)
end
find_by_id(options = {}) click to toggle source

www.flutterwave.com/documentation/ach-payments/#get-institution-by-id

# File lib/flutterwave/ach.rb, line 21
def find_by_id(options = {})
  @options = options

  response = post(
    Flutterwave::Utils::Constants::ACH[:id_url],
    institutionid: encrypt(:id),
    merchantid: client.merchant_key
  )

  Flutterwave::Response.new(response)
end
list() click to toggle source

www.flutterwave.com/documentation/ach-payments/#get-institutions

# File lib/flutterwave/ach.rb, line 11
def list
  response = post(
    Flutterwave::Utils::Constants::ACH[:list_url],
    merchantid: client.merchant_key
  )

  Flutterwave::Response.new(response)
end