Class: Flutterwave::BVN

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/flutterwave/bvn.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#encrypt_data, #post

Constructor Details

#initialize(client) ⇒ BVN

Returns a new instance of BVN.



6
7
8
# File 'lib/flutterwave/bvn.rb', line 6

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/flutterwave/bvn.rb', line 4

def client
  @client
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/flutterwave/bvn.rb', line 4

def options
  @options
end

Instance Method Details

#encrypt(key) ⇒ Object



65
66
67
68
69
70
71
72
# 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 = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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 = {}) ⇒ Object

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



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# 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 = {}) ⇒ Object

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



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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