Skip to main content

Von Payments for Medusa

Take card payments in a Medusa v2 store. The buyer types their card into a secure field served by the payment processor inside your storefront's checkout, and the card is charged when they place the order, or held until the order is fulfilled if you choose. Refunds and cancellations from the Medusa admin move the money at Von Payments.

This page is for the developer setting up the store. You need access to the Medusa backend's configuration and to the storefront code.

Two things to know first
  • Refund from Medusa, not from the Von Payments dashboard. A refund made in the dashboard does not reach your store, so the order would still show the money as taken.
  • The Redis modules and a worker are required. Payment notifications and the plugin's background checks run on Medusa's worker, and payments are only protected against being completed twice when the server and the worker share Redis. An in-memory setup is not supported.

Before you install​

  • Medusa 2.15.5 or newer, on Node 20.19 or newer (or 22.12 or newer). A new Medusa starter can need a newer Node than that: use what create-medusa-app asks for.
  • Medusa's Redis event bus, Redis workflow engine, Redis locking and Redis cache modules, and a Medusa process in worker (or shared) mode. Server and worker must use the same REDIS_URL, database number included, and Redis must not evict keys (maxmemory-policy noeviction): an evicting Redis silently drops queued events and locks.
  • Your Von Payments API keys: a secret key for the backend and a publishable key for the storefront, in the same mode.
  • Your storefront served over HTTPS (http://localhost is fine with test keys).

Install​

You set the plugin's keys and addresses as environment settings, not in the Medusa admin:

SettingWhereWhat goes there
VONPAY_SECRET_KEYServer .envYour secret key, vp_sk_test_… or vp_sk_live_….
VONPAY_MODEServer .envtest or live, matching the key.
VONPAY_STOREFRONT_URLServer .envYour storefront's address.
VONPAY_WEBHOOK_SECRETServer .envThe signing secret of your payment-updates endpoint, once you have created it (step 6).
MEDUSA_BACKEND_URLServer .envYour backend's public address.
NEXT_PUBLIC_VONPAY_PUBLISHABLE_KEYStorefront environmentYour publishable key, vp_pk_…, in the same mode. Never the secret key.
VONPAY_SHOPPER_IP_HEADERStorefront environmentOptional, for one-click offers: the header your hosting sets to the shopper's address.
VONPAY_SHOPPER_IP_SECRETServer .env and storefront environmentOptional, for one-click offers: a long random value of your own (openssl rand -hex 32), the same value on both. It proves the shopper's address on offer charges is real. Never your Von Payments key or the webhook signing secret.

In the Medusa admin you add the payment provider to your regions (step 5) and run the setup check (step 8).

Do these steps in order. Each one says where it happens.

  1. In your Medusa server project, install the plugin and Medusa's Redis caching provider:

    npm install vonpay-medusa @medusajs/caching-redis
  2. Set the environment in the server's .env (never in a committed file). The server and the worker both need it:

    VONPAY_SECRET_KEY=vp_sk_test_...
    VONPAY_WEBHOOK_SECRET= # empty for the first start; set in step 6
    VONPAY_STOREFRONT_URL=https://shop.example.com
    VONPAY_MODE=test
    MEDUSA_BACKEND_URL=https://api.example.com
    REDIS_URL=redis://... # the same Redis, database number included, for server and worker
  3. Register the plugin, its payment provider and the Redis modules in medusa-config.ts:

    import { defineConfig, Modules } from "@medusajs/framework/utils"

    const REDIS_URL = process.env.REDIS_URL

    module.exports = defineConfig({
    projectConfig: {
    // ...your existing database, CORS and secret settings
    redisUrl: REDIS_URL,
    workerMode: (process.env.MEDUSA_WORKER_MODE as "shared" | "worker" | "server" | undefined) ?? "shared", // "server" and "worker" when you run them apart
    },
    admin: {
    backendUrl: process.env.MEDUSA_BACKEND_URL, // lets the setup check confirm the endpoint is this store's
    },
    plugins: [{ resolve: "vonpay-medusa", options: {} }],
    modules: [
    {
    key: Modules.PAYMENT,
    resolve: "@medusajs/medusa/payment",
    options: {
    providers: [
    {
    resolve: "vonpay-medusa/providers/vonpay",
    id: "vonpay",
    options: {
    secretKey: process.env.VONPAY_SECRET_KEY,
    webhookSecret: process.env.VONPAY_WEBHOOK_SECRET,
    storefrontUrl: process.env.VONPAY_STOREFRONT_URL,
    mode: process.env.VONPAY_MODE, // "test" or "live"
    shopperIpSecret: process.env.VONPAY_SHOPPER_IP_SECRET, // optional, for one-click offers
    },
    },
    ],
    },
    },
    {
    key: Modules.CACHING,
    resolve: "@medusajs/medusa/caching",
    options: {
    providers: [
    { resolve: "@medusajs/caching-redis", id: "caching-redis", is_default: true, options: { redisUrl: REDIS_URL } },
    ],
    },
    },
    { key: Modules.EVENT_BUS, resolve: "@medusajs/medusa/event-bus-redis", options: { redisUrl: REDIS_URL } },
    { key: Modules.WORKFLOW_ENGINE, resolve: "@medusajs/medusa/workflow-engine-redis", options: { redis: { redisUrl: REDIS_URL } } },
    {
    key: Modules.LOCKING,
    resolve: "@medusajs/medusa/locking",
    options: {
    providers: [
    { resolve: "@medusajs/medusa/locking-redis", id: "locking-redis", is_default: true, options: { redisUrl: REDIS_URL } },
    ],
    },
    },
    ],
    })

    Options you add later (Configure) go in the provider's options.

  4. Create the plugin's tables and start the server and the worker with that environment:

    npx --no medusa db:migrate
    npx --no medusa develop # on your own computer: one process, shared mode

    In production, run npx --no medusa start twice: once with MEDUSA_WORKER_MODE=server and once with MEDUSA_WORKER_MODE=worker.

    A malformed value, or a missing required option other than the signing secret, stops the start with an error naming the option or variable, never its value. The store starts without the signing secret and takes payments, but refuses every payment update until step 6.

  5. In the Medusa admin, open Settings → Regions and add the Von Payments provider to the payment providers of each region that should offer it. The admin lists it as Vonpay (VONPAY); its id is pp_vonpay_vonpay. Checkout never shows it in a region you skip.

  6. Create the payment-updates endpoint (Payment updates), copy its signing secret into VONPAY_WEBHOOK_SECRET, and restart the server and the worker. Do this before you take live payments: a payment update the store refused is not sent again.

  7. In your storefront's folder, add the card step and set NEXT_PUBLIC_VONPAY_PUBLISHABLE_KEY (Add the card step to your storefront), then deploy the storefront.

  8. Check it. From the Medusa project folder, npx --package=vonpay-medusa vonpay-medusa-check must pass (on your own computer, two items cannot), or press Check Vonpay setup under Orders → Held payments (Check the setup). Then test a payment, and switch to live payments when you are ready.

Configure​

OptionRequiredWhat it is
secretKeyYesYour secret key, vp_sk_test_… or vp_sk_live_….
modeYestest or live. It must match the key; a mismatch stops the store from starting.
webhookSecretAfter setupThe signing secret of your payment-updates endpoint (below). The store starts without it, but refuses every payment update and fails the setup check until it is set. An API key here is refused.
storefrontUrlYesYour storefront's origin only, https:// (plain http://localhost only in test mode), with no path or country segment. A buyer returning from their bank's 3-D Secure page lands on <storefrontUrl>/checkout/vonpay-return, and the starter's middleware redirects that to the buyer's country path, keeping the query string.
recoveryNo, default trueEvery 5 minutes the worker looks for a checkout Von Payments reports paid but Medusa has no order for, and completes it, in case a payment update never arrived. It never refunds. From 1.6.0, when Medusa's default locking module is not a shared one (Redis or Postgres), it completes no paid checkout: each one goes to Held payments as Paid, order not created (a held wallet payment or held card: Payment held, no order), and the setup check's locking line says so. When runs keep ending with checkouts left for later, it logs the error recovery_backlog. With cardCapture: "at_fulfillment" it also retries held cards that were not taken and logs the day-4 warning (Card hold, then capture).
cardCaptureNo, default "at_payment"When a card payment's money is taken. "at_payment" charges the card when the shopper pays. "at_fulfillment" holds the card and charges it when the order is fully fulfilled (Card hold, then capture).
holdRecheckNo, default trueEvery 5 minutes the worker asks again about a held payment whose outcome was unknown, and takes it off the held list once Von Payments closes it with nothing charged.
savedCardsNo, default offLets logged-in customers save a card. Set it to "recurring" if you charge saved cards on a fixed schedule (subscription renewals), or "unscheduled" if you charge them later with no schedule. The value is what Von Payments tells the card networks for every card saved on your store, so it must match how you charge. Logged-in customers then see a "Save my card for future orders" checkbox, never pre-ticked; guests never see it. When you delete a customer in Medusa, their email is erased at Von Payments too. That erase does not remove every copy (for example, payment records keep what settlement needs), so do not describe it to a shopper as a complete deletion; see Erasing a buyer's email. Each customer can keep up to 10 saved cards (Saved cards).
savedCardsTermsNo, default unsetYour own consent wording, used instead of the checkbox (Consent by your own terms). Needs savedCards.
walletsNo, default offShows Apple Pay and Google Pay above the card form (Apple Pay and Google Pay).
upsellsNo, default offOne-click offers after the order, to signed-in customers and guests; guests: false leaves guests out (One-click add-ons).
subscriptionsNo, default offSet it to "store" when your own subscription plugin (for example ReorderJS) renews orders: the plugin then charges the customer's saved card when that plugin asks (Subscription renewals). Needs savedCards.
paidWithoutOrderLookbackDaysNo, default 90How many days back the setup check's paid_without_order line looks, 2 to 3650 (Check the setup). Set it higher for one run if your store took Von Payments payments before that.
statementDescriptorNo, default offWhat the plugin puts in the per-payment ending of your card-statement line (Statement descriptor).

An option the plugin cannot accept stops the store from starting with a vonpay_options_* error naming the option, never its value.

Payment updates​

In your Von Payments dashboard, create a webhook endpoint at your backend's public address followed by /hooks/payment/vonpay_vonpay, subscribed to charge.succeeded and charge.failed. Use the same public address as MEDUSA_BACKEND_URL, so the setup check can confirm the endpoint is this store's. Copy the signing secret shown when it is created into VONPAY_WEBHOOK_SECRET, then restart the server and the worker. With wallets on, also subscribe it to payment_intent.authorized (or select all events): a wallet payment sends no other update before the order exists, and the setup check warns when it is missing. Keep one endpoint per store: each active endpoint receives every event it is subscribed to, so a second endpoint for the same store delivers each update twice, and the setup check warns when it finds more than one. Test and live keys each need their own endpoint (Switch to live payments).

Medusa answers this route before the plugin checks the signature, so anyone can make your server do that work. At your proxy, rate-limit requests to this one path per client address, leaving room for a burst of payment updates. Keep the route public over HTTPS: the signature check is what stops a forged update.

Add the card step to your storefront​

The same vonpay-medusa package carries the storefront card step and the 3-D Secure return page for the Medusa Next.js starter. In your storefront's folder:

npm install vonpay-medusa
npx vonpay-medusa setup-storefront

The command adds two files to a src/lib/vonpay folder in your storefront: actions.ts (the server actions) and index.tsx (the card step and return page). It also adds the 3-D Secure return page at checkout/vonpay-return, and adds transpilePackages: ["vonpay-medusa"] to your Next config and the package's files to Tailwind's content. It is safe to run again, and --dry-run shows what it would do. A file it does not recognise, such as a customised checkout, is left alone and printed as a step for you to make by hand; --force replaces it. Then set the publishable key:

NEXT_PUBLIC_VONPAY_PUBLISHABLE_KEY=vp_pk_test_... # the publishable key only

If you wire the storefront by hand instead: render VonpayCardPayment and VonpayReturn from vonpay-medusa/storefront, build their actions with createVonpayStorefrontServer from vonpay-medusa/storefront/server in a "use server" file of your own, import vonpay-medusa/storefront/card-field.css once, add transpilePackages: ["vonpay-medusa"] (the pieces ship as TypeScript source), and add the package's files to Tailwind's content so their classes are generated.

Card entry appears in the Payment step, directly above Place order (1.2.1 and later). A Von Payments payment has no Review step; other payment methods keep the starter's Review step.

Upgrading a storefront set up with 1.2.0 or earlier: those versions put the card form in the Review step. Run npx vonpay-medusa setup-storefront again. It moves the form into the Payment step when your Payment step, Review step and checkout form are still the starter's. If you changed one of them, the command changes none of them and prints the step to make by hand. With one-click add-ons off, also export a prepareVonpayNoOffer action from the actions.ts file setup-storefront added to src/lib/vonpay, returning vonpay.prepareVonpayNoOffer(), like the other actions in that file. Without it the checkout works as before, but asks your store once for an offer pass when the order completes.

The typed card stays when the total changes (1.2.0 and later). Medusa replaces the cart's payment each time the total changes: an add-on, a coupon, another delivery option. The card form stays on screen and moves to the new payment, so the shopper does not type the card again. While it moves, the form shows "Updating your total…" and Place order waits. If the move does not match the total your page shows, the form is built again, empty, with "Your total changed. Enter your card again." A ticked "save my card" box comes back unticked, so the shopper confirms it again for the new total.

The card form loads vora.js from https://js.vonpay.com/v1/vora.js, which updates automatically. If your storefront sends a Content Security Policy (the Medusa starter does not), add the sources vora.js needs to your checkout pages' policy: vonpayCspSources() from vonpay-medusa/storefront/shared gives you the list (CSP requirements).

The card number is entered only inside the vora.js frame and never reaches your storefront, your Medusa server or Von Payments, which is what the plugin is designed around for SAQ-A. Whether your store qualifies also depends on your own checkout page, including the scripts it loads.

Your own words and language at checkout (1.6.0 and later)​

The card step and the 3-D Secure return page are in English. To change their words or translate them, give them up to three settings. The plugin ships no translations: you write the lines. Leave the settings out and the checkout looks as before.

  • copy: any line of CHECKOUT_COPY (exported from vonpay-medusa/storefront), changed or translated. Pass the same object to the card step and the return page. A line you leave out stays in English. A line that is empty, or a function that fails, shows the English line.
  • locale: a language tag such as "ja-JP". The pages use it to write the bank-check deadline, and the card step passes it to the card form. A tag the browser cannot read is ignored.
  • cardPlaceholder (card step only): the hints inside the card box, { number, expiry, cvc }. A hint you leave out keeps the default.

Set them in the index.tsx file that setup-storefront added to src/lib/vonpay. It runs in the browser, and a line of copy can be a function, which a server page cannot pass on. Change its two functions like this:

// Add `type VonpayCheckoutCopy` to the file's import from "vonpay-medusa/storefront".
// Any line you leave out stays in English.
const storeCopy: Partial<VonpayCheckoutCopy> = {
cardDetails: "カード情報",
placeOrder: "注文を確定する",
declined: "お支払いが承認されませんでした。別のカードをお試しください。",
}
const cardPlaceholder = { number: "カード番号", expiry: "月 / 年", cvc: "セキュリティコード" }

export function VonpayCardPayment(props: VonpayCardPaymentProps) {
return <PackagedCardPayment {...props} actions={actions} ui={ui} copy={storeCopy} locale="ja-JP" cardPlaceholder={cardPlaceholder} />
}

export function VonpayReturn() {
return <PackagedReturn actions={actions} ui={ui} copy={storeCopy} locale="ja-JP" />
}

Before you change the words:

  • Lines that ask for the shopper's agreement become yours. These are saveTermsLeadIn (shown before your terms on a subscription cart), upsellNotice (the offer notice under the pay button) and the "save my card" box (saveCardLabel, saveCardSubscriptionLabel, saveCardRequired). The plugin records your terms and the shopper's tick, not these lines.
  • Keep what the standard lines promise. Only a real decline says "declined". An unclear result says "don't pay again". No line says the payment "failed".
  • The card box's own labels and messages are in English. The hints inside it follow cardPlaceholder.
  • The reason a card was declined, and the subscription sentence (price and schedule), come from Von Payments as they are. Your lines go around them.
  • copy does not cover the My saved cards page (its lines are SAVED_CARDS_COPY). The one-click offer pages take their own copy (UPSELL_COPY) and the same locale (One-click add-ons).

Items that need no delivery​

From 1.5.0, a cart with nothing to deliver (a digital product or a service: no shipping profile and no stock item that needs shipping) starts the Von Payments payment. Medusa completes such a cart with no delivery method.

The starter's own checkout still waits for a delivery method in three places: the Payment step, the Review step and the pay button. If you sell such items, replace each of those checks with deliveryDone(cart) from vonpay-medusa/storefront/shared. It is true when the cart has a delivery method, or when nothing in it needs delivery. In your Delivery step, use noDeliveryNeeded(cart) to skip the delivery choice and show Continue to payment. Your cart query must include the items (the starter's *items does).

