This package provides a generic go
client template for the CoinPayments HTTP API
coinpayments-go
is compatible with modern Go releases in module mode, with Go installed:
go get github.com/NdoleStudio/coinpayments-go
Alternatively the same can be achieved if you use import
in a package:
import "github.com/NdoleStudio/coinpayments-go"
- Payments
create_transaction
: Create Transaction
An instance of the client can be created using New()
.
package main
import (
"github.com/NdoleStudio/coinpayments-go"
)
func main() {
client := coinpayments.New(
coinpayments.WithAPIKey(/* API Key */),
coinpayments.WithAPISecret(/* API Secret */),
)
}
All API calls return an error
as the last return object. All successful calls will return a nil
error.
status, response, err := client.Payments.CreatePayment(context.Background())
if err != nil {
//handle error
}
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
You can run the unit tests for this client from the root directory using the command below:
go test -v
This project is licensed under the MIT License - see the LICENSE file for details