Skip to content

Repository files navigation

Flutterwave v3 Ruby Library

This is a Ruby gem for easy integration of Flutterwave V3 API for various applications written in Ruby language from Flutterwave. See Here for Flutterwave V3 API Docs.

Installation

Add this line to your application's Gemfile:

gem'flutterwave_sdk'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install flutterwave_sdk

Usage

Instantiate Flutterwave Object

To use Flutterwave Ruby SDK, you need to instantiate the RaveRuby class with your API keys which are your public, secret and encryption keys. We recommend that you store your API keys in your environment variable named FLUTTERWAVE_PUBLIC_KEY, FLUTTERWAVE_SECRET_KEY and FLUTTERWAVE_ENCRYPTION_KEY. Instantiating your flutterwave object after adding your API keys in your environment is as illustrated below:

payment=Flutterwave.new

This throws a FLUTTERWAVEBadKeyError if no key is found in the environment variable or invalid public or secret key is found.

Instantiate FLutterwave object in sandbox without environment variable:

You can instantiate your Flutterwave object by setting your public, secret and encryption keys by passing them as an argument of the Flutterwave class just as displayed below:

payment=Flutterwave.new("FLWPUBK-xxxxxxxxxxx-X","FLWSECK-xxxxxxxxx-X","xxxxxxxxxxx")

NOTE: It is best practice to always set your API keys to your environment variable for security purpose. Please be warned not use this package without setting your API keys in your environment variables in production.

To instantiate Flutterwave object in production with environment variable:

Simply use it as displayed below:

Payment=Flutterwave.new("YOUR_FLUTTERWAVE_LIVE_PUBLIC_KEY","YOUR_FLUTTERWAVE_LIVE_SECRET_KEY","YOUR_ENCRYPTION_KEY",true)

Flutterwave Objects

Card.new(payment)

NB - Flutterwave's direct card charge endpoint requires PCI-DSS compliance

To charge cards, you will need to be PCI DSS compliant. If you are, you can proceed to charge cards. Alternatively, you can use any of our other payment methods such as Standard, Inline or SDKs which do not require processing card details directly and do not also require payload encryption.

To perform account transactions, instantiate the card object and pass Flutterwave object as its argument.

Its functions includes:

  • .initiate_charge
  • .validate_charge
  • .verify_charge

Full Account Transaction Flow

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxxxx-X","FLWSECK-xxxxxxxxx-X","xxxxxxxxxxxxxxxxxxxxxxx")# This is used to perform card chargepayload={"card_number"=>"5531886652142950","cvv"=>"564","expiry_month"=>"09","expiry_year"=>"22","currency"=>"NGN","amount"=>"10","email"=>"xxxxxxxxxx@gmail.com","fullname"=>"Test Name","tx_ref"=>"MC-3243e-if-12","redirect_url"=>"https://webhook.site/399"}charge_card=Card.new(payment)response=charge_card.initiate_charge(payload)putsresponse# update payload with suggested authifresponse["meta"]["authorization"]["mode"]suggested_auth=response["meta"]["authorization"]["mode"]auth_arg=charge_card.get_auth_type(suggested_auth)ifauth_arg == :pinupdated_payload=charge_card.update_payload(suggested_auth,payload,pin: {"pin"=>"3310"})elsifauth_arg == :addressupdated_payload=charge_card.update_payload(suggested_auth,payload,address:{"zipcode"=>"07205","city"=>"Hillside","address"=>"470 Mundet PI","state"=>"NJ","country"=>"US"})end# perform the second charge after payload is updated with suggested authresponse=charge_card.initiate_charge(updated_payload)printresponse# perform validation if it is requiredifresponse["data"]["status"] == "pending" || "success-pending-validation"response=charge_card.validate_charge(response["data"]["flw_ref"],"12345")printresponseendelse# You can handle the get the auth url from this response and load it for the customer to complete the transaction if an auth url is returned in the response.printresponseend# verify chargeresponse=charge_card.verify_charge(response["data"]["id"])printresponse

AccountPayment.new(payment)

Its functions includes:

  • .initiate_charge
  • .validate_charge
  • .verify_charge

