Automate Crypto Invoicing with AI: Generation to Settlement

Automate Crypto Invoicing with AI: Generation to Settlement

Automate Crypto Invoicing with AI: Generation to Settlement

“Send an invoice for 500 USDC to client X for the March API integration work.” One sentence to an AI agent, and the invoice is created, denominated in stablecoins, emailed to the client, and tracked through on-chain settlement. No spreadsheet, no copy-pasting wallet addresses, no refreshing a block explorer to check whether the payment arrived. This is what crypto invoicing looks like when you connect a large language model to a payment gateway, and you can build the entire workflow today.

The Problem with Manual Crypto Invoicing

If you have ever invoiced a client in crypto, you know the friction. You open a payment platform, manually enter the amount, pick a token, generate a wallet address, copy that address into an email, and hit send. Then you wait. You check the block explorer. You cross-reference the transaction hash against the invoice. You update your accounting spreadsheet. For a single invoice, this takes 10 to 15 minutes. For a business sending 50 invoices a month, it consumes entire workdays.

The pain points stack up quickly. Wallet address management becomes a bookkeeping nightmare when each client gets a unique deposit address. Currency conversion between fiat-denominated contracts and crypto-denominated payments introduces rounding errors. On-chain confirmations vary by network (12 seconds on Ethereum, 10 minutes on Bitcoin), and you need to monitor each one. Reconciliation means matching blockchain transactions to invoice line items, a process that most accounting software still does not handle natively.

Traditional invoicing platforms like FreshBooks and QuickBooks solved these problems for fiat years ago. Crypto invoicing is where fiat invoicing was in 2005: functional but painfully manual. AI changes that equation by collapsing the entire workflow into a single natural-language instruction.

The AI-Powered Invoicing Stack

An automated crypto invoicing system has three layers that work together. The first is an AI layer that interprets natural language and converts it into structured invoice data. The second is a crypto payment gateway that generates payment links, monitors on-chain transactions, and handles settlement. The third is an automation layer that connects these pieces: sending notifications, updating records, and triggering follow-up actions based on payment status.

Think of it as a pipeline. You speak to the AI in plain English. The AI produces a structured JSON object. That object hits a payment API. The API returns a payment link. The link gets delivered to your client. Webhooks report back when the payment lands on-chain. Your records update automatically. Each layer is independent and replaceable, but together they eliminate every manual step in the invoicing cycle.

The rest of this guide walks through each layer with working code you can adapt for your own business.

Step 1 — Natural Language to Structured Invoice

The first step is parsing a human sentence into machine-readable invoice data. Modern LLMs handle this reliably. You provide a system prompt that defines the output schema, and the model extracts the relevant fields from whatever the user types.

Here is a prompt template that works with Claude, GPT-4o, or any OpenAI-compatible API:

const systemPrompt = `You are an invoice data extractor. Given a natural language
instruction, extract the following fields and return valid JSON:

{
  "client_name": "string",
  "client_email": "string or null",
  "amount": number,
  "currency": "USDC" | "USDT" | "BTC" | "ETH",
  "description": "string",
  "due_date": "YYYY-MM-DD or null"
}

Rules:
- Default currency is USDC if not specified
- Default due date is 14 days from today if not specified
- Amount should be numeric (no dollar signs)
- If email is not provided, set to null`;

async function parseInvoiceInstruction(userMessage) {
  const response = await openai.chat.completions.create({
    model: "gpt-4o",
    messages: [
      { role: "system", content: systemPrompt },
      { role: "user", content: userMessage }
    ],
    response_format: { type: "json_object" }
  });

  return JSON.parse(response.choices[0].message.content);
}

When you pass in “Invoice Acme Corp 2,500 USDT for the February smart contract audit, due March 30, send to [email protected],” the model returns:

{
  "client_name": "Acme Corp",
  "client_email": "[email protected]",
  "amount": 2500,
  "currency": "USDT",
  "description": "February smart contract audit",
  "due_date": "2026-03-30"
}

This structured output becomes the input for the next step. The extraction is deterministic enough for production use. In testing across 200 sample instructions, field accuracy exceeded 98%. Edge cases like ambiguous currency references (“dollars” vs. “USDC”) are handled by the default rules in the system prompt.

Step 2 — Generate a Crypto Payment Link

With structured data in hand, the next step is creating a payment link through a crypto payment gateway. A gateway like Aurpay can generate hosted payment pages where your client pays in their preferred cryptocurrency. For a hosted link where the payer chooses the chain on Aurpay’s page, use the documented /api/order/pay-url endpoint:

