• Модуль интеграций
  • Сообщество
  • Блог
Документация
Плагины и интеграцииВсе расширения для Medusa от сообществаСтартерыЗапускайте проекты быстрее с готовыми решениями
ЭкспертыПодберите специалиста для разработки и развития вашего проекта на MedusaКейсыПосмотрите примеры Medusa в продакшене и успешные внедрения
Т-Касса от Т-Банка для Medusa: приём платежей для РФ

16 октября 2026 г. · Продукт

Gorgo снижает затраты на адаптацию Medusa к локальным рынкам.

Мы разрабатываем плагины интеграции, осуществляем поддержку и развиваем сообщество разработчиков на Medusa в Telegram.

  • Ресурсы Medusa
  • Плагины и интеграции
  • Модуль интеграций
  • Стартеры
  • Эксперты
  • Кейсы
  • Medusa Чат в Telegram
  • Medusa Новости в Telegram
  • Документация Gorgo
  • Связаться с нами
  • TelegramGitHub
Плагины
B

Blockonomics

Принимайте Bitcoin-платежи в Medusa v2 через Blockonomics, сразу на собственный кошелёк продавца.

npm install @blockonomics/medusa-payment-blockonomics
Категория
Платежи
Создано
Blockonomics
Версия
1.0.0
Последнее обновление
4 дня назад
Ежемесячные загрузки
Загрузка данных
Звезды на Github
0
npmNPMGitHubGithub

@blockonomics/medusa-payment-blockonomics

Accept Bitcoin payments in Medusa v2 through Blockonomics. Payments go straight to the merchant's own wallet: Blockonomics generates a fresh address for each checkout and notifies Medusa as the transaction is seen and confirmed on-chain.

Blockonomics never holds funds. That makes refunds a manual step, covered under Refunds. Read that section before going live.

Requirements

  • Medusa or later
  • A Blockonomics account with a store and a wallet (xPub) attached
  • A Medusa server reachable from the internet, so Blockonomics can deliver callbacks

Install

Configure

1. Register the plugin and the provider

Add the plugin to , then register the provider in the Payment Module:

Both entries are required. The entry loads the callback route; the provider entry loads the payment provider. Without the entry, checkout works but callbacks return , and no payment ever completes.

Generate the secret by running this in your Medusa project, after installing the plugin:

npx blockonomics-callback-secret

It prints a line to add to . Or, without the plugin installed:

The prefix is required; Medusa refuses to start without it. The secret is not issued by Blockonomics.

2. Set the callback URL in Blockonomics

In the Blockonomics dashboard, open Stores, edit the store, and set its callback URL to:

https://your-store.com/hooks/blockonomics/blockonomics_blockonomics?secret=YOUR_CALLBACK_SECRET

Get this exactly right. A wrong URL fails silently: callbacks arrive, are rejected, and orders stay unpaid.

  • The path is , where is the provider's in . With that gives . If you change the , change the URL.
  • must equal . Callbacks with a missing or different secret are logged and ignored.
  • Use , not Medusa's . Blockonomics sends callbacks as requests, which Medusa's own endpoint does not accept.

3. Enable the provider in a region

In the Medusa admin, go to Settings → Regions, edit the region, and add Blockonomics () to its payment providers.

Options

OptionDefaultDescription
-Required. API key of the Blockonomics merchant account.
-Required. Secret on the store's callback URL, starting with . Callbacks without it are ignored.
On-chain confirmations a callback has to report before the payment is taken as settled and the order is marked paid: , , or . See Choosing confirmations.
How long the quoted BTC amount stays valid. Once it expires with nothing received, the amount is re-quoted at the current rate. Clamped to 300–1800.
Fraction of the expected amount that may be missing and still count as paid, to absorb rounding and wallet fee deductions. allows a 1% shortfall. Blockonomics for WooCommerce calls this underpayment slack.
Excess above which the payment is flagged with for manual review. The payment still settles.
-Substring of the store's callback URL. Set it when the Blockonomics account has more than one store, so addresses are generated for the right one. An account with more than one store rejects address generation without it, with error , .
Base URL of the Blockonomics API. Only useful for testing against a stub.

Choosing confirmations

ValueOrder marked paidRisk
As soon as the transaction is seen in the mempoolThe sender can still double-spend it. Only use for low-value or reversible fulfilment.
After about 10 minutesLow.
After about 20 minutesLowest. Recommended default.

Whichever value you pick, the order is placed as soon as the transaction is seen and marked paid once it settles. See Orders.

