2

Following advice from users on this site, I have implemented a BTCPay Server and got it set up to receive payments. I am comfortable using the API.

My need is to set up receive addresses for many clients (1000+) but the clients pay indeterminate amounts. That is, I cannot generate fixed-amount invoices for the clients because they pay whichever amount they wish to.

I need to generate a receive address for each client, and then credit their account balance (in USD) on my site with however much they sent to the address in BTC once it has been received and settled.

Does anyone know how I can achieve this in BTCPay Server? I have listed my ideas below but am looking for the 'correct' solution as opposed to what feels like a hack.

Current Ideas

  1. Generate an invoice for a tiny amount, and then handle the over-payment that the client makes when they send the BTC. The over-payment must not be refunded.

  2. Ask the client how much they are expecting to pay on the website and generate an invoice for about this amount. I would love to avoid this method as the use case is for them to send however much they want to.

2
  • While the workaround you describe seems reasonnable,but just out of curiosity I don't quite understand what's the problem with asking how much your client wants to pay and generate an invoice for that much? If I remember correctly it is something that can be done easily with BTCPay. – Sosthène Jun 24 '20 at 17:21
  • 1
    @Sosthène The use case is for clients to be presented with a payment address and to send an amount of their choosing. The UI doesn't have a facility for them to specify how much they're paying. The software will then 'top up' their balance with the amount they paid to the address – Martin Jun 25 '20 at 8:51
3

I separately sought help on this issue from the BTCPay Server support channel, and with their help have devised a 'work-around' for this problem.

The initial response from their support is paraphrased below:

BTCPay Server does not currently support API access to the wallet, and it is not [currently] possible to generate ad-hoc receive addresses programmatically.

After a discussion, the method that I suggested in point 1 above seemed the most suitable:

  1. Generate a very low value invoice in BTCPay Server (for example, for 0.000001BTC). In my case I set the invoice expiry to be 24 hours as my clients will not necessarily pay immediately.
  2. Send the payment address\QR code to the client for payment.
  3. The client makes a payment of whatever amount they have decided.
  4. The invoice is marked as 'over-paid'. That is, the client paid more than the invoice amount.
  5. In my software, I credit their account with the actual amount they paid.
  6. Generate the next invoice for the client (which will need to be done each 24 hours as the invoices expire).

Unlike BitPay, BTCPay Server does not automatically refund overpayments. This is critical to the solution working - as I am expecting clients to pay an indeterminate amount but it will definitely be more than the very low invoice amount.

References

The following references are from my conversation with BTCPay Server support on their Mattermost support channel.

Ref 1 (Receive addresses and wallet API):

So we don't have a wallet API yet. BTCPay is compatible for the most part with BitPay's API. However, that API is not allowing the full potential of the software, so we're working on crafting a way better API. It's still in infancy you can preview docs here and in case you have some feedback you can join the discussion on GitHub. We don't have ETA when the new API will be fully ready, probably by the end of the year.

Ref 2 (My proposed solution)

Thank you for the response. Can I ask if this that I am about to describe is a viable work-around for now?

Create an invoice for each client for a low amount (such as 0.00001BTC) and then an address is available for a client to send payment to. They send their payment (which will be higher than the invoice amount) and then the invoice is flagged as over-paid.

This presumes that the over-paid amount will not be automatically refunded to the client.

Once received I can then generate a brand new invoice for that client so that they receive a new address.

Ref 2a (Their response)

sure that would work

Ref 3 (Invoice over-payments)

refunds are done by the merchant, not automatically

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.