PHP library
Accept crypto payments in your PHP app
Create a crypto invoice from any PHP site, send the customer to the payment page, and check the signed webhook when they pay. The money goes straight to your own wallet.
Install
composer require arionpay/arionpay-phpWhat it does
ArionPay for PHP developers
Read more
You can install it with Composer, or upload the folder and require its autoload.php, so it also fits shared hosting. ArionPay never holds the money: each payment goes straight to your own wallet.- PHP 7.4 or newer. No dependencies.
- Uses cURL when installed, PHP streams otherwise. Redirects are never followed.
- Works with Composer, or without it: copy the folder and require autoload.php.
- The same idempotencyKey always returns the same invoice, so a page reload does not create a second one. Without your own key, a random one protects retries.
- Signs each invoice request with HMAC-SHA256 and your API secret. The secret itself is never sent.
- Webhook::fromGlobals reads the raw body and the ArionPay-Signature header, and throws SignatureException when the signature is wrong or more than 5 minutes old.
- simulatePayment and sendTestWebhook let you try the whole flow without real money.
Requirements and licence
- Works with
- PHP 7.4 or newer · with or without Composer, shared hosting included · cURL or PHP streams
- 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
Install the library
Run composer require arionpay/arionpay-php. Without Composer, upload the folder next to your site and require __DIR__ . '/arionpay-php/autoload.php'.
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. Keep them in environment variables or a config file outside the web root.
Step 3
Create an invoice
Call createInvoice with the amount, currency, orderId and an idempotencyKey, then redirect the customer to $invoice['invoiceUrl'].
Step 4
Check the webhook
Set a public https:// address on port 443 or 8443 on the Webhooks page, or per invoice with callbackUrl. In that script, call Webhook::fromGlobals($secret) and deliver the order on invoice.paid.
Step 5
Test without real money
Create an invoice with 'test' => true and an asset such as USDT_TRC20, then call simulatePayment($invoice['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() says paid). Coming back to successUrl does not prove payment.
- Before you deliver, match the invoice to your order: your orderId or metadata, and the same amount and currency as the order's current total.
- 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 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 PHP library
Short answers before you add it to your code.