Пример #1
0
        public ActionResult GetPayResult(AllInOne oPayment, string OrderKey = "")
        {
            try
            {
                string        MyAppDomain = ConfigurationManager.AppSettings["MyAppDomain"];
                List <string> enErrors    = new List <string>();
                Hashtable     htFeedback  = null;

                oPayment.HashKey = ConfigurationManager.AppSettings["HashKey"];
                oPayment.HashIV  = ConfigurationManager.AppSettings["HashIV"];
                enErrors.AddRange(oPayment.CheckOutFeedback(ref htFeedback));

                if (enErrors.Count() == 0)
                {
                    // 將 KEY 加密
                    byte[] keyBytes     = Encoding.UTF8.GetBytes(OrderKey + string.Join("", OrderKey.Reverse()));
                    string EncryptedKey = Convert.ToBase64String(keyBytes);
                    using (var md5 = MD5.Create())
                    {
                        var result = md5.ComputeHash(Encoding.ASCII.GetBytes(EncryptedKey));
                        EncryptedKey = BitConverter.ToString(result);
                    }

                    return(Redirect($"{MyAppDomain}/OrderForm/CheckPayResult/?OrderKey={EncryptedKey}&PaySuccess=true"));
                }
                else
                {
                    return(Redirect($"{MyAppDomain}/OrderForm/CheckPayResult/?PaySuccess=false"));
                }
            }
            catch (Exception e)
            {
                return(Content($"發生錯誤{e},請將錯誤訊息截圖並寄給網站的管理員!"));
            }
        }
Пример #2
0
        public TradeResultModel ResolveTradeResult(HttpRequest request)
        {
            List <string> enErrors   = new List <string>();
            Hashtable     htFeedback = null;

            try
            {
                using (var oPayment = new AllInOne())
                {
                    oPayment.HashKey = ECPayHashKey;
                    oPayment.HashIV  = ECPayHashIV;
                    /* 取回付款結果 */
                    enErrors.AddRange(oPayment.CheckOutFeedback(request, ref htFeedback));
                }

                if (enErrors.IsNullOrEmpty())
                {
                    _appLogger.LogInfo($"htFeedback: {JsonConvert.SerializeObject(htFeedback)}");

                    var tradeResultModel = new TradeResultModel()
                    {
                        Provider = _ecpaySettings.Id,
                        Code     = htFeedback["MerchantTradeNo"].ToString(),
                        TradeNo  = htFeedback["TradeNo"].ToString(),
                        Amount   = htFeedback["TradeAmt"].ToString().ToInt()
                    };

                    var rtnCode = htFeedback["RtnCode"].ToString().ToInt();
                    if (rtnCode == 1) //付款成功
                    {
                        bool simulatePaid = false;
                        if (htFeedback.ContainsKey("SimulatePaid"))
                        {
                            simulatePaid = htFeedback["SimulatePaid"].ToString().ToInt() > 0;
                        }

                        tradeResultModel.Simulate = simulatePaid; //是否為模擬的付款紀錄

                        tradeResultModel.Payed     = true;
                        tradeResultModel.PayedDate = htFeedback["PaymentDate"].ToString();
                        tradeResultModel.PayWay    = GetPaymentType(htFeedback["PaymentType"].ToString());
                    }
                    else if (rtnCode == 2) //ATM 取號成功
                    {
                        tradeResultModel.Payed       = false;
                        tradeResultModel.PayWay      = GetPaymentType(htFeedback["PaymentType"].ToString());
                        tradeResultModel.BankCode    = htFeedback["BankCode"].ToString();
                        tradeResultModel.BankAccount = htFeedback["vAccount"].ToString();
                        tradeResultModel.ExpireDate  = htFeedback["ExpireDate"].ToString();
                    }
                    else
                    {
                        //Failed
                        throw new EcPayTradeFeedBackFailed($"htFeedback: {JsonConvert.SerializeObject(htFeedback)}");
                    }

                    tradeResultModel.Data = JsonConvert.SerializeObject(htFeedback);
                    return(tradeResultModel);
                }
                else
                {
                    //has error
                    throw new EcPayTradeFeedBackError(String.Join("\\r\\n", enErrors));
                }
            }
            catch (Exception ex)
            {
                throw new EcPayTradeFeedBackError(ex.Message, ex);
            }
        }
