MetacoSA / NBitpayClient

A non official library for using bitpay's API
MIT License
19 stars 18 forks source link

Added missing invoice properties #20

Closed kspearrin closed 5 years ago

kspearrin commented 5 years ago

The following is an example of the JSON returned for a GET /invoices/{id} call to the BitPay API.

Toggle GET /invoices/{id} JSON Response ``` { "facade":"merchant/invoice", "data":{ "url":"https://test.bitpay.com/invoice?id=***************", "posData":"some data", "status":"complete", "price":10, "currency":"USD", "itemDesc":"Item Desc", "invoiceTime":1550840708425, "expirationTime":1550841608425, "currentTime":1550931615822, "guid":"********************", "id":"***************", "lowFeeDetected":false, "amountPaid":254200, "exceptionStatus":false, "transactions":[ { "amount":254200, "confirmations":6, "receivedTime":"2019-02-22T13:05:36.481Z", "txid":"***********************", "exRates":{ "BTC":1, "USD":3933.84, "BCH":27.54789915966386 }, "outputIndex":1 } ], "buyer":{ "email":"test@example.com" }, "redirectURL":"https://google.com", "refundAddresses":[ { "********************":{ "type":"buyerSupplied", "date":"2019-02-22T14:02:59.595Z" } } ], "refundAddressRequestPending":false, "buyerProvidedEmail":"test@example.com", "buyerProvidedInfo":{ "selectedTransactionCurrency":"BTC", "emailAddress":"test@example.com" }, "paymentSubtotals":{ "BTC":254200, "BCH":7007700 }, "paymentTotals":{ "BTC":254200, "BCH":7007700 }, "exchangeRates":{ "BTC":{ "USD":3933.84, "BCH":27.54789915966386 }, "BCH":{ "USD":142.7, "BTC":0.03627950729022334 } }, "minerFees":{ "BTC":{ "satoshisPerByte":0, "totalFee":0 }, "BCH":{ "satoshisPerByte":0, "totalFee":0 } }, "transactionCurrency":"BTC", "supportedTransactionCurrencies":{ "BTC":{ "enabled":true }, "BCH":{ "enabled":true } }, "paymentCodes":{ "BTC":{ "BIP72b":"bitcoin:?r=https://test.bitpay.com/i/***************", "BIP73":"https://test.bitpay.com/i/***************" }, "BCH":{ "BIP72b":"bitcoincash:?r=https://test.bitpay.com/i/***************", "BIP73":"https://test.bitpay.com/i/***************" } }, "token":"****************" } } ```

I found several useful things (for my use case, at least) missing from the invoice object. This PR adds them so that they can be used.

  1. Added TxId to invoice transaction object.
  2. Changed transaction ReceivedTime to a proper DateTimeOffset type.
  3. Added RefundAddressRequestPending to invoice object.
  4. Added RefundAddresses array to invoice object, along with its new object class for RefundAddress.
  5. Added RefundInfo array as documented at https://bitpay.com/api#resource-Invoices
  6. Added TransactionCurrency string as documented at https://bitpay.com/api#resource-Invoices
kspearrin commented 5 years ago

Thanks @NicolasDorier . Any chance of getting an update published to nuget with this any time soon?

NicolasDorier commented 5 years ago

already did