escrow.ReleasedAt = _clock.Now();
await _dbContext.SaveChangesAsync();
var payoutToHostDetails = await _paymentGateway.PayoutToHost(escrow.CancelledAmount is not null ? (decimal)escrow.CancelledAmount : escrow.FullAmount,
escrow.Id,
escrow.Currency,
host.StripeConnectAccountId!);
if (!payoutToHostDetails.IsSuccess)
{
// Roll back the pending record if the transaction fails
escrow.ReleasedAt = null;
await _dbContext.SaveChangesAsync();
return new BadRequestObjectResult(payoutToHostDetails.Error.Message);
}
escrow.ReleasedAt = _clock.Now();
await _dbContext.SaveChangesAsync();
var payoutToHostDetails = await _paymentGateway.PayoutToHost(escrow.CancelledAmount is not null ? (decimal)escrow.CancelledAmount : escrow.FullAmount,
escrow.Id,
escrow.Currency,
host.StripeConnectAccountId!);
if (!payoutToHostDetails.IsSuccess)
{
// Roll back the pending record if the transaction fails
escrow.ReleasedAt = null;
await _dbContext.SaveChangesAsync();
return new BadRequestObjectResult(payoutToHostDetails.Error.Message);
}