//we group per store and init the transfers by each async Task <bool> TrypayBolt(ILightningClient lightningClient, PayoutBlob payoutBlob, PayoutData payoutData, BOLT11PaymentRequest bolt11PaymentRequest) { var boltAmount = bolt11PaymentRequest.MinimumAmount.ToDecimal(LightMoneyUnit.BTC); if (boltAmount != payoutBlob.CryptoAmount) { return(false); } var result = await lightningClient.Pay(bolt11PaymentRequest.ToString()); return(result.Result == PayResult.Ok); }
public static async Task <ResultVM> TrypayBolt(ILightningClient lightningClient, PayoutBlob payoutBlob, PayoutData payoutData, BOLT11PaymentRequest bolt11PaymentRequest, PaymentMethodId pmi) { var boltAmount = bolt11PaymentRequest.MinimumAmount.ToDecimal(LightMoneyUnit.BTC); if (boltAmount != payoutBlob.CryptoAmount) { return(new ResultVM { PayoutId = payoutData.Id, Result = PayResult.Error, Message = $"The BOLT11 invoice amount ({boltAmount} {pmi.CryptoCode}) did not match the payout's amount ({payoutBlob.CryptoAmount.GetValueOrDefault()} {pmi.CryptoCode})", Destination = payoutBlob.Destination }); } var result = await lightningClient.Pay(bolt11PaymentRequest.ToString(), new PayInvoiceParams()); if (result.Result == PayResult.Ok) { var message = result.Details?.TotalAmount != null ? $"Paid out {result.Details.TotalAmount.ToDecimal(LightMoneyUnit.BTC)}" : null; payoutData.State = PayoutState.Completed; return(new ResultVM { PayoutId = payoutData.Id, Result = result.Result, Destination = payoutBlob.Destination, Message = message }); } return(new ResultVM { PayoutId = payoutData.Id, Result = result.Result, Destination = payoutBlob.Destination, Message = result.ErrorDetail }); }