https://github.com/ndolestudio/coinpayments-go
Unofficial Go API for CoinPayments
https://github.com/ndolestudio/coinpayments-go
coinpayments coinpayments-api
Last synced: about 1 year ago
JSON representation
Unofficial Go API for CoinPayments
- Host: GitHub
- URL: https://github.com/ndolestudio/coinpayments-go
- Owner: NdoleStudio
- License: mit
- Created: 2022-05-21T09:50:48.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-08-30T13:57:06.000Z (almost 3 years ago)
- Last Synced: 2025-02-02T15:54:15.626Z (over 1 year ago)
- Topics: coinpayments, coinpayments-api
- Language: Go
- Homepage: https://www.coinpayments.net/apidoc-intro
- Size: 17.6 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# coinpayments-go
[](https://github.com/NdoleStudio/coinpayments-go/actions/workflows/main.yml)
[](https://codecov.io/gh/NdoleStudio/coinpayments-go)
[](https://scrutinizer-ci.com/g/NdoleStudio/coinpayments-go/?branch=main)
[](https://goreportcard.com/report/github.com/NdoleStudio/coinpayments-go)
[](https://github.com/NdoleStudio/coinpayments-go/graphs/contributors)
[](https://github.com/NdoleStudio/coinpayments-go/blob/master/LICENSE)
[](https://pkg.go.dev/github.com/NdoleStudio/coinpayments-go)
This package provides a generic `go` client template for the CoinPayments HTTP API
## Installation
`coinpayments-go` is compatible with modern Go releases in module mode, with Go installed:
```bash
go get github.com/NdoleStudio/coinpayments-go
```
Alternatively the same can be achieved if you use `import` in a package:
```go
import "github.com/NdoleStudio/coinpayments-go"
```
## Implemented
- [Payments](#payments)
- `create_transaction`: Create Transaction
## Usage
### Initializing the Client
An instance of the client can be created using `New()`.
```go
package main
import (
"github.com/NdoleStudio/coinpayments-go"
)
func main() {
client := coinpayments.New(
coinpayments.WithAPIKey(/* API Key */),
coinpayments.WithAPISecret(/* API Secret */),
)
}
```
### Error handling
All API calls return an `error` as the last return object. All successful calls will return a `nil` error.
```go
status, response, err := client.Payments.CreatePayment(context.Background())
if err != nil {
//handle error
}
```
### Payments
#### `create_transaction`: Create Transaction
```go
transaction, response, err := client.Payments.CreatePayment(context.Background(), &CreatePaymentRequest{
Amount: "1.00000000",
OriginalCurrency: "USD",
SendingCurrency: "USD",
BuyerEmail: "john@example.com",
}
)
if err != nil {
log.Fatal(err)
}
log.Println(transaction.Error) // ok
```
## 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