Skip to content
ArionPay

Go module

Accept crypto payments in your Go app

Create crypto invoices from your Go service and check signed webhooks with nothing but the standard library. The money goes straight to your own wallet.

Install

go get github.com/ArionPay-Dev/arionpay-go
Source on GitHub
Example

What it does

ArionPay for Go developers

arionpay-go is the official ArionPay client for Go 1.21 or newer, with no dependencies outside the standard library. It creates and reads invoices, checks webhook signatures on the raw body, and takes a context.Context on every call.
Read moreA webhook invoice and a GetInvoice result are the same arionpay.Invoice type, so one function can handle both. ArionPay never holds the money: it goes straight to your own wallet.
  • No dependencies (standard library only). Go 1.21 or newer.
  • Every call takes a context.Context. A cancelled context also stops the waits between retries.
  • Every invoice request carries an idempotency key, so a network error can never create two invoices.
  • VerifyWebhook checks the signature on the raw body and returns a *SignatureError when it does not match or is more than 5 minutes old.
  • Amounts are arionpay.Amount: the text exactly as ArionPay sent it, never rounded. inv.Matches("49.90", "USD") compares the order total to the cent.
  • A Client is safe to share between goroutines. The default HTTP client has a 20 s timeout and follows no redirects.
  • SimulatePayment and SendTestWebhook let you test without real money.

Requirements and licence

Works with
Go 1.21 or newer · net/http, Gin, Echo, Chi, Fiber · standard library only
Cost
The library is free. ArionPay charges 0.5% per payment, with no monthly fee.
Source
Open source (MIT) on GitHub.

Setup

Set it up in 5 steps

  1. Step 1

    Add the module

    Run go get github.com/ArionPay-Dev/arionpay-go and import it as arionpay "github.com/ArionPay-Dev/arionpay-go".

  2. Step 2

    Copy your keys

    In your ArionPay dashboard, open your store and copy the API key (pk_) and the API secret (sk_, it asks for your authenticator code). The webhook signing secret (whsec_) is on the Webhooks page. Pass them to arionpay.New in a Config.

  3. Step 3

    Create an invoice

    Call client.CreateInvoice(ctx, arionpay.InvoiceParams{...}) with the Amount, Currency and OrderID, then redirect to inv.InvoiceURL.

  4. Step 4

    Check the webhook

    Set your webhook address on the Webhooks page, or per invoice with CallbackURL. Read the raw body, pass it to client.VerifyWebhook with the ArionPay-Signature header, and deliver on invoice.paid.

  5. Step 5

    Test without real money

    Create an invoice with Test: arionpay.Bool(true) and an Asset such as USDT_TRC20, then call client.SimulatePayment(ctx, inv.ID, "exact"). Your webhook gets invoice.paid, like a real payment.

After the setup

How a payment reaches your code

  • invoice.pending: a payment was seen on the network and waits for confirmations. Do not deliver yet.
  • invoice.paid: fully paid and confirmed, or accepted by you by hand in the dashboard. Deliver only on this event (or when GetInvoice returns Status "paid"). Coming back to SuccessURL does not prove payment.
  • Before you deliver, match the invoice to your order: your OrderID or Metadata, and inv.Matches(order.Total, order.Currency).
  • invoice.partial, invoice.expired and invoice.needs_review never mean deliver. A late payment can still make an expired invoice paid.
  • ArionPay sends again for about 3 days when your server does not answer 2xx. Handle each ev.ID once.

16 coins and tokens on 9 networks

All coins
  • BTCBitcoin
  • ETHEthereum
  • USDTEthereum
  • USDCEthereum
  • BNBBNB Smart Chain
  • USDTBNB Smart Chain
  • USDCBNB Smart Chain
  • POLPolygon
  • USDTPolygon
  • USDCPolygon
  • TRXTRON
  • USDTTRON
  • LTCLitecoin
  • DOGEDogecoin
  • BCHBitcoin Cash
  • DASHDash

Questions about the ArionPay Go library

Short answers before you add it to your code.

Yes. Read the raw body with c.GetRawData() in Gin or io.ReadAll(c.Request().Body) in Echo, and pass it to VerifyWebhook. Do not bind the body to a struct first.