2022-06-29 19:46:41 -04:00
|
|
|
|
using Bit.Core.Settings;
|
2019-02-21 22:43:37 -05:00
|
|
|
|
|
2022-08-29 15:53:48 -04:00
|
|
|
|
namespace Bit.Core.Utilities
|
2019-02-21 22:43:37 -05:00
|
|
|
|
{
|
2022-08-29 15:53:48 -04:00
|
|
|
|
public class BitPayClient
|
2022-08-29 14:53:16 -04:00
|
|
|
|
{
|
2022-08-29 15:53:48 -04:00
|
|
|
|
private readonly BitPayLight.BitPay _bpClient;
|
|
|
|
|
|
|
|
|
|
|
|
public BitPayClient(GlobalSettings globalSettings)
|
2019-02-21 22:43:37 -05:00
|
|
|
|
{
|
2022-08-29 15:53:48 -04:00
|
|
|
|
if (CoreHelpers.SettingHasValue(globalSettings.BitPay.Token))
|
|
|
|
|
|
{
|
|
|
|
|
|
_bpClient = new BitPayLight.BitPay(globalSettings.BitPay.Token,
|
|
|
|
|
|
globalSettings.BitPay.Production ? BitPayLight.Env.Prod : BitPayLight.Env.Test);
|
|
|
|
|
|
}
|
2019-02-21 22:43:37 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-08-29 15:53:48 -04:00
|
|
|
|
public Task<BitPayLight.Models.Invoice.Invoice> GetInvoiceAsync(string id)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _bpClient.GetInvoice(id);
|
|
|
|
|
|
}
|
2019-02-21 22:43:37 -05:00
|
|
|
|
|
2022-08-29 15:53:48 -04:00
|
|
|
|
public Task<BitPayLight.Models.Invoice.Invoice> CreateInvoiceAsync(BitPayLight.Models.Invoice.Invoice invoice)
|
|
|
|
|
|
{
|
|
|
|
|
|
return _bpClient.CreateInvoice(invoice);
|
|
|
|
|
|
}
|
2019-02-21 22:43:37 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|