class Flutterwave::Account

Attributes

client[RW]
options[RW]

Public Class Methods

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

Public Instance Methods

alt_validate(options = {}) click to toggle source

www.flutterwave.com/documentation/alternative-payments/#validate-ii-alt

# File lib/flutterwave/account.rb, line 135
def alt_validate(options = {})
  @options = options

  request_params = {
    otp: encrypt(:otp),
    phonenumber: encrypt(:phonenumber),
    merchantid: client.merchant_key
  }

  response = post(
    Flutterwave::Utils::Constants::ACCOUNT[:alt_validate_url],
    request_params
  )

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

www.flutterwave.com/documentation/alternative-payments/#charge-ii

# File lib/flutterwave/account.rb, line 70
def charge(options = {})
  @options = options
  options[:country] ||= 'NG'

  request_params = {
    validateoption: encrypt(:validateoption),
    accountnumber: encrypt(:accountnumber),
    bankcode: encrypt(:bankcode),
    amount: encrypt(:amount),
    currency: encrypt(:currency),
    firstname: encrypt(:firstname),
    lastname: encrypt(:lastname),
    email: encrypt(:email),
    narration: encrypt(:narration),
    transactionreference: encrypt(:transactionreference),
    merchantid: client.merchant_key
  }

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

  response = post(
    Flutterwave::Utils::Constants::ACCOUNT[:charge_url],
    request_params
  )

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

www.flutterwave.com/documentation/alternative-payments-recurrent/#initiate

# File lib/flutterwave/account.rb, line 51
def charge_recurrent(options = {})
  @options = options

  request_params = {
    accountToken: encrypt(:accountToken),
    billingamount: encrypt(:billingamount),
    debitnarration: encrypt(:debitnarration),
    merchantid: client.merchant_key
  }

  response = post(
    Flutterwave::Utils::Constants::ACCOUNT[:charge_recurrent_url],
    request_params
  )

  Flutterwave::Response.new(response)
end
encrypt(key) click to toggle source
# File lib/flutterwave/account.rb, line 152
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
initiate_recurrent(options = {}) click to toggle source

www.flutterwave.com/documentation/alternative-payments-recurrent/#initiate

# File lib/flutterwave/account.rb, line 13
def initiate_recurrent(options = {})
  @options = options

  request_params = {
    accountNumber: encrypt(:accountNumber),
    merchantid: client.merchant_key
  }

  response = post(
    Flutterwave::Utils::Constants::ACCOUNT[:initiate_recurrent_url],
    request_params
  )

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

www.flutterwave.com/documentation/alternative-payments/#resend-otp

# File lib/flutterwave/account.rb, line 99
def resend(options = {})
  @options = options

  request_params = {
    validateoption: encrypt(:validateoption),
    transactionreference: encrypt(:transactionreference),
    merchantid: client.merchant_key
  }

  response = post(
    Flutterwave::Utils::Constants::ACCOUNT[:resend_url],
    request_params
  )

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

www.flutterwave.com/documentation/alternative-payments/#validate-ii

# File lib/flutterwave/account.rb, line 117
def validate(options = {})
  @options = options

  request_params = {
    otp: encrypt(:otp),
    transactionreference: encrypt(:transactionreference),
    merchantid: client.merchant_key
  }

  response = post(
    Flutterwave::Utils::Constants::ACCOUNT[:validate_url],
    request_params
  )

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

www.flutterwave.com/documentation/alternative-payments-recurrent/#validate

# File lib/flutterwave/account.rb, line 30
def validate_recurrent(options = {})
  @options = options

  request_params = {
    accountNumber: encrypt(:accountNumber),
    otp: encrypt(:otp),
    reference: encrypt(:reference),
    billingamount: encrypt(:billingamount),
    debitnarration: encrypt(:debitnarration),
    merchantid: client.merchant_key
  }

  response = post(
    Flutterwave::Utils::Constants::ACCOUNT[:validate_recurrent_url],
    request_params
  )

  Flutterwave::Response.new(response)
end