Class: Flutterwave::Account
- Inherits:
-
Object
- Object
- Flutterwave::Account
- Includes:
- Helpers
- Defined in:
- lib/flutterwave/account.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #alt_validate(options = {}) ⇒ Object
- #charge(options = {}) ⇒ Object
- #charge_recurrent(options = {}) ⇒ Object
- #encrypt(key) ⇒ Object
-
#initialize(client) ⇒ Account
constructor
A new instance of Account.
- #initiate_recurrent(options = {}) ⇒ Object
- #resend(options = {}) ⇒ Object
- #validate(options = {}) ⇒ Object
- #validate_recurrent(options = {}) ⇒ Object
Methods included from Helpers
Constructor Details
#initialize(client) ⇒ Account
Returns a new instance of Account.
8 9 10 |
# File 'lib/flutterwave/account.rb', line 8 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/flutterwave/account.rb', line 6 def client @client end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/flutterwave/account.rb', line 6 def @options end |
Instance Method Details
#alt_validate(options = {}) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/flutterwave/account.rb', line 135 def alt_validate( = {}) @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 = {}) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/flutterwave/account.rb', line 70 def charge( = {}) @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 [:passcode] response = post( Flutterwave::Utils::Constants::ACCOUNT[:charge_url], request_params ) Flutterwave::Response.new(response) end |
#charge_recurrent(options = {}) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/flutterwave/account.rb', line 51 def charge_recurrent( = {}) @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) ⇒ Object
152 153 154 155 156 157 158 159 |
# File 'lib/flutterwave/account.rb', line 152 def encrypt(key) plain_text = [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 = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/flutterwave/account.rb', line 13 def initiate_recurrent( = {}) @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 = {}) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/flutterwave/account.rb', line 99 def resend( = {}) @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 = {}) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/flutterwave/account.rb', line 117 def validate( = {}) @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 = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/flutterwave/account.rb', line 30 def validate_recurrent( = {}) @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 |