Skip to content

Commit

Permalink
debug: rename -d flag to -debug
Browse files Browse the repository at this point in the history
Fixes #38
  • Loading branch information
matm committed Jan 24, 2023
1 parent e6347ed commit de0104a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
v 1.0.4
- debug: rename -d flag to -debug. #38
- Remove hacks for pay_amount and payment_id with custom unmarshalling. #36

v 1.0.3
Expand Down
50 changes: 49 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,49 @@ Topic|Endpoint|Package.Method|Implemented
$ 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 with:

```go
package main

import (
"fmt"
"log"
"strings"

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

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)
}
```

## 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.
Expand All @@ -51,14 +94,19 @@ Usage of np:
-a float
pay amount for new payment/invoice (default 2)
-c show list of selected currencies
-d turn debugging on
-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
```
Expand Down
3 changes: 2 additions & 1 deletion cmd/np/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func main() {
payAmount := flag.Float64("a", 2.0, "pay amount for new payment/invoice")
payCurrency := flag.String("pc", "xmr", "crypto currency to pay in")
listPayments := flag.Bool("l", false, "list all payments")
debug := flag.Bool("d", false, "turn debugging on")
debug := flag.Bool("debug", false, "turn debugging on")
showCurrencies := flag.Bool("c", false, "show list of selected currencies")
newInvoice := flag.Bool("i", false, "new invoice")
newPaymentFromInvoice := flag.String("pi", "", "new payment from invoice ID")
Expand All @@ -45,6 +45,7 @@ func main() {

if *debug {
core.WithDebug(true)
fmt.Fprintln(os.Stderr, "Debug:", *debug)
}

if *paymentID != "" {
Expand Down

0 comments on commit de0104a

Please sign in to comment.