public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            RefundPaymentResult refund = new RefundPaymentResult();

            refund.AddError("Refund method not supported.");
            return(refund);
        }
Beispiel #2
0
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public override RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            result.AddError(_localizationService.GetResource("Common.Payment.NoRefundSupport"));
            return(result);
        }
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            string transactionId = refundPaymentRequest.Order.CaptureTransactionId;

            var req = new RefundTransactionReq();

            req.RefundTransactionRequest = new RefundTransactionRequestType();
            //NOTE: Specify amount in partial refund
            req.RefundTransactionRequest.RefundType    = RefundType.FULL;
            req.RefundTransactionRequest.Version       = GetApiVersion();
            req.RefundTransactionRequest.TransactionID = transactionId;

            var service = GetService();
            RefundTransactionResponseType response = service.RefundTransaction(req);

            string error;
            bool   success = PaypalHelper.CheckSuccess(response, out error);

            if (success)
            {
                result.NewPaymentStatus = PaymentStatus.Refunded;
                //cancelPaymentResult.RefundTransactionID = response.RefundTransactionID;
            }
            else
            {
                result.AddError(error);
            }

            return(result);
        }
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            var config = new HpsServicesConfig();

            config.SecretApiKey  = _secureSubmitPaymentSettings.SecretApiKey;
            config.DeveloperId   = "002914";
            config.VersionNumber = "1513";

            var creditService = new HpsCreditService(config);

            try
            {
                creditService.Refund(
                    refundPaymentRequest.AmountToRefund,
                    _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode,
                    Int32.Parse(refundPaymentRequest.Order.CaptureTransactionId));

                var isOrderFullyRefunded = (refundPaymentRequest.AmountToRefund + refundPaymentRequest.Order.RefundedAmount == refundPaymentRequest.Order.OrderTotal);
                result.NewPaymentStatus = isOrderFullyRefunded ? PaymentStatus.Refunded : PaymentStatus.PartiallyRefunded;
            }
            catch (HpsException ex)
            {
                result.AddError(ex.Message);
            }

            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            result.AddError("Refund method not supported");
            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// Handles refund
        /// </summary>
        /// <param name="request">RefundPaymentRequest</param>
        /// <returns>RefundPaymentResult</returns>
        public override RefundPaymentResult Refund(RefundPaymentRequest request)
        {
            var    result        = new RefundPaymentResult();
            string transactionId = request.Order.CaptureTransactionId;

            var req = new RefundTransactionReq();

            req.RefundTransactionRequest = new RefundTransactionRequestType();
            //NOTE: Specify amount in partial refund
            req.RefundTransactionRequest.RefundType          = RefundType.Full;
            req.RefundTransactionRequest.RefundTypeSpecified = true;
            req.RefundTransactionRequest.Version             = PayPalHelper.GetApiVersion();
            req.RefundTransactionRequest.TransactionID       = transactionId;

            using (var service = new PayPalAPISoapBinding())
            {
                service.Url = PayPalHelper.GetPaypalServiceUrl(Settings);
                service.RequesterCredentials = PayPalHelper.GetPaypalApiCredentials(Settings);
                RefundTransactionResponseType response = service.RefundTransaction(req);

                string error   = string.Empty;
                bool   Success = PayPalHelper.CheckSuccess(_helper, response, out error);
                if (Success)
                {
                    result.NewPaymentStatus = PaymentStatus.Refunded;
                    //cancelPaymentResult.RefundTransactionID = response.RefundTransactionID;
                }
                else
                {
                    result.AddError(error);
                }
            }

            return(result);
        }
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            //result.AddError("Refund method not supported");
            try
            {
                NumberFormatInfo nfi = CultureInfo.CurrentCulture.NumberFormat;
                nfi = (NumberFormatInfo)nfi.Clone();
                nfi.CurrencySymbol = "";
                var    order           = refundPaymentRequest.Order;
                string transactioncode = order.AuthorizationTransactionCode;
                string amount          = string.Format(nfi, "{0:c}", refundPaymentRequest.AmountToRefund);
                Regex  digitsOnly      = new Regex(@"[^\d]");
                amount = digitsOnly.Replace(amount, "");
                string apiobject = "refunds";
                string buildurl  = _PayMillPaymentSettings.apiUrl + apiobject + "/" + transactioncode + "?amount=" + amount;
                string response  = GetPMAPIResponse(buildurl, _PayMillPaymentSettings.privateKey);
                if (response != null)
                {
                }
            }
            catch (Exception ex)
            {
                _logger.InsertLog(Core.Domain.Logging.LogLevel.Error, ex.Message, ex.ToString());
                result.AddError(ex.ToString());
            }
            return(result);
        }
Beispiel #8
0
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result    = new RefundPaymentResult();
            var bpManager = new BluePayManager
            {
                AccountId = _bluePayPaymentSettings.AccountId,
                UserId    = _bluePayPaymentSettings.UserId,
                SecretKey = _bluePayPaymentSettings.SecretKey,
                IsSandbox = _bluePayPaymentSettings.UseSandbox,
                MasterId  = refundPaymentRequest.Order.CaptureTransactionId,
                Amount    = refundPaymentRequest.IsPartialRefund ?
                            GetUsdAmount(refundPaymentRequest.AmountToRefund).ToString("F", new CultureInfo("en-US")) : null
            };

            bpManager.Refund();

            if (bpManager.IsSuccessful)
            {
                result.NewPaymentStatus = (refundPaymentRequest.IsPartialRefund &&
                                           refundPaymentRequest.Order.RefundedAmount + refundPaymentRequest.AmountToRefund < refundPaymentRequest.Order.OrderTotal) ?
                                          PaymentStatus.PartiallyRefunded : PaymentStatus.Refunded;
            }
            else
            {
                result.AddError(bpManager.Message);
            }

            return(result);
        }
