Ejemplo n.º 1
0
        /// <summary>
        /// 申请退款
        /// </summary>
        /// <param name="requestModel">请求内容</param>
        /// <returns></returns>
        public static RefundResponseModel Refund(RefundModel requestModel)
        {
            AlipayTradeRefundRequest queryRequset = new AlipayTradeRefundRequest();

            queryRequset.BizContent = JsonConvert.SerializeObject(requestModel);
            LogUtil.WriteAlipayLog("申请退款请求", "请求参数", queryRequset.BizContent);
            Dictionary <string, string> paramsDict     = (Dictionary <string, string>)queryRequset.GetParameters();
            AlipayTradeRefundResponse   refundResponse = _client.Execute(queryRequset);

            LogUtil.WriteAlipayLog("申请退款响应", "响应参数", refundResponse.Body);
            return(new RefundResponseModel
            {
                msg = refundResponse.Msg,
                code = refundResponse.Code,
                subcode = refundResponse.SubCode,
                submsg = refundResponse.SubMsg,
                trade_no = refundResponse.TradeNo,
                send_back_fee = refundResponse.SendBackFee,
                store_name = refundResponse.StoreName,
                fund_change = refundResponse.FundChange,
                buyer_logon_id = refundResponse.BuyerLogonId,
                amount = refundResponse.RefundDetailItemList == null || refundResponse.RefundDetailItemList.Count == 0 ? "0.0" : refundResponse.RefundDetailItemList[0].Amount,
                fund_channel = refundResponse.RefundDetailItemList == null || refundResponse.RefundDetailItemList.Count == 0 ? "": refundResponse.RefundDetailItemList[0].FundChannel,
                out_trade_no = refundResponse.OutTradeNo,
                buyer_user_id = refundResponse.BuyerUserId,
                gmt_refund_pay = refundResponse.GmtRefundPay,
                refund_fee = refundResponse.RefundFee
            });
        }
Ejemplo n.º 2
0
        public IActionResult Payment(RefundModel model)
        {
            this.ViewBagData(model.LoanId);
            model.EmployeeId = GetEmployeeId().Result;

            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var request = _refundService.Create(model);

            if (request.Successful)
            {
                return(RedirectToAction("Refund", "Loans", new { id = model.LoanId }));
            }

            switch (request.ResultType)
            {
            case ResultType.PendingTransaction:
                TempData["Error"] = "This custormer has a pending loan transaction";
                break;

            case ResultType.DataIntegrity:
                TempData["Error"] = "Data inetgrity error";
                break;
            }

            return(View(model));
        }
Ejemplo n.º 3
0
 public SerOrdSerItModelList()
 {
     SerOrdSerItModelLists          = new List <SerOrdSerItModel>();
     PaymentsServiceOrderModelLists = new List <PaymentsServiceOrderModel>();
     PaymentInfos = new PaymentsModel();
     RefundInfos  = new RefundModel();
 }