Пример #3
0
        //網購傳回ATM訂單
        public void orderATM(string callback)
        {
            MotaiDataEntities dbContext  = new MotaiDataEntities();
            List <string>     enErrors   = new List <string>();
            Hashtable         htFeedback = null;

            try
            {
                using (AllInOne oPayment = new AllInOne())
                {
                    oPayment.HashKey = "5294y06JbISpM5x9";
                    oPayment.HashIV  = "v77hoKGq4kWxNNIS";
                    /* 取回付款結果 */
                    enErrors.AddRange(oPayment.CheckOutFeedback(ref htFeedback));
                }
                // 取回所有資料
                if (enErrors.Count() == 0)
                {
                    /* 支付後的回傳的基本參數 */
                    string szMerchantID      = String.Empty;
                    string szMerchantTradeNo = String.Empty;
                    string szPaymentType     = String.Empty;
                    string szRtnCode         = String.Empty;
                    string szRtnMsg          = String.Empty;
                    string szTradeAmt        = String.Empty;
                    string szTradeDate       = String.Empty;
                    string szTradeNo         = String.Empty;
                    string szBankCode        = String.Empty;
                    string szVirtualAccount  = String.Empty;
                    string szExpireDate      = String.Empty;
                    // 取得資料
                    foreach (string szKey in htFeedback.Keys)
                    {
                        switch (szKey)
                        {
                        /* 支付後的回傳的基本參數 */
                        case "MerchantID": szMerchantID = htFeedback[szKey].ToString(); break;

                        case "MerchantTradeNo": szMerchantTradeNo = htFeedback[szKey].ToString();
                            break;

                        case "RtnCode": szRtnCode = htFeedback[szKey].ToString(); break;

                        case "RtnMsg": szRtnMsg = htFeedback[szKey].ToString(); break;

                        case "TradeNo": szTradeNo = htFeedback[szKey].ToString(); break;

                        case "TradeAmt": szTradeAmt = htFeedback[szKey].ToString(); break;

                        case "PaymentType": szPaymentType = htFeedback[szKey].ToString(); break;

                        case "TradeDate": szTradeDate = htFeedback[szKey].ToString(); break;

                        case "BankCode": szBankCode = htFeedback[szKey].ToString(); break;

                        case "vAccount": szVirtualAccount = htFeedback[szKey].ToString(); break;

                        case "ExpireDate": szExpireDate = htFeedback[szKey].ToString(); break;

                        default:
                            break;
                        }
                    }
                    WebOrderModel Trade = Session[szMerchantTradeNo] as WebOrderModel;
                    //先建訂單
                    tOrder newOrder = new tOrder();
                    newOrder.oCustomerId    = Trade.customer.CustomerId;
                    newOrder.oDate          = Trade.payDate;
                    newOrder.oAddress       = Trade.webpay.shipAddress;
                    newOrder.oWarehouseName = 1;
                    dbContext.tOrders.Add(newOrder);
                    dbContext.SaveChanges();
                    tOrder CreateOrder = dbContext.tOrders.OrderByDescending(o => o.OrderId).FirstOrDefault();
                    foreach (var item in Trade.boughtList)
                    {
                        tOrderDetail orderDetail = new tOrderDetail();
                        orderDetail.oOrderId    = CreateOrder.OrderId;
                        orderDetail.oProductId  = item.sProductId;
                        orderDetail.oProductQty = item.sProductQty;
                        dbContext.tOrderDetails.Add(orderDetail);
                        dbContext.tStatus.Remove(item);
                    }
                    dbContext.SaveChanges();
                }
                else
                {
                    // 其他資料處理。
                }
            }
            catch (Exception ex)
            {
                // 例外錯誤處理。
                enErrors.Add(ex.Message);
            }
            finally
            {
                this.Response.Clear();
                // 回覆成功訊息。
                if (enErrors.Count() == 0)
                {
                    this.Response.Write("1|OK");
                }
                // 回覆錯誤訊息。
                else
                {
                    this.Response.Write(String.Format("0|{0}", String.Join("\\r\\n", enErrors)));
                }
                this.Response.Flush();
                this.Response.End();
            }
        }
