Pesamoni Ruby library
The Pesamoni Pesaway gem provides integration access to Pesamoni services. You can view API features by clicking the link https://pesamoni.com/developers#features-intro.
Installation
gem install pesamoni_ruby
Or add to your Gemfile:
gem 'pesamoni_ruby'
And then execute:
$ bundle
Quick Start Example
The SDK needs to be instantiated using your API username and API password, which you can get from your Pesamoni business account.
You can register a new Pesamoni business account Here or Sign in Here
# Load the gem
require 'pesamoni_ruby'
# Setup authorization
Pesamoni.configure do |config|
# Configure API key authorization: apipassword
# Configure API key authorization: apiusername
config.api_key['apiusername'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
#config.api_key_prefix['apiusername'] = 'Bearer'
config.api_key['apipassword'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
#config.api_key_prefix['apipassword'] = 'Bearer'
end
api_instance = Pesamoni::DefaultApi.new
method = 'method_example' # String | Enter a request method. To check for request methods <a href=''>click here</a>
Accepting funds from mobile subscriber
# you can either use method acreceive or acreceivekeac as explained below
# method acreceive
# This method enables you receive funds from a mobile subscriber in your registered native currency on the Pesamoni platform. If for instance your account is registered in currency UGX and you request money from a Kenyan number e.g 254712346789, a Pesamoni exchange rate will automatically be applied and money deposited into your Pesamoni wallet in your default currency
# method acreceivekeac
# You can have two native currencies on your Pesamoni account on request. If you would like to deposit funds from a mobile subscriber to your Kenyan Pesamoni wallet account then this is the method you use.
# example
method = 'acreceive'
opts = {
amount: 'amount_example', # String | Enter the amount you would like to request for. This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, acsendbank, pesab2c, sendairtime, cardaccept
mobile: 'mobile_example', # String | Enter the mobile number you would like to execute the above method in format 256.... or 254...This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, senderid, sendsms, sendairtime
reference: 'reference_example', # String | Enter your user generated transaction reference This method applies for request methodsacreceive, acreceivekeac, acsend, acsendkeac, sendsms, transactionstatus, sendairtime, pesab2c, sendsms, cardaccept
genericmsg: 'genericmsg_example', # String | Enter your user generated generic message for the requested transaction This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
token: 'token_example', # String | Enter your user generated token for the above mentioned method This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
}
begin
result = api_instance.transactions_post(method, opts)
p result
rescue Pesamoni::ApiError => e
puts "Exception when calling DefaultApi->transactions_post: #{e}"
end
Sending funds to a mobile subscriber
# you can either use method acreceive or acreceivekeac as explained below
# acsend
# This method enables you send funds to a mobile subscriber in your registered native currency on the Pesamoni platform. If for instance your account is registered in currency UGX and you send money to a kenyan number e.g 254712346789, a Pesamoni exchange rate will automatically be applied and the equivalent exchange amount deducted from your Pesamoni wallet in your default currency
# acsendkeac
# You can have two native currencies on your Pesamoni account on request. If you would like to send funds from your Pesamoni wallet to a mobile subscriber from your Kenyan Pesamoni wallet account then this is the method you use.
method = 'acsend'
opts = {
amount: 'amount_example', # String | Enter the amount you would like to execute the above method for. This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, acsendbank, pesab2c, sendairtime, cardaccept
mobile: 'mobile_example', # String | Enter the mobile number you would like to execute the above method in format 256.... or 254...This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, senderid, sendsms, sendairtime
reference: 'reference_example', # String | Enter your user generated transaction referenceThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, transactionstatus, sendairtime, pesab2c, sendsms, cardaccept
genericmsg: 'genericmsg_example', # String | Enter your user generated generic message for the requested transactionThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
token: 'token_example', # String | Enter your user generated token for the above mentioned method This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
}
Accepting Card Payments e.g VISA/MASTERCARD
method = 'acsend'
opts = {
amount: 'amount_example', # String | Enter the amount you would like to request for. This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, acsendbank, pesab2c, sendairtime, cardaccept
holdername: 'holdername_example', # String | Enter name of payer for Visa/MasterCard transactionsThis method applies for request method cardaccept
cardnumber: 'cardnumber_example', # String | Enter the Visa/MasterCard cardnumberThis method applies for request method cardaccept
cvv: 'cvv_example', # String | Enter the Visa/MasterCard cvvThis method applies for request method cardaccept
exp: 'exp_example', # String | Enter the Visa/MasterCard expiry date in the format MM/YYYY e.g 07/2030This method applies for request method cardaccept
currency: 'currency_example', # String | Enter the currency you intend to make the transaction for Visa/MasterCard based transactionsThis method applies for request method cardaccept
genericmsg: 'genericmsg_example', # String | Enter your user generated generic message for the requested transactionThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
token: 'token_example', # String | Enter your user generated token for the above mentioned methodThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
}
begin
result = api_instance.transactions_post(method, opts)
p result
rescue Pesamoni::ApiError => e
puts "Exception when calling DefaultApi->transactions_post: #{e}"
end
Bank transfers
# you can either use method acsendbank or acsendbankeac as explained below
# acsendbank
# This method enables you send funds to a users bank account. A Pesamoni exchange rate will automatically be applied and the equivalent exchange amount deposited to your bank account dependent on your default currency.
# acsendbankeac
# You can have two native currencies on your Pesamoni account on request. If you would like to send funds from your Pesamoni wallet to a mobile subscriber from your Kenyan Pesamoni wallet account then this is the method you use.
method = 'acsendbank'
opts = {
amount: 'amount_example', # String | Enter the amount you would like to request for. This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, acsendbank, pesab2c, sendairtime, cardaccept
currency: 'currency_example', # String | Enter the currency you intend to make the transaction for Visa/MasterCard based transactionsThis method applies for request method cardaccept
account: 'account_example', # String | Enter the Pesamoni account you would like to use for this transactionThis method applies for request method paybills
reference: 'reference_example', # String | Enter your user generated transaction referenceThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, transactionstatus, sendairtime, pesab2c, sendsms, cardaccept
genericmsg: 'genericmsg_example', # String | Enter your user generated generic message for the requested transactionThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
token: 'token_example', # String | Enter your user generated token for the above mentioned methodThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
}
begin
result = api_instance.transactions_post(method, opts)
p result
rescue Pesamoni::ApiError => e
puts "Exception when calling DefaultApi->transactions_post: #{e}"
end
Sending Airtime to a mobile subsriber
method = 'sendairtime'
opts = {
amount: 'amount_example', # String | Enter the amount you would like to request for. This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, acsendbank, pesab2c, sendairtime, cardaccept
mobile: 'mobile_example', # String | Enter the mobile number you would like to execute the above method in format 256.... or 254...This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, senderid, sendsms, sendairtime
reference: 'reference_example', # String | Enter your user generated transaction referenceThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, transactionstatus, sendairtime, pesab2c, sendsms, cardaccept
genericmsg: 'genericmsg_example', # String | Enter your user generated generic message for the requested transactionThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
token: 'token_example', # String | Enter your user generated token for the above mentioned methodThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
}
begin
result = api_instance.transactions_post(method, opts)
p result
rescue Pesamoni::ApiError => e
puts "Exception when calling DefaultApi->transactions_post: #{e}"
end
Sending to a Pesamoni users wallet
method = 'pesab2c'
opts = {
amount: 'amount_example', # String | Enter the amount you would like to request for. This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, acsendbank, pesab2c, sendairtime, cardaccept
account: 'account_example', # String | Enter the Pesamoni account you would like to use for this transactionThis method applies for request method paybills
reference: 'reference_example', # String | Enter your user generated transaction referenceThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, transactionstatus, sendairtime, pesab2c, sendsms, cardaccept
genericmsg: 'genericmsg_example', # String | Enter your user generated generic message for the requested transactionThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
token: 'token_example', # String | Enter your user generated token for the above mentioned methodThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
}
begin
result = api_instance.transactions_post(method, opts)
p result
rescue Pesamoni::ApiError => e
puts "Exception when calling DefaultApi->transactions_post: #{e}"
end
Accepting funds from a Pesamoni user
method = 'pesac2b'
opts = {
amount: 'amount_example', # String | Enter the amount you would like to request for. This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, acsendbank, pesab2c, sendairtime, cardaccept
account: 'account_example', # String | Enter the Pesamoni account you would like to use for this transactionThis method applies for request method paybills
reference: 'reference_example', # String | Enter your user generated transaction referenceThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, transactionstatus, sendairtime, pesab2c, sendsms, cardaccept
genericmsg: 'genericmsg_example', # String | Enter your user generated generic message for the requested transactionThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
token: 'token_example', # String | Enter your user generated token for the above mentioned methodThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
}
begin
result = api_instance.transactions_post(method, opts)
p result
rescue Pesamoni::ApiError => e
puts "Exception when calling DefaultApi->transactions_post: #{e}"
end
Paying Utility Bills
method = 'paybills'
opts = {
amount: 'amount_example', # String | Enter the amount you would like to request for. This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, acsendbank, pesab2c, sendairtime, cardaccept
mobile: 'mobile_example', # String | Enter the mobile number you would like to execute the above method in format 256.... or 254...This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, senderid, sendsms, sendairtime
currency: 'currency_example', # String | Enter the currency you intend to make the transaction for Visa/MasterCard based transactionsThis method applies for request method cardaccept
reference: 'reference_example', # String | Enter your user generated transaction referenceThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, transactionstatus, sendairtime, pesab2c, sendsms, cardaccept
genericmsg: 'genericmsg_example', # String | Enter your user generated generic message for the requested transactionThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
token: 'token_example', # String | Enter your user generated token for the above mentioned methodThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
bouquet: 'bouquet_example', # String | Enter the bouquet or package you would like to pay forThis method applies for request methods paybills
payoption: 'payoption_example', # String | Enter your prefered payment optionThis method applies for request methods paybills
meternumber: 'meternumber_example' # String | Enter the meter number for the intended paymentThis method applies for request methods paybills
}
begin
result = api_instance.transactions_post(method, opts)
p result
rescue Pesamoni::ApiError => e
puts "Exception when calling DefaultApi->transactions_post: #{e}"
end
Checking transaction status
method = 'transactionstatus'
opts = {
reference: 'reference_example', # String | Enter your user generated transaction referenceThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, transactionstatus, sendairtime, pesab2c, sendsms, cardaccept
}
begin
result = api_instance.transactions_post(method, opts)
p result
rescue Pesamoni::ApiError => e
puts "Exception when calling DefaultApi->transactions_post: #{e}"
end
Checking your Pesamoni Business Wallet Balance
method = 'acbalance'
opts = {
# No parameters are required here
}
Sending SMS to a mobile subscriber
opts = {
mobile: 'mobile_example', # String | Enter the mobile number you would like to execute the above method in format 256.... or 254...This method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, senderid, sendsms, sendairtime
reference: 'reference_example', # String | Enter your user generated transaction referenceThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, transactionstatus, sendairtime, pesab2c, sendsms, cardaccept
genericmsg: 'genericmsg_example', # String | Enter your user generated generic message for the requested transactionThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
token: 'token_example', # String | Enter your user generated token for the above mentioned methodThis method applies for request methods acreceive, acreceivekeac, acsend, acsendkeac, sendsms, sendairtime, pesab2c, sendsms, cardaccept
message: 'message_example'
# String | Enter your message This method applies for request methods sendsms
}
begin
result = api_instance.transactions_post(method, opts)
p result
rescue Pesamoni::ApiError => e
puts "Exception when calling DefaultApi->transactions_post: #{e}"
end
Documentation for API Endpoints
All Endpoint URIs are relative to https://pesamoni.com/api/live/v1/transactions
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/Pesamoni.
License
The gem is available as open source under the terms of the Apache License 2.0.