This package provides a go client for interacting with the Flutterwave API
flutterwave-go is compatible with modern Go releases in module mode, with Go installed:
go get github.com/NdoleStudio/flutterwave-goAlternatively the same can be achieved if you use import in a package:
import "github.com/NdoleStudio/flutterwave-go"- Bills
POST /bills/: Create a bill paymentGET /bill-items/:item_code/validate: Validate services like DStv smartcard number, Meter number etc.GET /bills/:reference: Get the verbose status of a bill payment
- Payments
GET /v3/transactions/:id/verify: Verify a transactionPOST /v3/transactions/:id/refund: Create a Refund
- Transfers
GET /v3/transfers/rates: Get the transfer rate of a transaction
An instance of the flutterwave client can be created using New().
package main
import (
"github.com/NdoleStudio/flutterwave-go"
)
func main() {
client := flutterwave.New(
flutterwave.WithSecretKey("" /* flutterwave Secret Key */),
)
}All API calls return an error as the last return object. All successful calls will return a nil error.
data, httpResponse, err := flutterwaveClient.Bills.Create(context.Background(), request)
if err != nil {
//handle error
}POST /bills/: Create a bill payment
response, _, err := flutterwaveClient.Bills.CreatePayment(context.Background(), &BillsCreatePaymentRequest{
Country: "NG",
Customer: "7034504232",
Amount: 100,
Recurrence: "ONCE",
Type: "DSTV",
Reference: uuid.New().String(),
BillerName: "DSTV",
})
if err != nil {
log.Fatal(err)
}
log.Println(response.Status) // successGET /bill-items/{item_code}/validate: validate services like DSTV smartcard number, Meter number etc.
response, _, err := flutterwaveClient.Bills.Validate(context.Background(), "CB177", "BIL099", "08038291822")
if err != nil {
log.Fatal(err)
}
log.Println(response.Status) // successGET /bills/{reference}: get the verbose status of a bill purchase
response, _, err := flutterwaveClient.Bills.GetStatusVerbose(context.Background(), "9300049404444")
if err != nil {
log.Fatal(err)
}
log.Println(response.Status) // successYou can run the unit tests for this client from the root directory using the command below:
go test -vThis project is licensed under the MIT License - see the LICENSE file for details