Пример #4
0
        //public static WebOrderModel order;
        //網購接受信用卡訂單
        public ActionResult orderCredit()
        {
            MotaiDataEntities dbContext  = new MotaiDataEntities();
            List <string>     enErrors   = new List <string>();
            Hashtable         htFeedback = null;

            try
            {
                using (AllInOne oPayment = new AllInOne())
                {
                    oPayment.HashKey = "5294y06JbISpM5x9";
                    oPayment.HashIV  = "v77hoKGq4kWxNNIS";
                    /* 取回付款結果 */
                    enErrors.AddRange(oPayment.CheckOutFeedback(ref htFeedback));
                    //htFeedback.Values[];
                }

                // 取回所有資料
                if (enErrors.Count() == 0)
                {
                    /* 支付後的回傳的基本參數 */
                    string szMerchantID      = String.Empty;
                    string szMerchantTradeNo = String.Empty;
                    string szRtnCode         = String.Empty;
                    string szRtnMsg          = String.Empty;
                    /* 使用定期定額交易時,回傳的額外參數 */
                    string szPeriodType        = String.Empty;
                    string szFrequency         = String.Empty;
                    string szExecTimes         = String.Empty;
                    string szAmount            = String.Empty;
                    string szGwsr              = String.Empty;
                    string szProcessDate       = String.Empty;
                    string szAuthCode          = String.Empty;
                    string szFirstAuthAmount   = String.Empty;
                    string szTotalSuccessTimes = String.Empty;
                    // 取得資料
                    foreach (string szKey in htFeedback.Keys)
                    {
                        switch (szKey)
                        {
                        /* 使用定期定額交易時回傳的參數 */
                        case "MerchantID": szMerchantID = htFeedback[szKey].ToString(); break;

                        case "MerchantTradeNo": szMerchantTradeNo = htFeedback[szKey].ToString();
                            break;

                        case "RtnCode": szRtnCode = htFeedback[szKey].ToString(); break;

                        case "RtnMsg": szRtnMsg = htFeedback[szKey].ToString(); break;

                        case "PeriodType": szPeriodType = htFeedback[szKey].ToString(); break;

                        case "Frequency": szFrequency = htFeedback[szKey].ToString(); break;

                        case "ExecTimes": szExecTimes = htFeedback[szKey].ToString(); break;

                        case "Amount": szAmount = htFeedback[szKey].ToString(); break;

                        case "Gwsr": szGwsr = htFeedback[szKey].ToString(); break;

                        case "ProcessDate": szProcessDate = htFeedback[szKey].ToString(); break;

                        case "AuthCode": szAuthCode = htFeedback[szKey].ToString(); break;

                        case "FirstAuthAmount": szFirstAuthAmount = htFeedback[szKey].ToString();
                            break;

                        case "TotalSuccessTimes": szTotalSuccessTimes = htFeedback[szKey].ToString();
                            break;

                        default: break;
                        }
                    }
                    //WebOrderModel order = http.Session[szMerchantTradeNo] as WebOrderModel;
                    ////先建訂單
                    //tOrder newOrder = new tOrder();
                    //newOrder.oCustomerId = order.customer.CustomerId;
                    //newOrder.oDate = order.payDate;
                    //newOrder.oAddress = order.webpay.shipAddress;
                    //newOrder.oWarehouseName = 1;
                    //dbContext.tOrders.Add(newOrder);
                    //dbContext.SaveChanges();
                    //tOrder CreateOrder = dbContext.tOrders.OrderByDescending(o => o.OrderId).FirstOrDefault();
                    //tOrderPay pay = new tOrderPay();
                    //pay.oOrderId = CreateOrder.OrderId;
                    //pay.oOrderInstallment = 1;
                    //pay.oPayType = order.webpay.payType;
                    //pay.oPayment = Convert.ToInt32(order.webpay.totalPay);
                    //pay.oPayDate = order.payDate;
                    //dbContext.tOrderPays.Add(pay);
                    //foreach (var item in order.boughtList)
                    //{
                    //    tOrderDetail orderDetail = new tOrderDetail();
                    //    orderDetail.oOrderId = CreateOrder.OrderId;
                    //    orderDetail.oProductId = item.sProductId;
                    //    orderDetail.oProductQty = item.sProductQty;
                    //    dbContext.tOrderDetails.Add(orderDetail);
                    //    dbContext.tStatus.Remove(item);
                    //    dbContext.SaveChanges();
                    //}
                    //dbContext.SaveChanges();
                }
                else
                {
                    // 其他資料處理。
                }
            }
            catch (Exception ex)
            {
                // 例外錯誤處理。
                enErrors.Add(ex.Message);
            }
            finally
            {
                this.Response.Clear();
                // 回覆成功訊息。
                if (enErrors.Count() == 0)
                {
                    this.Response.Write("1|OK");
                }
                // 回覆錯誤訊息。
                else
                {
                    this.Response.Write(String.Format("0|{0}", String.Join("\\r\\n", enErrors)));
                }
                this.Response.Flush();
                this.Response.End();
            }
            return(View(htFeedback));
        }
