A gem for cunsuming daraja 2.0 API.
Add this line to your application's Gemfile:
gem 'qwiik', :git => 'git@github.com:gathuku/qwiik.git'
And then execute:
$ bundle install
Or install it yourself as:
$ git clone git@github.com:gathuku/qwiik.git
$ cd qwiik && gem build qwiik.gemspec
$ gem install qwiik-[version].gem
To get started add your credentials to environment variables
export QWIIK_PAYOUT_KEY = your_payout_key
export QWIIK_PAYOUT_SECRET = your_payout_secret
Then configure the gem with.
Qwiik.configuration do |config|
# If sandbox
config.base_url='https://api-staging.qwwik.com'
# If live
config.base_url='https://api.qwwik.com'
key= ENV['QWIIK_PAYOUT_KEY']
secret=ENV['QWIIK_PAYOUT_SECRET']
end
The gem can be used to make payouts.
- Business to customer(B2C)
- Business to BusinessPayBill(B2B)
- Business to BusinessBuyGoods(B2B)
To make a customer payout use:
Category must be
BusinessPayment
Qwiik.payouts(category:, amount:, recipient_no:, reference:)
category:
String
- category of the payment.amount:
Integer
- amount to be paidrecepient_no:
String
- Phone number of the recepient.reference:
String
- payment reference
responce=Qwiik.payouts(category: 'BusinessPayment', amount:100, recipient_no: '0722000024', reference: '11234578')
Alternatively
args={
category:'BusinessPayment',
amount:100,
recipient_no: '0722000024',
reference:'11234578'
}
response=Qwiik.payouts(args)
Body response.body
/* json */
{
"data": {
"type": "responses",
"id": "AG_20191121_000046e92fe975f006d7",
"attributes": {
"resource_id": "bae4b140-8db7-4dc1-9be1-5650383d48f3"
}
}
}
To make a customer payout use:
Category must be
BusinessPayBill
Recepient_no must be a paybil no
Qwiik.payouts(category:, amount:, recipient_no:, reference:)
category:
String
- category of the payment.amount:
Integer
- amount to be paidrecepient_no:
String
- Paybill number of the recepient.reference:
String
- payment reference
Qwiik.payouts(category:'BusinessPayBill', amount:100, recipient_no:'601000', reference:'11234578')
To make a businessBuyGoods payout use:
Category must be
BusinessBuyGoods
Recepient_no must be a till no.
Qwiik.payouts(category:, amount:, recipient_no:, reference:)
category:
String
- category of the payment.amount:
Integer
- amount to be paidrecepient_no:
String
- Till no number of the recepient.reference:
String
- payment reference
Qwiik.payouts(category:'BusinessBuyGoods', amount:100, recipient_no:'116261', reference:'11234578')
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
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.
Bug reports and pull requests are welcome on GitHub at https://github.com/gathuku/qwiik. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the Qwiik project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.