Esempio n. 1
0
        public async Task <IActionResult> ReturnOrder(OrderViewModel viewModel, RefundStatus refundStatus, RefundReason refundReason)
        {
            return(await ModifyOrderView("ReturnDone", viewModel, async order =>
            {
                #region Fraud Protection Service
                var refund = new Refund
                {
                    RefundId = Guid.NewGuid().ToString(),
                    Amount = order.Total,
                    Currency = order.RiskPurchase?.Currency,
                    BankEventTimestamp = DateTimeOffset.Now,
                    PurchaseId = order.RiskPurchase.PurchaseId,
                    Reason = refundReason.ToString(),
                    Status = refundStatus.ToString(),
                    UserId = order.RiskPurchase.User.UserId,
                };

                var correlationId = _fraudProtectionService.NewCorrelationId;
                var response = await _fraudProtectionService.PostRefund(refund, correlationId);

                var fraudProtectionIO = new FraudProtectionIOModel(correlationId, refund, response, "Refund");
                TempData.Put(FraudProtectionIOModel.TempDataKey, fraudProtectionIO);
                #endregion

                order.ReturnOrChargebackReason = refundReason.ToString();
                order.Status = refundStatus == RefundStatus.Approved ? OrderStatus.ReturnCompleted : OrderStatus.ReturnRejected;
                order.RiskRefund = refund;
                order.RiskRefundResponse = response;
            }));
        }
Esempio n. 2
0
 /// <summary>
 /// Process a product Return / Refund.
 /// </summary>
 /// <remarks>
 /// <para>This method does not wrap a single, dedicated "ReturnEvent" call in the point-js API.</para>
 /// <para>Instead:</para>
 /// <para>
 /// If no arguments are provided, we simply call <see cref="ShowGUI"/> with the shortcut "refund".
 /// Otherwise, if a Touch Transaction ID and Reason is supplied, we call the GUI-less
 /// <see cref="AddItem"/>
 /// with the shortcut = "refund" and a Dictionary containing the Touch Transaction ID and Reason.
 /// </para>
 /// </remarks>
 /// <param name="transactionId"></param>
 /// <param name="reason"></param>
 public void Refund(string transactionId = "", RefundReason reason = RefundReason.OTHER)
 {
     if (string.IsNullOrEmpty(transactionId))
     {
         ShowGui("refund");
     }
     else
     {
         var data = new Dictionary <string, string>();
         data.Add("transactionId", transactionId);
         data.Add("reason", reason.ToString());
         AddItem("refund", data);
     }
 }