Full Account Transaction Flow

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxxxx-X","FLWSECK-xxxxxxx-X","xxxxxxx")payload={"tx_ref"=>"MC-1585230ew9v505010","amount"=>"100","account_bank"=>"044","account_number"=>"0690000037","currency"=>"NGN","email"=>"xxxxxxx@gmail.com","phone_number"=>"09000000000","fullname"=>"Test Name"}account_payment_ng=AccountPayment.new(payment)response=account_payment_ng.initiate_charge(payload)printresponse#validate payment with OTPifresponse["data"]["meta"]["authorization"]["mode"] == "otp"response=account_payment_ng.validate_charge(response["data"]["flw_ref"],"12345")printresponseelseprintresponseend#verify transactionresponse=account_payment_ng.verify_charge(response["data"]["tx_ref"])printresponse

Bank.new(payment)

Its functions includes:

  • .get_all_banks
  • .get_bank_branch

See the full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxxxx-X","FLWSECK-xxxxxxxxxx-X","xxxxxxxxx")bank=Bank.new(payment)#get all banksresponse=bank.get_all_banks("NG")printresponse# get bank branchesresponse=bank.get_bank_branch(280)printresponse

Bills.new(payment)

Its functions includes:

  • .create_bill_payment
  • .create_bulk_bill_payments
  • .get_status_of_a_bill_payment
  • .update_bills_order
  • .validate_bill_service
  • .get_bill_categories
  • .get_bill_payment_agencies
  • .get_amount_for_a_product
  • .get_bill_payments
  • .get_products_under_an_agency
  • .create_order_using_billing_code_and_productid

See full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK_TEST-3xxxxxxxxxx-X","FLWSECK_TEST-xxxxxxxxx-X","xxxxxxxxxxxxx")bill=Bills.new(payment)# Create a bill payment payload={"country"=>"NG","customer"=>"+23490803840303","amount"=>500,"recurrence"=>"ONCE","type"=>"AIRTIME","reference"=>"ifunaya-0987654"}response=bill.create_bill_payment(payload)printresponse#bulk bill paymentspayload={"bulk_reference"=>"edf-12de5223d2f32","callback_url"=>"https://webhook.site/5f9a659a-11a2-4925-89cf-8a59ea6a019a","bulk_data"=>[{"country"=>"NG","customer"=>"+23490803840303","amount"=>500,"recurrence"=>"WEEKLY","type"=>"AIRTIME","reference"=>"930049200929"},{"country"=>"NG","customer"=>"+23490803840304","amount"=>500,"recurrence"=>"ONCE","type": "AIRTIME","reference"=>"930004912332"}]}response=bill.create_bulk_bill_payments(payload)printresponse#get the status of a bill paymentresponse=bill.get_status_of_a_bill_payment("BPUSSD1591303717500102")printresponse#get billers categoriesresponse=bill.get_bill_categoriesprintresponse

BankTransfer.new(payment)

Its functions includes:

  • .initiate_charge
  • .verify_charge

See full flow below

require'./flutterwave_sdk'# This is a FLutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxxxxxx-X","FLWSECK-xxxxxxxxx-X","xxxxxxxxxxx")payload={"tx_ref"=>"MC-158523095056793","amount"=>"1500","email"=>"xxxxxxxxx@gmail.com","phone_number"=>"054709929220","currency"=>"NGN","duration"=>2,"frequency"=>5,"narration"=>"All star college salary for May","is_permanent"=>1}bank_transfer=BankTransfer.new(payment)response=bank_transfer.initiate_charge(payload)printresponse# verify transactionresponse=bank_transfer.verify_charge(response["data"]["tx_ref"])printresponse

Beneficiaries.new(payment)

Its functions includes:

  • .create_beneficiary
  • .list_beneficiaries
  • .fetch_beneficiary
  • .delete_beneficiary

See full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxxxxxx-X","FLWSECK-xxxxxxxx-X","xxxxxxxxxx")Beneficiary=Beneficiaries.new(payment)#create a beneficiarypayload={"account_number"=>"0690000032","account_bank"=>"044"}response=Beneficiary.create_beneficiary(payload)printresponse#list beneficiariesresponse=Beneficiary.list_beneficiariesprintresponse#fetch beneficiaryresponse=Beneficiary.fetch_beneficiary(7369)printresponse#delete beneficiaryresponse=Beneficiary.delete_beneficiary(7369)printresponse

USSD.new(payment)

Its functions includes:

  • .initiate_charge
  • .verify_charge

