mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-06 15:44:26 +01:00
Validate email in the api
This commit is contained in:
@@ -69,6 +69,7 @@ namespace BTCPayServer.Tests
|
|||||||
user.GrantAccess();
|
user.GrantAccess();
|
||||||
var invoice = user.BitPay.CreateInvoice(new Invoice()
|
var invoice = user.BitPay.CreateInvoice(new Invoice()
|
||||||
{
|
{
|
||||||
|
Buyer = new Buyer() { email = "test@fwf.com" },
|
||||||
Price = 5000.0,
|
Price = 5000.0,
|
||||||
Currency = "USD",
|
Currency = "USD",
|
||||||
PosData = "posData",
|
PosData = "posData",
|
||||||
|
|||||||
@@ -97,8 +97,12 @@ namespace BTCPayServer.Controllers
|
|||||||
entity.BuyerInformation = Map<Invoice, BuyerInformation>(invoice);
|
entity.BuyerInformation = Map<Invoice, BuyerInformation>(invoice);
|
||||||
//Another way of passing buyer info to support
|
//Another way of passing buyer info to support
|
||||||
FillBuyerInfo(invoice.Buyer, entity.BuyerInformation);
|
FillBuyerInfo(invoice.Buyer, entity.BuyerInformation);
|
||||||
|
if(entity?.BuyerInformation?.BuyerEmail != null)
|
||||||
entity.RefundMail = EmailValidator.IsEmail(entity?.BuyerInformation?.BuyerEmail) ? entity.BuyerInformation.BuyerEmail : null;
|
{
|
||||||
|
if(!EmailValidator.IsEmail(entity.BuyerInformation.BuyerEmail))
|
||||||
|
throw new BitpayHttpException(400, "Invalid email");
|
||||||
|
entity.RefundMail = entity.BuyerInformation.BuyerEmail;
|
||||||
|
}
|
||||||
entity.ProductInformation = Map<Invoice, ProductInformation>(invoice);
|
entity.ProductInformation = Map<Invoice, ProductInformation>(invoice);
|
||||||
entity.RedirectURL = invoice.RedirectURL ?? store.StoreWebsite;
|
entity.RedirectURL = invoice.RedirectURL ?? store.StoreWebsite;
|
||||||
entity.Status = "new";
|
entity.Status = "new";
|
||||||
|
|||||||
Reference in New Issue
Block a user