Skip to content

Crypto checkout for dynamic carts: keep prices on your server

Build crypto checkout for changing carts without trusting browser totals. Choose a payment link or Checkout Session, preserve order prices and fulfill once.

Cart pricingServer sets total

A dynamic crypto checkout should collect a total calculated by your server, not a price submitted by the buyer's browser. Keep products, quantities, discounts and taxes in your order system. Create a payment attempt for the agreed total, let the buyer choose an available payment method, and release the order only after verified payment confirmation.

This guide is for developers selling changing carts, digital goods or account credits. Its focus is price authority and order changes, rather than a general payment integration tutorial. USDC and USDT may be familiar payment choices, but the exact assets and networks offered still depend on the live payment configuration.

A reusable link suits an offer whose saved price stays the same across purchases. A cart needs a different boundary: your application determines what this buyer owes for this order now.

Yolfi payment links provide the reusable fixed-price option. The API Checkout overview documents a standalone Checkout Session created by an authenticated server request, without requiring a Paylink. It also describes Paylink-backed sessions for attaching attempt-specific information to an existing fixed-price offer.

Your sale Suitable starting point Price authority
One fixed-price product shared repeatedly Reusable Paylink Saved product price
Cart with quantities, discounts or other changing totals Standalone Checkout Session Final server-calculated order total
Existing fixed-price Paylink needing a unique reference or redirect Paylink-backed Checkout Session Saved Paylink price, not a browser override

Do not create a catalog of temporary fixed-price links merely to represent every cart variation. Conversely, a fixed-price product does not need a new pricing engine just because the buyer can choose a payment network.

Treat the browser as a request, not the price list

A browser may submit a product identifier, requested quantity and coupon code. Those are inputs to validate, not authority to set a charge. Load current prices from trusted storage, check eligibility and inventory, apply your discount and tax rules, and calculate the final total on the server.

A hidden form field is still buyer-controlled. So are a URL amount, a disabled input and a total calculated in client-side JavaScript. Authentication identifies a customer; it does not make their submitted price trustworthy.

For example, a buyer can request two license seats and a discount. Your server decides whether both seats are available, whether that buyer qualifies for the discount, and what the final payable total is. Save that decision before asking the payment provider to collect it. This is an implementation example, not a claim about Yolfi managing license inventory or calculating tax.

Avoid binary floating-point arithmetic for money. Use an exact representation suited to your pricing currency and calculation rules, then serialize the final amount as the provider requires. The Yolfi Checkout quickstart specifies a decimal string for amount; the browser should receive the returned hosted URL, not your API key.

Save a price snapshot before opening checkout

Keep a durable order version containing the items, quantities, price basis, discounts, tax treatment, currency and final total. The following are recommended merchant-side controls, not extra Yolfi request fields:

  • Give the agreed order version a stable reference.
  • Record the final amount and pricing currency together.
  • Record the rule or version behind a discount rather than only its display label.
  • Define how long inventory or a service slot is reserved, if reservations apply.
  • Keep the payment attempt linked to that order version.

Yolfi's Checkout Sessions API reference describes an immutable amount and currency snapshot. It deliberately does not accept product line items: your application retains the cart, discounts, tax and fulfillment information. A provider payment record therefore does not replace your commercial order record.

The pricing currency and the asset used to pay are separate concepts. A server-approved USD total is not an instruction to send the same number of USDC or USDT by hand. The current Invoice supplies the actual crypto amount and payment instructions after the buyer chooses an available method. Do not substitute a cached exchange rate or assume every stablecoin is always exactly one dollar.

Retry the same attempt without creating another one

A timeout after a session-creation request leaves uncertainty: the provider may have created the session even though your server did not receive the response. Retrying with an unrelated key can create a second attempt instead of recovering the first.

For standalone Yolfi Checkout Sessions, the API reference requires Idempotency-Key. Repeating the same key and request returns the original session; reusing that key with different data returns 409 Conflict. Store a stable key for the logical attempt and reuse it for network retries. Keep it on the server and within the documented format requirements.

