CamPay Ruby SDK

Ruby on Rails SDK for CamPay Payment Gateway

CamPay is a Fintech service of the company TAKWID GROUP which launched its financial services in Cameroon from January 2021.

We provide businesses and institutions with solutions for collecting and transferring money online, via primarily Mobile Money(MTN and Orange).

With CamPay, simplify the purchasing experience for your customers thanks to our mobile money payment solutions, accessible via your website and/or mobile application.

Summary

- [Getting Started](#getting-started)
- [Running the samples](#running-the-samples)
- [Deployment](#deployment)

Getting Started

These instructions will get you started with the CamPay SDK for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

  • Create an account on CamPay platform
  • Register an application under your account.
  • Expand your registered application to get access to your API keys

Installing

```
    gem install campay
```

or

gem campay

Running the samples

  • If you plan to use .env then add: gem 'dotenv' to your gemfile in order to save your secret credentials
campay = Campay::CamPay.new(
    ENV.fetch('PAY_UNIT_API_USERNAME'),
    ENV.fetch('PAY_UNIT_API_PASSWORD'),
    ENV.fetch('PAY_UNIT_MODE'))

To collect payments from your client - DIRECTLY

```
collect = collect(
    amount, #The amount you want to collect
    currency,   #XAF
    from,   #Phone number to request amount from - Must include country code
    description, #some description
    external_reference #Reference from the system initiating the transaction
    )
     

     puts collect
     #{"reference": "bcedde9b-62a7-4421-96ac-2e6179552a1a", "external_reference":"12345678", "status": "SUCCESSFUL", "amount": 5, "currency": "XAF", "operator": "MTN", "code": "CP201027T00005", "operator_reference":  "1880106956" }
     
```
> status can be SUCCESSFUL or FAILED
```
link = campay.fetch_payment_link(
    amount,
    currency,
    from,
    description,
    reference,
    redirect_url
    )
     '''
     Redirect your customer to the returned payment link 
     '''
     
```
> status can be SUCCESSFUL or FAILED

To disburse

Please enable API withdrawal under app settings before trying this request

```
disburse = campay.disburse(
    amount,
    currency,
    to,
    description,
    external_reference
    )

    puts disburse
    #{"reference": "bcedde9b-62a7-4421-96ac-2e6179552a1a", "external_reference":"12345678", "status": "SUCCESSFUL", "amount": 5, "currency": "XAF", "operator": "MTN", "code": "CP201027T00005", "operator_reference":  "1880106956" }

```
> status can be SUCCESSFUL or FAILED

To Get application balance.

```
balance = campay.fetch_balance

    puts balance
    #{"total_balance": 0, "mtn_balance": 0, "orange_balance": 0, "currency": "XAF"}
```

Transfer Airtime

Please enable API withdrawal under app settings before trying this request

```
airtime = campay.transfer_airtime(
    amount,
    to,
    external_reference
    )

    puts airtime
    #{"reference": "bcedde9b-62a7-4421-96ac-2e6179552a1a", "external_reference":"12345678", "status": "SUCCESSFUL", "amount": 5, "currency": "XAF", "operator": "MTN", "code": "CP201027U00005", "operator_reference":  "1880106956" }

```
> status can be SUCCESSFUL or FAILED

✒️ Authors

👤 Stanley Enow Lekunze

👤 CHE NSOH BLANCHARD

License

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

Code of Conduct

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