mirror of
https://github.com/bitwarden/server
synced 2026-01-03 09:03:44 +00:00
charge braintree customer tool
This commit is contained in:
30
src/Admin/Models/ChargeBraintreeModel.cs
Normal file
30
src/Admin/Models/ChargeBraintreeModel.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Bit.Admin.Models
|
||||
{
|
||||
public class ChargeBraintreeModel : IValidatableObject
|
||||
{
|
||||
[Required]
|
||||
[Display(Name = "Braintree Customer Id")]
|
||||
public string Id { get; set; }
|
||||
[Required]
|
||||
[Display(Name = "Amount")]
|
||||
public decimal? Amount { get; set; }
|
||||
public string TransactionId { get; set; }
|
||||
public string PayPalTransactionId { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if(Id != null)
|
||||
{
|
||||
if(Id.Length != 36 || (Id[0] != 'o' && Id[0] != 'u') ||
|
||||
!Guid.TryParse(Id.Substring(1, 32), out var guid))
|
||||
{
|
||||
yield return new ValidationResult("Customer Id is not a valid format.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user