class Flutterwave::BVN

Attributes

client[RW]
options[RW]

Public Class Methods

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

Public Instance Methods

encrypt(key) click to toggle source
# File lib/flutterwave/bvn.rb, line 65
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
resend(options = {}) click to toggle source

www.flutterwave.com/documentation/compliance/ - Resend OTP

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

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

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

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

www.flutterwave.com/documentation/compliance/ - Validate (This is used to validate the OTP entered by the user)

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

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

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

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

www.flutterwave.com/documentation/compliance/ - Verify (request a user enter their BVN for verification)

# File lib/flutterwave/bvn.rb, line 11
def verify(options = {})
  @options = options

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

  response = post(
    Flutterwave::Utils::Constants::BVN[:verify_url],
    request_params
  )

  Flutterwave::Response.new(response)
end