Пример #5
0
        public ActionResult test()
        {
            List <string> enErrors   = new List <string>();
            Hashtable     htFeedback = null;

            try
            {
                using (AllInOne oPayment = new AllInOne())
                {
                    oPayment.HashKey = "5294y06JbISpM5x9";
                    oPayment.HashIV  = "v77hoKGq4kWxNNIS";
                    /* 取回付款結果 */
                    enErrors.AddRange(oPayment.CheckOutFeedback(ref htFeedback));
                    //htFeedback.Values[];
                }

                // 取回所有資料
                if (enErrors.Count() == 0)
                {
                    /* 支付後的回傳的基本參數 */
                    string szMerchantID      = String.Empty;
                    string szMerchantTradeNo = String.Empty;
                    string szRtnCode         = String.Empty;
                    string szRtnMsg          = String.Empty;
                    /* 使用定期定額交易時,回傳的額外參數 */
                    string szPeriodType        = String.Empty;
                    string szFrequency         = String.Empty;
                    string szExecTimes         = String.Empty;
                    string szAmount            = String.Empty;
                    string szGwsr              = String.Empty;
                    string szProcessDate       = String.Empty;
                    string szAuthCode          = String.Empty;
                    string szFirstAuthAmount   = String.Empty;
                    string szTotalSuccessTimes = String.Empty;
                    // 取得資料
                    foreach (string szKey in htFeedback.Keys)
                    {
                        switch (szKey)
                        {
                        /* 使用定期定額交易時回傳的參數 */
                        case "MerchantID": szMerchantID = htFeedback[szKey].ToString(); break;

                        case "MerchantTradeNo":
                            szMerchantTradeNo = htFeedback[szKey].ToString();
                            break;

                        case "RtnCode": szRtnCode = htFeedback[szKey].ToString(); break;

                        case "RtnMsg": szRtnMsg = htFeedback[szKey].ToString(); break;

                        case "PeriodType": szPeriodType = htFeedback[szKey].ToString(); break;

                        case "Frequency": szFrequency = htFeedback[szKey].ToString(); break;

                        case "ExecTimes": szExecTimes = htFeedback[szKey].ToString(); break;

                        case "Amount": szAmount = htFeedback[szKey].ToString(); break;

                        case "Gwsr": szGwsr = htFeedback[szKey].ToString(); break;

                        case "ProcessDate": szProcessDate = htFeedback[szKey].ToString(); break;

                        case "AuthCode": szAuthCode = htFeedback[szKey].ToString(); break;

                        case "FirstAuthAmount":
                            szFirstAuthAmount = htFeedback[szKey].ToString();
                            break;

                        case "TotalSuccessTimes":
                            szTotalSuccessTimes = htFeedback[szKey].ToString();
                            break;

                        default: break;
                        }
                    }

                    WebOrderModel Trade = Session[szMerchantTradeNo] as WebOrderModel;
                }
                else
                {
                    // 其他資料處理。
                }
            }
            catch (Exception ex)
            {
                // 例外錯誤處理。
                enErrors.Add(ex.Message);
            }
            finally
            {
                this.Response.Clear();
                // 回覆成功訊息。
                if (enErrors.Count() == 0)
                {
                    this.Response.Write("1|OK");
                }
                // 回覆錯誤訊息。
                else
                {
                    this.Response.Write(String.Format("0|{0}", String.Join("\\r\\n", enErrors)));
                }
                this.Response.Flush();
                this.Response.End();
            }
            return(View(htFeedback));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            /*
             *  接收訂單資料產生完成的範例程式碼。
             */
            List <string> enErrors   = new List <string>();
            Hashtable     htFeedback = null;

            try
            {
                using (AllInOne oPayment = new AllInOne())
                {
                    oPayment.HashKey = "<<Hash Key>>";
                    oPayment.HashIV  = "<<Hash IV>>";
                    /* 取回付款結果 */
                    enErrors.AddRange(oPayment.CheckOutFeedback(ref htFeedback));
                }
                // 取回所有資料
                if (enErrors.Count() == 0)
                {
                    /* 支付後的回傳的基本參數 */
                    string szMerchantID           = String.Empty;
                    string szMerchantTradeNo      = String.Empty;
                    string szPaymentDate          = String.Empty;
                    string szPaymentType          = String.Empty;
                    string szPaymentTypeChargeFee = String.Empty;
                    string szRtnCode      = String.Empty;
                    string szRtnMsg       = String.Empty;
                    string szSimulatePaid = String.Empty;
                    string szTradeAmt     = String.Empty;
                    string szTradeDate    = String.Empty;
                    string szTradeNo      = String.Empty;
                    /* 使用定期定額交易時,回傳的額外參數 */
                    string szPeriodType        = String.Empty;
                    string szFrequency         = String.Empty;
                    string szExecTimes         = String.Empty;
                    string szAmount            = String.Empty;
                    string szGwsr              = String.Empty;
                    string szProcessDate       = String.Empty;
                    string szAuthCode          = String.Empty;
                    string szFirstAuthAmount   = String.Empty;
                    string szTotalSuccessTimes = String.Empty;
                    /* 使用 ATM、CVS 或 BARCODE 交易時,回傳的額外參數 */
                    string szExpireDate = String.Empty;
                    /* 使用 ATM 交易時,回傳的額外參數 */
                    string szBankCode       = String.Empty;
                    string szVirtualAccount = String.Empty;
                    /* 使用 CVS 或 BARCODE 交易時,回傳的額外參數 */
                    string szPaymentNo = String.Empty;
                    string szBarcode1  = String.Empty;
                    string szBarcode2  = String.Empty;
                    string szBarcode3  = String.Empty;
                    // 取得資料於畫面
                    foreach (string szKey in htFeedback.Keys)
                    {
                        switch (szKey)
                        {
                        /* 支付後的回傳的基本參數 */
                        case "MerchantID": szMerchantID = this.Request.Form[szKey]; break;

                        case "MerchantTradeNo": szMerchantTradeNo = this.Request.Form[szKey]; break;

                        case "PaymentDate": szPaymentDate = this.Request.Form[szKey]; break;

                        case "PaymentType": szPaymentType = this.Request.Form[szKey]; break;

                        case "PaymentTypeChargeFee": szPaymentTypeChargeFee = this.Request.Form[szKey]; break;

                        case "RtnCode": szRtnCode = this.Request.Form[szKey]; break;

                        case "RtnMsg": szRtnMsg = this.Request.Form[szKey]; break;

                        case "SimulatePaid": szSimulatePaid = this.Request.Form[szKey]; break;

                        case "TradeAmt": szTradeAmt = this.Request.Form[szKey]; break;

                        case "TradeDate": szTradeDate = this.Request.Form[szKey]; break;

                        case "TradeNo": szTradeNo = this.Request.Form[szKey]; break;

                        /* 使用定期定額交易時回傳的參數 */
                        //case "MerchantID": szMerchantID = this.Request.Form[szKey]; break;
                        //case "MerchantTradeNo": szMerchantTradeNo = this.Request.Form[szKey]; break;
                        //case "RtnCode": szRtnCode = this.Request.Form[szKey]; break;
                        //case "RtnMsg": szRtnMsg = this.Request.Form[szKey]; break;
                        //case "PeriodType": szPeriodType = this.Request.Form[szKey]; break;
                        //case "Frequency": szFrequency = this.Request.Form[szKey]; break;
                        //case "ExecTimes": szExecTimes = this.Request.Form[szKey]; break;
                        //case "Amount": szAmount = this.Request.Form[szKey]; break;
                        //case "Gwsr": szGwsr = this.Request.Form[szKey]; break;
                        //case "ProcessDate": szProcessDate = this.Request.Form[szKey]; break;
                        //case "AuthCode": szAuthCode = this.Request.Form[szKey]; break;
                        //case "FirstAuthAmount": szFirstAuthAmount = this.Request.Form[szKey]; break;
                        //case "TotalSuccessTimes": szTotalSuccessTimes = this.Request.Form[szKey]; break;

                        /* 使用 ATM 交易時回傳的參數 */
                        //case "MerchantID": szMerchantID = this.Request.Form[szKey]; break;
                        //case "MerchantTradeNo": szMerchantTradeNo = this.Request.Form[szKey]; break;
                        //case "RtnCode": szRtnCode = this.Request.Form[szKey]; break;
                        //case "RtnMsg": szRtnMsg = this.Request.Form[szKey]; break;
                        //case "TradeNo": szTradeNo = this.Request.Form[szKey]; break;
                        //case "TradeAmt": szTradeAmt = this.Request.Form[szKey]; break;
                        //case "PaymentType": szPaymentType = this.Request.Form[szKey]; break;
                        //case "TradeDate": szTradeDate = this.Request.Form[szKey]; break;
                        //case "BankCode": szBankCode = this.Request.Form[szKey]; break;
                        //case "vAccount": szVirtualAccount = this.Request.Form[szKey]; break;
                        //case "ExpireDate": szExpireDate = this.Request.Form[szKey]; break;

                        /* 使用 CVS 或 BARCODE 交易時回傳的參數 */
                        //case "MerchantID": szMerchantID = this.Request.Form[szKey]; break;
                        //case "MerchantTradeNo": szMerchantTradeNo = this.Request.Form[szKey]; break;
                        //case "RtnCode": szRtnCode = this.Request.Form[szKey]; break;
                        //case "RtnMsg": szRtnMsg = this.Request.Form[szKey]; break;
                        //case "TradeNo": szTradeNo = this.Request.Form[szKey]; break;
                        //case "TradeAmt": szTradeAmt = this.Request.Form[szKey]; break;
                        //case "PaymentType": szPaymentType = this.Request.Form[szKey]; break;
                        //case "TradeDate": szTradeDate = this.Request.Form[szKey]; break;
                        //case "PaymentNo": szPaymentNo = this.Request.Form[szKey]; break;
                        //case "ExpireDate": szExpireDate = this.Request.Form[szKey]; break;
                        //case "Barcode1": szBarcode1 = this.Request.Form[szKey]; break;
                        //case "Barcode2": szBarcode2 = this.Request.Form[szKey]; break;
                        //case "Barcode3": szBarcode3 = this.Request.Form[szKey]; break;

                        default: break;
                        }
                    }
                    // 其他資料處理。
                }
            }
            catch (Exception ex)
            {
                enErrors.Add(ex.Message);
            }
            finally
            {
                this.Response.Clear();
                // 回覆成功訊息。
                if (enErrors.Count() == 0)
                {
                    this.Response.Write("1|OK");
                }
                // 回覆錯誤訊息。
                else
                {
                    this.Response.Write(String.Format("0|{0}", String.Join("\\r\\n", enErrors)));
                }
                this.Response.Flush();
                this.Response.End();
            }
        }
