Giter VIP home page Giter VIP logo

go-payup-airtel-money's Introduction

go-payup-airtel-money

Airtel Money Ledger implementation for the go-payup library

DSN Endpoints

Staging -- https://openapiuat.airtel.africa/

Production -- https://openapi.airtel.africa/

DSN Parameters

Paramter Description Required Default
country 2 letter ISO country code yes
currency 3 letter ISO currency code yes
timeout http request timeout in seconds no 30
client_id Airtel app client ID yes
secret_key Airtel app secret key yes

Example

.ini
[airtel_money]
dsn = "https://openapiuat.airtel.africa?country=MW&currency=MWK&client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&secret_key=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&timeout=15"
import (
	"context"
	"testing"
	"time"

	gopayup "github.com/sharkfoursix/go-payup"
	"github.com/sharkfoursix/go-payup/pkg"
	"gopkg.in/ini.v1"
)

func failIfError(t *testing.T, err error) {
	if err != nil {
		t.Error(err)
		t.FailNow()
		return
	}
}

func Test(t *testing.T) {
	var (
		err           error
		dsn           string
		cfg           *ini.File
		transactionID string
		wallet        pkg.MobileWallet
		transaction   pkg.Transaction
	)
	cfg, err = ini.Load(".ini")
	failIfError(t, err)

	dsn = cfg.Section("airtel_money").Key("dsn").String()

	wallet, err = gopayup.NewMobileWallet("airtelMoney", dsn)
	failIfError(t, err)

	transactionID = "TRANS-ID"
	ctx, cancelFn := context.WithTimeout(
		context.Background(),
		30*time.Second,
	)
	defer cancelFn()

	transaction, err = wallet.VerifyTransaction(ctx, transactionID)
	failIfError(t, err)

	t.Log(transaction)
}

go-payup-airtel-money's People

Contributors

sharkfoursix avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.