Beispiel #9
0
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public async Task <RefundPaymentResult> Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            result.AddError("Refund method not supported");
            return(await Task.FromResult(result));
        }
Beispiel #10
0
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            try
            {
                var apiContext = PaypalHelper.GetApiContext(_paypalDirectPaymentSettings);
                var capture    = PayPal.Api.Capture.Get(apiContext, refundPaymentRequest.Order.CaptureTransactionId);
                var currency   = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId);
                var refund     = new Refund
                {
                    amount = new Amount
                    {
                        total    = refundPaymentRequest.AmountToRefund.ToString("N", new CultureInfo("en-US")),
                        currency = currency != null ? currency.CurrencyCode : null
                    }
                };
                capture.Refund(apiContext, refund);
                capture = PayPal.Api.Capture.Get(apiContext, refundPaymentRequest.Order.CaptureTransactionId);

                result.NewPaymentStatus = GetPaymentStatus(capture.state);
            }
            catch (PayPal.PayPalException exc)
            {
                if (exc is PayPal.ConnectionException)
                {
                    var error = JsonFormatter.ConvertFromJson <Error>((exc as PayPal.ConnectionException).Response);
                    if (error != null)
                    {
                        result.AddError(string.Format("PayPal error: {0} ({1})", error.message, error.name));
                        if (error.details != null)
                        {
                            error.details.ForEach(x => result.AddError(string.Format("{0} {1}", x.field, x.issue)));
                        }
                    }
                }

                //if there are not the specific errors add exception message
                if (result.Success)
                {
                    result.AddError(exc.InnerException != null ? exc.InnerException.Message : exc.Message);
                }
            }

            return(result);
        }
Beispiel #11
0
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            PrepareAuthorizeNet();

            var maskedCreditCardNumberDecrypted = _encryptionService.DecryptText(refundPaymentRequest.Order.MaskedCreditCardNumber);

            if (String.IsNullOrEmpty(maskedCreditCardNumberDecrypted) || maskedCreditCardNumberDecrypted.Length < 4)
            {
                result.AddError("Last four digits of Credit Card Not Available");
                return(result);
            }

            var lastFourDigitsCardNumber = maskedCreditCardNumberDecrypted.Substring(maskedCreditCardNumberDecrypted.Length - 4);
            var creditCard = new creditCardType
            {
                cardNumber     = lastFourDigitsCardNumber,
                expirationDate = "XXXX"
            };

            var codes = (string.IsNullOrEmpty(refundPaymentRequest.Order.CaptureTransactionId) ? refundPaymentRequest.Order.AuthorizationTransactionCode : refundPaymentRequest.Order.CaptureTransactionId).Split(',');
            var transactionRequest = new transactionRequestType
            {
                transactionType = transactionTypeEnum.refundTransaction.ToString(),
                amount          = Math.Round(refundPaymentRequest.AmountToRefund, 2),
                refTransId      = codes[0],
                currencyCode    = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode,

                order = new orderType
                {
                    //x_invoice_num is 20 chars maximum. hece we also pass x_description
                    invoiceNumber = refundPaymentRequest.Order.OrderGuid.ToString().Substring(0, 20),
                    description   = string.Format("Full order #{0}", refundPaymentRequest.Order.OrderGuid)
                },

                payment = new paymentType {
                    Item = creditCard
                }
            };

            var request = new createTransactionRequest {
                transactionRequest = transactionRequest
            };

            // instantiate the contoller that will call the service
            var controller = new createTransactionController(request);

            controller.Execute();

            GetApiResponse(controller, result.Errors);
            result.NewPaymentStatus = PaymentStatus.PartiallyRefunded;

            return(result);
        }
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result     = new RefundPaymentResult();
            var apiPayment = new Models.PaymentOrderMechantUpdate
            {
                apiId         = _manualPaymentSettings.AppId,
                merch_Id      = _manualPaymentSettings.MerchantUniqueId,
                merch_orderId = refundPaymentRequest.Order.OrderGuid.ToString(),
                order_status  = "CANCELLED"
            };

            using (var client = new HttpClient())
            {
                var content = new StringContent(JsonConvert.SerializeObject(apiPayment));
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
                using (var res = client.PostAsync(String.Format("{0}api/v1/SecurePayment/UpdateOrder", _manualPaymentSettings.AppUrl), content))
                {
                    res.Wait();
                    if (res.Result.IsSuccessStatusCode)
                    {
                        var data = res.Result.Content.ReadAsStringAsync();
                        var ret  = JsonConvert.DeserializeObject <Models.ApiResponse>(data.Result.ToString());
                        switch (ret.responseCode.ToUpper())
                        {
                        case "APPROVED":
                            result.NewPaymentStatus = Core.Domain.Payments.PaymentStatus.Voided;
                            break;

                        default:
                            result.AddError(ret.responseText);
                            break;
                        }
                    }
                    else
                    {
                        result.AddError("Unable to process your request, Please try again later.");
                    }
                }
            }
            return(result);
        }
