DEV Community

Cover image for Utility bill payment and airtime topup with Golang
Mathias Jiya
Mathias Jiya

Posted on • Updated on

Utility bill payment and airtime topup with Golang

Hello devs, this article is for developers who wishes to have these features in their projects:

  • Airtime topup
  • Buy data
  • Utility bills payment
  • Convert airtime to cash

With this package you can integrate these features into your project with some easy steps.

I know how difficult it can be to get API's to achieve these which is why I have taken time to create a Go library that handles all these. The library utilizes a 3rd party API provided by bingpay
Bingpay is a one app for everything platform which allow for Cheap Airtime & Data Topup, Send & Recieve Cash, Pay Utility Bills, Purchase Giftcards, Trade Airtime, Paypal & Giftcards and International Topup. All these features are available from within bingpay although the API which is made public have only some features available.

Now lets get right into the interesting stuffs.

Buy Airtime

Use this to perform airtime purchase.
You get 2% discount on every airtime purchase instantly.

package main

import (
    "fmt"
    bingpay "github.com/iqquee/bingpay-go"
    "github.com/iqquee/bingpay-go/airtime"
)

func main() {
    bingpay.Token = "your bingpay api secret key" // to add your secret key for the api requests 

    phone := "08000000000" // Phone number to recharge.
    amount := 100 // Amount to recharge. e.g 100 for 100 naria topup
    network_id := 0 // Network (As seen in the all-networks endpoint).
    response, status, err := airtime.BuyAirtime(phone,amount,network_id)
    if err != nil {
        fmt.Println(err)
    }

    fmt.Println(status)
    fmt.Println(response)
}
Enter fullscreen mode Exit fullscreen mode

A lot of other methods are available in github.com/iqquee/bingpay-go. You can visit github.com/iqquee/bingpay-go for more example code for each methods. This package have been properly documented to allow for easy use of it and as such every methods in this package have an example code to it.

Top comments (0)