Unconfirmed transactions that opted into Replace-By-Fee are never treated as paid, even with , because the sender can still replace them.

Offering both instant and secure checkout

There is no settings screen for provider options, but you can register the provider twice under different ids and choose between them per region in the admin:

These register as and . Each needs its own callback URL, so use a separate Blockonomics store for each, with set to tell them apart:

Payment lifecycle

The provider follows the payment model of the Blockonomics WooCommerce plugin. Every address handed out for a session is a payment with its own fiat quote, and the callback that reaches settles it:

CallbackPaymentPayment session status
None yet - the quote can still be refreshed
Below - address and quote are frozen, order is placed
At or above , amount covered, order is paid
At or above , amount short, underpaid

What a settled payment paid is recorded in satoshis and in fiat, valued at the rate that address was quoted at: a customer who sent 40% of the BTC asked for has paid 40% of the fiat, whatever the rate has done since.

Underpayments. The remainder in fiat is quoted on a fresh address at the current rate the next time the quote is refreshed (see Re-quoting the amount). The settled address stays on the session as the record of the partial payment. The order is paid once the last address settles in full. Nothing is refunded automatically.

Overpayments. The payment settles as normal, and Medusa records the order total as captured. What was actually received is shown in the Bitcoin payment box on the order page in the admin, flagged Overpaid above , and logged as a warning. Refund the difference from your wallet.

A settled address ignores further callbacks. An unconfirmed transaction that opted into Replace-By-Fee only has its transaction id recorded, since the sender can still cancel it.

Orders

  • The order is placed as soon as a transaction is seen. It shows in the admin with payment status Awaiting.
  • Once the payment settles in full, it changes to Captured. Only fulfil Captured orders.
  • An underpaid order stays Awaiting until the remainder settles.
  • If a transaction never confirms (e.g. double-spent), the order stays Awaiting. Cancel it in the admin.

Storefront

There is no hosted payment page. The storefront shows the customer where to send Bitcoin, using the payment session's .

is a working payment screen that implements everything in this section, in plain JavaScript with no framework. Start from it and port it to your storefront. Without a storefront shows how to run it against a cart.

The session's carries:

FieldDescription
Bitcoin address to pay.
Amount to send to it, in satoshis. Divide by for BTC.
The same amount in the cart's currency: the order total less what earlier addresses settled.
The order total.
Settled so far, over all addresses of the session. until an underpayment settles.
Rate the amount was quoted at.
Unix milliseconds until the quote expires.
nothing seen, payment in progress, settled.
Confirmations the latest callback reported.
Transaction id, once one has been seen.
Every address of the session with the fields above, oldest first.

The flow the Blockonomics WooCommerce plugin uses, and what to build. The function names point to where the example does each step:

  1. Find the cart's payment session whose starts with ().
  2. Show a QR code of , an "Open in wallet" link to the same URI, and the address and amount as copyable fields ().
  3. Count down to . When it runs out, re-quote through the plugin's store route below and update the amount, rate, and QR code (, , ). Do not create a new payment session for this: Medusa replaces the session, which hands the customer a new address.
  4. Open , and reconnect if it drops. The first message means the payment has been seen: switch to a receipt screen with the transaction id. Messages carry ( unconfirmed, , confirmed), in satoshis, and (, ).
  5. If is short of , show the shortfall in fiat (). The remainder can be paid once the underpayment has confirmed: call the re-quote route, and when it comes back with a new , return to the payment screen for it. Show and as the paid and remaining amounts (, the Pay remaining handler).
  6. Do not complete the cart from the storefront. The callbacks place the order and mark it paid. Poll the cart until is set, and follow the socket for confirmations ().
  7. When the page is reloaded after paying, is no longer : show the receipt from the session data instead of the payment screen (the boot block at the end of the page script).

Re-quoting the amount

Runs the provider's price refresh on the session, what the WooCommerce plugin does when its checkout page loads:

  • nothing seen yet: the amount is re-quoted at the current rate once the price lock has expired. The address is kept.
  • payment in progress: nothing changes; the customer sent what they were quoted.
  • settled underpayment: a new address is handed out for the remainder at the current rate. The response carries the new .

Refunds

Bitcoin payments are irreversible, and Blockonomics holds no funds, so refunds cannot go through the provider. Clicking Refund in the Medusa admin throws an error.

To refund a customer, send the amount from the wallet that received the payment, and record the refund outside of Medusa.

