Skip to content
HisarPay
  • Industries
  • Published:
  • Reading time: 5 min read
  • Türkçe oku

Selling game server credit for crypto: matching, webhooks, refunds

A player buys credit, the payment arrives, the credit appears. On paper that is three steps. In practice there is credit on the wrong account, a package granted twice and a queue of “I paid, where is it” messages. Here is a sturdy flow for Minecraft, FiveM and similar servers.

On this page
  1. Match the payment to the player
  2. Give credit on the paid event only
  3. A short webhook handler
  4. Open-amount links
  5. Small amounts and the $10 minimum
  6. Write the refund rules first
  7. Against abuse
  8. Frequently asked questions

Match the payment to the player

A transfer from a wallet carries no player name, so you match on the invoice instead. Put the player’s id into metadata when you create it and the webhook hands it back. Each invoice has its own payment address, so two players sending the same amount at the same second cannot be confused.

An invoice for a credit pack (Node.js)TypeScript
const invoice = await hisarpay.invoices.create({
  price_usd: pack.priceUsd, // from your own price list, never from the browser
  order_id: 'credit-' + purchase.id,
  description: pack.name,
  metadata: { player_id: player.id },
  success_url: 'https://yourserver.example/store/thanks',
});
  • Store the id, not the display name. Names change, ids do not. metadata holds up to 4 KB.
  • Save the purchase on your side first and take order_id from it. A player who clicks twice gets the same invoice back.
  • Verify the player. A code shown in the game or a login beats a text box; credit sent to a misspelt name is hard to bring back.

Give credit on the paid event only

The payment page reacts as soon as a transfer is seen, but the invoice counts as paid after 20 block confirmations, about a minute later. There is no reason to hand out credit before that. The player waits a minute, and you never have to claw back a mistake.

EventWhat to do
invoice.paidGive the credit
invoice.overpaidGive it if you have not yet; settle the extra by hand
invoice.partialWait; the rest can go to the same address
invoice.expiredClose the purchase but keep it, a late payment may come

A late payment can reopen an expired invoice, so invoice.paid after invoice.expired is normal. A visit to your success_url, on the other hand, proves nothing. Anyone can open that address.

A short webhook handler

This sketch checks the signature, ignores test events and grants credit once per invoice. grants.addOnce is yours to write: an insert into a table where the invoice id is unique. Work out the credit from price_amount, the dollar price of the invoice.

Express sketchTypeScript
app.post('/webhooks/hisarpay', express.raw({ type: 'application/json' }), async (req, res) => {
  let event;
  try {
    event = HisarPay.webhooks.constructEvent(req.body, req.headers['x-hisarpay-signature'], secret);
  } catch (err) {
    if (err instanceof SignatureVerificationError) return res.status(400).send(err.message);
    throw err;
  }
  if (!event.livemode) return res.sendStatus(200); // test invoices give no credit

  if (event.livemode && (event.type === 'invoice.paid' || event.type === 'invoice.overpaid')) {
    const { id, metadata, price_amount } = event.data.invoice;
    await grants.addOnce(id, metadata.player_id, price_amount); // invoice id is unique
  }
  res.sendStatus(200);
});

The same event can arrive more than once, and one invoice can send invoice.paid and later invoice.overpaid. The unique invoice id makes both harmless. If the game server is down, queue the credit, answer 200 and apply it at the next login. PHP and Python versions are in our first invoice guide.

Open-amount links

To let players choose how much to buy, the simplest route is an amount box on your own store page and an invoice through the API. Without a page, use an open-amount payment link. Mind the trap: a payment through a link says nothing about the player by itself. That is fine for donations and means matching by hand for credit. Have the link ask for the player’s name, and make it required:

A link that asks for the player’s nameTypeScript
const link = await hisarpay.paymentLinks.create({
  title: 'Server credit',
  kind: 'open',
  min_usd: '10.00',
  max_usd: '200.00',
  suggested_amounts: ['10.00', '25.00', '50.00'],
  ask: { note: 'required', note_label: 'Player name' },
});

// webhook: the name the payer entered
const player = await players.byName(event.data.invoice.payer.note);

What the payer entered is in payer.note of the invoice. Look the name up on your server in case of a typo; queue a payment that matches nobody and ask. A campaign link can have an end and a number of uses as well. The kinds of link are compared in our article on payment links.

Small amounts and the $10 minimum

The smallest invoice is $10, so a $3 item cannot be sold on its own. Sell at least $10 of credit and let the item cost credit. That also makes the 1 USDT network fee a smaller share. With the commission on you, USDT looks like this:

PackPlayer sendsReaches your balance
$1011 USDT9.96 USDT
$1516 USDT14.94 USDT
$2526 USDT24.90 USDT
$5051 USDT49.80 USDT

TRX payments carry no network fee. Players who send from an exchange can end up slightly short because its fee came off the amount. A small underpayment tolerance in the dashboard keeps those out of your inbox.

Write the refund rules first

A final payment cannot be reversed, so spent credit is not clawed back by a dispute. Refunds are therefore your decision alone. Take the credit back in the game, then send a withdrawal to an address the player gives you in writing. Do not return it to the address it came from, which may belong to an exchange. The smallest withdrawal is worth $10 and costs 1 USDT or 1 TRX, so for small sums returning credit makes more sense than returning coins. More in our article on refunds.

Against abuse

  • Let the server set the price. A store that trusts an amount from the browser will be fooled.
  • No test key in production. Anyone who opens a test invoice can mark it paid.
  • No credit for screenshots. Proof is an invoice shown as paid in your dashboard.
  • Cap open purchases per player.
  • Share links from official channels. For copied stores, see fake payment pages.
  • Know about held payments. Now and then one is flagged in screening and reviewed; you see it in the dashboard and in an alert. How screening works.
Three small trialsBefore going live, resend one event twice, pay an invoice in two parts, and pay one that has expired. In all three cases the credit must appear exactly once.

Frequently asked questions

Does a player get credit for a short payment?
No. The invoice waits as partly paid and the rest can go to the same address. Gaps within the tolerance you set count as paid.
Are hundreds of small payments a day a problem?
No. Each goes to its own address and your balance adds up in one place. You pay a withdrawal fee only when you withdraw.
Can I sell credit without a website?
Yes. A payment link or the Telegram bot is enough, but giving credit automatically needs a small piece of server code that receives the webhook.
What about players who are minors?
Who may buy depends on your own terms. Ask for a parent’s consent in the purchase step and state the refund rules plainly.
  • #Game servers
  • #Webhooks
  • #Payment links
  • #Credit

Try crypto payments in test mode

No setup or monthly fees. Experiment as much as you like in test mode and go live when you are ready.

More guides that go well with this one.