Do not silently change the total and resend the old key. A genuinely revised order needs an explicit new version and payment attempt, after checking the earlier attempt. Creation idempotency also does not replace fulfillment idempotency: retrying an API request and delivering an order twice are different failure modes. The webhook idempotency guide covers the latter.

Handle cart changes as a new agreement

Suppose a customer opens checkout, then returns to the cart and removes an item. The old session still represents the old agreed total; changing the cart display does not rewrite that snapshot.

Before offering a revised payment attempt:

  1. Retrieve the earlier attempt through the authenticated integration and inspect any linked Invoice.
  2. Check whether payment was submitted, detected or confirmed; do not treat a closed browser tab as cancellation.
  3. Decide whether the original order version is still payable under your terms and the provider's supported controls.
  4. Create a new version only when appropriate, preserve both references, and tell the buyer which instructions are current.
  5. Keep fulfillment guarded at the business-order level so two successful attempts cannot produce two deliveries.

Do not assume creating a new session invalidates an older Invoice or cancels an already-broadcast transfer. If the first attempt is unresolved, stop the retry and investigate. Use the expired-invoice checklist for that exception; it is not a mechanism for changing an agreed price after receiving funds.

Checkout completion is not payment confirmation

Yolfi's Checkout lifecycle documentation distinguishes a Checkout Session from its Invoice. A session marked COMPLETED means it has been linked to an Invoice; the actual payment can still be pending. The same session creates at most one Invoice, but that guarantee does not prevent your application from creating several sessions for one order.

Keep merchantOrderId, checkoutSessionId and invoiceId when available. Use the verified payment.confirmed event as the documented fulfillment trigger, verify its signature against the raw request body, and deduplicate processing. Match the provider record to the expected order and payment attempt before releasing goods or credits.

A return to successUrl is useful for showing progress, not granting access. The browser can be closed, refreshed or opened independently of payment. Your confirmation page should read the order's server-side state and display a pending state when payment has not yet been verified.

Test the price boundary before launch

Use your controlled integration test process; do not interpret this checklist as a claim that a public sandbox exists. The crypto payment integration testing guide covers broader event and delivery checks.

Test Expected merchant-side result
Buyer submits a cheaper total Server ignores the total and recalculates from trusted records
Buyer changes quantity or coupon after checkout opens Existing snapshot stays traceable; revised order follows an explicit new-attempt process
Session creation times out Retry uses the same key and unchanged request
Retry sends a different amount with the old key Conflict is handled, not hidden with an automatic duplicate attempt
Session becomes COMPLETED before payment confirms No delivery or credits are released
Two attempts eventually confirm for one order Order is fulfilled once and the extra receipt enters review

Also test authorization: one customer must not be able to retrieve or alter another customer's order by changing an identifier. Keep provider credentials in server-side secret storage. Do not put personal customer details in public blockchain notes or expose an internal order record merely because its hosted payment URL can be opened.

Frequently asked questions

Can I pass the cart total directly from my frontend?

Not as the authoritative amount. Send validated purchase inputs to your server and calculate the total there. Your server then creates the payment attempt with its own approved price.

No. Yolfi documents standalone API Checkout for dynamic orders without creating a Paylink. Use a reusable Paylink for a saved fixed-price offer, and a Paylink-backed session when that same offer needs attempt-specific context.

No. The current API reference says that amount and currency come from the enabled Paylink. Do not send replacement amount or currency fields in that mode.

Is a session marked COMPLETED enough to deliver?

No. That session status means an Invoice was created, not that it was paid. Verify and process the payment confirmation, then fulfill the order once.

Conclusion: one agreed total, traceable attempts, one delivery

Keep pricing decisions in your application, freeze the agreed order version and link every payment attempt to it. Retry unchanged requests safely, treat cart changes explicitly, and separate session completion from payment confirmation. Choose Yolfi payment links for fixed offers or the documented Checkout Session flow when your server must set a dynamic order total.

Start accepting crypto payments today

Connect a wallet, create your first link and get paid in minutes.

Business owner working at a laptop
Payment received+120.00 USDT