Testing

Blockonomics has a test mode that fires real callbacks without moving funds.

  1. Expose your local server with a tunnel such as ngrok, and set the store's callback URL to the tunnel address.
  2. In the Blockonomics dashboard, enable Testmode on the store.
  3. Place an order in your storefront and choose Blockonomics.
  4. On the Test Bench, send the quoted amount from the Test Bitcoin Wallet.

Callbacks arrive with status immediately, after about 5 minutes, and after about 10. The order appears in the admin as Awaiting after status , and turns Captured at .

Checkout failing with and error means the account has more than one store and is unset. Set it to a substring of this store's callback URL that no other store in the account shares.

Without a storefront

The payment screen can be exercised before a storefront exists. builds a cart and a Blockonomics payment session over the Store API, and serves the payment screen for it on port 8000.

The payment screen calls the Store API from the browser, so has to be in the server's . A local Medusa allows it by default. Point at a deployed store and you have to add that origin there yourself.

Both need Node 18 or later and have no dependencies. They sign in as an admin only to read a publishable key; everything after that goes through the Store API.

License

MIT

Еще в этой категории

Посмотреть все
Платежи
Braintree logo

Braintree

От Lambda Curry

Поддержка платежей и 3D Secure через Braintree

Загрузка данных
GitHubnpm
Платежи
Pay. logo

Pay.

От Webbers

Принимайте кредитные карты, цифровые платежи и купи сейчас, плати потом

Загрузка данных
GitHubnpm
Платежи
Mollie logo

Mollie

От Variable Vic

Легко принимайте мультивалютные платежи через Mollie

Загрузка данных
GitHubnpm
npm install @blockonomics/medusa-payment-blockonomics
1// medusa-config.ts
2import { defineConfig, loadEnv } from "@medusajs/framework/utils"
3
4loadEnv(process.env.NODE_ENV || "development", process.cwd())
5
6module.exports = defineConfig({
7 // ...
8 plugins: [
9 {
10 resolve: "@blockonomics/medusa-payment-blockonomics",
11 options: {},
12 },
13 ],
14 modules: [
15 {
16 resolve: "@medusajs/medusa/payment",
17 options: {
18 providers: [
19 {
20 resolve: "@blockonomics/medusa-payment-blockonomics/providers/blockonomics",
21 id: "blockonomics",
22 options: {
23 apiKey: process.env.BLOCKONOMICS_API_KEY,
24 callbackSecret: process.env.BLOCKONOMICS_CALLBACK_SECRET,
25 confirmations: 2,
26 },
27 },
28 ],
29 },
30 },
31 ],
32})
1# .env
2BLOCKONOMICS_API_KEY=your_api_key
3BLOCKONOMICS_CALLBACK_SECRET=MEDUSA_...
node -e "console.log('MEDUSA_' + require('crypto').randomBytes(32).toString('hex'))"
1// medusa-config.ts
2providers: [
3 {
4 resolve: "@blockonomics/medusa-payment-blockonomics/providers/blockonomics",
5 id: "instant",
6 options: {
7 apiKey: process.env.BLOCKONOMICS_API_KEY,
8 callbackSecret: process.env.BLOCKONOMICS_CALLBACK_SECRET,
9 confirmations: 0,
10 },
11 },
12 {
13 resolve: "@blockonomics/medusa-payment-blockonomics/providers/blockonomics",
14 id: "secure",
15 options: {
16 apiKey: process.env.BLOCKONOMICS_API_KEY,
17 callbackSecret: process.env.BLOCKONOMICS_CALLBACK_SECRET,
18 confirmations: 2,
19 },
20 },
21]
1https://your-store.com/hooks/blockonomics/blockonomics_instant?secret=...
2https://your-store.com/hooks/blockonomics/blockonomics_secure?secret=...
1POST /store/blockonomics/payment-sessions/{payment_session_id}
2x-publishable-api-key: pk_...
1{
2 "payment_session": {
3 "id": "payses_...",
4 "status": "pending",
5 "data": { "address": "...", "expected_fiat": 20, "expected_satoshis": 30149, "btc_price": 66338.6, "price_locked_until": 1789701331086, "payment_status": 0 }
6 }
7}
1export MEDUSA_URL=http://localhost:9000
2export ADMIN_EMAIL=you@example.com
3export ADMIN_PASSWORD=...
4
5node examples/create-cart.js # prints a cart id
6node examples/checkout-page.js <cart_id> # http://localhost:8000