0

Please refer to the title of my question.
This is how I am generating QR code in PHP:

https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl=BTC_ADDRESS

I want user to just scan and pay the amount of BTC set in the QR code Is it possible ? Please help. Thanks in Advance!

Murch
  • 71,155
  • 33
  • 180
  • 600
  • 1
    Does this answer your question? [Bitcoin QR codes: raw address or Bitcoin URI scheme](https://bitcoin.stackexchange.com/questions/21656/bitcoin-qr-codes-raw-address-or-bitcoin-uri-scheme) but see also [bip21](https://en.bitcoin.it/wiki/BIP_0021) – RedGrittyBrick Sep 01 '22 at 18:51
  • Thanks. @RedGrittyBrick Can you please also suggest any API in PHP, that converts Euro to amount of BTC. For example: 100 Euro to amount of BTC – abhishek sharma Sep 01 '22 at 19:38

1 Answers1

1

The best way to encode an amount in an on-chain bitcoin QR code is to generate a QR code from a BIP 21 URI scheme.

For example, if you wanted the payer to send 1 bitcoin to address 175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W, you would encode the following string into a QR code and display it to the payer.

bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.0

Any payer using a BIP 21 compatible wallet will be able to scan a QR code of this format. It's important to be aware that this does NOT force the payer to pay this amount. This amount field is merely a suggestion to help wallets autofill or suggest an amount to pay. In other words, when accepting bitcoin payments you must still check your wallet software to make sure that the correct amount was payed, even if you encode it in a BIP 21 URI scheme.

View full BIP 21 scheme options here: https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki

View a non-comprehensive list of supported wallets/services here: https://bitcoinqr.dev/


If you would like a stricter payment flow, I suggest you look into supporting BOLT-11 invoices (which can be wrapped in a BIP 21 URI) using the lightning network. Lightning invoices require that the payer sends the exact specified amount for the payment to go through. Although accepting bitcoin lightning payments does require more infrastructure and maintenance overhead, it offers a superior receiving experience in this regard.

View BOLT 11 spec here: https://github.com/lightning/bolts/blob/master/11-payment-encoding.md

jpkiser
  • 41
  • 3