public IActionResult Create()
        {
            HttpRequestChecker.RequieAjaxRequest();
            var orderManager          = Application.Ioc.Resolve <OrderManager>();
            var transactionManager    = Application.Ioc.Resolve <PaymentTransactionManager>();
            var sessionManager        = Application.Ioc.Resolve <SessionManager>();
            var createOrderParameters = HttpManager.CurrentContext.Request
                                        .Get <CreateOrderParameters>("CreateOrderParameters") ?? new CreateOrderParameters();

            createOrderParameters.SetLoginInfo();
            var result      = orderManager.CreateOrder(createOrderParameters);
            var transaction = result.CreatedTransactions.Last();
            var paymentUrl  = transactionManager.GetPaymentUrl(transaction.Id);

            return(new JsonResult(new { script = ScriptStrings.Redirect(paymentUrl) }));
        }
        /// <summary>
        /// 提交表单
        /// </summary>
        /// <returns></returns>
        protected override object OnSubmit()
        {
            // 创建交易
            var api                = GetApiFromRequest();
            var sessionManager     = Application.Ioc.Resolve <SessionManager>();
            var payerId            = sessionManager.GetSession().GetUser().Id;
            var payeeId            = api.Owner == null ? null : (long?)api.Owner.Id;
            var transactionManager = Application.Ioc.Resolve <PaymentTransactionManager>();
            var transaction        = transactionManager.CreateTestTransaction(api.Id, Amount, Currency, payerId, payeeId, Description);
            // 跳转到支付url地址
            var url = transactionManager.GetPaymentUrl(transaction.Id);

            return(new {
                message = new T("Create test transaction success, redirecting to payment page..."),
                script = ScriptStrings.Redirect(url, 3000)
            });
        }
Beispiel #3
0
            /// <summary>
            /// 提交表单
            /// </summary>
            /// <returns></returns>
            protected override object OnSubmit()
            {
                // 检查支付密码是否正确
                var apiData = Transaction.Api.ExtraData.GetOrDefault <ApiData>("ApiData") ?? new ApiData();

                apiData.CheckPaymentPassword(PaymentPassword);
                // 按类型执行支付操作
                UnitOfWork.WriteRepository <PaymentTransactionRepository>(r => {
                    var state = PayType == (int)PayTypes.ImmediateArrival ?
                                PaymentTransactionState.Success : PaymentTransactionState.SecuredPaid;
                    r.Process(Transaction.Id, null, state);
                });
                // 返回成功并跳转到交易结果页
                var resultUrl = string.Format("/payment/transaction/pay_result?id={0}", Transaction.Id);

                return(new {
                    message = new T("Payment Successfully, Redirecting to result page..."),
                    script = ScriptStrings.Redirect(resultUrl, 3000)
                });
            }