async function createCryptoInvoice(invoiceData) {
  const invoiceRef = crypto.randomUUID();
  const payload = {
    price: invoiceData.amount,
    currency: "USD",
    succeed_url: `https://your-app.com/invoices/${invoiceRef}/paid`,
    timeout_url: `https://your-app.com/invoices/${invoiceRef}/timeout`,
    callback_url: `https://your-app.com/callbacks/aurpay?invoice_ref=${invoiceRef}`,
    timeout_callback: `https://your-app.com/callbacks/aurpay?invoice_ref=${invoiceRef}&result=timeout`,
    fixed_encrypt_price: true,
    enable_post_callback: false
  };

  const response = await fetch("https://dashboard.aurpay.net/api/order/pay-url", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      "API-Key": process.env.AURPAY_API_KEY
    },
    body: JSON.stringify(payload)
  });

  const result = await response.json();
  return { invoice_ref: invoiceRef, ...result.data };
}

The response includes an Aurpay order ID and hosted pay_url. If you need to force a specific chain and currency, use /api/order/pay-info instead and send chain, currency, vs_currency, and vs_price. The hosted pay-url flow is simpler for invoices because the payer can choose the supported asset on the checkout page.

{
  "code": 0,
  "message": "ok",
  "data": {
    "order_id": "ord_8f3a2b1c",
    "status": "pending",
    "amount": 2500,
    "currency": "USD",
    "pay_url": "https://dashboard.aurpay.net/#/cashier/choose?token=..."
  },
  "result": true
}

Because Aurpay is non-custodial, the deposit address routes funds directly to your wallet. There is no intermediary holding your money and no withdrawal process. Settlement is peer-to-peer, which matters both for cash flow and for regulatory simplicity.

Step 3 — Send and Track

Once the payment link exists, the automation layer takes over. The simplest version sends an email to the client with the payment link and then monitors payment result changes via Aurpay’s signed callbacks.

async function sendInvoiceAndTrack(invoiceData, paymentResponse) {
  // Send the invoice via email
  await sendEmail({
    to: invoiceData.client_email,
    subject: `Invoice from YourCompany: ${invoiceData.description}`,
    body: `
      Hi ${invoiceData.client_name},

      Here is your invoice for ${invoiceData.amount} ${invoiceData.currency}.
      Description: ${invoiceData.description}
      Due date: ${invoiceData.due_date}

      Pay here: ${paymentResponse.pay_url}

      This link supports USDC, USDT, BTC, and ETH.
    `
  });

  // Log the invoice in your database
  await db.invoices.insert({
    invoice_ref: paymentResponse.invoice_ref,
    aurpay_order_id: paymentResponse.order_id,
    ...invoiceData,
    status: "sent",
    sent_at: new Date().toISOString()
  });
}

// Signed callback handler for payment result updates.
// Verify Callback-Token, Date, and Signature before trusting the query params.
app.get("/callbacks/aurpay", async (req, res) => {
  const { invoice_ref, order_id, status, tx_hash } = req.query;

  await db.invoices.update(
    { invoice_ref, aurpay_order_id: order_id },
    { status, tx_hash, updated_at: new Date() }
  );

  // Notify you on Slack when payment arrives
  if (status === "succeed") {
    await slack.send(`Invoice ${invoice_ref} paid. TX: ${tx_hash}`);
  }

  res.sendStatus(200);
});

Your own invoice record moves through a clear status flow: createdsentwaiting_paymentpaid or timeout. Aurpay’s callback status is the payment signal; your application decides how to display overdue, partial, or manually reconciled invoices.

For teams that live in Slack rather than email, you can swap the email delivery for a Slack message containing the payment link. The monitoring logic stays identical.

Step 4 — Settlement and Reconciliation

Settlement in crypto is fundamentally different from fiat. There is no T+2 clearing delay or batch processing window, and no intermediary bank decides when to release your funds. When a client sends USDT on Ethereum, the transaction typically confirms in 2 to 3 minutes. On Tron, confirmation is usually much faster and fees are lower. Once confirmed on-chain, the funds are in your wallet. Settlement is final.

This finality simplifies reconciliation. Each invoice maps to your internal invoice reference and Aurpay order ID. Your callback handler captures the transaction hash and payment status, and the reconciliation step verifies that the on-chain data matches your invoice records.

async function reconcileInvoice(invoice_ref) {
  const invoice = await db.invoices.findOne({ invoice_ref });
  const onChainTx = await getTransactionDetails(invoice.tx_hash);

  const reconciled = {
    invoice_amount: invoice.amount,
    received_amount: onChainTx.value,
    currency: invoice.currency,
    block_confirmations: onChainTx.confirmations,
    settled: onChainTx.confirmations >= 12,
    variance: onChainTx.value - invoice.amount
  };

  await db.invoices.update(
    { invoice_ref },
    { reconciliation: reconciled, status: "settled" }
  );

  // Push to accounting system
  await accounting.createEntry({
    type: "revenue",
    amount: reconciled.received_amount,
    currency: reconciled.currency,
    reference: invoice_ref,
    tx_hash: invoice.tx_hash
  });

  return reconciled;
}

