Insert credit payments

This commit is contained in:
2023-08-31 14:20:01 +01:00
parent 201344b622
commit 31144cffa3
8 changed files with 389 additions and 6 deletions

View File

@ -1,3 +1,5 @@
using System.Security.Cryptography;
using System.Text;
using Microsoft.EntityFrameworkCore;
using Nostr.Client.Utils;
using NostrStreamer.ApiModel;
@ -31,6 +33,15 @@ public class UserService
};
_db.Users.Add(user);
_db.Payments.Add(new Payment()
{
PubKey = pubkey,
Type = PaymentType.Credit,
IsPaid = true,
Amount = (ulong)user.Balance,
PaymentHash = SHA256.HashData(Encoding.UTF8.GetBytes($"{pubkey}-init-credit")).ToHex()
});
await _db.SaveChangesAsync();
return user;
}