setup-storefront does not make these edits, because they change your checkout for every payment method.

Apple Pay and Google Pay​

Set wallets: true in the provider options. Then register your storefront's domain, once per store and again if its address changes or you switch between test and live keys. From the Medusa project folder:

npx --package=vonpay-medusa vonpay-medusa-check --wallet-domains

It registers the host of storefrontUrl for both wallets, saves Apple's domain file in your store's own record, and asks Von Payments to check both. Your storefront serves that file at /.well-known/apple-developer-merchantid-domain-association through the route npx vonpay-medusa setup-storefront adds, so deploy the storefront first, or register again after you do. The setup check shows each wallet's status and compares the file your storefront serves with the saved one. Nothing here moves money.

The buttons appear above the card form only where the shopper's device supports the wallet and the domain is registered for it; anywhere else the checkout is the card form alone.

A wallet payment is held when the shopper approves it and taken once Medusa has the order, so the order shows the payment as captured. If the order cannot be created, or the cart changes, the hold is released and nothing is taken. A shopper who approves and then closes the page still gets an order: the recovery job completes it about 10 minutes after the tap.

If taking the held payment fails (usually a short outage), the plugin keeps retrying for 2 hours. What the Held payments row says meanwhile, and what to do when the retries end: Held payments on Medusa.