Ejemplo n.º 4
0
        public RefundModel GetByOutRefundNo(string outRefundNo)
        {
            string  sql = "SELECT * FROM `refund` WHERE OutRefundNo = @OutRefundNo;";
            DataRow dr  = MySqlHelper.ExecuteDataRow(ConfigHelper.ConnStr, sql, new MySqlParameter("@OutRefundNo", outRefundNo));

            if (dr != null)
            {
                RefundModel model = new RefundModel();
                model.Id            = dr["Id"].ToInt();
                model.AppId         = dr["AppId"].ToInt();
                model.OutTradeNo    = dr["OutTradeNo"].ToString();
                model.TradeNo       = dr["TradeNo"].ToString();
                model.OutRefundNo   = dr["OutRefundNo"].ToString();
                model.RefundNo      = dr["RefundNo"].ToString();
                model.TotalFee      = dr["TotalFee"].ToInt();
                model.RefundFee     = dr["RefundFee"].ToInt();
                model.RealRefundFee = dr["RealRefundFee"].ToInt();
                model.RState        = dr["RState"].ToInt();
                model.RefundState   = dr["RefundState"].ToString();
                model.CreateTime    = dr["CreateTime"].ToDateTime();
                model.UpdateTime    = dr["UpdateTime"].ToDateTime();
                return(model);
            }
            return(null);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 微信申请退款接口
        /// </summary>
        /// <param name="requestModel">请求参数</param>
        /// <returns></returns>
        public static RefundResponseModel Refund(RefundModel requestModel)
        {
            WxPayData data = new WxPayData();

            if (!string.IsNullOrEmpty(requestModel.transaction_id))//微信订单号存在的条件下,则已微信订单号为准
            {
                data.SetValue("transaction_id", requestModel.transaction_id);
            }
            else//微信订单号不存在,才根据商户订单号去退款
            {
                data.SetValue("out_trade_no", requestModel.out_trade_no);
            }
            data.SetValue("total_fee", requestModel.total_fee);            //订单总金额
            data.SetValue("refund_fee", requestModel.refund_fee);          //退款金额
            data.SetValue("out_refund_no", WxPayApi.GenerateOutTradeNo()); //随机生成商户退款单号
            data.SetValue("op_user_id", WxPayConfig.MCHID);                //操作员,默认为商户号
            LogUtil.WriteWxpayLog("申请退款请求", "请求参数", data.ToJson());
            WxPayData result = WxPayApi.Refund(data);                      //提交退款申请给API,接收返回数据

            LogUtil.WriteWxpayLog("申请退款响应", "响应参数", result.ToJson());
            RefundResponseModel response = LitJson.JsonMapper.ToObject <RefundResponseModel>(result.ToJson());

            //Log.Info("OrderQuery", "OrderQuery process complete, result : " + result.ToXml());
            return(response);
        }
Ejemplo n.º 6
0
        public void RefundWithSuccess(RefundModel refund, string responseData, string receiptId)
        {
            var httpClient = Substitute.For <IHttpClient>();
            var response   = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(responseData)
            };

            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var responseTask = new TaskCompletionSource <HttpResponseMessage>();

            responseTask.SetResult(response);

            httpClient.SendAsync(Arg.Any <HttpRequestMessage>()).Returns(responseTask.Task);

            var client = new Client(new Connection(httpClient,
                                                   DotNetLoggerFactory.Create,
                                                   "http://something.com"));

            var judo = new JudoPayApi(DotNetLoggerFactory.Create, client);

            var paymentReceiptResult = judo.Refunds.Create(refund).Result;

            Assert.NotNull(paymentReceiptResult);
            Assert.IsFalse(paymentReceiptResult.HasError);
            Assert.NotNull(paymentReceiptResult.Response);
            Assert.That(paymentReceiptResult.Response.ReceiptId, Is.EqualTo(134567));
        }
Ejemplo n.º 7
0
        public void RefundWithError(RefundModel refund, string responseData, JudoApiError error)
        {
            var httpClient = Substitute.For <IHttpClient>();
            var response   = new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new StringContent(responseData)
            };

            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var responseTask = new TaskCompletionSource <HttpResponseMessage>();

            responseTask.SetResult(response);

            httpClient.SendAsync(Arg.Any <HttpRequestMessage>()).Returns(responseTask.Task);

            var client = new Client(new Connection(httpClient,
                                                   DotNetLoggerFactory.Create,
                                                   "http://judo.com"));

            var judo = new JudoPayApi(DotNetLoggerFactory.Create, client);

            var paymentReceiptResult = judo.Market.Refunds.Create(refund).Result;

            Assert.NotNull(paymentReceiptResult);
            Assert.IsTrue(paymentReceiptResult.HasError);
            Assert.IsNull(paymentReceiptResult.Response);
            Assert.IsNotNull(paymentReceiptResult.Error);
            Assert.AreEqual(error, paymentReceiptResult.Error.ErrorType);
        }
Ejemplo n.º 8
0
        public ActionResult ImportRefund(int id)
        {
            var ctx    = new SmsContext();
            var refund = ctx.TRA_HANG.Find(id);

            if (refund.ACTIVE != "A")
            {
                return(RedirectToAction("ReturnPurchaseList", new { @inforMessage = "Không tìm thấy phiếu trả hàng nào tương ứng." }));
            }
            var         refundDetail = ctx.SP_GET_REFUND_DETAIL(id).ToList <SP_GET_REFUND_DETAIL_Result>();
            RefundModel model        = new RefundModel();

            model.Infor  = refund;
            model.Detail = refundDetail;
            if (!(bool)Session["IsAdmin"])
            {
                model.MaKho = Convert.ToInt32(Session["MyStore"]);
            }
            var stores = ctx.KHOes.Where(u => u.ACTIVE == "A").ToList <KHO>();

            ViewBag.Kho = stores;
            var storeList = ctx.SP_GET_STORES_BY_USR_ID(Convert.ToInt32(Session["UserId"])).ToList <SP_GET_STORES_BY_USR_ID_Result>();

            model.StoreList = storeList;

            ctx.Dispose();
            return(View(model));
        }
