Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 28 days 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 (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-05T10:37:38.000Z (over 1 year ago)
- Last Synced: 2024-06-20T17:46:46.355Z (7 months ago)
- Topics: api-client, api-client-go, flutterwave, flutterwave-api
- Language: Go
- Homepage: https://developer.flutterwave.com/reference
- Size: 31.3 KB
- Stars: 4
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flutterwave-go
[![Build](https://github.com/NdoleStudio/flutterwave-go/actions/workflows/main.yml/badge.svg)](https://github.com/NdoleStudio/flutterwave-go/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/NdoleStudio/flutterwave-go/branch/main/graph/badge.svg)](https://codecov.io/gh/NdoleStudio/flutterwave-go)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/NdoleStudio/flutterwave-go/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/NdoleStudio/flutterwave-go/?branch=main)
[![Go Report Card](https://goreportcard.com/badge/github.com/NdoleStudio/flutterwave-go)](https://goreportcard.com/report/github.com/NdoleStudio/flutterwave-go)
[![GitHub contributors](https://img.shields.io/github/contributors/NdoleStudio/flutterwave-go)](https://github.com/NdoleStudio/flutterwave-go/graphs/contributors)
[![GitHub license](https://img.shields.io/github/license/NdoleStudio/flutterwave-go?color=brightgreen)](https://github.com/NdoleStudio/flutterwave-go/blob/master/LICENSE)
[![PkgGoDev](https://pkg.go.dev/badge/github.com/NdoleStudio/flutterwave-go)](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## Usage
### Initializing the Client
An instance of the `flutterwave` client can be created using `New()`.
```go
package mainimport (
"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