Beispiel #13
0
        internal RefundPaymentResult ExecuteRefund(RefundPaymentRequest refundPaymentRequest)
        {
            RefundPaymentResult         result         = new RefundPaymentResult();
            Dictionary <string, Object> responseRefund = new Dictionary <string, Object>();
            Dictionary <string, Object> response       = new Dictionary <string, Object>();

            if (refundPaymentRequest.IsPartialRefund)
            {
                responseRefund = ReturnRequest(refundPaymentRequest);
            }
            else
            {
                responseRefund = VoidRequest(refundPaymentRequest);
            }

            if (responseRefund.ContainsKey("VoidResponse"))
            {
                response = (Dictionary <string, Object>)responseRefund["VoidResponse"];
            }

            if (responseRefund.ContainsKey("ReturnResponse"))
            {
                response = (Dictionary <string, Object>)responseRefund["ReturnResponse"];
            }

            if (response.ContainsKey(TODOPAGO_STATUS_CODE))
            {
                System.Int64 statusCode = (System.Int64)response[TODOPAGO_STATUS_CODE];

                if (!statusCode.Equals(2011))
                {
                    // REFUND CON ERRORES
                    String statusMessage = (String)response[TODOPAGO_STATUS_MESSAGE];
                    result.AddError(statusCode + " - " + statusMessage);
                }
                else
                {
                    // REFUND BIEN
                    if (refundPaymentRequest.IsPartialRefund && refundPaymentRequest.Order.RefundedAmount + refundPaymentRequest.AmountToRefund < refundPaymentRequest.Order.OrderTotal)
                    {
                        result.NewPaymentStatus = PaymentStatus.PartiallyRefunded;
                    }
                    else
                    {
                        result.NewPaymentStatus = PaymentStatus.Refunded;
                    }
                }
            }

            return(result);
        }
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            RefundPaymentResult result = new RefundPaymentResult();

            if (ePayPaymentSettings.UseRemoteInterface)
            {
                int pbsresponse  = -1;
                int epayresponse = -1;

                try
                {
                    var    orderTotal = Math.Round(refundPaymentRequest.AmountToRefund, 2);
                    string amount     = (orderTotal * 100).ToString("0", CultureInfo.InvariantCulture);

                    dk.ditonlinebetalingssystem.ssl.Payment payment = new dk.ditonlinebetalingssystem.ssl.Payment();
                    payment.credit(Convert.ToInt32(ePayPaymentSettings.MerchantId), Convert.ToInt32(refundPaymentRequest.Order.AuthorizationTransactionId), Convert.ToInt32(amount), "", ePayPaymentSettings.RemotePassword, ref pbsresponse, ref epayresponse);

                    if (epayresponse == -1)
                    {
                        result.NewPaymentStatus = refundPaymentRequest.Order.OrderTotal == refundPaymentRequest.Order.RefundedAmount + refundPaymentRequest.AmountToRefund ? PaymentStatus.Refunded : PaymentStatus.PartiallyRefunded;
                    }
                    else
                    {
                        result.AddError("Could not refund: pbsResponse:" + pbsresponse + " epayresponse: " + epayresponse);
                    }
                }
                catch (Exception error)
                {
                    result.AddError("Could not refund: " + error.Message);
                }
            }
            else
            {
                result.AddError("Remote interface is not activated.");
            }

            return(result);
        }
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            string transactionId = refundPaymentRequest.Order.CaptureTransactionId;

            var req = new RefundTransactionReq();

            req.RefundTransactionRequest = new RefundTransactionRequestType
            {
                Version       = GetApiVersion(),
                TransactionID = transactionId
            };

            if (refundPaymentRequest.IsPartialRefund)
            {
                req.RefundTransactionRequest.RefundType = RefundType.PARTIAL;
                req.RefundTransactionRequest.Amount     = new BasicAmountType
                {
                    currencyID = PaypalHelper.GetPaypalCurrency(_currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId)),
                    value      = refundPaymentRequest.AmountToRefund.ToString()
                };
            }
            else
            {
                req.RefundTransactionRequest.RefundType = RefundType.FULL;
            }

            var service = GetService();
            RefundTransactionResponseType response = service.RefundTransaction(req);

            string error;
            bool   success = PaypalHelper.CheckSuccess(response, out error);

            if (success)
            {
                result.NewPaymentStatus = (refundPaymentRequest.IsPartialRefund &&
                                           refundPaymentRequest.Order.RefundedAmount + refundPaymentRequest.AmountToRefund < refundPaymentRequest.Order.OrderTotal) ?
                                          PaymentStatus.PartiallyRefunded : PaymentStatus.Refunded;

                //set refund transaction id for preventing refund twice
                _genericAttributeService.SaveAttribute(refundPaymentRequest.Order, "RefundTransactionId", response.RefundTransactionID);
            }
            else
            {
                result.AddError(error);
            }

            return(result);
        }
