Browse Source

Add FailReason to PaymentRequest

pull/69/head
enisn 5 years ago
parent
commit
3ddd9f57c9
  1. 10
      modules/payment/src/Payment.Application/PaymentRequests/PaymentRequestAppService.cs
  2. 26
      modules/payment/src/Payment.Domain/PaymentRequests/PaymentRequest.cs

10
modules/payment/src/Payment.Application/PaymentRequests/PaymentRequestAppService.cs

@ -120,8 +120,14 @@ namespace Payment.PaymentRequests
var paymentRequest = await _paymentRequestRepository.GetAsync(paymentRequestId); var paymentRequest = await _paymentRequestRepository.GetAsync(paymentRequestId);
paymentRequest.State = order.Status == PayPalConsts.OrderStatus.Approved || order.Status == PayPalConsts.OrderStatus.Completed ? if (order.Status == PayPalConsts.OrderStatus.Approved || order.Status == PayPalConsts.OrderStatus.Completed)
PaymentRequestState.Completed : PaymentRequestState.Failed; {
paymentRequest.SetAsCompleted();
}
else
{
paymentRequest.SetAsFailed(order.Status);
}
paymentRequest.ExtraProperties.Add(PayPalConsts.OrderIdPropertyName, order.Id); paymentRequest.ExtraProperties.Add(PayPalConsts.OrderIdPropertyName, order.Id);

26
modules/payment/src/Payment.Domain/PaymentRequests/PaymentRequest.cs

@ -8,22 +8,24 @@ namespace Payment.PaymentRequests
public class PaymentRequest : CreationAuditedAggregateRoot<Guid>, ISoftDelete public class PaymentRequest : CreationAuditedAggregateRoot<Guid>, ISoftDelete
{ {
[CanBeNull] [CanBeNull]
public string CustomerId { get; private set; } public string CustomerId { get; protected set; }
[CanBeNull] [CanBeNull]
public string ProductId { get; private set; } public string ProductId { get; protected set; }
[NotNull] [NotNull]
public string ProductName { get; private set; } public string ProductName { get; protected set; }
public decimal Price { get; private set; } public decimal Price { get; protected set; }
public string Currency { get; private set; } public string Currency { get; protected set; }
public PaymentRequestState State { get; set; } public PaymentRequestState State { get; protected set; }
public bool IsDeleted { get; set; } public bool IsDeleted { get; set; }
public string FailReason { get; protected set; }
private PaymentRequest() private PaymentRequest()
{ {
@ -44,5 +46,17 @@ namespace Payment.PaymentRequests
Price = price; Price = price;
Currency = currency; Currency = currency;
} }
public virtual void SetAsCompleted()
{
State = PaymentRequestState.Completed;
FailReason = null;
}
public virtual void SetAsFailed(string failReason)
{
State = PaymentRequestState.Failed;
FailReason = failReason;
}
} }
} }
Loading…
Cancel
Save