class Flutterwave::Pay

Attributes

client[RW]
options[RW]

Public Class Methods

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

Public Instance Methods

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

www.flutterwave.com/documentation/pay/ - Get Linked Accounts

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

  response = post(
    Flutterwave::Utils::Constants::PAY[:linked_accounts_url],
    merchantid: client.merchant_key,
    country: encrypt(:country)
  )

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

www.flutterwave.com/documentation/pay/ - Send

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

  response = post(
    Flutterwave::Utils::Constants::PAY[:send_url],
    merchantid: client.merchant_key,
    accounttoken: encrypt(:accounttoken),
    destbankcode: encrypt(:destbankcode),
    currency: encrypt(:currency),
    country: encrypt(:country),
    transferamount: encrypt(:transferamount),
    uniquereference: encrypt(:uniquereference),
    narration: encrypt(:narration),
    recipientname: encrypt(:recipientname),
    sendername: encrypt(:sendername),
    recipientaccount: encrypt(:recipientaccount)
  )

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

www.flutterwave.com/documentation/pay/ - Get Transaction Status

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

  response = post(
    Flutterwave::Utils::Constants::PAY[:status_url],
    merchantid: client.merchant_key,
    uniquereference: encrypt(:uniquereference),
    country: encrypt(:country)
  )

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

www.flutterwave.com/documentation/pay/ - Validate Step 1

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

  response = post(
    Flutterwave::Utils::Constants::PAY[:validate_url],
    merchantid: client.merchant_key,
    otp: encrypt(:otp),
    relatedreference: encrypt(:relatedreference),
    otptype: encrypt(:otptype),
    country: encrypt(:country)
  )

  Flutterwave::Response.new(response)
end