Пример #7
0
        /// <summary>
        /// 綠界結帳後的檢查碼
        /// </summary>
        public void CheckECPayFeedBack()
        {
            List <string> enErrors   = new List <string>();
            Hashtable     htFeedback = null;

            try
            {
                using (AllInOne oPayment = new AllInOne())
                {
                    oPayment.HashKey = "5294y06JbISpM5x9"; //ECPay 提供的 HashKey
                    oPayment.HashIV  = "v77hoKGq4kWxNNIS"; //ECPay 提供的 HashIV
                    /* 取回付款結果 */
                    enErrors.AddRange(oPayment.CheckOutFeedback(ref htFeedback));
                }
                // 取回所有資料
                if (enErrors.Count() == 0)
                {
                    /* 支付後的回傳的基本參數 */
                    string szMerchantID           = String.Empty;
                    string szMerchantTradeNo      = String.Empty;
                    string szPaymentDate          = String.Empty;
                    string szPaymentType          = String.Empty;
                    string szPaymentTypeChargeFee = String.Empty;
                    string szRtnCode      = String.Empty;
                    string szRtnMsg       = String.Empty;
                    string szSimulatePaid = String.Empty;
                    string szTradeAmt     = String.Empty;
                    string szTradeDate    = String.Empty;
                    string szTradeNo      = String.Empty;
                    // 取得資料
                    foreach (string szKey in htFeedback.Keys)
                    {
                        switch (szKey)
                        {
                        /* 支付後的回傳的基本參數 */
                        case "MerchantID": szMerchantID = htFeedback[szKey].ToString(); break;

                        case "MerchantTradeNo": szMerchantTradeNo = htFeedback[szKey].ToString(); break;

                        case "PaymentDate": szPaymentDate = htFeedback[szKey].ToString(); break;

                        case "PaymentType": szPaymentType = htFeedback[szKey].ToString(); break;

                        case "PaymentTypeChargeFee": szPaymentTypeChargeFee = htFeedback[szKey].ToString(); break;

                        case "RtnCode": szRtnCode = htFeedback[szKey].ToString(); break;

                        case "RtnMsg": szRtnMsg = htFeedback[szKey].ToString(); break;

                        case "SimulatePaid": szSimulatePaid = htFeedback[szKey].ToString(); break;

                        case "TradeAmt": szTradeAmt = htFeedback[szKey].ToString(); break;

                        case "TradeDate": szTradeDate = htFeedback[szKey].ToString(); break;

                        case "TradeNo": szTradeNo = htFeedback[szKey].ToString(); break;

                        default: break;
                        }
                    }
                }
                else
                {
                    // 其他資料處理。
                }
            }
            catch (Exception ex)
            {
                // 例外錯誤處理。
                enErrors.Add(ex.Message);
            }
            finally
            {
                this.Response.Clear();
                // 回覆成功訊息。
                if (enErrors.Count() == 0)
                {
                    this.Response.Write("1|OK");
                }
                // 回覆錯誤訊息。
                else
                {
                    this.Response.Write(String.Format("0|{0}", String.Join("\\r\\n", enErrors)));
                    this.Response.Flush();
                    this.Response.End();
                }
            }
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <string> enErrors   = new List <string>();
            Hashtable     htFeedback = null;

            try
            {
                using (AllInOne oPayment = new AllInOne())
                {
                    oPayment.HashKey = "5294y06JbISpM5x9"; //ECPay 提供的 HashKey
                    oPayment.HashIV  = "v77hoKGq4kWxNNIS"; //ECPay 提供的 HashIV
                    /* 取回付款結果 */
                    enErrors.AddRange(oPayment.CheckOutFeedback(ref htFeedback));
                }
                // 取回所有資料
                if (enErrors.Count() == 0)
                {
                    /* 支付後的回傳的基本參數 */
                    string szMerchantID      = String.Empty;
                    string szMerchantTradeNo = String.Empty;
                    string szPaymentType     = String.Empty;
                    string szRtnCode         = String.Empty;
                    string szRtnMsg          = String.Empty;
                    string szTradeAmt        = String.Empty;
                    string szTradeDate       = String.Empty;
                    string szTradeNo         = String.Empty;
                    /* 使用 CVS 交易時,回傳的額外參數 */
                    string szPaymentNo  = String.Empty;
                    string szExpireDate = String.Empty;
                    string szBarcode1   = String.Empty;
                    string szBarcode2   = String.Empty;
                    string szBarcode3   = String.Empty;
                    // 取得資料於畫面
                    foreach (string szKey in htFeedback.Keys)
                    {
                        switch (szKey)
                        {
                        /* 使用 CVS 交易時回傳的參數 */
                        case "MerchantID": szMerchantID = htFeedback[szKey].ToString(); break;

                        case "MerchantTradeNo": szMerchantTradeNo = htFeedback[szKey].ToString(); break;

                        case "RtnCode": szRtnCode = htFeedback[szKey].ToString(); break;

                        case "RtnMsg": szRtnMsg = htFeedback[szKey].ToString(); break;

                        case "TradeNo": szTradeNo = htFeedback[szKey].ToString(); break;

                        case "TradeAmt": szTradeAmt = htFeedback[szKey].ToString(); break;

                        case "PaymentType": szPaymentType = htFeedback[szKey].ToString(); break;

                        case "TradeDate": szTradeDate = htFeedback[szKey].ToString(); break;

                        case "PaymentNo": szPaymentNo = htFeedback[szKey].ToString(); break;

                        case "ExpireDate": szExpireDate = htFeedback[szKey].ToString(); break;

                        case "Barcode1": szBarcode1 = htFeedback[szKey].ToString(); break;

                        case "Barcode2": szBarcode2 = htFeedback[szKey].ToString(); break;

                        case "Barcode3": szBarcode3 = htFeedback[szKey].ToString(); break;

                        default: break;
                        }
                    }
                    // 其他資料處理。
                }
                else
                {
                    // 其他資料處理。
                }
            }
            catch (Exception ex)
            {
                // 例外錯誤處理。
                enErrors.Add(ex.Message);
            }
            finally
            {
                this.Response.Clear();
                // 回覆成功訊息。
                if (enErrors.Count() == 0)
                {
                    this.Response.Write("1|OK");
                }
                // 回覆錯誤訊息。
                else
                {
                    this.Response.Write(String.Format("0|{0}", String.Join("\\r\\n", enErrors)));
                }
                this.Response.Flush();
                this.Response.End();
            }
        }