Ejemplo n.º 9
0
        public void ASimplePaymentAndRefund()
        {
            var paymentWithCard = GetCardPaymentModel();
            var response        = JudoPayApi.Payments.Create(paymentWithCard).Result;

            Assert.IsNotNull(response);
            Assert.IsFalse(response.HasError);
            Assert.AreEqual("Success", response.Response.Result);

            var refund = new RefundModel
            {
                Amount    = 25,
                ReceiptId = response.Response.ReceiptId,
            };

            response = JudoPayApi.Refunds.Create(refund).Result;

            Assert.IsNotNull(response);
            Assert.IsFalse(response.HasError);

            var receipt = response.Response as PaymentReceiptModel;

            Assert.IsNotNull(receipt);

            Assert.AreEqual("Success", receipt.Result);
            Assert.AreEqual("Refund", receipt.Type);
        }
Ejemplo n.º 10
0
        public SwishClientTests()
        {
            _defaultECommercePaymentModel = new ECommercePaymentModel(
                amount: "100",
                callbackUrl: "https://example.com/api/swishcb/paymentrequests",
                currency: "SEK",
                payerAlias: "467012345678")
            {
                PayeePaymentReference = "0123456789",
                Message = "Kingston USB Flash Drive 8 GB"
            };

            _defaultMCommercePaymentModel = new MCommercePaymentModel(
                amount: "100",
                callbackUrl: "https://example.com/api/swishcb/paymentrequests",
                currency: "SEK")
            {
                PayeePaymentReference = "0123456789",
                Message = "Kingston USB Flash Drive 8 GB"
            };

            _defaultRefund = new RefundModel(
                originalPaymentReference: "6D6CD7406ECE4542A80152D909EF9F6B",
                callbackUrl: "https://example.com/api/swishcb/refunds",
                payerAlias: "1231181189",
                amount: "100",
                currency: "SEK")
            {
                PayerPaymentReference = "0123456789",
                Message = "Refund for Kingston USB Flash Drive 8 GB"
            };
        }
Ejemplo n.º 11
0
        public void ExtraHeadersAreSent(RefundModel refundModel, string responseData, string receiptId)
        {
            const string EXTRA_HEADER_NAME = "X-Extra-Request-Header";

            var httpClient = Substitute.For <IHttpClient>();
            var response   = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(responseData)
            };

            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            var responseTask = new TaskCompletionSource <HttpResponseMessage>();

            responseTask.SetResult(response);

            httpClient.SendAsync(Arg.Is <HttpRequestMessage>(r => r.Headers.Contains(EXTRA_HEADER_NAME)))
            .Returns(responseTask.Task);

            var client = new Client(new Connection(httpClient,
                                                   DotNetLoggerFactory.Create,
                                                   "http://something.com"));

            var judo = new JudoPayApi(DotNetLoggerFactory.Create, client);

            refundModel.HttpHeaders.Add(EXTRA_HEADER_NAME, "some random value");

            IResult <ITransactionResult> refundReceipt = judo.Refunds.Create(refundModel).Result;

            Assert.NotNull(refundReceipt);
            Assert.IsFalse(refundReceipt.HasError);
            Assert.NotNull(refundReceipt.Response);
            Assert.That(refundReceipt.Response.ReceiptId, Is.EqualTo(134567));
        }
Ejemplo n.º 12
0
 public FRefund()
 {
     InitializeComponent();
     refundModel      = new RefundModel();
     listRefund       = new DataTable();
     selectedFunction = 0;
     refund           = new Refund();
 }