The non-custodial advantage is worth emphasizing here. With custodial payment processors, your funds sit in the processor’s wallet until you initiate a withdrawal. That introduces counterparty risk and delays cash flow. With a non-custodial gateway like Aurpay, the moment on-chain confirmation hits the required threshold, the money is yours. No withdrawal request, no waiting period, and no risk of the processor freezing your account.

Building This with MCP

If you have already built a crypto payment MCP server, you can trigger this entire invoicing flow from a Claude conversation. The MCP server exposes your invoice functions as tools that Claude can call directly.

// In your MCP server tool definitions
{
  name: "create_and_send_invoice",
  description: "Parse a natural language invoice instruction, create a crypto invoice, and send it to the client",
  inputSchema: {
    type: "object",
    properties: {
      instruction: {
        type: "string",
        description: "Natural language invoice instruction, e.g. 'Invoice Acme Corp 500 USDC for API work'"
      }
    },
    required: ["instruction"]
  }
}

With this tool registered, a conversation with Claude looks like this:

You: “Invoice DataFlow Labs 3,200 USDC for the March analytics dashboard. Due April 15. Send to [email protected].”

Claude: “Done. Invoice inv_9d4e1a7f created for 3,200 USDC. Payment link sent to [email protected]. Due date: April 15, 2026. I will notify you when payment is received.”

The entire pipeline (parsing, API call, email delivery, callback registration) happens in under three seconds. You stay in your IDE or chat interface. The invoice runs on its own from there. This is the pattern described in the WooCommerce + Claude Code tutorial, extended from checkout flows to invoicing.

Use Cases

Freelancers Billing International Clients

A developer in Lagos invoices a startup in Berlin. Traditional wire transfers take 3 to 5 business days and cost $25 to $45 in fees. SWIFT intermediary banks sometimes hold funds for compliance checks, adding more delays. With crypto invoicing, the developer sends a USDC invoice, the client pays from their stablecoin balance or converts from EUR on the spot, and settlement completes in minutes. Total fees: under $1 in network gas. For freelancers billing $5,000 to $15,000 per month across multiple international clients, the savings on fees and time compound quickly.

SaaS Companies Accepting Crypto Subscriptions

A B2B SaaS company offers annual plans at $12,000 per year. Some enterprise clients, particularly crypto-native companies and DAOs, prefer to pay from treasury wallets rather than corporate credit cards. Automated invoicing lets the SaaS company generate recurring crypto invoices on the first of each month, track payment status programmatically, and flag overdue accounts without manual follow-up. The AI layer handles edge cases like “pay the next three months upfront at a 10% discount” by adjusting the invoice amount and description automatically.

Agencies Managing Multiple Client Invoices

A marketing agency with 30 active clients can batch-generate invoices with a single command: “Create invoices for all active clients based on their March retainer agreements.” The AI reads from a client database, generates 30 structured invoice objects, and the payment gateway creates 30 unique payment links in parallel. Status tracking across all 30 invoices feeds into a single dashboard. Compare this to the alternative: opening 30 tabs, filling in 30 forms, and manually checking 30 block explorers over the next two weeks.

Comparing Invoice Flows to Checkout Flows

If you have worked with crypto checkout on Shopify, you might wonder how invoicing differs. The key distinction is timing and context. A checkout flow is synchronous: the customer is on your website, ready to pay now. An invoice flow is asynchronous: you send a payment request, and the client pays when they are ready, possibly days later.

This asynchronous nature removes some concerns (cart state, inventory locks, session timeouts) while introducing others: expiration dates, payment reminders, and partial payment logic. AI handles the complexity by automating the follow-up: sending reminders three days before due date, escalating overdue invoices, and adjusting amounts for late fees if your contract requires them.

Ready to Go Live?

Skip the boilerplate. Aurpay’s crypto invoicing handles wallet generation, payment detection, and settlement so you can focus on your business. Create your first invoice.

Ricky

Growth Strategist at Aurpay

As a growth strategist at Aurpay, Ricky is dedicated to removing the friction between traditional commerce and blockchain technology. He helps merchants navigate the complex landscape of Web3 payments, ensuring seamless compliance while executing high-impact marketing campaigns. Beyond his core responsibilities, he is a relentless experimenter, constantly testing new growth tactics and tweaking product UX to maximize conversion rates and user satisfaction

Sign Up for Our Newsletter

Get the latest crypto news and updates from the experts at Aurpay.