See full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxx-X","FLWSECK-xxxxxxx-X","xxxxxx")payload={"tx_ref"=>"MC-15852309v5050w34","account_bank"=>"044","amount"=>"1500","currency"=>"NGN","email"=>"xxxxxxxxxxxxx@gmail.com","phone_number"=>"054709929220","fullname"=>"Test Name"}ussd=USSD.new(payment)response=ussd.initiate_charge(payload)printresponse# verify transactioin with the idresponse=ussd.verify_charge(283516336)printresponse

Transfer.new(payment)

Its functions includes:

  • .transfer_fee
  • .initiate_transfer
  • .initiate_bulk_transfer
  • .get_all_transfers
  • .get_a_transfer

See full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxx-X","FLWSECK-xxxxxxx-X","xxxxxxxxx")transfer=Transfer.new(payment)payload={"account_bank"=>"044","account_number"=>"0690000040","amount"=>5000,"narration"=>"Akhlm Pstmn Trnsfr xx007","currency"=>"NGN","reference"=>"eightm-pstmnpyt-rfxx007_P0MCKDU_1","callback_url"=>"https://webhook.site/b3e505b0-fe02-430e-a538-22bbbce8ce0d","debit_currency"=>"NGN"}response=transfer.initiate_transfer(payload)printresponse# get transfer feecurrency="NGN"amount="5000"response=transfer.transfer_fee(currency,amount)printresponse#get all transfersresponse=transfer.get_all_transfersprintresponse#get a transferresponse=transfer.get_a_transfer(125445)printresponse

VirtualCard.new(payment)

Its functions includes:

  • .create_virtual_card
  • .get_all_virtual_cards
  • .get_virtual_card
  • .fund_virtual_card
  • .terminate_virtual_card
  • .get_virtual_card_transactions
  • .withdraw_from_virtual_card
  • .block_unblock_virtual_card

See full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK_TEST-xxxxxxxx-X","FLWSECK_TEST-xxxxxx-X","xxxxxxxxx")virtual_card=VirtualCard.new(payment)createvirtualcardpayload={"currency"=>"NGN","amount"=>20000,"billing_name"=>"Test Name","billing_address"=>"2014 Forest Hills Drive","billing_city"=>"Node","billing_state"=>"Javascript","billing_postal_code"=>"000009","billing_country"=>"NG","callback_url"=>"https://your-callback-url.com/"}response=virtual_card.create_virtual_card(payload)printresponse#get all virtual cardsresponse=virtual_card.get_all_virtual_cardsprintresponse#get a virtual cardresponse=virtual_card.get_virtual_card("594715a6-ae77-483c-811e-19057aedacff")printresponse#fund a virtual cardpayload={"debit_currency"=>"NGN","amount"=>4000}id="594715a6-ae77-483c-811e-19057aedacff"response=virtual_card.fund_virtual_card(id,payload)printresponse#get virtual card transactionsfrom="2019-01-01"to="2020-01-13"index=0size=1response=virtual_card.get_virtual_card_transactions("594715a6-ae77-483c-811e-19057aedacff",from,to,index,size)#withdraw from a virtual cardpayload={"amount"=>"1000"}id="594715a6-ae77-483c-811e-19057aedacff"response=virtual_card.withdraw_from_virtual_card(id,payload)printresponse#block/unblock virtualcardid="594715a6-ae77-483c-811e-19057aedacff"status_action="unblock"response=virtual_card.block_unblock_virtual_card(id,status_action)printresponse

TokenizedCharge.new(payment)

Its functions includes:

  • .tokenized_charge
  • .verify_tokenized_charge
  • .update_token
  • .bulk_tokenized_charge
  • .bulk_tokenized_charge_status
  • .bulk_tokenized_charge_transactions