Пример #9
0
        public EcPayViewModel GetEcPayOrderDetail()
        {
            List <string>  enErrors   = new List <string>();
            EcPayViewModel Feedback   = new EcPayViewModel();
            Hashtable      htFeedback = null;

            try
            {
                using (AllInOne oPayment = new AllInOne())
                {
                    oPayment.HashKey = "5294y06JbISpM5x9"; //ECPay 提供的 HashKey
                    oPayment.HashIV  = "v77hoKGq4kWxNNIS"; //ECPay 提供的 HashIV
                    /* 取回付款結果 */
                    enErrors.AddRange(oPayment.CheckOutFeedback(ref htFeedback));
                }
                // 取回所有資料
                if (enErrors.Count() == 0)
                {
                    /* 支付後的回傳的基本參數 */
                    string szMerchantID           = String.Empty;
                    string szMerchantTradeNo      = String.Empty;
                    string szPaymentDate          = String.Empty;
                    string szPaymentType          = String.Empty;
                    string szPaymentTypeChargeFee = String.Empty;
                    string szRtnCode      = String.Empty;
                    string szRtnMsg       = String.Empty;
                    string szSimulatePaid = String.Empty;
                    string szTradeAmt     = String.Empty;
                    string szTradeDate    = String.Empty;
                    string szTradeNo      = String.Empty;
                    string szCustomField1 = String.Empty;
                    string szCustomField2 = String.Empty;
                    string szCustomField3 = String.Empty;
                    string szCustomField4 = String.Empty;
                    // 取得資料
                    foreach (string szKey in htFeedback.Keys)
                    {
                        switch (szKey)
                        {
                        /* 支付後的回傳的基本參數 */
                        case "MerchantID": szMerchantID = htFeedback[szKey].ToString(); break;

                        case "MerchantTradeNo": szMerchantTradeNo = htFeedback[szKey].ToString(); break;

                        case "PaymentDate": szPaymentDate = htFeedback[szKey].ToString(); break;

                        case "PaymentType": szPaymentType = htFeedback[szKey].ToString(); break;

                        case "PaymentTypeChargeFee": szPaymentTypeChargeFee = htFeedback[szKey].ToString(); break;

                        case "RtnCode": szRtnCode = htFeedback[szKey].ToString(); break;

                        case "RtnMsg": szRtnMsg = htFeedback[szKey].ToString(); break;

                        case "SimulatePaid": szSimulatePaid = htFeedback[szKey].ToString(); break;

                        case "TradeAmt": szTradeAmt = htFeedback[szKey].ToString(); break;

                        case "TradeDate": szTradeDate = htFeedback[szKey].ToString(); break;

                        case "TradeNo": szTradeNo = htFeedback[szKey].ToString(); break;

                        case "CustomField1": szCustomField1 = htFeedback[szKey].ToString(); break;

                        case "CustomField2": szCustomField2 = htFeedback[szKey].ToString(); break;

                        case "CustomField3": szCustomField3 = htFeedback[szKey].ToString(); break;

                        case "CustomField4": szCustomField4 = htFeedback[szKey].ToString(); break;

                        default: break;
                        }
                    }


                    Feedback.MerchantID           = szMerchantID;
                    Feedback.MerchantTradeNo      = szMerchantTradeNo;
                    Feedback.PaymentDate          = szPaymentDate;
                    Feedback.PaymentType          = szPaymentType;
                    Feedback.PaymentTypeChargeFee = szPaymentTypeChargeFee;
                    Feedback.RtnCode      = szRtnCode;
                    Feedback.RtnMsg       = szRtnMsg;
                    Feedback.SimulatePaid = szSimulatePaid;
                    Feedback.TradeAmt     = szTradeAmt;
                    Feedback.TradeDate    = szTradeDate;
                    Feedback.TradeNo      = szTradeNo;
                    Feedback.CustomField1 = szCustomField1;
                    Feedback.CustomField2 = szCustomField2;
                    Feedback.CustomField3 = szCustomField3;
                    Feedback.CustomField4 = szCustomField4;
                }
                else
                {
                    // 其他資料處理。
                }
            }
            catch (Exception ex)
            {
                // 例外錯誤處理。
                enErrors.Add(ex.Message);
            }

            return(Feedback);
        }