Ejemplo n.º 13
0
        public void GetRefundsTransactions()
        {
            var judo = JudoPaymentsFactory.Create(Configuration.Token,
                                                  Configuration.Secret,
                                                  Configuration.Baseaddress);

            var paymentWithCard = new CardPaymentModel
            {
                JudoId = Configuration.Judoid,
                YourPaymentReference  = "578543",
                YourConsumerReference = "432438862",
                Amount      = 25,
                CardNumber  = "4976000000003436",
                CV2         = "452",
                ExpiryDate  = "12/15",
                CardAddress = new CardAddressModel
                {
                    Line1    = "Test Street",
                    PostCode = "W40 9AU",
                    Town     = "Town"
                }
            };

            var paymentResponse = judo.Payments.Create(paymentWithCard).Result;

            Assert.IsNotNull(paymentResponse);
            Assert.IsFalse(paymentResponse.HasError);
            Assert.AreEqual("Success", paymentResponse.Response.Result);

            var refund = new RefundModel
            {
                Amount               = 25,
                ReceiptId            = int.Parse(paymentResponse.Response.ReceiptId),
                YourPaymentReference = "578543"
            };

            var response = judo.Refunds.Create(refund).Result;

            Assert.IsNotNull(response);
            Assert.IsFalse(response.HasError);
            Assert.AreEqual("Success", response.Response.Result);

            var paymentReceipt = response.Response as PaymentReceiptModel;

            Assert.IsNotNull(paymentReceipt);

            var transactions = judo.Consumers.GetRefunds(paymentReceipt.Consumer.ConsumerToken).Result;

            Assert.IsNotNull(transactions);
            Assert.IsFalse(transactions.HasError);
            Assert.IsNotEmpty(transactions.Response.Results);
// ReSharper disable once PossibleNullReferenceException
            Assert.AreEqual(Configuration.Judoid, transactions.Response.Results.FirstOrDefault().JudoId.ToString(CultureInfo.InvariantCulture));
// ReSharper disable once PossibleNullReferenceException
            Assert.AreEqual(paymentReceipt.ReceiptId, transactions.Response.Results.FirstOrDefault().ReceiptId);
        }