Card hold, then capture​

From 1.5.0, you can hold the card at checkout and take the money later. Set cardCapture: "at_fulfillment" in the provider options. Left out, it is "at_payment": the card is charged when the shopper pays.

With "at_fulfillment":

  • The card is only held at checkout, and Medusa shows the payment as authorized.
  • The plugin takes the money when the whole order is fulfilled. That is when the fulfillment that completes the order is created in Medusa, not when it ships or is delivered.
  • It takes what the order still owes, at most the held amount. If you edited the order to a lower total, the lower total is taken and the rest of the hold goes back to the shopper.
  • Nothing is taken automatically when the amount due is more than the hold, when nothing is due, when the amount cannot be read, or when the order has more than one held card. The order then shows on Held payments as Order fulfilled, held card not collected (Held cards): Capture or Cancel it.
  • You can press Capture on the order sooner, for any amount up to the hold.
  • A held card is charged once. After a partial capture, the rest cannot be taken.
  • Cancelling the order releases the hold. Nothing is refunded, because nothing was taken. A refund on a card that is only held is refused: cancel the order instead.

These are still charged when the shopper pays:

  • a cart with a subscription, because its renewals need the card saved when it is charged;
  • an order edit's "pay the difference";
  • a checkout whose card connection cannot hold cards. The server logs an ERROR, and the setup check fails.

