Skip to content

Latest commit

 

History

History
110 lines (91 loc) · 7.47 KB

README.md

File metadata and controls

110 lines (91 loc) · 7.47 KB

NOWPayments Go Library

Go Reference Go Report Card codecov

This repository is originally forked from repository is https://codecov.io/gh/matn/go-nowpayments This is an unofficial Go library for the crypto NOWPayments API

Topic Endpoint Package.Method Implemented
Instant Payments Notifications Yes
Verify signature ipn.VerifyRequestSignature(...) ✔️
Subscriptions Yes
Create plan subscriptions.New(...) ✔️
Create e-mail subscription subscriptions.NewWithEmail(...) ✔️
Update plan subscriptions.Update(...) ✔️
Get plan subscriptions.Get(...) ✔️
List plans subscriptions.List(...) ✔️
Recurring payments Yes
Create recurring_payments.New(...) ✔️
Get recurring_payments.Get(...) ✔️
Delete recurring_payments.Delete(...) ✔️
Billing (sub-partner / Custody) Yes
Deposit with payment custody.NewDepositWithPayment(...) ✔️
Deposit from master account custody.NewDepositFroMasterAccount(...) ✔️
Get payments custody.GetPayments(...) ✔️
Transfer between users custody.NewTransfer(...) ✔️
Get transfer custody.GetTransfer(...) ✔️
List transfers custody.ListTransfers(...) ✔️
Create user custody.NewUser(...) ✔️
List users custody.ListUsers(...) ✔️
Get user balance custody.GetBalance(...) ✔️
Write-off to master account custody.NewWriteOffToMaster(...) ✔️
Payments Yes
Get estimated price payments.EstimatedPrice(...) ✔️
Get the minimum payment amount payments.MinimumAmount(...) ✔️
Get payment status payments.Status() ✔️
Get list of payments payments.List(...) ✔️
Get/Update payment estimate payments.RefreshEstimatedPrice(...) ✔️
Create invoice payments.NewInvoice(...) ✔️
Create payment payments.New(...) ✔️
Create payment from invoice payments.NewFromInvoice(...) ✔️
Currencies Yes
Get available currencies currencies.All() ✔️
Get available checked currencies currencies.Selected() ✔️
Payouts No
API status Yes
Get API status core.Status() ✔️
Authentication Yes
Authentication core.Authenticate(...) ✔️

Installation

$ go get github.com/CIDgravity/go-nowpayments@v1.0.0

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/CIDgravity/go-nowpayments/config"
	"github.com/CIDgravity/go-nowpayments/core"
	"github.com/CIDgravity/go-nowpayments/payments"
)

func main() {
	err := config.Load(strings.NewReader(`
            {
                  "server": "https://api-sandbox.nowpayments.io/v1",
                  "login": "some_email@domain.tld",
                  "password": "some_password",
                  "apiKey": "some_api_key"
            }
      `))

	if err != nil {
		log.Fatal(err)
	}

	core.UseBaseURL(core.BaseURL(config.Server()))
	core.UseClient(core.NewHTTPClient())

	ps, err := payments.List(&payments.ListOption{
		Limit: 2,
	})

	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("Last %d payments: %v\n", limit, ps)
}

CLI Tool

The CLI tool has not been updated and is not maintained in this repository To use it, you can do it from the original repository https://codecov.io/gh/matn/go-nowpayments