2019-02-21 22:43:37 -05:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2021-02-22 15:35:16 -06:00
|
|
|
|
using Bit.Core.Settings;
|
2019-02-21 22:43:37 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Bit.Core.Utilities
|
|
|
|
|
|
{
|
|
|
|
|
|
public class BitPayClient
|
|
|
|
|
|
{
|
2019-12-19 10:27:06 -05:00
|
|
|
|
private readonly BitPayLight.BitPay _bpClient;
|
2019-02-21 22:43:37 -05:00
|
|
|
|
|
|
|
|
|
|
public BitPayClient(GlobalSettings globalSettings)
|
|
|
|
|
|
{
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (CoreHelpers.SettingHasValue(globalSettings.BitPay.Token))
|
2019-03-19 23:32:54 -04:00
|
|
|
|
{
|
2019-12-19 10:27:06 -05:00
|
|
|
|
_bpClient = new BitPayLight.BitPay(globalSettings.BitPay.Token,
|
|
|
|
|
|
globalSettings.BitPay.Production ? BitPayLight.Env.Prod : BitPayLight.Env.Test);
|
2019-03-19 23:32:54 -04:00
|
|
|
|
}
|
2019-02-21 22:43:37 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-12-19 10:27:06 -05:00
|
|
|
|
public Task<BitPayLight.Models.Invoice.Invoice> GetInvoiceAsync(string id)
|
2019-02-21 22:43:37 -05:00
|
|
|
|
{
|
2019-12-19 10:27:06 -05:00
|
|
|
|
return _bpClient.GetInvoice(id);
|
2019-02-21 22:43:37 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-12-19 10:27:06 -05:00
|
|
|
|
public Task<BitPayLight.Models.Invoice.Invoice> CreateInvoiceAsync(BitPayLight.Models.Invoice.Invoice invoice)
|
2019-02-21 22:43:37 -05:00
|
|
|
|
{
|
2019-12-19 10:27:06 -05:00
|
|
|
|
return _bpClient.CreateInvoice(invoice);
|
2019-02-21 22:43:37 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|