Project

ecocash

0.02
No release in over 3 years
Low commit activity in last 3 years
EcoCash is the easiest way to accept mobile payments online. See https://ecocash.co.zw for more details.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 5.0
~> 13.0

Runtime

~> 0.16.2
 Project Readme

EcoCash Ruby Library

This library provides developers with convenient access to the EcoCash Instant Payments(EIP) API from applications written in Ruby. The EcoCash Online API provides functionality to receive payments directly on your website or easily refund transactions to your customers.

Documentation

See the Ruby API docs

Requirements

To use the EcoCash Online API, the following things are required:

  • Get yourself a Merchant account from EcoCash
  • Apply to be an Online Merchant(This is subject to approval)
  • Now you're ready to use EcoCash Online API
  • In order to accept payments in production mode, your integration will need to be verified by EcoCash.

Installing

This package is available in RubyGems and can be installed with:

gem install ecocash

Or import it to your Gemfile

gem 'ecocash'

Usage

require 'ecocash'

Values you will need from Ecocash

  • Username and password: These are credentials to authenticate the API
  • Merchant number, merchant code and pin: You change PIN on the time of activating your merchant number.

Configuration

The library uses a configuration block for easy setup:

Ecocash.configure do |config|
  config.api_base_url = ENV['API_BASE_URL']
  #Authentication
  config.username = ENV['USERNAME'] 
  config.password = ENV['PASSWORD'] 
  config.merchant_number =ENV['MERCHANT_NUMBER'] 
  config.merchant_code = ENV['MERCHANT_CODE'] 
  config.merchant_pin = ENV['MERCHANT_PIN'] 
  #Payment information
  config.description = "Payment description"
  config.on_behalf_of = "Service description"
  config.payment_remarks = "Transaction description"
  config.reference_code = "Transaction reference"
  config.purchase_category_code = "Online Payment"
  config.refund_remarks = "Refund transaction description"
  #Merchant details
  config.super_merchant_name = ENV['SUPER_MERCHANT_NAME'] 
  config.merchant_name = ENV['MERCHANT_NAME'] 
  config.terminal_id = "unique identifier"
  config.location = "your business physical location"
  config.notify_url = ENV['YOUR_CALLBACK_URL'] 
  
  config.currency_code = "USD"
  config.country_code = "ZW"
  #Client Correlator Prefix
  config.client_correlator_prefix = "any letter(up to 7) to prefix your client correlator"
end

Initialize the API client

client = Ecocash::Client.new

Charge Subscriber

client.charge_subscriber('subscriber_mobile_number','amount')

Refund Subscriber

client.transaction_reversal('subscriber_mobile_number','transaction_id','amount')

Transaction Status

client.transaction_status('subscriber_mobile_number','client_correlator')

List Subscriber Transactions

client.list_transactions('subscriber_mobile_number')

API Documentation

The API document can be obtain from EcoCash upon approval of your application.

Contributing

Please read CONTRIBUTING.md for details and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

License

This project is licensed under the MIT License - see the LICENSE file for details