btcpayserver/node-btcpay

custom invoice fields not allowed

wallopthecat opened this issue · 6 comments

Limiting the payload here means we can't take advantage of orderId, buyer, etc.
https://github.com/btcpayserver/node-btcpay/blob/master/src/core/client.ts#L65
payload: { currency: string; price: string | number },

full example of create_invoice is more like:

let post_data = {
   "currency": "USD",
   "price": 5,
   "orderId": "MerchantOrder123",
   "fullNotifications": true,
   "extendedNotifications": true,
   "transactionSpeed": "medium",
   "notificationURL": "https://yournotificationurl.com",
   "notificationEmail": "merchant@email.com",
   "redirectURL": "https://yourredirecturl.com",
   "buyer": {
       "email": "fox.mulder@trustno.one",
       "name": "Fox Mulder",
       "phone": "555-123-456",
       "address1": "2630 Hegal Place",
       "address2": "Apt 42",
       "locality": "Alexandria",
       "region": "VA",
       "postalCode": "23242",
       "country": "US",
       "notify": true
   },
   "posData": "tx1234",
   "itemDesc": "Item XYZ",
   "token": "GcAUe7hgY3F2FSh95Dsy5d"
};

#8 might be related

Potential fix could be something like:

payload: {
            currency: string;
            price: string | number;
            orderId?: string | number;
            fullNotifications?: boolean;
            extendedNotifications?: boolean;
            transactionSpeed?: string;
            notificationURL?: string;
            notificationEmail?: string;
            redirectUrl?: string;
            buyer?: object;
            posData?: string;
            itemDesc?: string;
        },

@junderw your thoughts?

@wallopthecat sounds reasonable, would you be interested in submitting a PR for this?

This isn't really a "reason" argument.

Either this suggestion reflects the accepted args of the API or it doesn't.

The former would be a bugfix.

Someone should go through the C# code to see exactly what the API accepts and fix it here.

Since lack of documentation, I just copied over Bitpay's API types.

I copied the Bitpay types too since I couldn't find API docs - not sure if this reflects the actual btcpayserver API, but recall reading that the invoice part is the same api for backwards compatibility. Have not gone through the C# yet (ticket was submitted before realizing btcpayserver does not have feature parity with Bitpay)

It looks like this is the type definition for the argument to POST /invoices

https://github.com/btcpayserver/btcpayserver/blob/6407e15187d1e3216c55ab63eb6237064c21c85b/BTCPayServer/Models/CreateInvoiceRequest.cs

I will change this to allow all these parameters.

@NicolasDorier please check to make sure I read everything correctly.

Excellent, thanks for the example, now I can easily find other models.

Sidenote:
The fact that you had to look into the model AND a reference client sucks. I'm not super familiar with C# ecosystem, but I assume there are API doc generators we can wire up? Or perhaps the API is small enough to do this by hand and require maintainers to update docs as features change? (edit: solved by btcpayserver/btcpayserver#1049)