Beispiel #16
0
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            string transactionId = refundPaymentRequest.Order.CaptureTransactionId;

            var req = new RefundTransactionReq();

            req.RefundTransactionRequest = new RefundTransactionRequestType();
            //NOTE: Specify amount in partial refund
            req.RefundTransactionRequest.RefundType          = RefundType.Full;
            req.RefundTransactionRequest.RefundTypeSpecified = true;
            req.RefundTransactionRequest.Version             = GetApiVersion();
            req.RefundTransactionRequest.TransactionID       = transactionId;

            using (var service1 = new PayPalAPISoapBinding())
            {
                if (!_paypalDirectPaymentSettings.UseSandbox)
                {
                    service1.Url = "https://api-3t.paypal.com/2.0/";
                }
                else
                {
                    service1.Url = "https://api-3t.sandbox.paypal.com/2.0/";
                }

                service1.RequesterCredentials                       = new CustomSecurityHeaderType();
                service1.RequesterCredentials.Credentials           = new UserIdPasswordType();
                service1.RequesterCredentials.Credentials.Username  = _paypalDirectPaymentSettings.ApiAccountName;
                service1.RequesterCredentials.Credentials.Password  = _paypalDirectPaymentSettings.ApiAccountPassword;
                service1.RequesterCredentials.Credentials.Signature = _paypalDirectPaymentSettings.Signature;
                service1.RequesterCredentials.Credentials.Subject   = "";

                RefundTransactionResponseType response = service1.RefundTransaction(req);

                string error   = string.Empty;
                bool   Success = PaypalHelper.CheckSuccess(response, out error);
                if (Success)
                {
                    result.NewPaymentStatus = PaymentStatus.Refunded;
                    //cancelPaymentResult.RefundTransactionID = response.RefundTransactionID;
                }
                else
                {
                    result.AddError(error);
                }
            }

            return(result);
        }
Beispiel #17
0
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            var codes = refundPaymentRequest.Order.CaptureTransactionId == null
                ? refundPaymentRequest.Order.AuthorizationTransactionCode.Split(',')
                : refundPaymentRequest.Order.CaptureTransactionId.Split(',');

            _httpClient.DefaultRequestHeaders.Add("developer-id", _paySafePaymentSettings.DeveloperId);
            _httpClient.DefaultRequestHeaders.Add("user-id", _paySafePaymentSettings.UserId);
            _httpClient.DefaultRequestHeaders.Add("user-api-key", _paySafePaymentSettings.UserApiKey);

            var json = JsonConvert.SerializeObject(new
            {
                transaction = new Dictionary <string, string>
                {
                    { "action", "refund" },
                    { "payment_method", "cc" },
                    { "previous_transaction_id", codes[0] },
                    { "transaction_amount", refundPaymentRequest.AmountToRefund.ToString("0.00", CultureInfo.InvariantCulture) },
                    { "location_id", _paySafePaymentSettings.LocationId }
                }
            });
            var data = new StringContent(json, Encoding.UTF8, "application/json");

            try
            {
                var response          = _httpClient.PostAsync(GetUrl(), data).Result;
                var paySafeResponse   = JsonConvert.DeserializeObject <PaySafeResponse>(response.Content.ReadAsStringAsync().Result);
                var transactionResult = paySafeResponse.Transaction;

                if (response.IsSuccessStatusCode)
                {
                    var refundedTotalAmount = refundPaymentRequest.AmountToRefund + refundPaymentRequest.Order.RefundedAmount;

                    var isOrderFullyRefunded = refundedTotalAmount == refundPaymentRequest.Order.OrderTotal;

                    result.NewPaymentStatus = isOrderFullyRefunded ? PaymentStatus.Refunded : PaymentStatus.PartiallyRefunded;
                }
            }
            catch (Exception exception)
            {
                _logger.Error("PaySafe Error", exception);
                result.AddError("Exception Occurred: " + exception.Message);
                return(result);
            }

            return(result);
        }
Beispiel #18
0
        /// <summary>
        /// 退款
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var   result = new RefundPaymentResult();
            Order order  = refundPaymentRequest.Order;

            if (order == null)
            {
                result.AddError("订单为空");
                return(result);
            }
            //PaymentInfo paymentInfo = _paymentInfoService.GetByOrderId(order.Id);
            //if (!(paymentInfo != null && !string.IsNullOrEmpty(paymentInfo.Out_Trade_No)))
            //{
            //    result.AddError("交易号为空");
            //    return result;
            //}

            if (refundPaymentRequest.AmountToRefund <= 0)
            {
                result.AddError("退款金额大于0");
                return(result);
            }
            //if (refundPaymentRequest.AmountToRefund + refundPaymentRequest.Order.RefundedAmount > paymentInfo.Total)
            //{
            //    result.AddError("退款金额错误");
            //    return result;
            //}



            //退款通知
            string notify_url = _webHelper.GetStoreLocation(false) + "Plugins/AliPay/RefundNotify";

            //result.AddError("退款请求已提交,请到支付宝网站中进行退款确认");//必须有,否则影响退款金额
            return(result);
        }
Beispiel #19
0
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();
            PayfirmaTransaction         payfirma         = new PayfirmaTransaction();
            PayfirmaTransactionResponse payfirmaResponse =
                payfirma.ProcessRefund(this.PopulateMerchantCredentials(), refundPaymentRequest.Order.AuthorizationTransactionId,
                                       Convert.ToDouble(refundPaymentRequest.AmountToRefund), _payfirmaPaymentSettings.IsTest);

            if (!String.IsNullOrEmpty(payfirmaResponse.Error))
            {
                result.AddError(payfirmaResponse.Error);
            }
            else if (!payfirmaResponse.Result)
            {
                result.AddError(payfirmaResponse.ResultMessage);
            }
            else
            {
                var isOrderFullyRefunded = (refundPaymentRequest.AmountToRefund + refundPaymentRequest.Order.RefundedAmount == refundPaymentRequest.Order.OrderTotal);
                result.NewPaymentStatus = isOrderFullyRefunded ? PaymentStatus.Refunded : PaymentStatus.PartiallyRefunded;
            }

            return(result);
        }
