← All Posts
Integrations

Integrating Paychainly with WooCommerce: Accept Crypto in Your WordPress Store

May 21, 2026· 1 min read

Overview

WooCommerce exposes a WC_Payment_Gateway class that you extend to add custom payment methods. Your gateway will create a Paychainly payment link, redirect the customer, and listen for the webhook to mark the order complete.

Plugin Skeleton

<?php
class WC_Paychainly_Gateway extends WC_Payment_Gateway {
  public function __construct() {
    $this->id = 'paychainly';
    $this->method_title = 'USDT (Paychainly)';
    $this->has_fields = false;
    $this->init_settings();
    $this->api_key = $this->get_option('api_key');
  }

  public function process_payment($order_id) {
    $order = wc_get_order($order_id);
    $response = wp_remote_post('https://api.paychainly.com/api/v1/payment-links', [
      'headers' => ['x-api-key' => $this->api_key, 'Content-Type' => 'application/json'],
      'body' => json_encode([
        'amount' => $order->get_total(),
        'description' => 'Order #' . $order_id,
        'metadata' => ['orderId' => $order_id],
      ]),
    ]);
    $data = json_decode(wp_remote_retrieve_body($response), true);
    return ['result' => 'success', 'redirect' => $data['data']['payUrl']];
  }
}

Webhook Handler

add_action('woocommerce_api_paychainly', function() {
  $payload = file_get_contents('php://input');
  $sig = $_SERVER['HTTP_X_PAYCHAINLY_SIGNATURE'] ?? '';
  $secret = get_option('paychainly_webhook_secret');

  if (!hash_equals('sha256=' . hash_hmac('sha256', $payload, $secret), $sig)) {
    http_response_code(401); exit;
  }

  $event = json_decode($payload, true);
  $orderId = $event['metadata']['orderId'];
  $order = wc_get_order($orderId);
  $order->payment_complete($event['txHash']);
});

Webhook URL

Register the webhook URL in Paychainly dashboard as:

https://yourstore.com/wc-api/paychainly

Testing

Enable Paychainly sandbox mode and set WooCommerce to test mode. Place a test order and verify the order status transitions to Processing after the sandbox credit fires.

← Back to Blog
WooCommerceWordPresscrypto checkoutUSDTe-commerce