Held orders get no one-click offer page.

Holds expire. Banks drop a card hold after about 5 to 7 days, and the money is then lost. A hold 3 days old shows on Held payments, and from day 4 the server logs an ERROR once a day. If the money is not taken when the order is fulfilled, the background job tries again 5 minutes, 20 minutes, 80 minutes and about 5 hours after the order was fully fulfilled, then every 6 hours. It stops 7 days after the card was held, so an order fulfilled late gets fewer tries. What each row means: Held cards.

Before you turn it on:

  • Keep recovery on. It retries a failed capture and logs the day-4 warning.
  • Use a shared locking module as Medusa's default: Redis (as in Before you install) or Postgres. The capture when an order is fulfilled and the recovery job's capture can run in different processes, and the lock keeps them apart.
  • Run the setup check with your test keys. It makes a sandbox hold and releases it, to prove your card connection can hold (Check the setup).

Saved cards​

With savedCards set, logged-in customers see Save my card for future orders, never pre-ticked. Each customer can keep up to 10 saved cards; at 10 the checkbox is not offered until they remove one.

npx vonpay-medusa setup-storefront adds a My saved cards page at /account/saved-cards when your storefront has the starter's account area, and prints where to add the menu link. Customers see every card saved for them and can remove one, which revokes it at Von Payments for good. A card the customer did not agree to have shown back is listed as "A saved card", without brand or last digits, and can still be removed. The page uses the plugin's store routes at /store/vonpay/saved-cards, which answer only a signed-in customer, and only about their own cards.

