Integrating SUBTC Protocol with Blesta — BTC Payment Gateway Architecture

permalink SUBTC
#blesta#btc#integrating#protocol#subtc

SUBTC Protocol can be integrated with Blesta to enable automated Bitcoin payments for hosting services, domains, and subscriptions.

Blesta is modular and developer-friendly, making it ideal for a custom BTC gateway powered by SUBTC.

Base API:<br>https://subtc.net/api


1. Architecture Overview

Blesta acts as the billing system.

SUBTC acts as the execution layer.

Flow:

Client → Blesta → SUBTC API → Bitcoin Network


2. Integration Components

1. Payment Gateway Plugin (Blesta)

Create a custom gateway inside:

/components/gateways/nonmerchant/

Responsibilities:

  • Generate BTC payment address
  • Link invoice to wallet/address
  • Trigger payment checks
  • Confirm transactions

2. SUBTC API Layer

Blesta communicates with SUBTC using curl or PHP HTTP client.

Core operations:

  • wallet_create
  • wallet_receive
  • wallet_poll
  • wallet_wait_event

3. Payment Flow

Step 1 — Invoice Created

  • Blesta generates invoice
  • Gateway assigns expected_sat

Step 2 — Generate Address

$response = http_post("https://api.subtc.net/v1/btc?mode=wallet_receive", [
  "wallet_id" => $wallet_id
]);

$address = $response["result"]["address"];
<br>Display address to client.


Step 3 — Client Pays

User sends BTC to address

Blesta stores:

address

expected_sat

invoice_id


Step 4 — Monitor Payment

Option A: Polling<br>

$response = http_post("https://api.subtc.net/v1/btc?mode=wallet_poll", [
  "wallet_id" => $wallet_id,
  "address" => $address,
  "expected_sat" => $amount
]);
<br>Option B: Webhook (Recommended)<br>
$response = http_post("https://api.subtc.net/v1/btc?mode=wallet_wait_event", [
  "wallet_id" => $wallet_id,
  "address" => $address,
  "expected_sat" => $amount,
  "callback_url" => "https://yourblesta.com/webhook"
]);


Step 5 — Activate Service

When:

received_sat >= expected_sat

Blesta:

Marks invoice as paid

Activates hosting / domain

Sends confirmation to client


  1. Webhook Handler Example
$data = json_decode(file_get_contents("php://input"), true);

if ($data["reached"] && $data["received_sat"] >= $data["expected_sat"]) {
    // Mark invoice paid
    activate_service($data);
}

  1. Wallet Strategy

Use dedicated wallets:

main wallet (gateway)

profit wallet (withdrawals)

cold wallet (storage)

Best practice:

Auto-withdraw daily to cold wallet

Treat Blesta wallet as hot wallet only


  1. Security Best Practices

Store X-SUBTC-KEY in .env

Do not expose wallet_id publicly

Use Docker for isolation

Use HTTPS webhook endpoints

Optional: integrate WireGuard for internal API layer


  1. Use Cases

Hosting services

VPS provisioning

Domain registration

SaaS subscriptions

One-time digital products


  1. Advantages Over Traditional Gateways

No Bitcoin node required

No RPC complexity

No KYC systems

Fully automated

AI-agent compatible


  1. AI Automation Layer

Blesta + SUBTC can be extended with AI:

Auto invoice monitoring

Smart pricing

Fraud detection

Autonomous refunds

Trading bots managing treasury


Conclusion

Integrating SUBTC Protocol with Blesta creates a fully automated BTC payment system for hosting platforms.

Simple curl-based API

Deterministic execution

Real-time payment tracking

AI-ready infrastructure

Blesta becomes the interface.

SUBTC becomes the engine.

Together:

→ Sovereign, automated Bitcoin billing system for modern infrastructure.