Пример #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            List <string> enErrors   = new List <string>();
            Hashtable     htFeedback = null;

            try
            {
                using (AllInOne oPayment = new AllInOne())
                {
                    oPayment.HashKey = "";   //ECPay 提供的 HashKey
                    oPayment.HashIV  = "";   //ECPay 提供的 HashIV
                    /* 取回付款結果 */
                    enErrors.AddRange(oPayment.CheckOutFeedback(ref htFeedback));
                }
                // 取回所有資料
                if (enErrors.Count() == 0)
                {
                    /* 支付後的回傳的基本參數 */
                    string szMerchantID      = String.Empty;
                    string szMerchantTradeNo = String.Empty;
                    string szRtnCode         = String.Empty;
                    string szRtnMsg          = String.Empty;
                    /* 使用定期定額交易時,回傳的額外參數 */
                    string szPeriodType        = String.Empty;
                    string szFrequency         = String.Empty;
                    string szExecTimes         = String.Empty;
                    string szAmount            = String.Empty;
                    string szGwsr              = String.Empty;
                    string szProcessDate       = String.Empty;
                    string szAuthCode          = String.Empty;
                    string szFirstAuthAmount   = String.Empty;
                    string szTotalSuccessTimes = String.Empty;
                    // 取得資料於畫面
                    foreach (string szKey in htFeedback.Keys)
                    {
                        switch (szKey)
                        {
                        /* 使用定期定額交易時回傳的參數 */
                        case "MerchantID": szMerchantID = htFeedback[szKey].ToString(); break;

                        case "MerchantTradeNo": szMerchantTradeNo = htFeedback[szKey].ToString();
                            break;

                        case "RtnCode": szRtnCode = htFeedback[szKey].ToString(); break;

                        case "RtnMsg": szRtnMsg = htFeedback[szKey].ToString(); break;

                        case "PeriodType": szPeriodType = htFeedback[szKey].ToString(); break;

                        case "Frequency": szFrequency = htFeedback[szKey].ToString(); break;

                        case "ExecTimes": szExecTimes = htFeedback[szKey].ToString(); break;

                        case "Amount": szAmount = htFeedback[szKey].ToString(); break;

                        case "Gwsr": szGwsr = htFeedback[szKey].ToString(); break;

                        case "ProcessDate": szProcessDate = htFeedback[szKey].ToString(); break;

                        case "AuthCode": szAuthCode = htFeedback[szKey].ToString(); break;

                        case "FirstAuthAmount": szFirstAuthAmount = htFeedback[szKey].ToString();
                            break;

                        case "TotalSuccessTimes": szTotalSuccessTimes = htFeedback[szKey].ToString();
                            break;

                        default: break;
                        }
                    }
                    // 其他資料處理。
                }
                else
                {
                    // 其他資料處理。
                }
            }
            catch (Exception ex)
            {
                enErrors.Add(ex.Message);
            }
            finally
            {
                this.Response.Clear();
                // 回覆成功訊息。
                if (enErrors.Count() == 0)
                {
                    this.Response.Write("1|OK");
                }
                // 回覆錯誤訊息。
                else
                {
                    this.Response.Write(String.Format("0|{0}", String.Join("\\r\\n", enErrors)));
                }
                this.Response.Flush();
                this.Response.End();
            }
        }