Beispiel #20
0
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            var refundResult = _sagePayServerWorkflowService.RefundTransaction(refundPaymentRequest.Order.OrderGuid.ToString(), refundPaymentRequest.Order.OrderTotal, refundPaymentRequest.Order.CustomerCurrencyCode);

            if (!refundResult.Success)
            {
                result.AddError(refundResult.Message);
            }
            else
            {
                result.NewPaymentStatus = PaymentStatus.Refunded;
            }

            return(result);
        }
        /// <summary>
        /// Ödeme Talebi İadesi
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var refundResult = new RefundPaymentResult();

            if (!refundPaymentRequest.IsPartialRefund)
            {
                CreateCancelRequest request = new CreateCancelRequest();
                request.ConversationId = refundPaymentRequest.Order.CustomOrderNumber;
                request.Locale         = Locale.TR.ToString();
                request.PaymentId      = refundPaymentRequest.Order.AuthorizationTransactionId;
                request.Ip             = refundPaymentRequest.Order.CustomerIp;
                Cancel cancel = Cancel.Create(request, HelperApiOptions.GetApiContext(_iyzicoPayPaymentSettings));
                if (cancel.Status == "success")
                {
                    refundResult.NewPaymentStatus = PaymentStatus.Refunded;
                }
                else
                {
                    refundResult.AddError(cancel.ErrorGroup);
                }
            }
            else
            {
                string[]            list    = refundPaymentRequest.Order.AuthorizationTransactionResult.Split('-');
                CreateRefundRequest request = new CreateRefundRequest();
                request.ConversationId       = refundPaymentRequest.Order.CustomOrderNumber;
                request.Locale               = Locale.TR.ToString();
                request.PaymentTransactionId = list[0];
                request.Price    = refundPaymentRequest.AmountToRefund.ToString("##.###").Replace(',', '.');
                request.Ip       = refundPaymentRequest.Order.CustomerIp;
                request.Currency = Currency.TRY.ToString();
                Iyzico.Models.Refund refund = Iyzico.Models.Refund.Create(request, HelperApiOptions.GetApiContext(_iyzicoPayPaymentSettings));
                if (refund.Status == "success")
                {
                    refundResult.NewPaymentStatus = PaymentStatus.PartiallyRefunded;
                }
            }

            return(refundResult);
        }
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var stripeCharge = _chargeEntityService.Get(refundPaymentRequest.Order.OrderGuid);

            var customerDomainModel = _customerEntityService.GetOrCreate(stripeCharge.SellerCustomerId);
            var requestOptions      = new StripeRequestOptions();

            requestOptions.StripeConnectAccountId = customerDomainModel.StripeUserId;

            var refund = _stripeRefundService.Create(stripeCharge.StripeChargeId, requestOptions: requestOptions);
            var result = new RefundPaymentResult();

            if (refund.Status == "succeeded")
            {
                result.NewPaymentStatus = Core.Domain.Payments.PaymentStatus.Refunded;
            }
            else
            {
                result.AddError("Error " + refund.FailureReason);
            }
            return(result);
        }
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var     result = new RefundPaymentResult();
            dynamic outrequest;

            if (refundPaymentRequest.IsPartialRefund)
            {
                outrequest        = new CheckoutPartialRefundRequest();
                outrequest.amount = refundPaymentRequest.AmountToRefund;
            }
            else
            {
                outrequest = new CheckoutRefundRequest();
            }

            outrequest.checkout_id   = refundPaymentRequest.Order.AuthorizationTransactionId;
            outrequest.refund_reason = "Refund for Order #" + refundPaymentRequest.Order.OrderGuid;

            WebClientResponse wcresponse = ProcessWebClient(outrequest);

            foreach (string error in wcresponse.Errors)
            {
                result.AddError(error);
            }
            if (result.Errors.Count <= 0 && wcresponse.state == "refunded")
            {
                if (refundPaymentRequest.IsPartialRefund)
                {
                    result.NewPaymentStatus = PaymentStatus.PartiallyRefunded;
                }
                else
                {
                    result.NewPaymentStatus = PaymentStatus.Refunded;
                }
            }

            return(result);
        }