See full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxxxxxxx-X","FLWSECK-xxxxxxxxxx-X","xxxxxxxxxxxxx")# This is used to perform card chargepayload={"token"=>"flw-t1nf-264db944ee46d0a2627573a496f5432c-m03k","currency"=>"NGN","country"=>"NG","amount"=>"10","email"=>"user@example.com","first_name"=>"Test","last_name"=>"Name","ip"=>"pstmn","narration"=>"testing charge with token"}charge_with_token=TokenizedCharge.new(payment)response=charge_with_token.tokenized_charge(payload)printresponse# Verify tokenized transactionresponse=charge_with_token.verify_tokenized_charge(response["data"]["tx_ref"])printresponse#update tokenpayload={"email"=>"user@example.com","first_name"=>"Test","last_name"=>"Name","phone_number"=>"09000000000000"}charge_with_token=TokenizedCharge.new(payment)token="flw-t1nf-264db944ee46d0a2627573a496f5432c-m03k"response=charge_with_token.update_token(payload,token)printresponse#bulk tokenized chargepayload={"title"=>"test","retry_strategy"=>{"retry_interval"=>120,"retry_amount_variable"=>60,"retry_attempt_variable"=>2,},"bulk_data"=>[{"token"=>"flw-t1nf-264db944ee46d0a2627573a496f5432c-m03k","currency"=>"NGN","country"=>"NG","amount"=>"10","email"=>"user@example.com","first_name"=>"Test","last_name"=>"Name","ip"=>"pstmn","narration"=>"testing charge with token",},{"token"=>"flw-t1nf-264db944ee46d0a2627573a496f5432c-m03k","currency"=>"NGN","country"=>"NG","amount"=>"10","email"=>"user@example.com","first_name"=>"Test","last_name"=>"Name","ip"=>"pstmn","narration"=>"testing charge with token"}]}charge_with_token=TokenizedCharge.new(payment)response=charge_with_token.bulk_tokenized_charge(payload)printresponse#get status of bulk tokenized chargesid=175charge_with_token=TokenizedCharge.new(payment)response=charge_with_token.bulk_tokenized_charge_status(id)printresponse#fetch bulk tokenized transactionsid=175charge_with_token=TokenizedCharge.new(payment)response=charge_with_token.bulk_tokenized_charge_transactions(id)printresponse

Settlements.new(payment)

Its functions includes:

  • .get_settlements
  • .get_settlement

See full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK_TEST-xxxxxxxxx-X","FLWSECK_TEST-xxxxxxxxxx-X","xxxxxxxxxxxxx")settlement=Settlements.new(payment)# get all settlementsresponse=settlement.get_settlementsprintresponse#get a settlmentresponse=settlement.get_settlement(63016)printresponse

QR.new(payment)

Its functions includes:

  • .initiate_charge
  • .verify_charge

See full flow below

require'./flutterwave_sdk'# This is a FLutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxxxxxx-X","FLWSECK-xxxxxxxxxxxxxxx-X","xxxxxxxxxxxxxxxx")payload={"tx_ref"=>"MC-15852309v5050w34","amount"=>"1500","currency"=>"NGN","email"=>"xxxxxxxxxxxx@gmail.com","phone_number"=>"090000000000","fullname"=>"Test name"}qr=QR.new(payment)response=qr.initiate_charge(payload)printresponse# verify QR transactionresponse=qr.verify_charge(response["data"]["tx_ref"])printresponse

Transactions.new(payment)

Its functions includes:

  • .transaction_fee
  • .get_transactions
  • .verify_transaction
  • .transactions_events
  • .initiate_a_refund
  • .resend_transaction_webhook

see full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxxxxxx-X","FLWSECK-xxxxxxxxxxxxxxxxxx-X","xxxxxxxxxxxxxxx")fee=Transactions.new(payment)currency="NGN"amount="1000"response=fee.transaction_fee(currency,amount)printresponse# get Transactionsfee=Transactions.new(payment)response=fee.get_transactionsprintresponse# get transaction eventsfee=Transactions.new(payment)response=fee.transactions_events(1321548)printresponse# initiate a refundpayload={"amount"=>"5"}# id = 1321548fee=Transactions.new(payment)response=fee.initiate_a_refund(payload,1321548)printresponse#resend transaction webhookpayload={"id"=>1321548}fee=Transactions.new(payment)response=fee.resend_transactions_webhook(payload)printresponse

VirtualAccountNumber.new(payment)

Its functions includes:

  • .create_virtual_account_number
  • .create_bulk_virtual_account_number
  • .get_bulk_virtual_account_number
  • .get_virtual_account_number

see full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK_TEST-xxxxxxxx-X","FLWSECK_TEST-xxxxxxxxxx-X","xxxxxxxxx")account_number=VirtualAccountNumber.new(payment)# #create virtual account numberpayload={"email"=>"xxxxxxxxxx@gmail.com","duration"=>5,"frequency"=>5,"is_permanent"=>true,"tx_ref"=>"jhn-Test-10192029920"}response=account_number.create_virtual_account_number(payload)printresponse#bulk account numberpayload={"email"=>"xxxxxxxxx@gmail.com","duration"=>5,"accounts"=>5,"is_permanent"=>true,"tx_ref"=>"jhn-Test-10192029920"}response=account_number.create_bulk_virtual_account_number(payload)printresponse# get bulk virtual account numberresponse=account_number.get_bulk_virtual_account_number("-RND_1071591303048505")printresponse# Get a virtual account number response=account_number.get_virtual_account_number("URF_1591302653177_6055335")printresponse

