public async Task Payment_CreateDebt() { //Create a payment of 10GBP from 0 -> 1 await _db.InsertUnconfirmedPayment(0, 1, 10, "gbp", "note", "guid"); //Confirm that payment var confirmed = await _db.ConfirmPending("guid", 1); Assert.IsTrue(confirmed.HasValue); Assert.AreEqual(10, (int)confirmed.Value.Amount); Assert.AreEqual(0, (int)confirmed.Value.PayerId); Assert.AreEqual(1, (int)confirmed.Value.ReceiverId); //Now check that the balance between 0 and 1 is correct (1 owes 10GBP to 0) var owed1 = (await _db.GetOwed(1)).ToArray(); Assert.AreEqual(1, owed1.Length); var owedSingle = owed1.Single(); Assert.AreEqual(10, owedSingle.Amount); Assert.AreEqual(1, (int)owedSingle.BorrowerId); Assert.AreEqual(0, (int)owedSingle.LenderId); Assert.AreEqual("gbp", owedSingle.Unit); }
public async Task ConfirmPendingPayment(string id) { using (Context.Channel.EnterTypingState()) { var result = await _database.ConfirmPending(id); if (result.HasValue) { await ReplyAsync($"{Context.User.Mention} Confirmed transaction of {FormatCurrency(result.Value.Amount, result.Value.Unit)} from {Context.Client.GetUser(result.Value.PayerId).Mention} to {Context.Client.GetUser(result.Value.ReceiverId).Mention}"); } else { await ReplyAsync($"{Context.User.Mention} I can't find a pending payment with that ID"); } } }