At Von Payments each customer appears as a buyer with the reference medusa_<mode>_<customer id> (for example medusa_live_cus_01…), which is what to search for in the dashboard.

Consent by your own terms​

Instead of the Save my card checkbox, you can collect the agreement through your own wording (why that counts as consent, and what it must say). Set savedCardsTerms to the exact wording, 20 to 1,000 characters of plain text, for example: "Your card is saved and charged automatically for this subscription's renewals until you cancel." It needs savedCards.

With it set, the checkout shows no checkbox. On a subscription cart the page shows By placing your order you agree to: followed by your wording, above the Apple Pay and Google Pay buttons when they show, otherwise just above the pay button. Completing that checkout saves the card for the renewals, for a card or a wallet payment alike. A one-time purchase saves nothing. On a vora.js older than 1.43.0, a subscription cart also shows the required checkbox.

The plugin records your configured wording with each payment it applied to, when the payment is confirmed: save_consent_record on the payment's data, with basis: "store_terms", the wording, its SHA-256, whether the cart was a subscription, and recorded_at. Each recorded payment is also written to your server's log as save_consent_recorded, with the payment's ids and the wording's SHA-256 but never the wording itself. It records what the store was set to show, so change the wording deliberately. Cards saved this way appear under My saved cards as "A saved card".

The wording is yours to get right: state the price (or how it is set), how often it renews, that it continues until cancelled, and how to cancel; send your own confirmation email with those terms after the order; and have the wording reviewed by your legal counsel. If in doubt, keep the checkbox.

Subscription renewals​

For a store whose own subscription plugin, such as ReorderJS, creates renewal orders. Set savedCards: "recurring" and subscriptions: "store".

On a cart with a subscription line (ReorderJS marks it with metadata.is_subscription):

  • The checkbox reads Save my card for future orders, including this subscription's renewals, and the shopper must tick it before paying.
  • A guest is asked to sign in, because the card can only be saved to an account.
  • A customer can keep up to 50 saved cards for subscriptions.
  • Apple Pay and Google Pay appear here too, and save the wallet's card with the same tick (vora.js 1.43.0 or later, which the live channel serves).

The plugin charges a renewal only for a payment session opened with off_session: true (as ReorderJS 1.1.0 and 1.1.1 do) on an existing order, for that order's own customer, with a saved card in the store's current mode. Anything else is refused and nothing is charged. Each order is charged once; only ReorderJS's own retries of a declined order can charge it again (below). An attempt whose result is unclear goes to Held payments, and later attempts on that order are refused until a person closes the row (Held payments on Medusa). Before each charge the plugin also checks that Von Payments does not bill your subscriptions itself; if it does, or the answer cannot be read, nothing is charged and renewal_subscription_billing is logged.

One charge per period (1.4.0 and later). The plugin charges each subscription period once, even when ReorderJS asks again on a new order. Before a renewal charge it reads its own record of the period and asks Von Payments for that period's payments, so your secret key needs payment_intents.read (restricted keys). If the period is already paid, the plugin refuses the charge and nothing is charged. That refusal comes back to ReorderJS as not authorized, and ReorderJS's dunning stops retrying it. A full refund does not reopen a paid period: only a person can, from Held payments. If an earlier charge of the period is not finished or its result is unknown, or the record or Von Payments cannot be read, the plugin refuses for now and ReorderJS tries again later. An order with no renewal cycle and no subscription (another subscription plugin) is charged as before, once per order.