Subscriptions.new(payment)

Its functions includes:

  • .get_all_subscriptions
  • .cancel_subscription
  • .activate_subscription

see full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxxx-X","FLWSECK-xxxxxxxxxx-X","xxxxxxxxxxx")subscription=Subscriptions.new(payment)#get all subscriptionsresponse=subscription.get_all_subscriptionsprintresponse#cancel subscriptionresponse=subscription.cancel_subscription(247490)printresponse#activate subcriptionresponse=subscription.activate_subscription(247490)printresponse

OTP.new(payment)

Its functions includes:

  • .create_otp
  • .validate_otp

see full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK_TEST-xxxxxxxxxxxxxx-X","FLWSECK_TEST-xxxxxxxxxxxx-X","xxxxxxxxx")otp=OTP.new(payment)payload={"length"=>7,"customer"=>{"name"=>"Test","email"=>"xxxxxxxxxxx@gmail.com","phone"=>"2348131149273"},"sender"=>"Test Name","send"=>true,"medium"=>["email","whatsapp"],"expiry"=>5}response=otp.create_otp(payload)printresponse#validate otppayload={"otp"=>481208}reference="CF-BARTER-20190420022611377491"response=otp.validate_otp(reference,payload)printresponse

Subaccount.new(payment)

Its functions includes:

  • .create_subaccount
  • .fetch_subaccounts
  • .fetch_subaccount
  • .update_subaccount
  • .delete_subaccount

see full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK_TEST-xxxxxxxx-X","FLWSECK_TEST-xxxxxxxx-X","xxxxxx")subaccount=Subaccount.new(payment)#create subaccountpayload={"account_bank"=>"044","account_number"=>"0690000036","business_name"=>"Test Name","business_email"=>"xxxxxx@gmail.com","business_contact"=>"Anonymous","business_contact_mobile"=>"090890382","business_mobile"=>"09087930450","country"=>"NG","split_type"=>"percentage","split_value"=>0.5}reponse=subaccount.create_subaccount(payload)printreponse#fetch all subaccountsreponse=subaccount.fetch_subaccountsprintreponse#fetch a sub accountreponse=subaccount.fetch_subaccount(5740)printreponse#update subaccountpayload={"business_email"=>"xxxxx@gmail.com"}id=5740reponse=subaccount.update_subaccount(id,payload)printreponse#delete subaccountreponse=subaccount.delete_subaccount(5740)printreponse

PaymentPlan.new(payment)

Its functions includes:

  • .create_payment_plan
  • .get_payment_plans
  • .get_a_payment_plan
  • .update_payment_plan
  • .cancel_payment_plan

see full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxxxx-X","FLWSECK-xxxxxxxxxx-X","xxxxxxxxxxxxx")payment_plan=PaymentPlan.new(payment)#create payment planpayload={"amount"=>5000,"name"=>"the akhlm postman plan 2","interval"=>"monthly","duration"=>48}response=payment_plan.create_payment_plan(payload)printresponse#get payment plansresponse=payment_plan.get_payment_plansprintresponse#get a payment planresponse=payment_plan.get_a_payment_plan(5981)printresponse#update a payment planpayload={"name"=>"Test name","status"=>"active"}response=payment_plan.update_payment_plan(5981,payload)printresponse#cancel payment planresponse=payment_plan.cancel_payment_plan(5981)printresponse

MobileMoney.new(payment)

Its functions includes:

  • .initiate_charge
  • .verify_charge

