Buy medicine for an injured card
const url = 'https://foxleague.ai/api/shop/medicine';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"days":1,"player_nonce":1,"tx_hash":"example","wallet_address":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://foxleague.ai/api/shop/medicine \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "days": 1, "player_nonce": 1, "tx_hash": "example", "wallet_address": "example" }'Applies medicine after you paid for it with shopPay on the game contract, in FOXSY. The server prices it again for days (the number you asked the quote for) when you confirm and the payment must equal that cost exactly, so confirm soon after the quote. The injury then ends days days earlier, never before its served third.
Who: a signed-in player, for a card in their wallet; wallet_address must be the session wallet and the payment must come from it.
Rate limit: at most 10 confirms per session wallet in any 60 seconds by default, counted together with the other paid confirms (POST /api/shop/confirm, POST /api/shop/waive-cooldown, POST /api/shop/ranked-ticket); one more is answered HTTP 429 before the payment is read.
Refusals:
Too many purchase confirmations: at most <n> per wallet every <s> seconds. Your payment is kept: confirm the same transaction again in <wait> <unit>.(tx_pending, HTTP 429 with aRetry-Afterheader): this session wallet sent more confirms than its budget allows (10 within 60 seconds by default). The payment was not read: confirm the same hash again after the wait.Wallet mismatch: sign with the correct wallet:wallet_addressis not the session wallet.Chain is temporarily unavailable. Please retry shortly.(tx_pending): the server cannot read the chain right now.Transaction already processed: this transaction already delivered a purchase.This payment was already refunded and cannot be used for a purchase.: this transaction was refunded.This payment is being refunded: the money has not been returned yet. It cannot be used for a purchase; if it does not arrive, contact support.: the refund of this transaction was claimed and has not landed yet.This transaction was already used for a badge regeneration.: this transaction paid a badge regeneration.Our support team is handling this payment and will return it to you, so it cannot be used here.: our support team holds this payment.Medicine cannot be checked right now. Please retry in a moment.(tx_pending): a read failed while the medicine was priced again.Medicine is not on sale right now.<refund note>: the injuries have not started (or their switch is off).That player is not in your wallet.<refund note>: the card is not in your wallet.This player is not injured.<refund note>: the card has no injury running.A third of every injury is always served: this player's injury cannot be shortened further.<refund note>: less than a whole day is left above the served third.Medicine has no price for this player's rarity.<refund note>: the card’s rarity is none of the five.Choose from 1 to <n> days for this player.<refund note>:daysis outside 1 tomax_days.The chain cannot be read right now. Your payment is kept: confirm again in a moment.(tx_pending): the chain cannot be read right now.Could not verify transaction yet. Please confirm again in a moment.(tx_pending): the transaction could not be read in time.Transaction <status> on chain: cannot confirm medicine: the transaction failed on chain.Your payment isn't confirmed on chain yet, but it may still settle. Please retry the medicine in a moment.(tx_pending): the transaction is not final yet.Transaction was rejected on chain (<reason>) and refunded: medicine not confirmed: the call reverted on chain.Transaction sender does not match your wallet: another wallet sent it.Transaction was not sent to the medicine contract: it went to another contract.Transaction is not a medicine call: it is not ashopPaycall.Transaction did not pay in FOXSY: medicine not confirmed: it paid another token.Payment (<paid> FOXSY) is less than required (<cost> FOXSY)<refund note>: you paid less than the cost.Transaction paid <paid> but <n> days of medicine cost <cost> FOXSY.<refund note>: you paid more than the cost;<paid>reads like150 FOXSY.Your payment is still being checked. Confirm again in a moment: you will not pay twice.(tx_pending): the transaction cannot be proved yet.Could not verify the payment state right now. Please retry in a moment.(tx_pending): the payment’s state could not be read.Failed to record purchase. Your payment is kept: confirm again in a moment.(tx_pending): the purchase could not be written.This transaction was already processed for medicine.: another confirm of the same transaction was applied first.This player's injury changed while your payment was confirmed. Your payment is kept: confirm again and it is checked against the new injury.(tx_pending): a new injury or another medicine moved the end since the quote.This player is no longer in your wallet, so the medicine was not applied.<refund note>: the card left your wallet before the medicine was applied.Payment verified but applying the medicine failed. Your payment is kept: confirm again in a moment.(tx_pending): the injury could not be written.
Refusals ending in <refund note> add one of these sentences (nothing when no payment can be refunded): Your payment is being refunded automatically. / Your refund has been queued and will be issued by our team. / This payment was already applied to a completed purchase, so no refund is needed. / This payment was already used for a badge regeneration, so no refund is needed. / Our support team is handling this payment and will return it to you. / The automatic refund could not be issued. Our team has been notified and will return your payment.
Refusals marked (tx_pending) carry code: "tx_pending": the payment was not refused, it could not be checked or recorded yet. Keep the transaction hash and confirm again with the same hash; never pay twice.
Authorizations
Section titled “Authorizations ”Request Body required
Section titled “Request Body required ”Paid medicine to confirm.
object
The days the payment bought: the same days you asked the quote for.
The NFT nonce of the injured card.
The hash of your shopPay transaction, 64 hexadecimal characters.
Your wallet; it must be the session wallet.
Example generated
{ "days": 1, "player_nonce": 1, "tx_hash": "example", "wallet_address": "example"}Responses
Section titled “ Responses ”Success or a refusal: read success (the refusals are in the description).
object
A machine-readable reason next to error, set only where the caller must act differently. tx_pending: the payment was not refused but could not be verified yet; keep the transaction hash and confirm again with the same hash, never pay twice.
The answer. Present when success is true.
object
FOXSY paid.
Days of the injury the payment saved.
The new end of the injury (RFC 3339, UTC).
The card’s NFT nonce.
Why the request was refused, in plain words. Present when success is false.
true when the request did what it asked. false is a refusal: read error.
Example
{ "data": { "cost_foxsy": 2500, "days_paid": 5, "injured_until": "2026-12-05T14:00:00Z", "player_nonce": 3990 }, "success": true}No valid session. The body is plain text: Missing Authorization header, Invalid Authorization format, Invalid session token or Session expired or invalid. Sign in again.
Example
Session expired or invalidThe body does not match the request schema, for example a tx_hash that is not 64 hexadecimal characters. The body is plain text.
Too many confirms from this session wallet (10 within 60 seconds by default). The answer carries Retry-After and the usual JSON refusal with code: "tx_pending": the payment was not read, so confirm the same hash again after the wait.
object
A machine-readable reason next to error, set only where the caller must act differently. tx_pending: the payment was not refused but could not be verified yet; keep the transaction hash and confirm again with the same hash, never pay twice.
The answer. Present when success is true.
object
FOXSY paid.
Days of the injury the payment saved.
The new end of the injury (RFC 3339, UTC).
The card’s NFT nonce.
Why the request was refused, in plain words. Present when success is false.
true when the request did what it asked. false is a refusal: read error.
Example generated
{ "code": "example", "data": { "cost_foxsy": 1, "days_paid": 1, "injured_until": "2026-04-15T12:00:00Z", "player_nonce": 1 }, "error": "example", "success": true}