https://github.com/ndolestudio/flutterwave-go
Unofficial Go client for the flutterwave API
https://github.com/ndolestudio/flutterwave-go
api-client api-client-go flutterwave flutterwave-api
Last synced: 5 months ago
JSON representation
Unofficial Go client for the flutterwave API
- Host: GitHub
- URL: https://github.com/ndolestudio/flutterwave-go
- Owner: NdoleStudio
- License: mit
- Created: 2021-11-13T07:01:23.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-05T10:56:31.000Z (12 months ago)
- Last Synced: 2025-04-10T17:34:20.783Z (10 months ago)
- Topics: api-client, api-client-go, flutterwave, flutterwave-api
- Language: Go
- Homepage: https://developer.flutterwave.com/reference
- Size: 45.9 KB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flutterwave-go
[](https://github.com/NdoleStudio/flutterwave-go/actions/workflows/main.yml)
[](https://codecov.io/gh/NdoleStudio/flutterwave-go)
[](https://scrutinizer-ci.com/g/NdoleStudio/flutterwave-go/?branch=main)
[](https://goreportcard.com/report/github.com/NdoleStudio/flutterwave-go)
[](https://github.com/NdoleStudio/flutterwave-go/graphs/contributors)
[](https://github.com/NdoleStudio/flutterwave-go/blob/master/LICENSE)
[](https://pkg.go.dev/github.com/NdoleStudio/flutterwave-go)
This package provides a `go` client for interacting with the [Flutterwave API](https://developer.flutterwave.com/docs)
## Installation
`flutterwave-go` is compatible with modern Go releases in module mode, with Go installed:
```bash
go get github.com/NdoleStudio/flutterwave-go
```
Alternatively the same can be achieved if you use `import` in a package:
```go
import "github.com/NdoleStudio/flutterwave-go"
```
## Implemented
- **[Bills](#bills)**
- `POST /bills/`: Create a bill payment
- `GET /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 transaction
- `POST /v3/transactions/:id/refund`: Create a Refund
- **Transfers**
- `GET /v3/transfers/rates`: Get the transfer rate of a transaction
## Usage
### Initializing the Client
An instance of the `flutterwave` client can be created using `New()`.
```go
package main
import (
"github.com/NdoleStudio/flutterwave-go"
)
func main() {
client := flutterwave.New(
flutterwave.WithSecretKey("" /* flutterwave Secret Key */),
)
}
```
### Error handling
All API calls return an `error` as the last return object. All successful calls will return a `nil` error.
```go
data, httpResponse, err := flutterwaveClient.Bills.Create(context.Background(), request)
if err != nil {
//handle error
}
```
### BILLS
#### Create a bill payment
`POST /bills/`: Create a bill payment
```go
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) // success
```
#### Create a bill payment
`GET /bill-items/{item_code}/validate`: validate services like DSTV smartcard number, Meter number etc.
```go
response, _, err := flutterwaveClient.Bills.Validate(context.Background(), "CB177", "BIL099", "08038291822")
if err != nil {
log.Fatal(err)
}
log.Println(response.Status) // success
```
#### Get verbose status of a bill payment
`GET /bills/{reference}`: get the verbose status of a bill purchase
```go
response, _, err := flutterwaveClient.Bills.GetStatusVerbose(context.Background(), "9300049404444")
if err != nil {
log.Fatal(err)
}
log.Println(response.Status) // success
```
## Testing
You can run the unit tests for this client from the root directory using the command below:
```bash
go test -v
```
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details