After a declined renewal (1.4.0 and later), only ReorderJS's own retries of the order that declined charge that card again. They go through at least 24 hours apart (longer if the card network names a longer wait), and never after a decline that Von Payments or the card network marks final. A new order for the same period on that card is refused, and a re-saved copy of the card counts as the same card. A card with no decline of its own charges as normal. A decline from before 1.4.0 does not say which card it was on, so it holds such a card for up to 24 hours. This refusal goes back to ReorderJS as a temporary failure, so its dunning keeps its schedule. When ReorderJS keeps asking for a period, the period shows on Held payments (Renewal periods).

The first refusal of a period logs one ERROR line, renewal_period_already_charged or renewal_retry_limited. Later refusals of the same period are WARN lines with a count, so an alert fires once.

A held renewal, or one refused because its period is already paid, comes back to ReorderJS as not authorized, so ReorderJS opens a dunning case even when the charge may have gone through. Check the payment in the Von Payments dashboard first. Use ReorderJS 1.1.1 or later: in 1.1.0, a retry of a failed renewal never reached the payment provider. Mark a case recovered only once the money has arrived.

One-click add-ons​

Offer a product right after checkout, paid with one click and added to the order the shopper just placed: set upsells in the provider options. What the shopper sees, how offers are paid, the shopper's-address settings, offers to guests, the time limit, holding fulfillment and the email are on their own page: One-click add-ons on Medusa.

Statement descriptor​

Your card-statement line is a brand line plus a short per-payment ending. You set both, and which payment field the ending is read from, in your Von Payments dashboard (Statement descriptors). statementDescriptor tells the plugin what to put in that field:

statementDescriptor: { key: "order_id", from: ["product_title", "store_name"] },

key is the field your dashboard rule reads: order_id, subscription_id, customer_id, or your own field name. from lists one to three sources in order, and the first one the payment has is sent; with none, your rule's fallback applies.

