KeldroveOpen dashboard
Keldrove / Merchant guides

Build the PHP side of a hosted checkout

A PHP crypto checkout starts with the order your server priced and ends with a verified payment decision. Keldrove proposes a language-neutral API for merchant-owned wallets, including Monero. This local example uses ordinary PHP to prepare an invoice request. There is no Keldrove PHP SDK, API key or production endpoint to use today.

By the Published · Updated

Begin with the order in your database

Consider a merchant selling a $48 spare part. When a customer taps a payment method, the PHP controller should receive an order identifier and an allowed payment choice. It can check the signed-in user or authorized checkout session, load the current order and reject attempts to pay an unrelated cart.

It should calculate shipping, tax and discounts from the stored order and confirm the price has not changed since the customer last reviewed it.

Never use a browser field as the final commercial total. A customer can have two tabs open on different order versions even without doing anything unusual. Persist the priced order version in the payment attempt. If a new shipping address changes tax after a quote was issued, the application can explain why a fresh invoice is needed and identify which old attempt must still be monitored for a late transfer.

Encode the quote without floating-point arithmetic

The example takes a positive USD amount already stored as integer cents. Integer division gives the dollar portion and the remainder gives cents. This code only prints proposed request data. It neither contacts a server nor generates any receiving address. The token and network shown together identify a proposed supported pair.

<?php
declare(strict_types=1);

function formatUsdCents(int $cents): string
{
    if ($cents <= 0) {
        throw new InvalidArgumentException('Expected a positive order amount');
    }
    return sprintf('%d.%02d', intdiv($cents, 100), $cents % 100);
}

$request = [
    'store_id' => 'store_example',
    'order_ref' => 'parts-407',
    'price' => ['currency' => 'USD', 'amount' => formatUsdCents(4800)],
    'asset' => 'USDC',
    'network' => 'ethereum',
];
echo json_encode($request, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);

The amount in this message is the agreed price of the part. A later invoice response would contain the crypto quantity the customer should actually send. Retain that quantity as a string for display and an exact decimal or atomic-unit integer for arithmetic. PHP’s underlying integer range depends on the environment. Check your data model before representing arbitrary eighteen-decimal asset quantities as native integers. PHP JSON encoding.

Save the attempt before network I/O

In one database transaction, lock or version-check the order, find any reusable open attempt, and persist a newly allocated attempt plus idempotency key if needed. Commit before making an outbound API call. A database transaction cannot roll back an external service.

Holding an order lock through a network timeout can also block other parts of the store, including inventory and customer support.

Persist the exact request body and the key used for that attempt. If the HTTP response were lost, a later worker could resend the same body with the same key. It could recover an invoice created on the first call without issuing another payable request. A change in basket price, asset or network requires an explicit replacement workflow. The old reference remains relevant because payment might already be traveling to its destination. PHP PDO transaction guidance.

Keep the redirect and payment decision separate

A successful create response would include an invoice ID, a hosted checkout URL and an expiry. Before redirecting, retain the ID and verify that the destination belongs to the expected HTTPS checkout origin for the current environment. Production and staging examples must not share a domain allowlist accidentally.

The store’s return page can show the order reference and its last verified state. It should not mark an order as paid just because the visitor loaded it.

A buyer might approve the transfer in a mobile wallet and never return to the PHP session they started on a laptop. The server should still reconcile and deliver according to the order rules. Associate the invoice with the database order. A PHP session can help present the experience, but a volatile browser or server session alone cannot be the merchant’s only record of a $48 payment.

What happens after a timeout?

A timeout in PHP can happen after the invoice service has already created the invoice. Look up the saved attempt and reuse that request’s key and commercial values. Record a new attempt only when the order genuinely changes or the previous invoice can no longer be used.

PHP checkout recovery decisions for a saved invoice attempt
Observed stateNext action
Request saved, no response capturedRepeat with the persisted request and idempotency key.
Invoice ID already presentRead that invoice and reuse the valid hosted URL.
Request changed since creationResolve the existing attempt before issuing a replacement.
Customer says paid, local session expiredLook up the order and invoice through the durable records.

A typical failure case begins with a double-click followed by a slow server response. Two PHP workers might execute the same controller at once. An application-level check followed by two inserts can still race. Enforce uniqueness in persistent storage and let the losing worker load the committed attempt. Later, a unique fulfillment job covering the order prevents duplicated shipping when two callbacks arrive together.

Give the integration an exit test

Write a local fixture for the $48 request and compare the serialized field types with the contract. Assert that $0.01 becomes the string 0.01, that the wrong store cannot read the order, and that the browser cannot supply a different amount.

With an inert fake transport, simulate a successful creation followed by a connection drop, then retry. Count attempts and verify the same idempotency key in both calls.

Exercise paid, unpaid and review outcomes through your own application service using documented test fixtures. An HTTP success only establishes that an API request succeeded. The store should verify the latest invoice fields and fulfillment state before releasing the part. If your project is a WooCommerce plugin, use the store’s order APIs and test its actual checkout surface separately. These PHP concepts support a custom server without assuming that an unverified SDK or connector already exists.

Questions merchants ask

Can I install a Composer package for Keldrove?

Keldrove has no published PHP SDK. The proposed service uses HTTP and JSON. The example in this guide runs locally and only serializes an illustrative order.

Should PHP compute the amount of Monero to charge?

The proposed merchant request would specify an agreed USD price and supported asset and network. A future invoice response would return the exact payable quantity and expiry.

Can the return controller issue a download?

It can display the current order state. Only the server’s verified payment and fulfillment process should issue access, including when the buyer never returns.

Merchant terms at a glance
Subscription currencies
BTC, LTC, ETH, SOL, USDC on Ethereum, USDT on Ethereum or Tron, and Monero (XMR).
Account
Register with an email and password or a private account code. No identity document is requested.
Price on 2026-11-27
$25 for Starter per 30 days. Keldrove charges only the subscription, with 0% transaction fees on every plan. The subscription funding minimum is $25. Customer invoices have separate network limits.
Activation
Create an order at checkout. Activation follows payment verification.
Compare three published gateway fee models
Provider pricing checked November 27, 2026, excluding network costs
ProviderService fee basis
CryptAPI1% in the entry volume band.
BitPay2% plus 25¢ per transaction under $500,000 monthly volume. Higher-risk industries may pay more.
BTCPay Server0% software processing fee. Operating or renting a server carries separate costs.