TLY Pay
Stablecoin and crypto payments to your wallet
TLY Pay for Medusa
TLY Pay is a Medusa payment provider for crypto payments in Medusa 2.23. Your store accepts stablecoin payments in USDT, USDC and DAI, and coins such as BTC, LTC and ETH, on nine networks. Each payment goes straight to your own wallet: TLY Pay is non-custodial and does not hold your funds. Screenshots, requirements and the accepted coins are on the Crypto payments for Medusa page.
Features
- A TLY Pay payment provider with a checkout title, coin icons and an optional line naming the coins.
- The TLY Pay payment window on your storefront, or the hosted TLY Pay payment page.
- Your Medusa order number as the order reference on the payment page and in TLY Pay.
- Orders are marked paid only after TLY Pay confirms the payment through a signed notification or the scheduled check.
- A TLY Pay page in Medusa Admin: connect your account, follow every TLY Pay order with its status, amount and payment ID, and see partial payments, overpayments and payments that need review.
- A cancelled Medusa order cancels its open TLY Pay payment.
What customers and merchants see
Checkout: the customer chooses Crypto payment, shown with the coin icons you select.
Payment window: the customer pays in the TLY Pay window on your storefront, with your order number as the order reference.
Connection and settings: you connect your TLY Pay account by signing in and approving it in Medusa Admin, then choose the checkout mode and appearance.
Orders: Medusa Admin lists every TLY Pay order with its payment status.
Requirements
- Medusa 2.23 (Copy to clipboard
>=2.23.0 <2.24.0) and Node.js 22.22.0 or later. - A TLY Pay account with a store and a verified wallet.
- A Medusa backend on a public HTTPS address (port 443): TLY Pay sends payment notifications to it and returns to it after you approve the connection.
- A public HTTPS storefront.
- The same currency in the Medusa Region, the provider entry and your TLY Pay store.
Install
In your Medusa application:
1npm install medusa-plugin-tly-pay
Register the plugin, its module and the payment provider in Copy to clipboardmedusa-config.ts:
1234567891011121314151617181920module.exports = defineConfig({plugins: [{ resolve: "medusa-plugin-tly-pay", options: {} }],modules: [{ resolve: "medusa-plugin-tly-pay/modules/tly-pay" },{resolve: "@medusajs/medusa/payment",dependencies: ["tlyPay"],options: {providers: [{resolve: "medusa-plugin-tly-pay/providers/tly-pay",id: "main",options: {providerConfigId: "pp_tly-pay_main",storefrontOrigin: process.env.TLY_PAY_STOREFRONT_ORIGIN,sourceCurrency: "USD",},}],},},],
Provider options:
- Copy to clipboard
providerConfigId: Copy to clipboardpp_tly-pay_<id>, where Copy to clipboard<id>is the provider entry Copy to clipboardid. - Copy to clipboard
storefrontOrigin: the HTTPS origin of your storefront; the payment window opens only from this origin. - Copy to clipboard
sourceCurrency: your store currency code, for example Copy to clipboardUSD.
The provider takes no credentials as options.
Server environment
- Copy to clipboard
TLY_PAY_MEDUSA_SECRET_KEY(required): a random 32-byte Base64URL value. It encrypts the saved credentials; keep it the same on every server and back it up with your database. - Copy to clipboard
TLY_PAY_MEDUSA_RECONCILE_CRON: the schedule of the TLY Pay check job, for example Copy to clipboard* * * * *. Without it, payments are not checked on a schedule.
Generate the key once:
1node -e "console.log(require('crypto').randomBytes(32).toString('base64url'))"
Then create the plugin tables and enable the TLY Pay provider in the Regions that use your store currency:
1npx medusa db:migrate
Connect your TLY Pay account
- Open Medusa Admin on the public HTTPS address of your backend, then TLY Pay in the sidebar.
- Click Connect TLY Pay, sign in to TLY Pay in the window that opens and approve your store.
- The page shows Connected once your store and wallet are ready. In Settings you choose the checkout mode (hosted payment page or embedded payment window) and the checkout appearance (title, coin icons and an optional line naming the coins).
Storefront
Medusa storefronts are headless. Install the package in your storefront too and use its helper from Copy to clipboardmedusa-plugin-tly-pay/storefront; it needs no Medusa server packages.
1234567891011121314151617181920import { checkoutPresentation, completeCartAndPay, orderPaymentPath, orderPaymentFrom,PAID_STATUSES, payOrder } from "medusa-plugin-tly-pay/storefront"const providerId = "pp_tly-pay_main"// Payment step: the title, coin icons and coin names the merchant chose.const method = checkoutPresentation(await sdk.client.fetch(`/store/tly-pay/checkout?provider_id=${providerId}`),{ backendUrl: MEDUSA_BACKEND_URL })// Place order: the payment is created after the order exists, then paid in its checkout mode.const { order, result } = await completeCartAndPay({initiatePayment: async () => {const { payment_collection } = await sdk.store.payment.initiatePaymentSession(cart,{ provider_id: providerId, data: { return_url: `${STOREFRONT_ORIGIN}/order/confirmed` } })return payment_collection.payment_sessions?.find((session) => session.provider_id === providerId)?.data},completeCart: () => sdk.store.cart.complete(cart.id),orderPayment: (placed) => sdk.client.fetch(orderPaymentPath(placed.id), { method: "POST" }),
Copy to clipboardresult is one of:
- Copy to clipboard
paid: the window closed after payment. - Copy to clipboard
closed: the window closed without payment; offer "Pay now". - Copy to clipboard
hosted: the page is leaving for the hosted payment page. - Copy to clipboard
unavailable: the order exists but its payment could not be started yet; offer "Pay now".
Copy to clipboardreturn_url is optional: a page on your Copy to clipboardstorefrontOrigin where the customer returns after paying. The hosted payment page shows a button back to it once the payment is complete.
Show the method's title as text, then its icons, then its coin names when they are not Copy to clipboardnull. An order is paid only when TLY Pay confirms it, not when the customer closes the window.
Notes
- Refunds are not available through TLY Pay.
- Check partial payments, overpayments and payments that need review in Medusa Admin before you fulfil the order.
- This package replaces Copy to clipboard
tly-pay-medusa, the name it was first published under.
Support
Write to support@tlypay.com and include the payment ID shown in Medusa Admin. Plans, security and the TLY Pay app are on tlypay.com.
License
MIT
