A zero-dependency, idiomatic Go client for the Plisio cryptocurrency payment gateway API.
go get github.com/obeliskdev/plisio-gopackage main
import (
"context"
"fmt"
"log"
"os"
"github.com/obeliskdev/plisio-go"
)
func main() {
client := plisio.NewClient(os.Getenv("PLISIO_KEY")) // your SECRET_KEY
inv, err := client.CreateInvoice(context.Background(),
plisio.WithOrderName("order-1"),
plisio.WithOrderNumber(1001),
plisio.WithSourceAmount(20, plisio.USD), // 20 USD, converted to crypto
plisio.WithAllowedCurrencies(plisio.BTC, plisio.ETH, plisio.USDT_TRX),
plisio.WithCallbackURL("https://example.com/plisio/callback?json=true"),
plisio.WithExpireMin(30),
)
if err != nil {
log.Fatal(err)
}
fmt.Println("Pay at:", inv.InvoiceURL)
}Append ?json=true to your callback URL, then validate and parse each POST:
func handler(w http.ResponseWriter, r *http.Request) {
body, _ := io.ReadAll(r.Body)
cb, err := client.ParseCallback(body)
if err != nil {
http.Error(w, "invalid", http.StatusUnprocessableEntity)
return
}
if cb.Status == plisio.StatusCompleted {
// fulfill the order for cb.OrderNumber
}
w.WriteHeader(http.StatusOK)
}Plisio does not guarantee a consistent JSON type for monetary fields, so every
amount/rate is returned as plisio.Number:
f, _ := cb.Amount.Float64() // as float
s := cb.Amount.String() // exact text, no precision loss
if cb.Amount.IsNull() { ... }| Method | Description |
|---|---|
GetBalance |
Cryptocurrency balance |
GetCurrencies |
Supported cryptocurrencies |
CreateInvoice |
Create a payment invoice |
GetCommission |
Estimate commission + network fee |
Withdraw |
Send crypto (single or mass cash-out) |
GetFee |
Estimate network fee |
GetFeePlan |
Available fee plans |
GetOperations |
List transactions (paginated, filterable) |
GetOperation |
Transaction details |
ValidateCallback / ParseCallback |
Verify webhook signatures |
MIT