Java library
Accept crypto payments in your Java app
Create crypto invoices from your Java or Kotlin service and check signed webhooks, with nothing but the JDK. The money goes straight to your own wallet.
Install
implementation("com.arionpay:arionpay-java:1.0.0")What it does
ArionPay for Java developers
Read more
A webhook invoice and a getInvoice result are the same Invoice class, so one method can handle both. ArionPay never holds the money: it goes straight to your own wallet.- No dependencies: only the JDK (java.net.http). Java 11 or newer.
- Exact amounts: fiat prices are BigDecimal, crypto amounts are kept as text, never a rounded double.
- 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 throws SignatureException when it does not match or is more than 5 minutes old.
- inv.matches(order total, currency) compares the order total to the cent before you deliver.
- The client is safe to share between threads: build it once, for example as a Spring bean.
- Every file on Maven Central is signed with the ArionPay release key.
Requirements and licence
- Works with
- Java 11 or newer · Spring Boot, Jakarta Servlet, Micronaut, Quarkus, Javalin, plain Java, Kotlin · JDK 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
Step 1
Add the dependency
With Gradle: implementation("com.arionpay:arionpay-java:1.0.0"). With Maven: groupId com.arionpay, artifactId arionpay-java, version 1.0.0.
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.builder().
Step 3
Create an invoice
Call createInvoice(new InvoiceParams("49.90").currency("USD").orderId("1001")), then send the customer to invoice.getInvoiceUrl().
Step 4
Check the webhook
Set your webhook address on the Webhooks page, or per invoice with callbackUrl(...). Take the body as byte[], pass it to verifyWebhook with the ArionPay-Signature header, and deliver on invoice.paid.
Step 5
Test without real money
Create an invoice with .asset("USDT_TRC20").test(true), then call simulatePayment(inv.getId(), "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(id).isPaid()). Coming back to the success URL does not prove payment.
- Before you deliver, match the invoice to your order: your order id or metadata, and inv.matches(order.getTotal(), order.getCurrency()).
- 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 event.getId() 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 Java library
Short answers before you add it to your code.