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
After a discussion, the method that I suggested in point 1 above seemed the most suitable:
- 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.
- Send the payment address\QR code to the client for payment.
- The client makes a payment of whatever amount they have decided.
- The invoice is marked as 'over-paid'. That is, the client paid more than the invoice amount.
- In my software, I credit their account with the actual amount they paid.
- 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.
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
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