see full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxxxxxxxxxx-X","FLWSECK-xxxxxxxxxxxx-X","xxxxxxxxxx")# This is used to perform Mpesa transactionpayload={"tx_ref"=>"khlm-158943942o3","amount"=>"50","currency"=>"KES","email"=>"johnmadakin@gmail.com","phone_number"=>"054709929220","fullname"=>"John Madakin","client_ip"=>"154.123.220.1","device_fingerprint"=>"62wd23423rq32dskd4323qew1"}charge_mpesa=MobileMoney.new(payment)response=charge_mpesa.initiate_charge(payload)printresponse#verify transaction response=charge_mpesa.verify_charge(response["data"]["tx_ref"])printresponse#zambia testpayload={"tx_ref"=>"MC-158523s09v5050e8","amount"=>"1500","currency"=>"ZMW","network"=>"MTN","email"=>"xxxxxxxxxx@gmail.com","phone_number"=>"054709929220","fullname"=>"Test Name"}charge_zambia=MobileMoney.new(payment)response=charge_zambia.initiate_charge(payload)printresponse#verify transactionresponse=charge_zambia.verify_charge(response["data"]["tx_ref"])printresponse# # Ghana mobile money testpayload={"tx_ref"=>"MC-158523s09v5050e8","amount"=>"150","currency"=>"GHS","voucher"=>"143256743","network"=>"MTN","email"=>"xxxxx@gmail.com","phone_number"=>"054709929220","fullname": "Test Name"}charge_ghana=MobileMoney.new(payment)#initiate transactionresponse=charge_ghana.initiate_charge(payload)printresponse#verify transactionresponse=charge_ghana.verify_charge(response["data"]["tx_ref"])printresponse# Rwanda mobile money testpayload={"tx_ref"=>"MC-158523s09v5050e8","amount"=>"1500","currency"=>"RWF","network"=>"MTN","email"=>"xxxxx@gmail.com","phone_number"=>"054709929220","fullname"=>"Test Name"}charge_rwanda=MobileMoney.new(payment)response=charge_rwanda.initiate_charge(payload)printresponse# verify transactionresponse=charge_rwanda.verify_charge(response["data"]["tx_ref"])printresponse#uganda testpayload={"tx_ref"=>"MC-1585230950500","amount"=>"1500","email"=>"xxxxxxxx@gmail.com","phone_number"=>"054709929220","currency"=>"UGX","redirect_url"=>"https://rave-webhook.herokuapp.com/receivepayment","network"=>"MTN"}charge_uganda=MobileMoney.new(payment)response=charge_uganda.initiate_charge(payload)printresponseresponse=charge_uganda.verify_charge(response["data"]["tx_ref"])printresponse# franco phonepayload={"tx_ref"=>"MC-1585230950501","amount"=>"1500","email"=>"xxxxxx@gmail.com","phone_number"=>"054709929220","currency"=>"XAF","redirect_url"=>"https://rave-webhook.herokuapp.com/receivepayment"}charge_franco=MobileMoney.new(payment)response=charge_franco.initiate_charge(payload)printresponseresponse=charge_franco.verify_charge(response["data"]["tx_ref"])printresponse

Misc.new(payment)

Its functions includes:

_ .get_all_wallet_balance

  • .get_balance_per_currency
  • .resolve_account
  • .resolve_bvn
  • .resolve_card_bin

see full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxxxxx-X","FLWSECK-xxxxx-X","xxxxxxxxxxxxxxx")misc=Misc.new(payment)#get all wallet balanceresponse=misc.get_all_wallet_balanceprintresponse#get balance per cuurencyresponse=misc.get_balance_per_currency("NGN")printresponse#resolve accountpayload={"account_number"=>"0690000032","account_bank"=>"044"}response=misc.resolve_account(payload)printresponse#resolve bvnresponse=misc.resolve_bvn("12345678901")printresponse#resolve card binresponse=misc.resolve_card_bin(553188)printresponse

Preauth.new(payment)

Its functions includes:

  • .capture_preauth
  • .void_preauth
  • .refund_preauth

see full flow below

require'./flutterwave_sdk'# This is a Flutterwave object which is expecting public, secret and encrption keyspayment=Flutterwave.new("FLWPUBK-xxxxxxxxx-X","xxxxxxxxxxxxxx","xxxxxxxxxxxxxx")# This is used to perform preauth captureauth=Preauth.new(payment)payload={"amount"=>"50"}flw_ref="FLW-MOCK-d6b76a67a639dc124917b8957baa5278"repsonse=auth.capture_preauth(flw_ref,payload)printresponse#Voidresponse=auth.void_preauth(flw_ref)printresponse#Refundpayload={"amount"=>"30"}flw_ref="FLW-MOCK-d6b76a67a639dc124917b8957baa5278"response=auth.refund_preauth(flw_ref,payload)printresponse

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Iphytech/flutterwave_sdk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the FlutterwaveSdk project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

About

Ruby Library for Flutterwave for Business (F4B) v3 APIs.

Topics

Resources

Code of conduct

Contributing

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages