<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: CigalPay</title>
    <description>The latest articles on DEV Community by CigalPay (@cigalpay).</description>
    <link>https://dev.to/cigalpay</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4191283%2Fdf17c8d4-ac2b-432d-96c2-24e6e3f19661.png</url>
      <title>DEV Community: CigalPay</title>
      <link>https://dev.to/cigalpay</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cigalpay"/>
    <language>en</language>
    <item>
      <title>Sent on the Wrong Network? How to Prevent Lost Crypto Payments</title>
      <dc:creator>CigalPay</dc:creator>
      <pubDate>Thu, 26 Nov 2026 14:00:05 +0000</pubDate>
      <link>https://dev.to/cigalpay/sent-on-the-wrong-network-how-to-prevent-lost-crypto-payments-2jmp</link>
      <guid>https://dev.to/cigalpay/sent-on-the-wrong-network-how-to-prevent-lost-crypto-payments-2jmp</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;In short&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The same token can exist on several blockchains. Funds only arrive if they're sent on the network the receiving address belongs to.&lt;/li&gt;
&lt;li&gt;The most common mistake is choosing the wrong network when withdrawing a stablecoin from an exchange, such as ERC-20 instead of TRC-20.&lt;/li&gt;
&lt;li&gt;Clear network labels at checkout and format checks on payout addresses prevent most losses.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;"I sent the money, why hasn't it arrived?" is one of the hardest support tickets in crypto payments. Often the answer is that the transfer went out on a different blockchain from the one the address lives on. Unlike a mistyped card number, the network won't reject it - the funds simply end up somewhere the recipient can't access.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the same token exists on several networks
&lt;/h2&gt;

&lt;p&gt;Stablecoins in particular are issued on many blockchains. Tether, for example, lists USDT on Ethereum, Tron, Solana and more than a dozen others on its &lt;a href="https://tether.to/en/supported-protocols/" rel="noopener noreferrer"&gt;supported protocols page&lt;/a&gt;. Each version is a separate token on a separate chain. When a customer withdraws USDT from an exchange, they must pick the network - and the exchange may default to a different one than your checkout expects.&lt;/p&gt;

&lt;h2&gt;
  
  
  The most common mix-ups
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Sent on&lt;/th&gt;
&lt;th&gt;To an address for&lt;/th&gt;
&lt;th&gt;What usually happens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Ethereum (ERC-20)&lt;/td&gt;
&lt;td&gt;Tron (TRC-20)&lt;/td&gt;
&lt;td&gt;Usually rejected before sending: a Tron address (starts with T) isn't valid on Ethereum (0x)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;BNB Smart Chain&lt;/td&gt;
&lt;td&gt;Ethereum&lt;/td&gt;
&lt;td&gt;Arrives on a different chain at the same address; recovery needs the recipient's private key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ethereum&lt;/td&gt;
&lt;td&gt;Polygon&lt;/td&gt;
&lt;td&gt;Same situation: identical address format, different network&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bitcoin&lt;/td&gt;
&lt;td&gt;Bitcoin Cash&lt;/td&gt;
&lt;td&gt;Different chains with similar histories; funds aren't visible on the intended one&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;Same-format addresses are the dangerous case.&lt;/strong&gt; Ethereum, Polygon and other EVM networks share the 0x address format, so an address check can't tell them apart. Only the network label protects the customer here.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How to prevent it at checkout
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Name the network next to every address&lt;/strong&gt;, in plain words. CigalPay's checkout shows, for example, "Send only on Tron (TRC-20). Funds sent on another network can't be recovered."&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Show the token and network together in the coin list&lt;/strong&gt; - "Tether USD, Tron (TRC-20)" rather than just "USDT".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use payment URIs where they exist.&lt;/strong&gt; Standards like &lt;a href="https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki" rel="noopener noreferrer"&gt;BIP 21&lt;/a&gt; for Bitcoin and &lt;a href="https://docs.solanapay.com/spec" rel="noopener noreferrer"&gt;Solana Pay&lt;/a&gt; encode the chain and amount in the QR code, so the customer's wallet fills in the right details.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to prevent it on your own payouts
&lt;/h2&gt;

&lt;p&gt;The same risk applies when you move funds out. Before requesting a payout, check that the destination address is on the network you're paying out on. CigalPay's merchant dashboard checks the address format for the selected network - a 0x Ethereum address is rejected for a Tron payout - and shows a review screen with the full address before anything is submitted. Every payout request is also reviewed before funds move. The same check applies to refunds: the address the customer enters on their refund link must match the coin's network. Read more in our &lt;a href="https://cigalpay.com/blog/crypto-payment-security-checklist?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=wrong-network-crypto-deposits" rel="noopener noreferrer"&gt;security checklist&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  If it already happened
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Find the transaction ID in the sending wallet or exchange and look it up in that network's block explorer.&lt;/li&gt;
&lt;li&gt;If the funds went to an exchange address on an unsupported network, contact the exchange's support - some can recover deposits, often for a fee.&lt;/li&gt;
&lt;li&gt;If they went to an address on a network the recipient controls the keys for, the recipient may be able to access them by importing the key into a wallet for that network.&lt;/li&gt;
&lt;li&gt;If neither applies, recovery is usually not possible. That's why prevention matters so much.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can USDT sent on Ethereum be recovered from a Tron address?
&lt;/h3&gt;

&lt;p&gt;In most cases the transfer never leaves: a Tron address isn't valid on Ethereum, so wallets and exchanges reject it. If USDT was sent on Ethereum to some other, valid Ethereum address, recovery depends on who controls that address.&lt;/p&gt;

&lt;h3&gt;
  
  
  How can I tell which network an address belongs to?
&lt;/h3&gt;

&lt;p&gt;Some formats are distinctive: Tron addresses start with T, Bitcoin addresses often with bc1, 1 or 3, Ethereum-style addresses with 0x. But many networks share the 0x format, so always confirm the network explicitly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://tether.to/en/supported-protocols/" rel="noopener noreferrer"&gt;Supported protocols&lt;/a&gt;, Tether&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki" rel="noopener noreferrer"&gt;BIP 21: URI scheme for Bitcoin payments&lt;/a&gt;, Bitcoin Improvement Proposals&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.solanapay.com/spec" rel="noopener noreferrer"&gt;Solana Pay specification&lt;/a&gt;, Solana Pay&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developers.tron.network/docs/resource-model" rel="noopener noreferrer"&gt;Resource model (Tron accounts and addresses)&lt;/a&gt;, TRON Developer Hub&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://cigalpay.com/blog/wrong-network-crypto-deposits?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=wrong-network-crypto-deposits" rel="noopener noreferrer"&gt;CigalPay blog&lt;/a&gt;. Disclosure: I'm part of the CigalPay team. Questions? Ask in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>ethereum</category>
      <category>webdev</category>
      <category>crypto</category>
    </item>
    <item>
      <title>Why Crypto Invoices Expire: Exchange-Rate Locks Explained</title>
      <dc:creator>CigalPay</dc:creator>
      <pubDate>Tue, 24 Nov 2026 14:00:06 +0000</pubDate>
      <link>https://dev.to/cigalpay/why-crypto-invoices-expire-exchange-rate-locks-explained-2dk3</link>
      <guid>https://dev.to/cigalpay/why-crypto-invoices-expire-exchange-rate-locks-explained-2dk3</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;In short&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A crypto invoice converts your fiat price into a coin amount at the current rate. Because crypto prices move, that quote is valid only for a short window.&lt;/li&gt;
&lt;li&gt;CigalPay locks the rate for 30 minutes. If no payment arrives in time, the invoice expires and the customer starts a new one at a fresh rate.&lt;/li&gt;
&lt;li&gt;Stablecoins like USDT remove most of the price risk, but a time limit still keeps orders and payments matched cleanly.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Customers sometimes ask why a crypto checkout has a countdown when a card payment doesn't. The answer is price: a card payment settles in your own currency, while a crypto payment is a fixed amount of a coin whose value changes minute by minute. The timer is what makes that work fairly for both sides.&lt;/p&gt;

&lt;h2&gt;
  
  
  How a rate lock works
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Your order is priced in your currency, for example €240.&lt;/li&gt;
&lt;li&gt;When the customer picks a coin, the checkout converts €240 at the current exchange rate into an exact amount of that coin.&lt;/li&gt;
&lt;li&gt;That amount is held for a fixed period - 30 minutes in CigalPay - while the customer completes the transfer.&lt;/li&gt;
&lt;li&gt;If the payment arrives within the window, the order is paid at the locked rate, even if the market moved meanwhile.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why the window can't be open forever
&lt;/h2&gt;

&lt;p&gt;Without a time limit, a customer could open a checkout, wait for the coin's price to rise, and pay later with fewer euros' worth of crypto. Or the price could fall and you'd receive less than the order is worth. A short window keeps the quoted amount close to the real value of the order. It also keeps your records tidy: each invoice has a clear outcome - paid, partially paid, expired or failed.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens when an invoice expires?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No payment received:&lt;/strong&gt; the invoice closes. The customer returns to your shop and starts a new payment at the current rate.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Payment sent too late:&lt;/strong&gt; a transfer that arrives after the window closes isn't matched to the order automatically. The customer should contact you with their payment ID so it can be resolved by hand.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Part of the amount paid:&lt;/strong&gt; the invoice is marked partially paid. See &lt;a href="https://cigalpay.com/blog/underpaid-overpaid-crypto-payments?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=crypto-invoice-expiry-exchange-rate-lock" rel="noopener noreferrer"&gt;how to handle partial payments&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Make the countdown visible.&lt;/strong&gt; CigalPay's checkout shows the remaining time and switches to a warning in the last five minutes. Once a payment is detected, the timer disappears - a ticking clock after the customer has paid only causes worry.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Rate locks and payment links
&lt;/h2&gt;

&lt;p&gt;The same window applies to payment links you create in the merchant dashboard: a link is open for 30 minutes from the moment it's created. Create the link when the customer is ready to pay - not days in advance - and create a fresh one if it expires. We cover link workflows in &lt;a href="https://cigalpay.com/blog/payment-links-vs-api-integration?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=crypto-invoice-expiry-exchange-rate-lock" rel="noopener noreferrer"&gt;payment links vs. API integration&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Do stablecoin invoices still need a timer?
&lt;/h2&gt;

&lt;p&gt;A dollar stablecoin barely moves against the dollar, so the price risk is small for USD-priced orders. For a euro-priced order, the EUR/USD rate still moves. And a time limit keeps the link between order and payment clear. That's why stablecoin invoices use the same window - see &lt;a href="https://cigalpay.com/blog/accept-usdt-trc20-payments?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=crypto-invoice-expiry-exchange-rate-lock" rel="noopener noreferrer"&gt;accepting USDT on Tron&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How long does a customer have to pay a CigalPay invoice?
&lt;/h3&gt;

&lt;p&gt;30 minutes from the moment the invoice is created. The checkout shows a live countdown.&lt;/p&gt;

&lt;h3&gt;
  
  
  My payment link expired before the customer paid. What now?
&lt;/h3&gt;

&lt;p&gt;Create a new payment link from the dashboard and send it to the customer. The new link uses the current exchange rate.&lt;/p&gt;

&lt;h3&gt;
  
  
  The customer paid after the invoice expired. Is the money lost?
&lt;/h3&gt;

&lt;p&gt;Not necessarily. Late payments need manual handling: ask the customer for their payment ID and the transaction details, and contact support.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://bitcoin.org/en/you-need-to-know" rel="noopener noreferrer"&gt;Some things you need to know (on volatility)&lt;/a&gt;, Bitcoin.org&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki" rel="noopener noreferrer"&gt;BIP 21: URI scheme (amount field)&lt;/a&gt;, Bitcoin Improvement Proposals&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://cigalpay.com/blog/crypto-invoice-expiry-exchange-rate-lock?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=crypto-invoice-expiry-exchange-rate-lock" rel="noopener noreferrer"&gt;CigalPay blog&lt;/a&gt;. Disclosure: I'm part of the CigalPay team. Questions? Ask in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ecommerce</category>
      <category>payments</category>
      <category>crypto</category>
    </item>
    <item>
      <title>How to Accept Crypto Payments in n8n (No Code)</title>
      <dc:creator>CigalPay</dc:creator>
      <pubDate>Sat, 21 Nov 2026 14:00:07 +0000</pubDate>
      <link>https://dev.to/cigalpay/how-to-accept-crypto-payments-in-n8n-no-code-5e0p</link>
      <guid>https://dev.to/cigalpay/how-to-accept-crypto-payments-in-n8n-no-code-5e0p</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;In short&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The CigalPay community node (n8n-nodes-cigalpay) adds crypto payments to n8n: one node creates checkouts and reads payments, and the CigalPay Trigger starts a workflow when a payment is confirmed.&lt;/li&gt;
&lt;li&gt;You price in USD or EUR; customers pay in Bitcoin, USDT, Ethereum, Solana or another coin on the CigalPay payment page.&lt;/li&gt;
&lt;li&gt;The trigger checks each notification's signature before the workflow runs. Before delivering, compare the checkout ID and the amount with the order you created.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;n8n connects your forms, shop, CRM, email and chat without code. With the CigalPay node, the same workflows can take crypto payments: send a customer a payment link, then deliver, email a receipt or update a sheet once the payment is confirmed. This guide installs the node, creates a first checkout and builds the workflow that runs when a customer pays.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the CigalPay node does
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Node&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CigalPay&lt;/td&gt;
&lt;td&gt;Create a checkout and get its payment link; get a payment, the payments of an order or the active payments; refund a payment; list the coins accepted directly or converted at payment.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CigalPay Trigger&lt;/td&gt;
&lt;td&gt;Starts a workflow when CigalPay sends a signed payment notification: paid payments only, every status change, or the statuses you choose.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The CigalPay node also works as a tool for n8n's AI Agent, so an assistant can answer "which coins can I pay with?" or look up the status of an order.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Install the node
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;In a workflow, open the nodes panel (press &lt;strong&gt;N&lt;/strong&gt; or click &lt;strong&gt;+&lt;/strong&gt;) and search for &lt;strong&gt;CigalPay&lt;/strong&gt;. It shows n8n's verified badge.&lt;/li&gt;
&lt;li&gt;Select it and click &lt;strong&gt;Install node&lt;/strong&gt;. On self-hosted n8n you can also install it from &lt;strong&gt;Settings → Community Nodes → Install&lt;/strong&gt; with the package name &lt;code&gt;n8n-nodes-cigalpay&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Add a &lt;strong&gt;CigalPay&lt;/strong&gt; node to a workflow and create a &lt;strong&gt;CigalPay API&lt;/strong&gt; credential with your Account ID, API key and notification signing secret, from your &lt;a href="https://cigalpay.com/register" rel="noopener noreferrer"&gt;CigalPay dashboard&lt;/a&gt;, Settings → API credentials. Saving it tests the connection.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;n8n Cloud and self-hosted&lt;/strong&gt; CigalPay is a verified node: n8n reviewed and approved it, and it is available on n8n Cloud and in self-hosted n8n. Installing it takes an owner or admin of the instance. On n8n Cloud, if CigalPay doesn't show up, check that verified community nodes are enabled in the Admin Panel.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  2. Create a checkout
&lt;/h2&gt;

&lt;p&gt;Add the &lt;strong&gt;CigalPay&lt;/strong&gt; node with the action &lt;strong&gt;Create a checkout&lt;/strong&gt;. Set the price in USD or EUR (up to 5,000), your own order ID, a description, the page the customer returns to, and the &lt;strong&gt;Notification URL&lt;/strong&gt;: the production URL of the CigalPay Trigger from the next step. The node returns a &lt;code&gt;chargeLink&lt;/code&gt;: send it by email or chat, or redirect the customer to it.&lt;/p&gt;

&lt;p&gt;On the payment page, the customer picks a coin and sends the exact amount shown. The price is locked for 30 minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Run a workflow when the payment arrives
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Add a &lt;strong&gt;CigalPay Trigger&lt;/strong&gt; with the same credential, and choose &lt;strong&gt;Paid payments only&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Activate the workflow and copy the trigger's &lt;strong&gt;Production URL&lt;/strong&gt; into the checkout's Notification URL.&lt;/li&gt;
&lt;li&gt;Connect what should happen next: send the download link, email the receipt, add a row to Google Sheets, post in Slack or Telegram.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each notification carries the payment's status, your order ID as &lt;code&gt;extraId&lt;/code&gt;, the coin paid, and the checkout's &lt;code&gt;checkoutId&lt;/code&gt;, &lt;code&gt;checkoutAmount&lt;/code&gt; and &lt;code&gt;checkoutCurrency&lt;/code&gt;. The trigger checks the &lt;code&gt;x-cigalpay-sig&lt;/code&gt; signature and refuses anything unsigned or forged with a 401, before the workflow runs. To try it without paying, send a sample from the dashboard: Settings → API credentials → Test notification.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check the order before delivering
&lt;/h2&gt;

&lt;p&gt;Your Account ID is not secret: anyone can create a checkout with it and one of your order references, pay a small amount, and get a genuinely signed notification. Add an &lt;strong&gt;If&lt;/strong&gt; node after the trigger and deliver only when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;checkoutId&lt;/code&gt; is the ID the Create a checkout node returned for this order,&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;checkoutAmount&lt;/code&gt; and &lt;code&gt;checkoutCurrency&lt;/code&gt; match the price you set,&lt;/li&gt;
&lt;li&gt;the order hasn't been delivered yet: CigalPay notifies both &lt;code&gt;CONFIRMED&lt;/code&gt; and &lt;code&gt;FINISHED&lt;/code&gt;, so a workflow without this check would deliver twice.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Our &lt;a href="https://cigalpay.com/blog/crypto-payment-security-checklist" rel="noopener noreferrer"&gt;security checklist&lt;/a&gt; covers the other checks a payment workflow needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  A ready-made workflow: sell digital products
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://github.com/cigalpay/n8n-nodes-cigalpay/tree/main/examples" rel="noopener noreferrer"&gt;example workflow on GitHub&lt;/a&gt; does all of the above with n8n's built-in nodes. An n8n form takes the order, the workflow creates the checkout, saves the order in a Data Table and sends the customer to the payment page. When the payment is confirmed, it checks the checkout ID, currency and amount, emails the download link once and marks the order as delivered; a payment that doesn't match is sent to you instead. Import it with &lt;strong&gt;⋯ → Import from File&lt;/strong&gt; and follow the yellow note on the canvas.&lt;/p&gt;

&lt;h2&gt;
  
  
  Good to know
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Up to 5,000 USD or EUR per payment.&lt;/li&gt;
&lt;li&gt;One-time payments: there are no automatic renewals, so send a new checkout for each period.&lt;/li&gt;
&lt;li&gt;Payments that are &lt;a href="https://cigalpay.com/blog/underpaid-overpaid-crypto-payments" rel="noopener noreferrer"&gt;underpaid or overpaid&lt;/a&gt; arrive with their own status (&lt;code&gt;PARTIALLY_PAID&lt;/code&gt;): choose "Selected statuses" in the trigger to handle them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Can n8n accept crypto payments?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes. Add the CigalPay node, verified by n8n, from the nodes panel: it creates checkouts priced in USD or EUR, and the CigalPay Trigger starts a workflow when the customer's crypto payment is confirmed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do I need to write code?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No. The checkout, the payment notification and the signature check are handled by the nodes. You connect them to n8n's other nodes, such as forms, email, Google Sheets or Slack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Does it work on n8n Cloud?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes. CigalPay is a verified community node: search for CigalPay in the nodes panel and click Install node. If it doesn't show up, check that verified community nodes are enabled in your Admin Panel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which coins can customers pay with?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Bitcoin, USDT on Tron, Ethereum, Solana, Litecoin, Dogecoin, Dash, Bitcoin Cash, Polygon and TRX, plus other coins converted automatically at payment.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://cigalpay.com/blog/accept-crypto-payments-n8n" rel="noopener noreferrer"&gt;cigalpay.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>nocode</category>
      <category>automation</category>
      <category>crypto</category>
    </item>
    <item>
      <title>When Is a Crypto Payment Final? Blockchain Confirmations Explained</title>
      <dc:creator>CigalPay</dc:creator>
      <pubDate>Thu, 19 Nov 2026 14:00:18 +0000</pubDate>
      <link>https://dev.to/cigalpay/when-is-a-crypto-payment-final-blockchain-confirmations-explained-1f23</link>
      <guid>https://dev.to/cigalpay/when-is-a-crypto-payment-final-blockchain-confirmations-explained-1f23</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;In short&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A transaction is confirmed once it's included in a block; each later block adds another confirmation and makes reversal harder.&lt;/li&gt;
&lt;li&gt;Bitcoin blocks arrive about every 10 minutes on average, so waiting for several confirmations can take tens of minutes.&lt;/li&gt;
&lt;li&gt;Ethereum finalizes blocks through validator checkpoints; other networks have their own rules. Match the wait to the order's value.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;When a customer pays in crypto, the transaction is broadcast in seconds - but "sent" isn't the same as "final". Until a transaction is buried under enough blocks, there's a small chance it could be replaced. Understanding confirmations helps you decide when to ship, and explains why a checkout shows "payment detected" before "payment complete".&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a confirmation?
&lt;/h2&gt;

&lt;p&gt;A transaction gets its &lt;strong&gt;first confirmation&lt;/strong&gt; when it's included in a block. Every block added after that one counts as another confirmation. Because each new block builds on the previous ones, reversing a transaction would require redoing all the work since it was included - which gets harder with every block.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bitcoin: probabilistic finality
&lt;/h2&gt;

&lt;p&gt;Bitcoin's block interval averages 10 minutes, but individual blocks can come much faster or slower because mining is a random process. Bitcoin finality is probabilistic: the chance that a confirmed payment is reversed falls quickly with each block. Six confirmations (about an hour) is a long-standing convention for larger payments, though the &lt;a href="https://en.bitcoin.it/wiki/Confirmation" rel="noopener noreferrer"&gt;Bitcoin Wiki&lt;/a&gt; notes that the right number depends on the value at risk and an attacker's assumed share of mining power. Bitcoin.org's &lt;a href="https://bitcoin.org/en/you-need-to-know" rel="noopener noreferrer"&gt;guidance for users&lt;/a&gt; also stresses that unconfirmed transactions aren't secure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ethereum: checkpoints and finalized blocks
&lt;/h2&gt;

&lt;p&gt;Since moving to proof of stake, Ethereum divides time into 12-second slots grouped into epochs of 32 slots. Validators vote on checkpoints at the start of each epoch, and a block is &lt;strong&gt;finalized&lt;/strong&gt; once it's part of a chain with a supermajority link between two checkpoints - in normal conditions roughly two epochs, or around 13 minutes. Reverting a finalized block would cost attackers a large share of all staked ETH, as described on &lt;a href="https://ethereum.org/en/developers/docs/consensus-mechanisms/pos/" rel="noopener noreferrer"&gt;ethereum.org&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Faster networks
&lt;/h2&gt;

&lt;p&gt;Networks such as Tron and Solana produce blocks every few seconds or less, so payments are detected and confirmed far sooner. That's one reason they're popular for retail payments where the customer is waiting at checkout.&lt;/p&gt;

&lt;h2&gt;
  
  
  When should you ship or deliver?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Order type&lt;/th&gt;
&lt;th&gt;Sensible approach&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Digital goods, low value&lt;/td&gt;
&lt;td&gt;Deliver once the payment is confirmed by your provider&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Physical goods&lt;/td&gt;
&lt;td&gt;Ship after the payment is marked complete - there's time before dispatch anyway&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;High-value orders&lt;/td&gt;
&lt;td&gt;Wait for full confirmation; consider stricter thresholds on Bitcoin&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;Don't ship on "payment detected".&lt;/strong&gt; A transaction seen in the network but not yet confirmed can still fail or be replaced. Use the completed status from your payment notification, not the first sighting.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How CigalPay reports confirmation
&lt;/h2&gt;

&lt;p&gt;CigalPay's checkout moves from "Waiting for your payment" to &lt;strong&gt;"Payment detected"&lt;/strong&gt; as soon as the transfer reaches the network, then to &lt;strong&gt;"Payment complete"&lt;/strong&gt; once it's confirmed. Customers can close the page while confirmations come in, and your server receives a signed notification at each status change - see our &lt;a href="https://cigalpay.com/blog/crypto-payment-security-checklist?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=blockchain-confirmations-payment-finality" rel="noopener noreferrer"&gt;security checklist&lt;/a&gt; for how to verify it.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How many confirmations does a Bitcoin payment need?
&lt;/h3&gt;

&lt;p&gt;There's no single rule. Six confirmations (about an hour) is a common convention for larger amounts; lower-value payments often accept fewer. The right threshold depends on how much is at risk.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does my customer's payment show as detected but not complete?
&lt;/h3&gt;

&lt;p&gt;The transaction has been broadcast but is waiting for network confirmations. It completes automatically once enough blocks are added.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can a confirmed crypto payment be reversed?
&lt;/h3&gt;

&lt;p&gt;With each additional confirmation reversal becomes far less likely, and finalized Ethereum blocks are designed to be irreversible. There is no chargeback mechanism like with cards.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://en.bitcoin.it/wiki/Confirmation" rel="noopener noreferrer"&gt;Confirmation&lt;/a&gt;, Bitcoin Wiki&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://bitcoin.org/en/you-need-to-know" rel="noopener noreferrer"&gt;Some things you need to know&lt;/a&gt;, Bitcoin.org&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.bitcoin.org/devguide/block_chain.html" rel="noopener noreferrer"&gt;Block chain guide&lt;/a&gt;, Bitcoin Developer Documentation&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://ethereum.org/en/developers/docs/consensus-mechanisms/pos/" rel="noopener noreferrer"&gt;Proof-of-stake (PoS)&lt;/a&gt;, ethereum.org&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://cigalpay.com/blog/blockchain-confirmations-payment-finality?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=blockchain-confirmations-payment-finality" rel="noopener noreferrer"&gt;CigalPay blog&lt;/a&gt;. Disclosure: I'm part of the CigalPay team. Questions? Ask in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>bitcoin</category>
      <category>webdev</category>
      <category>crypto</category>
    </item>
    <item>
      <title>Underpaid and Overpaid Crypto Payments: How to Handle Partial Payments</title>
      <dc:creator>CigalPay</dc:creator>
      <pubDate>Tue, 17 Nov 2026 14:00:06 +0000</pubDate>
      <link>https://dev.to/cigalpay/underpaid-and-overpaid-crypto-payments-how-to-handle-partial-payments-8h6</link>
      <guid>https://dev.to/cigalpay/underpaid-and-overpaid-crypto-payments-how-to-handle-partial-payments-8h6</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;In short&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Underpayments usually happen because an exchange deducts its withdrawal fee from the amount the customer typed.&lt;/li&gt;
&lt;li&gt;A partially paid invoice shows what arrived and what's still due; the customer can send the remainder to the same address while the invoice is open.&lt;/li&gt;
&lt;li&gt;Write your policy down before launch: top up, ship anyway under a small tolerance, or refund.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Card payments are all-or-nothing. Crypto transfers aren't: a customer types an amount into their wallet or exchange, and that exact amount - minus anything deducted along the way - is what arrives. Most of the time it matches the invoice. When it doesn't, a clear process saves you and your customer a lot of back-and-forth.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why customers underpay
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Exchange withdrawal fees.&lt;/strong&gt; Many exchanges subtract their fee from the amount entered, so "send 49.90" delivers slightly less. This is the most common cause.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rounding.&lt;/strong&gt; A wallet that rounds to fewer decimals can drop the last digits of the amount.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Paying from two places.&lt;/strong&gt; A customer pays part from one wallet and plans to send the rest from another.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overpayments happen too - usually a customer rounding up or sending twice. Note that the customer's own network fee is added on top by their wallet and never counts as an overpayment; read &lt;a href="https://cigalpay.com/blog/crypto-network-fees-explained?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=underpaid-overpaid-crypto-payments" rel="noopener noreferrer"&gt;how network fees work&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How a partial payment works at checkout
&lt;/h2&gt;

&lt;p&gt;When less than the full amount arrives, CigalPay marks the invoice &lt;strong&gt;partially paid&lt;/strong&gt;. The checkout shows the amount received and the amount still to send, and keeps the same address and QR code ready for the remainder. If the customer sends the rest while the invoice is open, it completes normally. If the invoice &lt;a href="https://cigalpay.com/blog/crypto-invoice-expiry-exchange-rate-lock?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=underpaid-overpaid-crypto-payments" rel="noopener noreferrer"&gt;expires&lt;/a&gt; first, it stays partially paid and needs a decision from you.&lt;/p&gt;

&lt;h2&gt;
  
  
  A simple partial-payment policy
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Situation&lt;/th&gt;
&lt;th&gt;Suggested action&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Shortfall is tiny (e.g. under 1%)&lt;/td&gt;
&lt;td&gt;Ship the order and absorb the difference - cheaper than the support time&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shortfall is larger, invoice still open&lt;/td&gt;
&lt;td&gt;Ask the customer to send the remaining amount to the same address&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Invoice expired with a shortfall&lt;/td&gt;
&lt;td&gt;Offer a top-up via a new payment link, or refund what arrived&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Customer overpaid&lt;/td&gt;
&lt;td&gt;Refund the excess to an address the customer provides, on the same network&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  How to refund a crypto payment safely
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Ask the customer for a refund address in writing - never refund automatically to the address the payment came from, which may belong to an exchange's shared wallet.&lt;/li&gt;
&lt;li&gt;Confirm the network with the customer: a USDT refund on Ethereum to a Tron address won't arrive. See &lt;a href="https://cigalpay.com/blog/wrong-network-crypto-deposits?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=underpaid-overpaid-crypto-payments" rel="noopener noreferrer"&gt;wrong-network deposits&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Agree on the amount - in coin or in fiat value - and note who covers the network fee.&lt;/li&gt;
&lt;li&gt;Send the refund and share the transaction ID so the customer can track it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;CigalPay refunds follow these steps for you. Pick the payment in the dashboard, or refund from your WooCommerce or PrestaShop order page, and enter the amount. Your customer gets a link to enter their address, which is checked against the coin's network, and CigalPay sends the refund and its transaction ID. The customer receives exactly the amount you refunded, and the network fee comes from your balance. More in &lt;a href="https://cigalpay.com/blog/whats-new-forwarding-refunds-plugins?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=underpaid-overpaid-crypto-payments#refunds" rel="noopener noreferrer"&gt;what's new at CigalPay&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Prevent most partial payments with one sentence.&lt;/strong&gt; "Your wallet adds the network fee on top. Make sure the full amount arrives." Showing this next to the amount - as CigalPay's checkout does - catches most exchange-fee underpayments before they happen.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can the customer pay the remaining amount later?
&lt;/h3&gt;

&lt;p&gt;Yes, while the invoice is still open: they send the difference to the same address. After the invoice expires, create a new payment link for the balance instead.&lt;/p&gt;

&lt;h3&gt;
  
  
  Who pays the network fee on a refund?
&lt;/h3&gt;

&lt;p&gt;The sender - in a refund, that's you. Agree in advance whether you deduct it from the refund amount. With CigalPay refunds, the fee comes from your balance, and you pay only what the transfer really cost.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why did less arrive than the customer sent?
&lt;/h3&gt;

&lt;p&gt;Usually because the exchange they paid from deducted its withdrawal fee from the amount. Their exchange's transaction history will show the fee.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://bitcoin.org/en/you-need-to-know" rel="noopener noreferrer"&gt;Some things you need to know&lt;/a&gt;, Bitcoin.org&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://tether.to/en/supported-protocols/" rel="noopener noreferrer"&gt;Supported protocols&lt;/a&gt;, Tether&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://cigalpay.com/blog/underpaid-overpaid-crypto-payments?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=underpaid-overpaid-crypto-payments" rel="noopener noreferrer"&gt;CigalPay blog&lt;/a&gt;. Disclosure: I'm part of the CigalPay team. Questions? Ask in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ecommerce</category>
      <category>payments</category>
      <category>crypto</category>
    </item>
    <item>
      <title>Security Checklist for Merchants Accepting Crypto Payments</title>
      <dc:creator>CigalPay</dc:creator>
      <pubDate>Thu, 12 Nov 2026 14:00:05 +0000</pubDate>
      <link>https://dev.to/cigalpay/security-checklist-for-merchants-accepting-crypto-payments-1ah5</link>
      <guid>https://dev.to/cigalpay/security-checklist-for-merchants-accepting-crypto-payments-1ah5</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;In short&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Treat your API key like a password: keep it on your server, never in browser code or a public repository.&lt;/li&gt;
&lt;li&gt;Mark orders as paid only from a server-to-server notification whose signature you've verified - never from a redirect.&lt;/li&gt;
&lt;li&gt;Protect the way money leaves: verify payout addresses, review before sending, and watch for address-swapping malware and phishing.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;Crypto payments are final, which is great for merchants - no chargebacks - but it also means mistakes and fraud are hard to undo. Most incidents don't involve breaking cryptography. They come from leaked keys, trusting the wrong signal, or sending funds to the wrong address. This checklist covers those.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Keep API keys on the server
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Store keys in environment variables or a secrets manager, not in source code. The &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html" rel="noopener noreferrer"&gt;OWASP Secrets Management Cheat Sheet&lt;/a&gt; is a good reference.&lt;/li&gt;
&lt;li&gt;Never put a secret key in JavaScript that runs in the browser or in a mobile app - anyone can extract it.&lt;/li&gt;
&lt;li&gt;Limit who can see the key. In CigalPay's merchant dashboard the API key is hidden until you choose to show it.&lt;/li&gt;
&lt;li&gt;If a key may have leaked, contact support right away to have it replaced, and review recent activity.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Trust only verified payment notifications
&lt;/h2&gt;

&lt;p&gt;When a customer finishes paying, they're usually redirected back to your site. That redirect is a convenience, not proof of payment - anyone can open the URL. Mark an order paid only when your server receives a &lt;strong&gt;signed server-to-server notification&lt;/strong&gt; (often called an IPN or webhook) and the signature checks out.&lt;/p&gt;

&lt;p&gt;CigalPay sends payment notifications as a JSON &lt;code&gt;POST&lt;/code&gt; to your notification URL, with an &lt;code&gt;x-cigalpay-sig&lt;/code&gt; header containing an HMAC-SHA512 signature computed with your account's secret. Your endpoint should recompute the signature from the payload as described in the API documentation, compare the two using a constant-time comparison, and reject the request if they don't match.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use HTTPS for your notification endpoint.&lt;/li&gt;
&lt;li&gt;Make processing idempotent: the same status may be delivered more than once.&lt;/li&gt;
&lt;li&gt;Check that the amount and currency in the notification match the order before fulfilling it.&lt;/li&gt;
&lt;li&gt;Treat "confirming" as pending and ship only on a completed status - see &lt;a href="https://cigalpay.com/blog/blockchain-confirmations-payment-finality?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=crypto-payment-security-checklist" rel="noopener noreferrer"&gt;payment finality&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Protect the way money leaves
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Copy, then verify.&lt;/strong&gt; Clipboard-hijacking malware replaces a copied crypto address with the attacker's. After pasting a payout address, check the first and last several characters against the source.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check the network.&lt;/strong&gt; A valid address on the wrong network can still lose funds - see &lt;a href="https://cigalpay.com/blog/wrong-network-crypto-deposits?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=crypto-payment-security-checklist" rel="noopener noreferrer"&gt;wrong-network deposits&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use a review step.&lt;/strong&gt; In CigalPay, payout requests show a confirmation screen with the full address and require you to confirm you've checked it; every request is then reviewed before funds move.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Send a small test first&lt;/strong&gt; to a new destination before moving a large amount.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch forwarding changes.&lt;/strong&gt; If payments are forwarded automatically to your wallet, a new address is confirmed with a code sent to your email and only used after 24 hours, and every change is emailed to you. Act on any change email you didn't expect.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't take refund addresses from chat.&lt;/strong&gt; A message asking you to refund to a new address may come from someone pretending to be the customer. CigalPay refunds send the customer their own link to enter it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Secure your accounts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Protect the email account that receives your login codes - with access to it, someone could sign in to your dashboard.&lt;/li&gt;
&lt;li&gt;Bookmark your dashboard URL and sign in only from the bookmark; phishing sites copy payment dashboards closely.&lt;/li&gt;
&lt;li&gt;Remove access for staff who leave, and give each person their own login rather than sharing one.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  5. Harden your own integration
&lt;/h2&gt;

&lt;p&gt;If you build on a payment API, the &lt;a href="https://owasp.org/API-Security/editions/2023/en/0x11-t10/" rel="noopener noreferrer"&gt;OWASP API Security Top 10&lt;/a&gt; lists the most common weaknesses - broken authorization and excessive data exposure among them. A quick review against that list before launch catches most of them.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;⚠️ &lt;strong&gt;Nobody legitimate will ask for your keys or login code.&lt;/strong&gt; Support staff never need your API key, your login code or a verification code. Treat any request for them as an attack.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is the redirect after payment enough to confirm an order?
&lt;/h3&gt;

&lt;p&gt;No. A redirect can be forged by anyone who knows the URL. Confirm orders only from a signed server-to-server notification that your server has verified.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is an HMAC signature?
&lt;/h3&gt;

&lt;p&gt;A code computed from the message and a shared secret. If someone changes the message or doesn't know the secret, the signature won't match - so your server can tell the notification is genuine.&lt;/p&gt;

&lt;h3&gt;
  
  
  What should I do if my API key leaks?
&lt;/h3&gt;

&lt;p&gt;Contact support right away to have it replaced, update your server with the new key, and review recent payments and payout requests for anything unexpected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html" rel="noopener noreferrer"&gt;Secrets Management Cheat Sheet&lt;/a&gt;, OWASP&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://owasp.org/API-Security/editions/2023/en/0x11-t10/" rel="noopener noreferrer"&gt;OWASP Top 10 API Security Risks - 2023&lt;/a&gt;, OWASP&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://bitcoin.org/en/you-need-to-know" rel="noopener noreferrer"&gt;Some things you need to know&lt;/a&gt;, Bitcoin.org&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://cigalpay.com/blog/crypto-payment-security-checklist?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=crypto-payment-security-checklist" rel="noopener noreferrer"&gt;CigalPay blog&lt;/a&gt;. Disclosure: I'm part of the CigalPay team. Questions? Ask in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>api</category>
      <category>crypto</category>
    </item>
    <item>
      <title>How to accept crypto payments in a Telegram bot (Node.js)</title>
      <dc:creator>CigalPay</dc:creator>
      <pubDate>Tue, 10 Nov 2026 09:00:02 +0000</pubDate>
      <link>https://dev.to/cigalpay/how-to-accept-crypto-payments-in-a-telegram-bot-nodejs-1b18</link>
      <guid>https://dev.to/cigalpay/how-to-accept-crypto-payments-in-a-telegram-bot-nodejs-1b18</guid>
      <description>&lt;p&gt;Many shops sell through a Telegram bot: customers browse, order and get updates without leaving the chat. Adding crypto payments takes two pieces of code on your server: one that creates the payment when the customer orders, and one that confirms the order when the payment arrives.&lt;/p&gt;

&lt;p&gt;In this post we build both with Node.js, &lt;a href="https://grammy.dev" rel="noopener noreferrer"&gt;grammY&lt;/a&gt; and &lt;a href="https://cigalpay.com/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=telegram-bot" rel="noopener noreferrer"&gt;CigalPay&lt;/a&gt; (disclosure: I'm part of the team building it). The complete bot, with tests, is &lt;a href="https://github.com/cigalpay/cigalpay-telegram-bot-example" rel="noopener noreferrer"&gt;on GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;The customer taps &lt;strong&gt;Buy&lt;/strong&gt; in your bot and sends a delivery address.&lt;/li&gt;
&lt;li&gt;Your server creates a payment, priced in USD or EUR, and the bot answers with a &lt;strong&gt;Pay in crypto&lt;/strong&gt; button.&lt;/li&gt;
&lt;li&gt;The checkout opens inside Telegram. The customer picks a coin (USDT, Bitcoin, Solana…) and sends the exact amount shown, locked for 30 minutes.&lt;/li&gt;
&lt;li&gt;When the network confirms the payment, your server receives a signed notification.&lt;/li&gt;
&lt;li&gt;Your server checks it, the bot confirms the order to the customer, and you get the paid order in your own chat.&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What Telegram allows.&lt;/strong&gt; Telegram's &lt;a href="https://telegram.org/tos/bot-developers" rel="noopener noreferrer"&gt;terms for bot developers&lt;/a&gt; let bots use any payment provider for physical goods and real-world services. Digital goods and services sold inside Telegram (channel access, files, courses, subscriptions) must be paid in Telegram Stars. This example sells a physical product.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install grammy cigalpay-js-sdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You need a bot token from &lt;a href="https://t.me/BotFather" rel="noopener noreferrer"&gt;@BotFather&lt;/a&gt;, and your CigalPay Account ID and notification signing secret (dashboard, Settings → API).&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Create the payment when the customer orders
&lt;/h2&gt;

&lt;p&gt;Once the customer has sent their address, create a checkout with the order's price and your own order id, keep the checkout id with the order, and send the payment link as a button:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Bot&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;InlineKeyboard&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'grammy'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;CigalPay&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'cigalpay-js-sdk'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;bot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Bot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;BOT_TOKEN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;cigalpay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CigalPay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;accountId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CIGALPAY_ACCOUNT_ID&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// After the customer sent their address:&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;checkout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;cigalpay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createCheckout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;24.9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'EUR'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                  &lt;span class="c1"&gt;// sent back as extraId in the notification&lt;/span&gt;
  &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Coffee beans, 1 kg'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;returnUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`https://t.me/${bot.botInfo.username}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;notifyUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'https://your-server.example.com/cigalpay/notify'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;checkoutId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;checkout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;       &lt;span class="c1"&gt;// checked when the notification arrives&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Tap to pay. The price is locked for 30 minutes.'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;reply_markup&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;InlineKeyboard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;url&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Pay in crypto'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;checkout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chargeLink&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Confirm the order from the signed notification
&lt;/h2&gt;

&lt;p&gt;The payment's status is posted to your &lt;code&gt;notifyUrl&lt;/code&gt; each time it changes, signed with HMAC-SHA512 in the &lt;code&gt;x-cigalpay-sig&lt;/code&gt; header. Verify the raw body first, then confirm only once it's paid:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;CigalPay&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;isPaid&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'cigalpay-js-sdk'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// raw: the request body exactly as received&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nc"&gt;CigalPay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;verifyWebhook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'x-cigalpay-sig'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CIGALPAY_NOTIFICATION_SECRET&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeHead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;payment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extraId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Only the checkout this bot created, at this price.&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;checkoutId&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;checkoutId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeHead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;checkoutCurrency&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;currency&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;checkoutAmount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeHead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;isPaid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s1"&gt;'paid'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'paid'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;              &lt;span class="c1"&gt;// notifications can repeat: confirm once&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;telegramUserId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'✅ Payment confirmed, your order is on its way.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MERCHANT_CHAT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sb"&gt;`🛒 New paid order ${order.id}, ship to: ${order.address}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeHead&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The three checks that protect your orders
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Check&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;The signature&lt;/td&gt;
&lt;td&gt;Without it, anyone could post a fake "paid" status to your server.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The checkout id&lt;/td&gt;
&lt;td&gt;Your Account ID isn't secret: someone could create their own checkout for your order number, pay $1 and get a genuine signed notification. Only the checkout you created counts.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The price&lt;/td&gt;
&lt;td&gt;The checkout amount and currency must still match the order.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Never confirm an order because the customer came back to the chat: only the signed notification proves the payment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Payments that aren't simple
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;CONFIRMING&lt;/code&gt;&lt;/strong&gt;: on the network, not final. Tell the customer you're waiting; don't ship yet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;PARTIALLY_PAID&lt;/code&gt;&lt;/strong&gt;: less arrived, often because an exchange took its fee. The customer can send the rest to the same address.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;EXPIRED&lt;/code&gt;&lt;/strong&gt;: the 30 minutes passed. Offer a new &lt;strong&gt;Buy&lt;/strong&gt; button: a new checkout gets a fresh rate.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The complete bot
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://github.com/cigalpay/cigalpay-telegram-bot-example" rel="noopener noreferrer"&gt;example on GitHub&lt;/a&gt; puts it all together in about 250 lines: product, delivery address, checkout, the notification checks, the customer's confirmation and the order sent to your chat, in English and French. Its tests run the whole purchase against a fake Telegram and a fake payment API. To sell a service instead, ask for a date or a table instead of an address.&lt;/p&gt;

&lt;p&gt;Full guide on the CigalPay blog: &lt;a href="https://cigalpay.com/blog/accept-crypto-payments-telegram-bot?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=telegram-bot" rel="noopener noreferrer"&gt;How to Accept Crypto Payments in a Telegram Bot&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Questions about confirmations or partial payments? Ask in the comments.&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>telegram</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Payment Links vs. API Integration: Choosing How to Accept Crypto</title>
      <dc:creator>CigalPay</dc:creator>
      <pubDate>Sat, 07 Nov 2026 18:28:27 +0000</pubDate>
      <link>https://dev.to/cigalpay/payment-links-vs-api-integration-choosing-how-to-accept-crypto-28d6</link>
      <guid>https://dev.to/cigalpay/payment-links-vs-api-integration-choosing-how-to-accept-crypto-28d6</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;In short&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Payment links need no code: create one in the dashboard with an amount and description, send it, and the customer pays.&lt;/li&gt;
&lt;li&gt;An API integration creates the payment from your own checkout for every order and is the right choice once you sell online regularly.&lt;/li&gt;
&lt;li&gt;Either way, use signed payment notifications to mark orders as paid automatically.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;There are two ways to start taking crypto with a payment provider: share a link, or connect your checkout to its API. Both lead the customer to the same payment page. The difference is who creates the payment - you, by hand, or your system, automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  Payment links: no code
&lt;/h2&gt;

&lt;p&gt;A payment link is a checkout page for one specific amount. In CigalPay's merchant dashboard you enter the amount in USD or EUR, a description your customer will see, and optionally the checkout language and your own order reference. You get a link and a QR code to share by email, chat or in person.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Good for:&lt;/strong&gt; invoices, freelance and B2B work, selling on social media or marketplaces, and taking payments in person.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep in mind:&lt;/strong&gt; each link's exchange rate is locked for 30 minutes from creation, so create the link when the customer is ready to pay. More in &lt;a href="https://cigalpay.com/blog/crypto-invoice-expiry-exchange-rate-lock?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=payment-links-vs-api-integration" rel="noopener noreferrer"&gt;why crypto invoices expire&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Track them&lt;/strong&gt; in the dashboard, where every link shows whether it's open, paid, partly paid or expired.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  API integration: automatic, per order
&lt;/h2&gt;

&lt;p&gt;With an API integration, your server creates the payment when a customer checks out, passing the order total, currency and your order reference. The customer is sent to the payment page and, once done, back to your site. It's the right choice when you have a shop with its own order system and regular volume.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your server calls the API with the order amount, description and reference.&lt;/li&gt;
&lt;li&gt;The API returns a checkout URL; your site redirects the customer there.&lt;/li&gt;
&lt;li&gt;The customer picks a coin and pays.&lt;/li&gt;
&lt;li&gt;Your server receives a signed payment notification and marks the order paid.&lt;/li&gt;
&lt;li&gt;The customer returns to the page you set as the redirect URL.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Developers can find the API reference and SDK examples on our &lt;a href="https://cigalpay.com/developers?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=payment-links-vs-api-integration" rel="noopener noreferrer"&gt;developers page&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting payments to orders: notifications
&lt;/h2&gt;

&lt;p&gt;Payment notifications (IPN) are what make either approach hands-off. When a payment's status changes - detected, confirmed, partially paid, expired - CigalPay sends a &lt;code&gt;POST&lt;/code&gt; to your notification URL, signed with an HMAC-SHA512 signature in the &lt;code&gt;x-cigalpay-sig&lt;/code&gt; header. Your server verifies the signature and updates the order. Don't rely on the customer's redirect back to your site; it isn't proof of payment. Our &lt;a href="https://cigalpay.com/blog/crypto-payment-security-checklist?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=payment-links-vs-api-integration" rel="noopener noreferrer"&gt;security checklist&lt;/a&gt; explains how to verify notifications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Side by side
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Payment links&lt;/th&gt;
&lt;th&gt;API integration&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Setup&lt;/td&gt;
&lt;td&gt;Minutes, no code&lt;/td&gt;
&lt;td&gt;Developer time for one endpoint and one webhook&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Who creates the payment&lt;/td&gt;
&lt;td&gt;You, in the dashboard&lt;/td&gt;
&lt;td&gt;Your checkout, automatically&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Order matching&lt;/td&gt;
&lt;td&gt;Your reference on the link&lt;/td&gt;
&lt;td&gt;Your order ID passed in the API call&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best for&lt;/td&gt;
&lt;td&gt;Invoices, social and in-person sales&lt;/td&gt;
&lt;td&gt;Online shops with regular orders&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  A third option: WooCommerce and PrestaShop plugins
&lt;/h2&gt;

&lt;p&gt;If your website runs on WooCommerce or PrestaShop, you get the API integration without writing it. The plugin creates the checkout for every order, checks the signed notifications and marks the order paid. You paste your Account ID and notification signing secret, and add your API key to refund orders in crypto from the order page. Download them from the &lt;a href="https://cigalpay.com/developers?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=payment-links-vs-api-integration" rel="noopener noreferrer"&gt;developers page&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Start simple.&lt;/strong&gt; Many merchants begin with payment links to see whether their customers want to pay in crypto, then add the API once volume grows. Nothing about the customer's payment experience changes when you switch.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can I reuse a payment link for several customers?
&lt;/h3&gt;

&lt;p&gt;No. Each link is a single payment with a 30-minute rate lock. Create a new link for each order or customer.&lt;/p&gt;

&lt;h3&gt;
  
  
  Which languages does the checkout support?
&lt;/h3&gt;

&lt;p&gt;CigalPay's checkout is available in English, French, Spanish and German. You can choose the language when creating a payment link.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need a developer for payment links?
&lt;/h3&gt;

&lt;p&gt;No. Payment links are created in the merchant dashboard without any code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki" rel="noopener noreferrer"&gt;BIP 21: URI scheme for Bitcoin payments&lt;/a&gt;, Bitcoin Improvement Proposals&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.solanapay.com/spec" rel="noopener noreferrer"&gt;Solana Pay specification&lt;/a&gt;, Solana Pay&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://owasp.org/API-Security/editions/2023/en/0x11-t10/" rel="noopener noreferrer"&gt;OWASP Top 10 API Security Risks - 2023&lt;/a&gt;, OWASP&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Originally published on the &lt;a href="https://cigalpay.com/blog/payment-links-vs-api-integration?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=payment-links-vs-api-integration" rel="noopener noreferrer"&gt;CigalPay blog&lt;/a&gt;. Disclosure: I'm part of the CigalPay team. Questions? Ask in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>api</category>
      <category>payments</category>
      <category>crypto</category>
    </item>
    <item>
      <title>How to accept crypto payments in Node.js (Express) in 5 minutes</title>
      <dc:creator>CigalPay</dc:creator>
      <pubDate>Sun, 18 Oct 2026 01:22:44 +0000</pubDate>
      <link>https://dev.to/cigalpay/how-to-accept-crypto-payments-in-nodejs-express-in-5-minutes-4516</link>
      <guid>https://dev.to/cigalpay/how-to-accept-crypto-payments-in-nodejs-express-in-5-minutes-4516</guid>
      <description>&lt;p&gt;Adding crypto as a payment option sounds like a lot of work: running nodes, generating addresses, watching the blockchain, handling confirmations, converting prices. With a payment gateway, it comes down to two endpoints on your server:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a payment&lt;/strong&gt; and send the customer to a hosted checkout.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Receive a signed notification&lt;/strong&gt; when the payment confirms, and mark the order as paid.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this tutorial we build both with Node.js and Express, using &lt;a href="https://cigalpay.com/?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=node-tutorial" rel="noopener noreferrer"&gt;CigalPay&lt;/a&gt; (disclosure: I'm part of the team building it). It's plain HTTP, so the same flow works in any language. If your site runs on WooCommerce or PrestaShop, or you'd rather not write code, this guide compares the &lt;a href="https://cigalpay.com/blog/how-to-accept-crypto-payments?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=node-tutorial" rel="noopener noreferrer"&gt;3 ways to accept crypto payments on your website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What you need:&lt;/strong&gt; Node.js 18 or later (for the built-in &lt;code&gt;fetch&lt;/code&gt;), and a CigalPay account. Your &lt;strong&gt;account ID&lt;/strong&gt; and your &lt;strong&gt;notification signing secret&lt;/strong&gt; are in the merchant dashboard, under Settings.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Set up the project
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;crypto-checkout &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;cd &lt;/span&gt;crypto-checkout
npm init &lt;span class="nt"&gt;-y&lt;/span&gt;
npm pkg &lt;span class="nb"&gt;set type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;module
npm &lt;span class="nb"&gt;install &lt;/span&gt;express
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put your credentials in environment variables, never in the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;CIGALPAY_ACCOUNT_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your-account-id"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;CIGALPAY_IPN_SECRET&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your-notification-signing-secret"&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;CIGALPAY_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"your-api-key"&lt;/span&gt;     &lt;span class="c"&gt;# only for refunds (step 5)&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PUBLIC_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"https://your-app.com"&lt;/span&gt;   &lt;span class="c"&gt;# where CigalPay can reach your server&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Create a payment
&lt;/h2&gt;

&lt;p&gt;When the customer clicks "Pay with crypto", your server creates a payment and redirects them to the checkout. The price is in USD or EUR; the customer chooses the coin on the checkout, and the rate is locked while they pay.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// server.js&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;crypto&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;node:crypto&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;CIGALPAY_ACCOUNT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;CIGALPAY_IPN_SECRET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;PUBLIC_URL&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// A tiny in-memory "database" for the demo.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;orders&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/checkout/:orderId&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;orderId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;49.9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;USD&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pending&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://coins-api.cigalpay.com/api/pre-invoice&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;accountId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;CIGALPAY_ACCOUNT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;              &lt;span class="c1"&gt;// USD or EUR&lt;/span&gt;
      &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`Order #&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;      &lt;span class="c1"&gt;// shown to the customer&lt;/span&gt;
      &lt;span class="na"&gt;extraId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                      &lt;span class="c1"&gt;// your reference, sent back in the notification&lt;/span&gt;
      &lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;en&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;                            &lt;span class="c1"&gt;// checkout language: en, fr, es, de&lt;/span&gt;
      &lt;span class="na"&gt;callback&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;PUBLIC_URL&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/thank-you`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;// where the customer returns&lt;/span&gt;
      &lt;span class="na"&gt;ipn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;PUBLIC_URL&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/cigalpay/ipn`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;     &lt;span class="c1"&gt;// where the signed notification goes&lt;/span&gt;
    &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;502&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Could not create the payment&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;chargeLink&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checkoutId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;                     &lt;span class="c1"&gt;// checked when the notification arrives&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;303&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;chargeLink&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the whole integration on the "pay" side. The customer lands on the checkout, picks a coin (Bitcoin, USDT, Ethereum and many others), scans the QR code or copies the address, and pays.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Verify the signed notification
&lt;/h2&gt;

&lt;p&gt;When the payment status changes, CigalPay sends a &lt;code&gt;POST&lt;/code&gt; with a JSON body to your &lt;code&gt;ipn&lt;/code&gt; URL. The &lt;code&gt;x-cigalpay-sig&lt;/code&gt; header holds an &lt;strong&gt;HMAC-SHA512&lt;/strong&gt; signature of the body, computed with your signing secret over the JSON with its top-level keys sorted.&lt;/p&gt;

&lt;p&gt;Never mark an order as paid from the customer's redirect to &lt;code&gt;/thank-you&lt;/code&gt;: anyone can open that URL. Only trust the notification, and only after checking its signature.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isSignatureValid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;received&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;expected&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;crypto&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createHmac&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sha512&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;CIGALPAY_IPN_SECRET&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;()))&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hex&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;received&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
    &lt;span class="nx"&gt;received&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;expected&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
    &lt;span class="nx"&gt;crypto&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;timingSafeEqual&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;received&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;Buffer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;expected&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/cigalpay/ipn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;payment&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;isSignatureValid&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;x-cigalpay-sig&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;extraId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Anyone can create a checkout with your account ID and an order number.&lt;/span&gt;
  &lt;span class="c1"&gt;// Only trust a payment for the checkout you created, at the order's price.&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checkoutId&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checkoutId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checkoutCurrency&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;currency&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checkoutAmount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mf"&gt;0.01&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;switch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CONFIRMING&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="c1"&gt;// Seen on the network, not final yet: show "payment pending", don't ship.&lt;/span&gt;
      &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;confirming&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CONFIRMED&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;FINISHED&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="c1"&gt;// Final: fulfil the order. Notifications can arrive more than once,&lt;/span&gt;
      &lt;span class="c1"&gt;// so make this step idempotent.&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;paid&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;paid&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;paymentId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;        &lt;span class="c1"&gt;// needed to refund it later&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Order &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; paid`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;PARTIALLY_PAID&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;EXPIRED&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;FAILED&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;payment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/thank-you&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Thanks! Your payment is being confirmed.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Listening on http://localhost:3000&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few details worth knowing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Check the checkout, not just the order number.&lt;/strong&gt; Your account ID isn't secret: it's in every checkout you create. Without the &lt;code&gt;checkoutId&lt;/code&gt; check, someone could create their own checkout for your order number, pay $1, and get a signed notification for it. The signature proves the notification comes from CigalPay, not that it's for the checkout you made.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Constant-time comparison.&lt;/strong&gt; &lt;code&gt;crypto.timingSafeEqual&lt;/code&gt; avoids leaking how much of the signature matched.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Idempotency.&lt;/strong&gt; The same status can be delivered more than once; check the current order state before acting.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;CONFIRMING&lt;/code&gt; is not paid.&lt;/strong&gt; The transaction is on the network but not confirmed yet. Ship only on a final status.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other coins.&lt;/strong&gt; If the customer paid with a coin that was converted at checkout, the notification also contains &lt;code&gt;swapFromCurrency&lt;/code&gt;, &lt;code&gt;swapFromNetwork&lt;/code&gt; and &lt;code&gt;swapFromAmount&lt;/code&gt;, so you can show what they actually sent.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  4. Test it end to end
&lt;/h2&gt;

&lt;p&gt;Your notification URL must be reachable from the internet. Locally, a tunnel does the job:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node server.js
&lt;span class="c"&gt;# in another terminal&lt;/span&gt;
npx localtunnel &lt;span class="nt"&gt;--port&lt;/span&gt; 3000     &lt;span class="c"&gt;# or ngrok, cloudflared...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set &lt;code&gt;PUBLIC_URL&lt;/code&gt; to the tunnel's address, restart, then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="nt"&gt;-X&lt;/span&gt; POST &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$PUBLIC_URL&lt;/span&gt;&lt;span class="s2"&gt;/checkout/1042"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the &lt;code&gt;Location&lt;/code&gt; URL from the response, pay a small amount (a real $1 payment is the best test), and watch your terminal: &lt;code&gt;Order 1042 paid&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Refund an order
&lt;/h2&gt;

&lt;p&gt;A crypto transfer can't be reversed, so a refund is a new payment to the customer. CigalPay asks the customer for their address and sends it; you only say which payment and how much. This call needs your &lt;strong&gt;API key&lt;/strong&gt; (dashboard, Settings), on top of the account ID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/orders/:orderId/refund&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;orders&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;paymentId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;404&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// save payment.id from the notification&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://merchant-api.cigalpay.com/api/refunds&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cigalpay-api-key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CIGALPAY_API_KEY&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;paymentId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;paymentId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;checkoutAmount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;         &lt;span class="c1"&gt;// in the order's USD / EUR, or `amount` in the coin paid&lt;/span&gt;
      &lt;span class="na"&gt;customerEmail&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;           &lt;span class="c1"&gt;// gets the link to enter their address&lt;/span&gt;
      &lt;span class="na"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Returned item&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// e.g. balance too low&lt;/span&gt;
  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;refundId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;refund&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;customerLink&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;link&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The refund and its network fee come out of your CigalPay balance in the coin the customer paid. &lt;code&gt;checkoutAmount&lt;/code&gt; is converted at the payment's rate, so the customer gets back the same share of what they sent.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prefer an SDK?
&lt;/h2&gt;

&lt;p&gt;Everything above is plain HTTP so you can see what happens. In a real app, the official SDK (&lt;a href="https://www.npmjs.com/package/cigalpay-js-sdk" rel="noopener noreferrer"&gt;&lt;code&gt;cigalpay-js-sdk&lt;/code&gt;&lt;/a&gt;, no dependencies, TypeScript types included) does the same in a few lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;CigalPay&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cigalpay-js-sdk&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cigalpay&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;CigalPay&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;accountId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CIGALPAY_ACCOUNT_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;apiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CIGALPAY_API_KEY&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;chargeLink&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;cigalpay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createCheckout&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;49.9&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;USD&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1042&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Order #1042&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;returnUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;PUBLIC_URL&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/thank-you`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;notifyUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;PUBLIC_URL&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/cigalpay/ipn`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;CigalPay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;verifyWebhook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;x-cigalpay-sig&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;CIGALPAY_IPN_SECRET&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// true or false&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;cigalpay&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createRefund&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;paymentId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;checkoutAmount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;customerEmail&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customer@example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On WooCommerce or PrestaShop, you don't need code at all: the official plugins do all of this, refunds included.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;The whole integration is two routes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Route&lt;/th&gt;
&lt;th&gt;Job&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;POST /checkout/:orderId&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Create the payment with &lt;code&gt;POST /api/pre-invoice&lt;/code&gt;, redirect to &lt;code&gt;chargeLink&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;POST /cigalpay/ipn&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Verify &lt;code&gt;x-cigalpay-sig&lt;/code&gt; and &lt;code&gt;checkoutId&lt;/code&gt;, update the order from &lt;code&gt;status&lt;/code&gt; and &lt;code&gt;extraId&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;POST /orders/:orderId/refund&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Optional: refund with &lt;code&gt;POST /api/refunds&lt;/code&gt; and your API key&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;No nodes, no wallets to run, no blockchain polling. If you'd rather not write code at all, the dashboard can also create a &lt;strong&gt;payment link&lt;/strong&gt; you can send by message or show as a QR code.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Docs and API reference: &lt;a href="https://cigalpay.com/developers?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=node-tutorial" rel="noopener noreferrer"&gt;cigalpay.com/developers&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;SDKs: &lt;a href="https://www.npmjs.com/package/cigalpay-js-sdk" rel="noopener noreferrer"&gt;Node.js&lt;/a&gt; and &lt;a href="https://packagist.org/packages/cigalpay/cigalpay-php-sdk" rel="noopener noreferrer"&gt;PHP&lt;/a&gt;, plus WooCommerce and PrestaShop plugins.&lt;/li&gt;
&lt;li&gt;Pricing: 1% per transaction with no monthly fee, or 0.5% on the Pro plan.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Questions about confirmations, underpayments or wrong-network deposits? Ask in the comments, happy to help.&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
