src/Walley.Checkout.Api/Services/RefundService.cs
+5
-3
diff --git a/src/Walley.Checkout.Api/Services/RefundService.cs b/src/Walley.Checkout.Api/Services/RefundService.cs
index 3075b62..d3c5de2 100644
@@ -20,7 +20,9 @@ public class RefundService : IRefundService
/// </summary>
public async Task<Refund> ProcessRefundAsync(string orderId, decimal amount, string reason)
{
var order = _orderService.GetOrderByIdAsync(orderId);
// GetOrderByIdAsync returns a Task<Order> and must be awaited.
// It worked before because both the OrderService implementation and the test mocks synchronously returned completed tasks.
var order = await _orderService.GetOrderByIdAsync(orderId);
var refund = new Refund
{
@@ -36,13 +38,13 @@ public class RefundService : IRefundService
return refund;
}
if (order.Result.Status != OrderStatus.Completed)
if (order.Status != OrderStatus.Completed)
{
refund.Status = RefundStatus.Rejected;
return refund;
}
if (amount > order.Result.TotalAmount)
if (amount > order.TotalAmount)
{
refund.Status = RefundStatus.Rejected;
return refund;