Here is the general workflow for how to work with our service to process payments for your service:

1

Create invoice

First, you will need to create an invoice for your client to pay

2

Let the client pay

The invoice will contain the link to checkout page that you should redirect your customer to. On this page, client will choose the payment method (coin), based on which wallets you have setup in your console, and will conduct payment itself

3

Get payment webhook

Once the client paid and we confirmed the transaction, we mark the invoice as paid and send to your endpoints a webhook with all the information you need to know. The endpoint looks that way:

{
  "event": "invoice.paid",
  "invoice_id": "b0473464-120e-458b-97a3-a292504ca2a9",
  "merchant_id": "the-dev-merchant-cq8d",
  "absolute_amount": 10.0112,
  "fiat_amount_usd": 10.01,
  "payment_method": "usdt-trc20",
  "receiving_wallet": "TMvUo8nhSXzYF624QGBBU6LMKnAvReUtdr",
  "taken_fee": 0.2,
  "invoice_title": "",
  "invoice_description": "",
  "paid_at": 1745356435,
  "simulated_invoice": true,
  "custom_data": {"some_custom_data": "..."},
  "hmac": "e9aef0c9633f683c9094665bb3681e012074b85a3d55cf60b1bfbd0c6f008bc6"
}
4

Verify webhook

Sometimes, attackers may try to simulate the webhook to make your service think that the invoice has been paid, when it actually hasn’t been. To counter this issue our API and SDKs have built in method for webhooks verification. Here is how to do that:

from squaredinc_sdk import SquaredSDK


squared = SquaredSDK(
    api_key="your-api-key"
)

webhook = {
    "event": "invoice.paid",
    "invoice_id": "b0473464-120e-458b-97a3-a292504ca2a9",
    "merchant_id": "the-dev-merchant-cq8d",
    "absolute_amount": 10.0112,
    "fiat_amount_usd": 10.01,
    "payment_method": "usdt-trc20",
    "receiving_wallet": "TMvUo8nhSXzYF624QGBBU6LMKnAvReUtdr",
    "taken_fee": None,
    "invoice_title": "",
    "invoice_description": "",
    "paid_at": 1745356435,
    "simulated_invoice": None,
    "custom_data": {"some_custom_data": "..."},
    "hmac": "e9aef0c9633f683c9094665bb3681e012074b85a3d55cf60b1bfbd0c6f008bc6",
}

verified = squared.verify_webhook(webhook=webhook, raise_on_invalid=False)
if verified:
    print("Webhook verified!")
else:
    print("Webhook is not verified, hence invalid")

5

Implement your own logic

After you received and confirmed the webhook, you can now use your own business logic on top of that to process the payment