Cryptocurrency Payment Gateway Integration (CoinGate/NOWPayments/BitPay)
CoinGate, NOWPayments, BitPay are crypto payment aggregators. Accept 50–300 cryptocurrencies, convert at current rate and pay seller in fiat or crypto on schedule. Seller doesn't need private keys, wait blockchain confirmations or track exchange — aggregator handles it.
Integration takes 1–3 working days.
Provider Comparison
NOWPayments — largest coin list (300+), has sandbox, well-documented API. Commission 0.5%. Works with individuals.
CoinGate — verified provider since 2014, good reputation, strict business verification. Commission 1%.
BitPay — oriented for large business, minimum volume for commercial plan, high KYB requirements.
NOWPayments: Creating Payment
use GuzzleHttp\Client;
class NOWPaymentsClient
{
private Client $http;
private string $apiKey;
public function __construct(string $apiKey, bool $sandbox = false)
{
$this->apiKey = $apiKey;
$baseUri = $sandbox
? 'https://api-sandbox.nowpayments.io/v1/'
: 'https://api.nowpayments.io/v1/';
$this->http = new Client([
'base_uri' => $baseUri,
'headers' => ['x-api-key' => $apiKey],
]);
}
public function createPayment(array $params): array
{
$response = $this->http->post('payment', ['json' => $params]);
return json_decode($response->getBody()->getContents(), true);
}
public function getMinAmount(string $currency, string $fiatCurrency = 'usd'): float
{
$response = $this->http->get("min-amount?currency_from={$currency}¤cy_to={$fiatCurrency}");
return json_decode($response->getBody()->getContents(), true)['min_amount'];
}
}
// Create payment
$client = new NOWPaymentsClient(env('NOWPAYMENTS_API_KEY'), app()->isLocal());
$payment = $client->createPayment([
'price_amount' => $order->total,
'price_currency' => 'usd',
'pay_currency' => 'btc', // or 'eth', 'usdttrc20', etc.
'order_id' => (string) $order->id,
'order_description'=> 'Order #' . $order->id,
'ipn_callback_url' => route('payments.nowpayments.webhook'),
'success_url' => route('orders.success', $order),
'cancel_url' => route('checkout'),
]);
Redirect customer to $payment['invoice_url']. NOWPayments shows coin selection page and QR code with payment address.
CoinGate: API
$payment = $coingate->order->create([
'order_id' => $order->id,
'price_amount' => $order->total,
'price_currency' => 'EUR',
'receive_currency' => 'EUR', // receive in euro, not crypto
'title' => 'Order #' . $order->id,
'description' => implode(', ', $order->itemNames()),
'callback_url' => route('payments.coingate.webhook'),
'success_url' => route('orders.success', $order),
'cancel_url' => route('checkout'),
'token' => $order->token, // unique token for security
]);
// Redirect to $payment->payment_url
Webhook Handling — NOWPayments
NOWPayments sends IPN (Instant Payment Notification) to ipn_callback_url:
public function handleNowPaymentsWebhook(Request $request): Response
{
$raw = $request->getContent();
$signature = $request->header('x-nowpayments-sig');
// Signature verification
$sorted = json_encode(
collect(json_decode($raw, true))->sortKeys()->all(),
JSON_UNESCAPED_UNICODE
);
$expected = hash_hmac('sha512', $sorted, config('services.nowpayments.ipn_secret'));
if (!hash_equals($expected, $signature)) {
return response('Forbidden', 403);
}
$data = json_decode($raw, true);
$order = Order::find($data['order_id']);
$statusMap = [
'waiting' => 'pending',
'confirming' => 'pending',
'confirmed' => 'paid',
'sending' => 'paid',
'partially_paid' => 'partially_paid',
'finished' => 'paid',
'failed' => 'failed',
'refunded' => 'refunded',
'expired' => 'expired',
];
$order->update(['payment_status' => $statusMap[$data['payment_status']] ?? 'unknown']);
if ($data['payment_status'] === 'finished') {
$order->markAsPaid($data['payment_id']);
event(new OrderPaid($order));
}
return response('OK', 200);
}
Webhook — CoinGate
CoinGate sends form-encoded POST with token field for verification:
public function handleCoingateWebhook(Request $request): Response
{
$token = $request->input('token');
$orderId = $request->input('order_id');
$status = $request->input('status');
$order = Order::find($orderId);
if (!$order || $order->payment_token !== $token) {
return response('Forbidden', 403);
}
match ($status) {
'paid' => $order->markAsPaid($request->input('id')),
'canceled' => $order->update(['payment_status' => 'cancelled']),
'expired' => $order->update(['payment_status' => 'expired']),
default => null,
};
return response('OK', 200);
}
Customer Cryptocurrency Selection
Most aggregators show their own coin selection page. For custom selection on your site — create invoice for each coin or get supported coins list via API and create invoice only on selection:
// NOWPayments: get coin list
$currencies = $client->getAvailableCurrencies();
// Show dropdown to user
// On selection — create payment with chosen pay_currency
Partial Payments
NOWPayments supports partially_paid status — user paid less than required. Standard scenario: notify user and offer to pay difference or refund. Automatic refund via NOWPayments API — available via refunds endpoint, but only in crypto.