Ejemplo n.º 14
0
        public DateTime?GetHandleTime(RefundModel model)
        {
            DateTime?result = null;

            if (model.HandleStatus == RefundStatus.Refunded || model.HandleStatus == RefundStatus.Refused)
            {
                return(model.FinishTime.HasValue ? model.FinishTime : model.AgreedOrRefusedTime);
            }
            return(result);
        }
        public async Task <ActionResult> RefundMoneyDialog(RefundModel model)
        {
            var viewmodel = new RefundMoneyDialogViewModel()
            {
                SelectedMerchant       = model.SelectedMerchant,
                SelectedPaymentRequest = model.SelectedPaymentRequest,
                SelectedWalletAddress  = model.SelectedWalletAddress,
                Wallets = model.Wallets.Split(';').ToList()
            };

            return(View(viewmodel));
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 退款结果查询
        /// </summary>
        /// <param name="argChargeId">支付订单编号</param>
        /// <param name="argRefundId">退款订单编号</param>
        /// <returns></returns>
        public RefundModel Retrieve(string argChargeId, string argRefundId)
        {
            RefundModel model = null;


            string url = PaymaxConfig.API_BASE_URL + PaymaxConfig.CREATE_CHARGE + "/" + argChargeId + "/refunds/" + argRefundId;

            Dictionary <string, string> result = Request(url, null);

            model = convertToModel <RefundModel>(result);

            return(model);
        }
Ejemplo n.º 17
0
        public ValidationResult ValidateUpdate(RefundModel model)
        {
            this.validationResult = new ValidationResult();

            if (model == null)
            {
                this.validationResult.AddErrorMessage(ResourceDesignation.Invalid_Designation);
                return(this.validationResult);
            }

            this.ValidateName(model.EmployeeId);

            return(this.validationResult);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 新增/修改会员信息
        /// </summary>
        /// <param name="memberInfo"></param>
        /// <returns></returns>
        public int PostRefundDetail(RefundModel refundInfo)
        {
            int result = 0;

            try
            {
                result = GenerateDal.Create(refundInfo);
            }
            catch (Exception e)
            {
            }

            return(result);
        }
Ejemplo n.º 19
0
        public async Task ECommerceScenario()
        {
            var clientCert = new X509Certificate2("testcertificates/SwishMerchantTestCertificate1231181189.p12", "swish");
            var caCert     = new X509Certificate2("testcertificates/Swish TLS Root CA.pem");
            var client     = new SwishClient(configuration, clientCert, caCert);

            // Make payment
            var ecommercePaymentModel = new ECommercePaymentModel(
                amount: "100",
                currency: "SEK",
                callbackUrl: "https://example.com/api/swishcb/paymentrequests",
                payerAlias: "1231234567890")
            {
                PayeePaymentReference = "0123456789",
                Message = "Kingston USB Flash Drive 8 GB"
            };

            var paymentResponse = await client.MakeECommercePaymentAsync(ecommercePaymentModel);

            Console.WriteLine("Hello");

            // Wait so that the payment request has been processed
            Thread.Sleep(5000);

            // Check payment request status
            var paymentStatus = await client.GetPaymentStatus(paymentResponse.Id);

            Assert.Equal("PAID", paymentStatus.Status);

            // Make refund
            var refundModel = new RefundModel(
                originalPaymentReference: paymentStatus.PaymentReference,
                callbackUrl: "https://example.com/api/swishcb/refunds",
                payerAlias: "1231181189",
                amount: "100",
                currency: "SEK")
            {
                PayerPaymentReference = "0123456789",
                Message = "Refund for Kingston USB Flash Drive 8 GB"
            };
            var refundResponse = await client.MakeRefundAsync(refundModel);

            // Wait so that the refund request has been processed
            Thread.Sleep(10000);

            // Check refund request status
            var refundStatus = await client.GetRefundStatus(refundResponse.Id);

            Assert.Equal("PAID", refundStatus.Status);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 创建退款请求
        /// </summary>
        /// <param name="argChargeId"></param>
        /// <param name="argParams"></param>
        /// <returns></returns>
        public RefundModel Create(string argChargeId, Dictionary <string, object> argParams)
        {
            RefundModel model = null;


            string url      = PaymaxConfig.API_BASE_URL + PaymaxConfig.CREATE_CHARGE + "/" + argChargeId + "/refunds";
            string jsonData = JsonUtility.ToJsonString(argParams);

            Dictionary <string, string> result = Request(url, jsonData);

            model = convertToModel <RefundModel>(result);

            return(model);
        }
Ejemplo n.º 21
0
        public RefundModel CustomerLastTransaction(RefundModel model)
        {
            var loan = _loanRepository.GetById(model.LoanId);

            if (loan == null)
            {
                return(null);
            }

            var refund = _refundRepository.GetAll()
                         .OrderByDescending(x => x.DateCreated)
                         .FirstOrDefault(x => x.CustomerId == model.CustomerId && x.LoanId == model.LoanId);

            if (refund == null)
            {
                var firstRefund = new Refund
                {
                    Amount      = 0,
                    Balance     = loan.Amount + loan.Interest,
                    CustomerId  = model.CustomerId,
                    EmployeeId  = model.EmployeeId,
                    RefundId    = _generator.GenerateGuid(),
                    Reference   = _generator.RandomNumber(1111111, 9999999),
                    LoanId      = model.LoanId,
                    DateCreated = DateTime.UtcNow.ToLocalTime(),
                    StatusCode  = StatusCode.Confirmed
                };

                _refundRepository.Insert(firstRefund);
                _refundRepository.Save();

                //manual mapping got the job done
                var refundModel = new RefundModel()
                {
                    StatusCode = firstRefund.StatusCode
                };

                return(refundModel);
            }

            //manual mapping got the job done
            var newModel = new RefundModel()
            {
                StatusCode = refund.StatusCode
            };

            return(newModel);
        }
Ejemplo n.º 22
0
        public void ASimplePaymentAndRefund()
        {
            var judo = JudoPaymentsFactory.Create(Configuration.Token,
                                                  Configuration.Secret,
                                                  Configuration.Baseaddress);

            var paymentWithCard = new CardPaymentModel
            {
                JudoId = Configuration.Judoid,
                YourPaymentReference  = "578543",
                YourConsumerReference = "432438862",
                Amount      = 25,
                CardNumber  = "4976000000003436",
                CV2         = "452",
                ExpiryDate  = "12/15",
                CardAddress = new CardAddressModel
                {
                    Line1    = "Test Street",
                    PostCode = "W40 9AU",
                    Town     = "Town"
                }
            };

            var response = judo.Payments.Create(paymentWithCard).Result;

            Assert.IsNotNull(response);
            Assert.IsFalse(response.HasError);
            Assert.AreEqual("Success", response.Response.Result);

            var refund = new RefundModel
            {
                Amount               = 25,
                ReceiptId            = int.Parse(response.Response.ReceiptId),
                YourPaymentReference = "578543"
            };

            response = judo.Refunds.Create(refund).Result;

            Assert.IsNotNull(response);
            Assert.IsFalse(response.HasError);

            var receipt = response.Response as PaymentReceiptModel;

            Assert.IsNotNull(receipt);

            Assert.AreEqual("Success", receipt.Result);
            Assert.AreEqual("Refund", receipt.Type);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 创建退款订单
        /// </summary>
        /// <param name="payClient"></param>
        private static void CreateRefundCharge(PaymaxClient payClient)
        {
            Dictionary <string, object> dic = CreateRefundParmeters();
            String      charge      = "ch_e4cbdb4c9aa9cca77ae49b06";
            RefundModel refundModel = payClient.Refund(charge, dic);

            if (refundModel != null)
            {
                Debug.WriteLine("查询订单:" + refundModel.id);
                Console.WriteLine(refundModel.id);
            }
            else
            {
                Console.WriteLine("查询订单失败");
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 查询退款订单
        /// </summary>
        /// <param name="payClient"></param>
        private static void RetriveRefundCharge(PaymaxClient payClient)
        {
            String      ch_chargeId = "ch_e4cbdb4c9aa9cca77ae49b06";
            String      re_chargeId = "re_50c188e484d82273e00a4bcf";
            RefundModel rm          = payClient.RetrieveRefund(ch_chargeId, re_chargeId);

            if (rm != null)
            {
                Debug.WriteLine("查询退款订单:" + rm.id);
                Console.WriteLine(rm.id);
            }
            else
            {
                Console.WriteLine("查询退款订单失败");
            }
        }
Ejemplo n.º 25
0
        public async Task ECommerceScenario()
        {
            var client = new SwishClient(SwishEnvironment.Test, _merchantCertificateData, _merchantCertificatePassword, _merchantId);

            // Make payment
            var ecommercePaymentModel = new ECommercePaymentModel(
                amount: "100",
                currency: "SEK",
                callbackUrl: "https://example.com/api/swishcb/paymentrequests",
                payerAlias: "1231234567890")
            {
                PayeePaymentReference = "0123456789",
                Message = "Kingston USB Flash Drive 8 GB"
            };

            var paymentResponse = await client.MakeECommercePaymentAsync(ecommercePaymentModel);

            // Wait so that the payment request has been processed
            await Task.Delay(5000);

            // Check payment request status
            var paymentStatus = await client.GetPaymentStatus(paymentResponse.Id);

            Assert.Equal("PAID", paymentStatus.Status);

            // Make refund
            var refundModel = new RefundModel(
                originalPaymentReference: paymentStatus.PaymentReference,
                callbackUrl: "https://example.com/api/swishcb/refunds",
                payerAlias: "1231181189",
                amount: "100",
                currency: "SEK")
            {
                PayerPaymentReference = "0123456789",
                Message = "Refund for Kingston USB Flash Drive 8 GB"
            };
            var refundResponse = await client.MakeRefundAsync(refundModel);

            // Wait so that the refund request has been processed
            await Task.Delay(10000);

            // Check refund request status
            var refundStatus = await client.GetRefundStatus(refundResponse.Id);

            Assert.Equal("PAID", refundStatus.Status);
        }
Ejemplo n.º 26
0
        public RefundModel GetRefundPayment(Guid customerId, string paymentId)
        {
            //Customer customer = _customerRepository.Get(customerId);

            var payment = StripeFactory.GetStripeService().GetCustomerPayment(paymentId);

            var viewModel = new RefundModel
            {
                CustomerId = customerId,
                PaymentId  = paymentId,
                Amount     = GetRemainingAmount(
                    payment.Amount,
                    payment.AmountRefunded),
            };

            return(viewModel);
        }
Ejemplo n.º 27
0
        public RefundModel CustomerLastConfirmedTransaction(RefundModel model)
        {
            var refund = _refundRepository.GetAll()
                         .OrderByDescending(x => x.DateCreated)
                         .FirstOrDefault(x => x.CustomerId == model.CustomerId && x.LoanId == model.LoanId && x.StatusCode == StatusCode.Confirmed);

            if (refund == null)
            {
                return(null);
            }

            var newModel = new RefundModel()
            {
                Amount  = refund.Amount,
                Balance = refund.Balance,
            };

            return(newModel);
        }
Ejemplo n.º 28
0
        public Response <RefundModel> Update(RefundModel model)
        {
            try
            {
                var validationResult = _refundValidation.ValidateUpdate(model);
                if (!validationResult.IsValid)
                {
                    return new Response <RefundModel>
                           {
                               Message    = validationResult.ErrorMessage,
                               ResultType = ResultType.ValidationError
                           }
                }
                ;

                var existingModel = _refundRepository.GetById(model.RefundId);
                if (existingModel != null)
                {
                    existingModel.Balance = model.Balance;

                    existingModel.StatusCode = model.StatusCode;
                }

                _refundRepository.Update(existingModel);
                _refundRepository.Save();

                return(new Response <RefundModel>
                {
                    Result = model,
                    ResultType = ResultType.Success
                });
            }
            catch (Exception ex)
            {
                //online error log
                var err = ex.Message;
            }

            return(new Response <RefundModel>
            {
                ResultType = ResultType.Error
            });
        }
Ejemplo n.º 29
0
        public ActionResult RefundPayment(RefundModel refundModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    CustomersDetailsModel customer = _customerService.GetCustomerDetails(refundModel.CustomerId);
                    if (customer == null)
                    {
                        return(HttpNotFound());
                    }

                    var payment         = StripeFactory.GetStripeService().GetCustomerPayment(refundModel.PaymentId);
                    var remainingAmount = GetRemainingAmount(
                        payment.Amount,
                        payment.AmountRefunded);
                    if (refundModel.Amount > remainingAmount)
                    {
                        return(RedirectToAction("payments", "customers", new { id = refundModel.CustomerId })
                               .AndAlert(AlertType.Danger, "Error.", "Provided data is incorrect."));
                    }

                    StripeFactory.GetStripeService().Refund(refundModel.PaymentId, refundModel.AmountCents);
                }
                catch
                {
                    return(RedirectToAction("payments", "customers", new { id = refundModel.CustomerId })
                           .AndAlert(AlertType.Danger, "Refund error.", "Error was thrown during refunding payment."));
                }

                return(RedirectToAction("payments", "customers", new { id = refundModel.CustomerId })
                       .AndAlert(AlertType.Success, "Refund.", "Payment was refunded sucessfully."));
            }

            return(RedirectToAction("payments", "customers", new { id = refundModel.CustomerId })
                   .AndAlert(AlertType.Danger, "Error.", "Provided data is incorrect."));
        }
Ejemplo n.º 30
0
        public void GetRefundsTransactions()
        {
            var paymentWithCard = GetCardPaymentModel("432438862");

            var paymentResponse = JudoPayApi.Payments.Create(paymentWithCard).Result;

            Assert.IsNotNull(paymentResponse);
            Assert.IsFalse(paymentResponse.HasError);
            Assert.AreEqual("Success", paymentResponse.Response.Result);

            var refund = new RefundModel
            {
                Amount    = 25,
                ReceiptId = paymentResponse.Response.ReceiptId,
            };

            var response = JudoPayApi.Refunds.Create(refund).Result;

            Assert.IsNotNull(response);
            Assert.IsFalse(response.HasError);
            Assert.AreEqual("Success", response.Response.Result);

            var paymentReceipt = response.Response as PaymentReceiptModel;

            Assert.IsNotNull(paymentReceipt);

            var transactions = JudoPayApi.Consumers.GetRefunds(paymentReceipt.Consumer.ConsumerToken).Result;

            Assert.IsNotNull(transactions);
            Assert.IsFalse(transactions.HasError);
            Assert.IsNotEmpty(transactions.Response.Results);
            // ReSharper disable once PossibleNullReferenceException
            Assert.AreEqual(Configuration.Judoid, transactions.Response.Results.FirstOrDefault().JudoId.ToString(CultureInfo.InvariantCulture));
            // ReSharper disable once PossibleNullReferenceException
            Assert.IsTrue(transactions.Response.Results.Any(t => t.ReceiptId == response.Response.ReceiptId));
        }