Class: Flutterwave::Card
- Inherits:
-
Object
- Object
- Flutterwave::Card
- Includes:
- Helpers
- Defined in:
- lib/flutterwave/card.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
- #capture(options = {}) ⇒ Object
- #charge(options = {}) ⇒ Object
- #encrypt(key) ⇒ Object
-
#enquiry(options = {}) ⇒ Object
www.flutterwave.com/documentation/card-enquiry/ - Card Enquiry.
-
#initialize(client) ⇒ Card
constructor
A new instance of Card.
- #preauthorize(options = {}) ⇒ Object
- #recurrent_charge(options = {}) ⇒ Object
- #refund(options = {}) ⇒ Object
- #tokenize(options = {}) ⇒ Object
- #validate_charge(options = {}) ⇒ Object
-
#validate_enquiry(options = {}) ⇒ Object
www.flutterwave.com/documentation/card-enquiry/ - Validate.
- #verify(options = {}) ⇒ Object
- #void(options = {}) ⇒ Object
Methods included from Helpers
Constructor Details
#initialize(client) ⇒ Card
Returns a new instance of Card.
8 9 10 |
# File 'lib/flutterwave/card.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/card.rb', line 6 def client @client end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/flutterwave/card.rb', line 6 def @options end |
Instance Method Details
#capture(options = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/flutterwave/card.rb', line 60 def capture( = {}) @options = [:country] ||= 'NG' request_params = { amount: encrypt(:amount), currency: encrypt(:currency), country: encrypt(:country), trxreference: encrypt(:trxreference), trxauthorizeid: encrypt(:trxauthorizeid), chargetoken: encrypt(:chargetoken), merchantid: client.merchant_key } response = post( Flutterwave::Utils::Constants::CARD[:capture_url], request_params ) Flutterwave::Response.new(response) end |
#charge(options = {}) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/flutterwave/card.rb', line 168 def charge( = {}) @options = [:country] ||= 'NG' request_params = { amount: encrypt(:amount), authmodel: encrypt(:authmodel), cardno: encrypt(:cardno), currency: encrypt(:currency), custid: encrypt(:custid), country: encrypt(:country), cvv: encrypt(:cvv), expirymonth: encrypt(:expirymonth), expiryyear: encrypt(:expiryyear), narration: encrypt(:narration), merchantid: client.merchant_key } request_params[:pin] = encrypt(:pin) if [:authmodel] == 'PIN' request_params[:bvn] = encrypt(:bvn) if [:authmodel] == 'BVN' request_params[:responseurl] = encrypt(:responseurl) if [:authmodel] == 'VBVSECURECODE' request_params[:cardtype] = encrypt(:cardtype) if [:cardtype] response = post( Flutterwave::Utils::Constants::CARD[:charge_url], request_params ) Flutterwave::Response.new(response) end |
#encrypt(key) ⇒ Object
263 264 265 266 267 268 269 270 |
# File 'lib/flutterwave/card.rb', line 263 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 |
#enquiry(options = {}) ⇒ Object
www.flutterwave.com/documentation/card-enquiry/ - Card Enquiry
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/flutterwave/card.rb', line 127 def enquiry( = {}) @options = request_params = { cardno: encrypt(:cardno), cvv: encrypt(:cvv), expirymonth: encrypt(:expirymonth), expiryyear: encrypt(:expiryyear), pin: encrypt(:pin), trxreference: encrypt(:trxreference), merchantid: client.merchant_key } response = post( Flutterwave::Utils::Constants::CARD[:enquiry_url], request_params ) Flutterwave::Response.new(response) end |
#preauthorize(options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/flutterwave/card.rb', line 39 def ( = {}) @options = [:country] ||= 'NG' request_params = { amount: encrypt(:amount), currency: encrypt(:currency), chargetoken: encrypt(:chargetoken), country: encrypt(:country), merchantid: client.merchant_key } response = post( Flutterwave::Utils::Constants::CARD[:preauthorize_url], request_params ) Flutterwave::Response.new(response) end |
#recurrent_charge(options = {}) ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/flutterwave/card.rb', line 222 def recurrent_charge( = {}) @options = [:country] ||= 'NG' request_params = { amount: encrypt(:amount), currency: encrypt(:currency), custid: encrypt(:custid), country: encrypt(:country), narration: encrypt(:narration), chargetoken: encrypt(:chargetoken), merchantid: client.merchant_key } request_params[:cardtype] = encrypt(:cardtype) if [:cardtype] response = post( Flutterwave::Utils::Constants::CARD[:charge_url], request_params ) Flutterwave::Response.new(response) end |
#refund(options = {}) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/flutterwave/card.rb', line 83 def refund( = {}) @options = [:country] ||= 'NG' request_params = { amount: encrypt(:amount), currency: encrypt(:currency), country: encrypt(:country), trxreference: encrypt(:trxreference), trxauthorizeid: encrypt(:trxauthorizeid), merchantid: client.merchant_key } response = post( Flutterwave::Utils::Constants::CARD[:refund_url], request_params ) Flutterwave::Response.new(response) end |
#tokenize(options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/flutterwave/card.rb', line 13 def tokenize( = {}) @options = [:country] ||= 'NG' request_params = { validateoption: encrypt(:validateoption), authmodel: encrypt(:authmodel), cardno: encrypt(:cardno), cvv: encrypt(:cvv), country: encrypt(:country), expirymonth: encrypt(:expirymonth), expiryyear: encrypt(:expiryyear), merchantid: client.merchant_key } request_params[:bvn] = encrypt(:bvn) if [:authmodel] == 'BVN' response = post( Flutterwave::Utils::Constants::CARD[:tokenize_url], request_params ) Flutterwave::Response.new(response) end |
#validate_charge(options = {}) ⇒ Object
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/flutterwave/card.rb', line 204 def validate_charge( = {}) @options = request_params = { otp: encrypt(:otp), otptransactionidentifier: encrypt(:otptransactionidentifier), merchantid: client.merchant_key } response = post( Flutterwave::Utils::Constants::CARD[:validate_charge_url], request_params ) Flutterwave::Response.new(response) end |
#validate_enquiry(options = {}) ⇒ Object
www.flutterwave.com/documentation/card-enquiry/ - Validate
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/flutterwave/card.rb', line 149 def validate_enquiry( = {}) @options = request_params = { otp: encrypt(:otp), otptransactionidentifier: encrypt(:otptransactionidentifier), trxreference: encrypt(:trxreference), merchantid: client.merchant_key } response = post( Flutterwave::Utils::Constants::CARD[:validate_enquiry_url], request_params ) Flutterwave::Response.new(response) end |
#verify(options = {}) ⇒ Object
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/flutterwave/card.rb', line 247 def verify( = {}) @options = request_params = { trxreference: encrypt(:trxreference), merchantid: client.merchant_key } response = post( Flutterwave::Utils::Constants::CARD[:verify_url], request_params ) Flutterwave::Response.new(response) end |
#void(options = {}) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/flutterwave/card.rb', line 105 def void( = {}) @options = [:country] ||= 'NG' request_params = { amount: encrypt(:amount), currency: encrypt(:currency), country: encrypt(:country), trxreference: encrypt(:trxreference), trxauthorizeid: encrypt(:trxauthorizeid), merchantid: client.merchant_key } response = post( Flutterwave::Utils::Constants::CARD[:void_url], request_params ) Flutterwave::Response.new(response) end |