2022-06-29 19:46:41 -04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2019-02-15 16:18:34 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Bit.Admin.Models;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2019-02-15 16:18:34 -05:00
|
|
|
|
public class ChargeBraintreeModel : IValidatableObject
|
|
|
|
|
|
{
|
|
|
|
|
|
[Required]
|
2020-03-27 14:36:37 -04:00
|
|
|
|
[Display(Name = "Braintree Customer Id")]
|
|
|
|
|
|
public string Id { get; set; }
|
2019-02-15 16:18:34 -05:00
|
|
|
|
[Required]
|
|
|
|
|
|
[Display(Name = "Amount")]
|
|
|
|
|
|
public decimal? Amount { get; set; }
|
|
|
|
|
|
public string TransactionId { get; set; }
|
|
|
|
|
|
public string PayPalTransactionId { get; set; }
|
2022-08-29 15:53:48 -04:00
|
|
|
|
|
2020-03-27 14:36:37 -04:00
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
2022-08-29 16:06:55 -04:00
|
|
|
|
{
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (Id != null)
|
2019-02-15 16:18:34 -05:00
|
|
|
|
{
|
2020-03-27 14:36:37 -04:00
|
|
|
|
if (Id.Length != 36 || (Id[0] != 'o' && Id[0] != 'u') ||
|
2019-02-15 16:18:34 -05:00
|
|
|
|
!Guid.TryParse(Id.Substring(1, 32), out var guid))
|
|
|
|
|
|
{
|
|
|
|
|
|
yield return new ValidationResult("Customer Id is not a valid format.");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|