ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - matm/go-nowpayments: Go library for the crypto NOWPayments API
Go library for the crypto NOWPayments API. Contribute to matm/go-nowpayments development by creating an account on GitHub.
Visit Site

GitHub - matm/go-nowpayments: Go library for the crypto NOWPayments API

GitHub - matm/go-nowpayments: Go library for the crypto NOWPayments API

NOWPayments Go Library

Go Reference Go Report Card codecov

This is an unofficial Go library for the crypto NOWPayments API version 1.

Note that the current implementation mostly focuses on the payments API for now:

Topic Endpoint Package.Method Implemented
Recurring payments No
Billing (sub-partner) No
Payments Yes
Get estimated price payments.EstimatedPrice(...) :heavy_check_mark:
Get the minimum payment amount payments.MinimumAmount(...) :heavy_check_mark:
Get payment status payments.Status() :heavy_check_mark:
Get list of payments payments.List(...) :heavy_check_mark:
Get/Update payment estimate payments.RefreshEstimatedPrice(...) :heavy_check_mark:
Create invoice payments.NewInvoice(...) :heavy_check_mark:
Create payment payments.New(...) :heavy_check_mark:
Create payment from invoice payments.NewFromInvoice(...) :heavy_check_mark:
Currencies Yes
Get available currencies currencies.All() :heavy_check_mark:
Get available checked currencies currencies.Selected() :heavy_check_mark:
Payouts No
API status Yes
Get API status core.Status() :heavy_check_mark:
Authentication Yes
Authentication core.Authenticate(...) :heavy_check_mark:

Installation

$ go get github.com/matm/[email protected]

Usage

Just load the config with all the credentials from a file or using a Reader then display the NOWPayments' API status and the last 2 payments made with:

package main

import (
	"fmt"
	"log"
	"strings"

	"github.com/matm/go-nowpayments/config"
	"github.com/matm/go-nowpayments/core"
	"github.com/matm/go-nowpayments/payments"
)

func main() {
      // Load sandbox's credentials.
	err := config.Load(strings.NewReader(`
{
      "server": "https://api-sandbox.nowpayments.io/v1",
      "login": "[email protected]",
      "password": "some_password",
      "apiKey": "some_api_key"
}
`))
	if err != nil {
		log.Fatal(err)
	}

	// Use the server URL defined above.
	core.UseBaseURL(core.BaseURL(config.Server()))
	// Use default HTTP client.
	core.UseClient(core.NewHTTPClient())

	st, err := core.Status()
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println("API status:", st)

	const limit = 2
	ps, err := payments.List(&payments.ListOption{
		Limit: limit,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Last %d payments: %v\n", limit, ps)
}

CLI Tool

A np tool is available to easily play with the payments API from the command line. Please make sure to target the sandbox API server in this case.

Can be installed with:

$ go install github.com/matm/go-nowpayments/cmd/np@latest

The following commands are available:

Usage of np:
  -a float
        pay amount for new payment/invoice (default 2)
  -c    show list of selected currencies
  -case string
        payment's case (sandbox only) (default "success")
  -debug
        turn debugging on
  -f string
        JSON config file to use
  -i    new invoice
  -l    list all payments
  -n    new payment
  -p string
        status of payment ID
  -pc string
        crypto currency to pay in (default "xmr")
  -pi string
        new payment from invoice ID

In order to work, np expects a JSON config file provided as an argument, like

$ np -f conf.json -c

to list all crypto currencies available for payments.

The JSON config file looks like

{
  "server": "https://api-sandbox.nowpayments.io/v1",
  "login": "your_email_adresse",
  "password": "some_password",
  "apiKey": "the API key to use"
}
  • server is the path to the API server, i.e. one of
    • sandbox: https://api-sandbox.nowpayments.io/v1
    • production: https://api.nowpayments.io/v1
  • login and password are your NOWPayments credentials
  • apiKey is one API key generated in your admin account

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory