Skip to content

NdoleStudio/orangemoney-go

Repository files navigation

orangemoney-go

Build codecov Scrutinizer Code Quality Go Report Card GitHub contributors GitHub license PkgGoDev

This package provides a generic go client for the Orange Money API

Installation

orangemoney-go is compatible with modern Go releases in module mode, with Go installed:

go get github.com/NdoleStudio/orangemoney-go

Alternatively the same can be achieved if you use import in a package:

import "github.com/NdoleStudio/orangemoney-go"

Implemented

  • Token
    • POST {baseURL}/token: Get Access Token
  • Merchant Payments
    • POST {baseURL}/omcoreapis/1.0.2/mp/init: Generate pay token.
    • GET {baseURL}/omcoreapis/1.0.2/mp/push/{payToken}: Push payment notification.
    • GET {baseURL}/omcoreapis/1.0.2/mp/paymentstatus/{payToken}: Get the status of a transaction
    • GET {baseURL}/omcoreapis/1.0.1/mp/pay: Execute and initiated transaction

Usage

Initializing the Client

An instance of the client can be created using New().

package main

import (
    "github.com/NdoleStudio/orangemoney-go"
)

func main() {
    client := orangemoney.New(
        orangemoney.WithUsername(""),
        orangemoney.WithPassword(""),
        orangemoney.WithAuthToken(""),
    )
}

Error handling

All API calls return an error as the last return object. All successful calls will return a nil error.

status, response, err := client.MerchantPayment.Init(context.Background())
if err != nil {
    //handle error
}

Testing

You can run the unit tests for this client from the root directory using the command below:

go test -v

License

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