private async Task ProcessSingleOrder(HSOrder order) { try { var rmaList = await _rmaCommand.ListRMAsByOrderID(order.ID, CommerceRole.Seller, new MeUser { }); if (rmaList.Items.Any(x => x.Status == RMAStatus.Complete)) { LogSkip($"{order.ID} has been refunded - RMA process handles authorizing new partial amount if necessary"); await _oc.Orders.PatchAsync(OrderDirection.Incoming, order.ID, new PartialOrder { xp = new { IsPaymentCaptured = true } }); return; } var payment = await GetValidPaymentAsync(order); var transaction = GetValidTransaction(order.ID, payment); if (await HasBeenCapturedPreviouslyAsync(order, transaction)) { LogSkip($"{order.ID} has already been captured"); await _oc.Orders.PatchAsync(OrderDirection.Incoming, order.ID, new PartialOrder { xp = new { IsPaymentCaptured = true } }); } else { await CapturePaymentAsync(order, payment, transaction); await _oc.Orders.PatchAsync(OrderDirection.Incoming, order.ID, new PartialOrder { xp = new { IsPaymentCaptured = true } }); LogSuccess(order.ID); } } catch (OrderCloudException ex) { LogFailure($"{ ex.InnerException.Message} { JsonConvert.SerializeObject(ex.Errors)}. OrderID: {order.ID}"); } catch (PaymentCaptureJobException ex) { LogFailure(ex.Message); } catch (Exception ex) { LogFailure($"{ex.Message}. OrderID: {order.ID}"); } }
public async Task <CosmosListPage <RMA> > ListRMAsByOrderID(string orderID, CommerceRole commerceRole, MeUser me, bool accessAllRMAsOnOrder = false) { return(await _rmaCommand.ListRMAsByOrderID(orderID, commerceRole, me, accessAllRMAsOnOrder)); }