Beispiel #24
0
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            Log(string.Format("Refund Amount: {0}, IsPartial {1}, TransactionCode {2}, TransactionId {3}",
                              refundPaymentRequest.AmountToRefund, refundPaymentRequest.IsPartialRefund,
                              refundPaymentRequest.Order.AuthorizationTransactionCode, refundPaymentRequest.Order.AuthorizationTransactionId));

            var result = new RefundPaymentResult();

            try
            {
                var payment = new Payment(refundPaymentRequest.Order.AuthorizationTransactionId);

                var refund = new Refund();
                refund.Amount  = (long)(refundPaymentRequest.AmountToRefund * 100);
                refund.Payment = payment;
                var storeName = _storeContext.CurrentStore.Name;
                refund.Reason = GetMsg("Plugins.Payments.Simplify.Refund.Reason", storeName);
                refund        = (Refund)_paymentsApi.Create(refund, GetAuth());

                Log("Refund id " + refund.Id);

                if (refundPaymentRequest.IsPartialRefund)
                {
                    result.NewPaymentStatus = PaymentStatus.PartiallyRefunded;
                }
                else
                {
                    result.NewPaymentStatus = PaymentStatus.Refunded;
                }
            }
            catch (Exception e)
            {
                LogException("Refund", e);
                result.AddError(GetMsg("Plugins.Payments.Simplify.Refund.Exception"));
            }

            return(result);
        }
        /// <summary>
        /// Full or partial refund
        /// </summary>
        /// <param name="refundPaymentRequest"></param>
        /// <returns></returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            string chargeID          = refundPaymentRequest.Order.AuthorizationTransactionId;
            var    orderAmtRemaining = refundPaymentRequest.Order.OrderTotal - refundPaymentRequest.AmountToRefund;
            bool   isPartialRefund   = orderAmtRemaining > 0;

            if (!IsChargeID(chargeID))
            {
                throw new NopException($"Refund error: {chargeID} is not a Stripe Charge ID. Refund cancelled");
            }
            var service       = new RefundService();
            var refundOptions = new RefundCreateOptions
            {
                ChargeId = chargeID,
                Amount   = (long)(refundPaymentRequest.AmountToRefund * 100),
                Reason   = RefundReasons.RequestedByCustomer
            };
            var refund = service.Create(refundOptions, GetStripeApiRequestOptions());

            RefundPaymentResult result = new RefundPaymentResult();

            switch (refund.Status)
            {
            case "succeeded":
                result.NewPaymentStatus = isPartialRefund ? PaymentStatus.PartiallyRefunded : PaymentStatus.Refunded;
                break;

            case "pending":
                result.NewPaymentStatus = PaymentStatus.Pending;
                result.AddError($"Refund failed with status of ${ refund.Status }");
                break;

            default:
                throw new NopException("Refund returned a status of ${refund.Status}");
            }
            return(result);
        }
        /// <summary>
        /// 退款
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var   result = new RefundPaymentResult();
            Order order  = refundPaymentRequest.Order;

            if (order == null)
            {
                result.AddError("订单为空");
                return(result);
            }
            PaymentInfo paymentInfo = _paymentInfoService.GetByOrderId(order.Id);

            if (!(paymentInfo != null && !string.IsNullOrEmpty(paymentInfo.Out_Trade_No)))
            {
                result.AddError("交易号为空");
                return(result);
            }
            if (_aliPayPaymentSettings.Partner != paymentInfo.Seller_id)
            {
                result.AddError("退款合作身份者ID错误");
                return(result);
            }
            if (refundPaymentRequest.AmountToRefund <= 0)
            {
                result.AddError("退款金额大于0");
                return(result);
            }
            if (refundPaymentRequest.AmountToRefund + refundPaymentRequest.Order.RefundedAmount > paymentInfo.Total)
            {
                result.AddError("退款金额错误");
                return(result);
            }

            //卖家账号,退款账号
            string seller_emailToRefund = paymentInfo.Seller_email; // 卖家退款账号邮箱
            string seller_user_id       = paymentInfo.Seller_id;    //卖家退款账号ID

            //批次号,必填,格式:当天日期[8位]+序列号[3至24位],如:201603081000001

            string batch_no = DateTime.Now.ToString("yyyyMMdd") + GuidToLongID();//退款编号

            //退款笔数,必填,参数detail_data的值中,“#”字符出现的数量加1,最大支持1000笔(即“#”字符出现的数量999个)

            string batch_num = "1";

            //退款详细数据,必填,格式(支付宝交易号^退款金额^备注),多笔请用#隔开
            string out_trade_no   = paymentInfo.Out_Trade_No;                                    //支付宝交易号交易号
            string amountToRefund = refundPaymentRequest.AmountToRefund.ToString().TrimEnd('0'); //退款金额
            string refundResult   = "协商退款";                                                      //备注
            string detail_data    = string.Format("{0}^{1}^{2}",
                                                  out_trade_no,
                                                  amountToRefund,
                                                  refundResult
                                                  );
            //退款通知
            string notify_url = _webHelper.GetStoreLocation(false) + "Plugins/AliPay/RefundNotify";

            //新增退款记录
            var refundInfo = new RefundInfo()
            {
                OrderId        = refundPaymentRequest.Order.Id,
                Batch_no       = batch_no,
                AmountToRefund = refundPaymentRequest.AmountToRefund,
                RefundStatusId = (int)RefundStatus.refunding,
                CreateOnUtc    = DateTime.Now,
                Seller_Email   = seller_emailToRefund,
                Seller_Id      = seller_user_id,
                Out_Trade_No   = out_trade_no,
            };

            _refundInfoService.Insert(refundInfo);

            ////////////////////////////////////////////////////////////////////////////////////////////////
            var alipayReturnConfig = new AlipayReturnConfig()
            {
                partner       = _aliPayPaymentSettings.Partner,
                key           = _aliPayPaymentSettings.Key,
                sign_type     = "MD5",
                input_charset = "utf-8"
            };
            //把请求参数打包成数组
            SortedDictionary <string, string> sParaTemp = new SortedDictionary <string, string>();

            sParaTemp.Add("service", alipayReturnConfig.service);
            sParaTemp.Add("partner", alipayReturnConfig.partner);
            sParaTemp.Add("_input_charset", alipayReturnConfig.input_charset.ToLower());
            sParaTemp.Add("refund_date", alipayReturnConfig.refund_date);
            sParaTemp.Add("seller_user_id", seller_user_id);
            sParaTemp.Add("batch_no", batch_no);
            sParaTemp.Add("batch_num", batch_num);
            sParaTemp.Add("detail_data", detail_data);
            sParaTemp.Add("notify_url", notify_url);

            var post = AlipaySubmit.BuildRequest(sParaTemp, alipayReturnConfig, "POST");

            post.Post();

            result.AddError("退款请求已提交,请到支付宝网站中进行退款确认");//必须有,否则影响退款金额
            return(result);
        }
        public override RefundPaymentResult Refund(RefundPaymentRequest request)
        {
            // "Transaction refused (10009). You can not refund this type of transaction.":
            // merchant must accept the payment in his PayPal account
            var result = new RefundPaymentResult
            {
                NewPaymentStatus = request.Order.PaymentStatus
            };

            var settings = Services.Settings.LoadSetting <TSetting>(request.Order.StoreId);

            var transactionId = request.Order.CaptureTransactionId;

            var req = new RefundTransactionReq();

            req.RefundTransactionRequest = new RefundTransactionRequestType();

            if (request.IsPartialRefund)
            {
                var store        = Services.StoreService.GetStoreById(request.Order.StoreId);
                var currencyCode = store.PrimaryStoreCurrency.CurrencyCode;

                req.RefundTransactionRequest.RefundType = RefundType.Partial;

                req.RefundTransactionRequest.Amount            = new BasicAmountType();
                req.RefundTransactionRequest.Amount.Value      = Math.Round(request.AmountToRefund, 2).ToString("N", new CultureInfo("en-us"));
                req.RefundTransactionRequest.Amount.currencyID = (CurrencyCodeType)Enum.Parse(typeof(CurrencyCodeType), currencyCode, true);

                // see https://developer.paypal.com/docs/classic/express-checkout/digital-goods/ECDGIssuingRefunds/
                // https://developer.paypal.com/docs/classic/api/merchant/RefundTransaction_API_Operation_NVP/
                var memo = Services.Localization.GetResource("Plugins.cloudCommerce.PayPal.PartialRefundMemo", 0, false, "", true);
                if (memo.HasValue())
                {
                    req.RefundTransactionRequest.Memo = memo.FormatInvariant(req.RefundTransactionRequest.Amount.Value);
                }
            }
            else
            {
                req.RefundTransactionRequest.RefundType = RefundType.Full;
            }

            req.RefundTransactionRequest.RefundTypeSpecified = true;
            req.RefundTransactionRequest.Version             = ApiVersion;
            req.RefundTransactionRequest.TransactionID       = transactionId;

            using (var service = GetApiService(settings))
            {
                var response = service.RefundTransaction(req);

                var error   = "";
                var Success = IsSuccess(response, out error);

                if (Success)
                {
                    if (request.IsPartialRefund)
                    {
                        result.NewPaymentStatus = PaymentStatus.PartiallyRefunded;
                    }
                    else
                    {
                        result.NewPaymentStatus = PaymentStatus.Refunded;
                    }

                    //cancelPaymentResult.RefundTransactionID = response.RefundTransactionID;
                }
                else
                {
                    result.AddError(error);
                }
            }

            return(result);
        }
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            // null to refund full amount
            decimal?amountToRefund = null;

            if (refundPaymentRequest.AmountToRefund != refundPaymentRequest.Order.OrderTotal)
            {
                amountToRefund = refundPaymentRequest.AmountToRefund;

                //try convert to Skrill account currency
                var capturedTransactionId = refundPaymentRequest.Order.CaptureTransactionId;
                var(currencyCode, currencyCodeError) = _serviceManager.GetTransactionCurrencyCode(capturedTransactionId);
                if (!string.IsNullOrEmpty(currencyCodeError))
                {
                    return new RefundPaymentResult {
                               Errors = new[] { currencyCodeError }
                    }
                }
                ;

                var primaryCurrency = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId);
                if (!primaryCurrency.CurrencyCode.Equals(currencyCode, StringComparison.InvariantCultureIgnoreCase))
                {
                    var skrillCurrency = _currencyService.GetCurrencyByCode(currencyCode);

                    if (skrillCurrency != null)
                    {
                        amountToRefund = _currencyService.ConvertCurrency(amountToRefund.Value, primaryCurrency, skrillCurrency);
                    }
                    else
                    {
                        var currencyError = $"Cannot convert the refund amount to Skrill currency {currencyCode}. Currency ({currencyCode}) not install.";
                        return(new RefundPaymentResult {
                            Errors = new[] { currencyError }
                        });
                    }
                }
            }

            var(completed, error) = _serviceManager.Refund(refundPaymentRequest.Order, amountToRefund);

            if (!string.IsNullOrEmpty(error))
            {
                return new RefundPaymentResult {
                           Errors = new[] { error }
                }
            }
            ;

            var result = new RefundPaymentResult
            {
                NewPaymentStatus = completed
                    ? (refundPaymentRequest.IsPartialRefund
                    ? PaymentStatus.PartiallyRefunded
                    : PaymentStatus.Refunded)
                    : refundPaymentRequest.Order.PaymentStatus
            };

            //the refund is pending, actually it'll be completed upon receiving successful refund status report
            if (!completed)
            {
                result.AddError(_localizationService.GetResource("Plugins.Payments.Skrill.Refund.Warning"));
            }

            return(result);
        }
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            //primary currency
            var currency = _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId);

            if (currency == null)
            {
                throw new NopException("Currency could not be loaded");
            }

            //settings
            var g2apayPaymentSettings = _settingService.LoadSetting <G2APayPaymentSettings>(refundPaymentRequest.Order.StoreId);

            //hash
            var stringToHash = $"{refundPaymentRequest.Order.CaptureTransactionId}{refundPaymentRequest.Order.OrderGuid}{refundPaymentRequest.Order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture)}{refundPaymentRequest.AmountToRefund.ToString("0.00", CultureInfo.InvariantCulture)}{g2apayPaymentSettings.SecretKey}";

            //post parameters
            var parameters = QueryHelpers.ParseQuery(string.Empty);

            parameters.Add("action", "refund");
            parameters.Add("order_id", refundPaymentRequest.Order.OrderGuid.ToString());
            parameters.Add("amount", refundPaymentRequest.AmountToRefund.ToString("0.00", CultureInfo.InvariantCulture));
            parameters.Add("currency", currency.CurrencyCode);
            parameters.Add("hash", GetSHA256Hash(stringToHash));

            var postData = Encoding.Default.GetBytes(parameters.ToString());

            //post
            var request = (HttpWebRequest)WebRequest.Create($"{GetG2APayRestUrl(g2apayPaymentSettings)}/rest/transactions/{refundPaymentRequest.Order.CaptureTransactionId}");

            request.Method        = "PUT";
            request.ContentType   = "application/x-www-form-urlencoded";
            request.ContentLength = postData.Length;
            request.Headers.Add(HttpRequestHeader.Authorization, GetAuthHeader(g2apayPaymentSettings));

            try
            {
                using (var stream = request.GetRequestStream())
                {
                    stream.Write(postData, 0, postData.Length);
                }
                var httpResponse = (HttpWebResponse)request.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var response = JsonConvert.DeserializeObject <G2APayPaymentResponse>(streamReader.ReadToEnd());
                    if (!response.Status.Equals("ok", StringComparison.InvariantCultureIgnoreCase))
                    {
                        throw new NopException($"G2A Pay refund error: transaction status is {response.Status}");
                    }

                    //leaving payment status, we will change it later, upon receiving IPN
                    result.NewPaymentStatus = refundPaymentRequest.Order.PaymentStatus;
                    result.AddError(_localizationService.GetResource("Plugins.Payments.G2APay.Refund"));

                    //change error notification to warning one
                    _pageHeadBuilder.AddCssFileParts(ResourceLocation.Head, @"~/Plugins/Payments.G2APay/Content/styles.css", string.Empty);
                }
            }
            catch (WebException ex)
            {
                var error = "G2A Pay refund error. ";
                using (var streamReader = new StreamReader(ex.Response.GetResponseStream()))
                {
                    error += streamReader.ReadToEnd();
                }
                _logger.Error(error, ex);
                result.AddError(string.Format("{1}. {0}", error, ex.Message));
            }

            return(result);
        }
        /// <summary>
        /// Refunds a payment
        /// </summary>
        /// <param name="refundPaymentRequest">Request</param>
        /// <returns>Result</returns>
        public RefundPaymentResult Refund(RefundPaymentRequest refundPaymentRequest)
        {
            var result = new RefundPaymentResult();

            var webClient = new WebClient();
            var form      = new NameValueCollection();

            form.Add("x_login", _authorizeNetPaymentSettings.LoginId);
            form.Add("x_tran_key", _authorizeNetPaymentSettings.TransactionKey);

            form.Add("x_delim_data", "TRUE");
            form.Add("x_delim_char", "|");
            form.Add("x_encap_char", "");
            form.Add("x_version", GetApiVersion());
            form.Add("x_relay_response", "FALSE");

            form.Add("x_method", "CC");
            form.Add("x_currency_code", _currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId).CurrencyCode);

            string[] codes = refundPaymentRequest.Order.CaptureTransactionId == null?
                             refundPaymentRequest.Order.AuthorizationTransactionCode.Split(',') : refundPaymentRequest.Order.CaptureTransactionId.Split(',');

            //x_trans_id. When x_test_request (sandbox) is set to a positive response,
            //or when Test mode is enabled on the payment gateway, this value will be "0".
            form.Add("x_trans_id", codes[0]);

            string maskedCreditCardNumberDecrypted = _encryptionService.DecryptText(refundPaymentRequest.Order.MaskedCreditCardNumber);

            if (String.IsNullOrEmpty(maskedCreditCardNumberDecrypted) || maskedCreditCardNumberDecrypted.Length < 4)
            {
                result.AddError("Last four digits of Credit Card Not Available");
                return(result);
            }
            var lastFourDigitsCardNumber = maskedCreditCardNumberDecrypted.Substring(maskedCreditCardNumberDecrypted.Length - 4);

            form.Add("x_card_num", lastFourDigitsCardNumber); // only last four digits are required for doing a credit
            form.Add("x_amount", refundPaymentRequest.AmountToRefund.ToString("0.00", CultureInfo.InvariantCulture));
            //x_invoice_num is 20 chars maximum. hece we also pass x_description
            form.Add("x_invoice_num", refundPaymentRequest.Order.OrderGuid.ToString().Substring(0, 20));
            form.Add("x_description", string.Format("Full order #{0}", refundPaymentRequest.Order.OrderGuid));
            form.Add("x_type", "CREDIT");

            // Send Request to Authorize and Get Response
            var responseData = webClient.UploadValues(GetAuthorizeNetUrl(), form);
            var reply        = Encoding.ASCII.GetString(responseData);

            if (!String.IsNullOrEmpty(reply))
            {
                string[] responseFields = reply.Split('|');
                switch (responseFields[0])
                {
                case "1":
                    var isOrderFullyRefunded = (refundPaymentRequest.AmountToRefund + refundPaymentRequest.Order.RefundedAmount == refundPaymentRequest.Order.OrderTotal);
                    result.NewPaymentStatus = isOrderFullyRefunded ? PaymentStatus.Refunded : PaymentStatus.PartiallyRefunded;
                    break;

                case "2":
                    result.AddError(string.Format("Declined ({0}: {1})", responseFields[2], responseFields[3]));
                    break;

                case "3":
                    result.AddError(string.Format("Error: {0}", reply));
                    break;
                }
            }
            else
            {
                result.AddError("Authorize.NET unknown error");
            }
            return(result);
        }