mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
Validate email in the api
This commit is contained in:
parent
d1961e0938
commit
9ddceae824
2 changed files with 7 additions and 2 deletions
|
@ -69,6 +69,7 @@ namespace BTCPayServer.Tests
|
|||
user.GrantAccess();
|
||||
var invoice = user.BitPay.CreateInvoice(new Invoice()
|
||||
{
|
||||
Buyer = new Buyer() { email = "test@fwf.com" },
|
||||
Price = 5000.0,
|
||||
Currency = "USD",
|
||||
PosData = "posData",
|
||||
|
|
|
@ -97,8 +97,12 @@ namespace BTCPayServer.Controllers
|
|||
entity.BuyerInformation = Map<Invoice, BuyerInformation>(invoice);
|
||||
//Another way of passing buyer info to support
|
||||
FillBuyerInfo(invoice.Buyer, entity.BuyerInformation);
|
||||
|
||||
entity.RefundMail = EmailValidator.IsEmail(entity?.BuyerInformation?.BuyerEmail) ? entity.BuyerInformation.BuyerEmail : null;
|
||||
if(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.RedirectURL = invoice.RedirectURL ?? store.StoreWebsite;
|
||||
entity.Status = "new";
|
||||
|
|
Loading…
Add table
Reference in a new issue