public string Return(TpayNotification notification)
        {
            if (!IsNotificationValid(notification) || !IsTpayPaymentProcessorEnabled())
            {
                return(GenerateErrorResponse("Invalid request"));
            }

            var localOrderNumber = Convert.ToInt32(notification.tr_crc);
            var order            = orderService.GetOrderById(localOrderNumber);

            if (IsSuccessfullTransaction(notification) &&
                orderProcessingService.CanMarkOrderAsPaid(order))
            {
                orderProcessingService.MarkOrderAsPaid(order);
            }
            else
            {
                order.CaptureTransactionResult = notification.tr_error;
                orderService.UpdateOrder(order);
            }

            return(TpayTransactionStatus.Success);
        }
 private static bool IsSuccessfullTransaction(TpayNotification notification)
 {
     return(notification.tr_status.Equals(TpayTransactionStatus.Success, StringComparison.OrdinalIgnoreCase) &&
            !notification.tr_error.Equals(TpayTransactionStatus.Absent, StringComparison.OrdinalIgnoreCase));
 }
 private bool IsNotificationValid(TpayNotification notification) => availableIPsTable.Contains(Request.UserHostAddress) && notification.Md5Sum.Equals(GenerateCheckSum(notification), StringComparison.OrdinalIgnoreCase);
 private string GenerateCheckSum(TpayNotification notification)
 {
     return(Md5HashManager.GetMd5Hash($"{tPayPaymentSettings.MerchantId}{notification.tr_id}{notification.tr_amount}{notification.tr_crc}{tPayPaymentSettings.MerchantSecret}"));
 }