fromWhat is sent
"product_title"The product's title; with several lines, the first title plus "+N" (Blue Mug +2). On an offer, the offered product.
"store_name"Your Medusa store's name.
"order_number"The order number as the admin shows it (#1001). Offers and renewals only.
"customer_reference"The plugin's own customer reference (medusa_live_cus_…), for signed-in shoppers and renewals.
"subscription_reference"The subscription id your subscription plugin records on a renewal order.
{ text: "ACME COFFEE" }Fixed text, 5 to 22 plain characters. Only as the last source.

Checkout payments (card, Apple Pay and Google Pay), one-click offer card charges and renewals carry the ending. On a checkout payment the value is the one the plugin read when the shopper reached the payment step, so a cart change that does not start a new payment keeps the earlier value. Offers paid with Apple Pay or Google Pay show your plain descriptor. A key that suggests personal data, such as email or phone, stops the store from starting with an error naming the word it found. The setup check compares this option with your dashboard setting.

Keep the plugin updated​

Updating vonpay-medusa updates the server plugin and the storefront pieces together, and releases follow semantic versioning.

When an update is available​

The admin's Orders page shows vonpay-medusa X is available (or Security fix: …) with the exact command and a What changed link. Each release and its update steps are in the changelog. Your Medusa server reads this from a file Von Payments signs, at https://www.vonpay.com/medusa/update.json, about twice a day; your store sends nothing about itself, and an unsigned or unreachable file is never shown. With no outbound internet, turn the check off with VONPAY_UPDATE_CHECK=off on the server.

From 1.5.0, your server also reads a small "still current" file that Von Payments signs every few hours, at https://www.vonpay.com/medusa/timestamp.json. If your server's outbound traffic is filtered, allow it. Once your server has read a valid one, an update file it cannot confirm is current shows "Couldn't confirm plugin updates" and points to docs.vonpay.com for the latest version, instead of a notice. Payments are not affected.

Apply an update​

  1. In your Medusa server project and in your storefront's folder, install the exact version the notice names:

    npm install vonpay-medusa@X

    Name the version: npm update stays inside your current version range and can do nothing. Then run npx --no medusa db:migrate in the Medusa server project. From 1.2.1 it also creates the background job's table. If your medusa-config.ts does not list the plugin under plugins:, add its job module to modules too:

    { resolve: "vonpay-medusa/modules/vonpay-jobs" },
  2. Rebuild and redeploy both the Medusa server (and its worker) and the storefront.

  3. From the Medusa project folder, run npx --package=vonpay-medusa vonpay-medusa-check, then place a test payment.

Each release's own steps are in the changelog: 1.7.0, 1.6.0, 1.5.1, 1.5.0, 1.4.0, 1.3.0 and 1.2.1. 1.4.0 replaces 1.3.0: coming from 1.2.x, update straight to 1.4.0 and do the 1.3.0 steps too. Coming from 1.2.0 or older, do the 1.2.1 steps too: they run the setup check once and move the card form into the Payment step.

Automatic updates​

npx vonpay-medusa setup-storefront offers to turn on automatic updates (--auto-updates or --no-auto-updates answers without the question). It adds .github/dependabot.yml, a daily check for vonpay-medusa in every folder that installs it (for a workspace with one lock file at the top, that top folder), and a workflow that merges patch releases once your required checks pass. Turn on Settings → General → Allow auto-merge in your repository for that. Minor and major releases wait for you. If you already have a dependabot.yml, it is left alone and the command tells you what to add.

To set it up yourself, let an update bot open the pull requests and merge patch releases on its own:

renovate.json
{
"extends": ["config:recommended"],
"packageRules": [
{
"matchPackageNames": ["vonpay-medusa"],
"matchUpdateTypes": ["patch"],
"automerge": true,
"schedule": ["at any time"]
}
]
}

With Dependabot, add an npm entry for each folder with a lock file that installs the package (the Medusa server and the storefront, or their workspace's top folder when they share one lock file), on a daily schedule, allowing vonpay-medusa, and turn on auto-merge for its pull requests. After an update, redeploy the Medusa server, its worker and the storefront.

Check the setup​

From your Medusa project folder (in an image built with medusa build, from .medusa/server):

npx --package=vonpay-medusa vonpay-medusa-check

Or press Check Vonpay setup on the Held payments page under Orders in the admin. The check confirms the provider is enabled and Von Payments accepts its key, that the signing secret is set, that at least one region offers Von Payments, that a payment-updates endpoint is registered and active, that the Redis modules and the worker are configured, with upsells on that an email provider is configured and the shopper's-address secret is set, with statementDescriptor set that it matches your dashboard setting, and, with a test key, that a test update is actually processed (run it again after 10 seconds to see that step). With a live key it sends nothing. From 1.2.0 it also fails amount_check when the plugin cannot check each charge against the cart's total, because every card payment would then be held (Troubleshooting).

From 1.2.1 the check also fails paid_without_order for each checkout more than a day old that Von Payments reports paid (or holds) with no order and not on Held payments. It looks back 90 days (paidWithoutOrderLookbackDays). Press Move to Held payments beside each one, or run npx --package=vonpay-medusa vonpay-medusa-check --move-to-held <payment id>. The plugin checks the payment with Von Payments again, then lists it on Held payments, where you refund it or mark it resolved (a held wallet payment: release it or complete the order). A payment refunded in full in Von Payments is not listed.

From 1.4.0, with subscriptions: "store" and saved cards on, the check fails renewal_search when your key lacks payment_intents.read, because every renewal would be refused. renewal_period reports when the plugin's record of paid periods is missing: it fails once one of your newest 100 orders is a ReorderJS renewal, and warns before that, because the first ReorderJS renewal will be refused. Run npx --no medusa db:migrate.

From 1.5.0, with cardCapture: "at_fulfillment", the check fails card_holds when your card connection cannot hold cards (tested with test keys only), when recovery is off, or when Medusa's default locking provider is not a shared one such as Redis or Postgres (Card hold, then capture).

From 1.6.0 the check fails collection_handle when the plugin cannot save its records safely through Medusa's database connection. With no connection, the plugin saves its records the old way, which can erase a record saved at the same moment. With a connection that cannot see your payment records, the plugin saves no held-payment, refund, renewal or offer record, and logs an error for each one (vonpay_log_collection_write_failed or vonpay_log_collection_write_row_not_seen). While a charged payment cannot be recorded, a shopper's cart change fails with vonpay_hold_not_listed (the shopper can try again), and a cancel leaves that payment uncancelled in Medusa (Medusa logs the error). To fix it, run the plugin on Medusa's own payment module with its database connection (one Medusa database, the default setup), then restart the server and the worker. On a store with no payment yet, the line can say the connection is not proven until the first payment: run the check again after it.

The endpoint line names the address Von Payments sends to and compares it with MEDUSA_BACKEND_URL (the button also accepts the address you reached the admin at). If it cannot confirm the endpoint is this store's, it warns and sends no test update, because the update could reach another store. --strict also fails when a check could not run.

Test a payment​

With a test key, pay with the test card 4111 1111 1110 1203, expiry 03/30 and security code 100, at an ordinary total: the order shows the payment as captured (with cardCapture: "at_fulfillment", as authorized until the order is fulfilled). To test a decline, use a test-mode total. Sandboxes run 3-D Secure on every card payment, so the buyer passes through the bank-check page and back to /checkout/vonpay-return, which shows the outcome the server reports.

Testing on your own computer​

Without a public address, Von Payments cannot reach your server with payment updates. npx --package=vonpay-medusa vonpay-medusa-check then reports the signing secret as failed and skips the test update. Payments and orders still work; holds, refunds and renewals reported by a payment update do not arrive. To test payment updates too, expose your server through a public HTTPS tunnel, set MEDUSA_BACKEND_URL to that address, and register the endpoint (Payment updates).

One Von Payments account, several stores. The setup check looks for exactly one active payment-updates endpoint for /hooks/payment/vonpay_vonpay on this store's own address (from MEDUSA_BACKEND_URL). If your account already has that endpoint for another store, for example your staging store, the check warns, names that address, and sends no test update, so it can never reach the other store. On your own computer this is expected. Von Payments sends every event to every endpoint on the account, so keep one endpoint per store: the check also warns when two active endpoints share this path.

If your Medusa project has apps/backend and apps/storefront in one folder (newer create-medusa-app projects do), "the Medusa project folder" on this page is apps/backend, and "your storefront's folder" is apps/storefront.

Switch to live payments​

Your test keys belong to your business's sandbox, a separate account from your live business with its own payment-updates endpoints and signing secrets, so going live takes a new endpoint as well as new keys:

  1. In your Von Payments dashboard, on your live business (not the sandbox), create the payment-updates endpoint at the same address with the same events (Payment updates), and copy its signing secret.
  2. On the server, change these together, since a key and mode that disagree stop the store from starting: VONPAY_SECRET_KEY to your live secret key, VONPAY_MODE=live, and VONPAY_WEBHOOK_SECRET to the live endpoint's signing secret. Then restart the server and the worker.
  3. In the storefront, set NEXT_PUBLIC_VONPAY_PUBLISHABLE_KEY to your live publishable key, then rebuild and redeploy it.
  4. With wallets on, register your storefront's domain again with npx --package=vonpay-medusa vonpay-medusa-check --wallet-domains (Apple Pay and Google Pay).
  5. Run the setup check. The endpoint line must show the live endpoint at this store's address. With a live key the check sends no test update, so it does not prove updates are processed.

Refunds and cancellations​

Refund from the order in the Medusa admin, in full or in part; cancelling a paid order refunds what was captured. A refund made in the Von Payments dashboard is not reflected in Medusa. A card that is only held (Card hold, then capture) cannot be refunded: cancel the order to release the hold. From 1.3.0, a refund that Von Payments does not complete comes back on Held payments (Refunds that did not complete).

Held payments​

When a payment cannot be matched to an order safely, the plugin does not complete the cart and does not refund on its own. It lists the payment on Held payments under Orders. This includes a charge that does not equal the cart's total (1.2.0 and later), a wallet payment with no order, and a renewal or offer charge whose result is unknown. What each row means, and what each action does to the money: Held payments on Medusa.

Running a second payment provider​

You can also offer another payment provider in the same regions, so buyers have a second way to pay. If Von Payments cannot be reached, a Von Payments checkout waits in a "confirming" state rather than failing.

Troubleshooting​

What you seeWhat to do
The store does not start, with a vonpay_options_* errorFix the named option (Configure). vonpay_options_mode_key_mismatch: mode and the key are for different modes.
The setup check reports the event bus, workflow engine or lockingAdd the Redis module it names to medusa-config.ts and restart both processes.
The setup check reports no payment-updates endpointRegister /hooks/payment/vonpay_vonpay on your backend's public address (Payment updates).
The setup check fails webhook_secret, or payment updates are refusedCopy the endpoint's signing secret into VONPAY_WEBHOOK_SECRET (Payment updates), then restart the server and the worker.
The setup check fails regions, or checkout does not offer Von PaymentsAdd pp_vonpay_vonpay to the payment providers of each region you sell in.
The setup check fails amount_check (1.2.0 and later)The plugin cannot reach Medusa's Query, so it cannot check that each charge equals the cart's total, and every card payment is held instead of becoming an order. Install the plugin and your Medusa packages so there is one copy of @medusajs/framework (npm ls @medusajs/framework), then restart the server and the worker.
The setup check fails card_holds (1.5.0 and later)With cardCapture: "at_fulfillment": turn recovery on, make a shared locking module (Redis or Postgres) Medusa's default, and run the check with test keys. While your card connection cannot hold cards, its payments are charged when the shopper pays (Card hold, then capture).
The endpoint line warns the address is not this store'sSet MEDUSA_BACKEND_URL to your backend's public address, and register the endpoint at that same address.
Orders stay pending after a successful paymentCheck that a worker is running and shares the server's Redis, then run the setup check with a test key. The recovery job completes the order within minutes once the worker runs.
The setup check warns saved_cards_termsYour store saves cards and sells subscriptions (the subscriptions option is set, or medusa-config lists a subscription plugin such as ReorderJS) with only the Save my card checkbox, which does not show the price, how often it renews, any trial or how to cancel. Set savedCardsTerms to those terms (Consent by your own terms), then restart the server and the worker.
The setup check warns shopper_ip, the server logs shopper_ip_sig_rejected, or the storefront logs "VONPAY_SHOPPER_IP_SECRET is missing or shorter than 32 characters"Offer charges are going out without the shopper's address. Set VONPAY_SHOPPER_IP_SECRET to the same value on the Medusa server and the storefront, update the storefront to the same plugin version as the server, then restart and redeploy both (One-click add-ons).
A payment appears on Held paymentsOpen it: it says why. Refund a checkout payment there, or mark it resolved once you have settled it with the buyer. A renewal or offer row has its own actions (Held payments on Medusa).
The setup check fails job_status (1.2.1 and later)Run npx --no medusa db:migrate, then restart the server. If medusa-config.ts does not list the plugin under plugins:, also add { resolve: "vonpay-medusa/modules/vonpay-jobs" } to modules (Apply an update).