/// <summary> /// 測試訂單的XML資料是否正確 /// </summary> /// <returns></returns> public ActionResult PaymentCeneter() { //### 建立KeyCrypt物件 AllPay.ShareLib.KeyCrypt _keyCrypt = new AllPay.ShareLib.KeyCrypt(); string deHashKey = _keyCrypt.DeCrypt("AGkQgnTfBOClgtRSVI5RPc6abMihC2+8/z70hlN9Ezt="); string deHashIV = _keyCrypt.DeCrypt("ssCLnmJYxU7grRxnEF9Y+XEI7B8Ye4/lx2sEpJe2NRu="); string tradeXML = "VjiKskbhRlwoR7RfzGjihxB1aFStOd2mhSWqoimj4R3ztRaV0E5CNmyBtTFnhE5emW4H0E9VpNbRoCK1g4cp5rIEe3NYjI7 DIUDyBqvO4tY hRiY3q/ZmblU2E8f7CeCkr/UaJoWF3Qk 2p9CHZm7ywqx3OPZk7fJGpDNe5GTmMXFDb4z5PLAooN5K JLEvlUS3CBzfPOcxDxnUv3ho7GcHJ5RRf5/OFV9ynNt1zV g8JcFo/m/8GG3d8I m94yvLe6KhaRN4IoBzGRyn32LHBjiI4E6bsXwNs6NygznHk528tDEs8rb3eDu9oxvFfrzVLqMmieb6uqO9FeNWsPBPhTnQA/lGNp LZiUAnc3MoYMAP YmouBWPYHgG7WnP614R614AER9hzRDK64qJ6W466uBGcRV0OeKUuL511eEGWw5X MGrOcUHW9jOh2Uiu8nqr7SOy5DYYBwSyrcbA5AcWgjDQHkuI8KDZxlhDLL9Mrou71aRJYlkMA6so4IXm22gD4BnNQgc5PiU0eXCwko0MVP7oV1eQWtNzkyIpp3JDLEYRFASjzt1Rvx5Rm67RxWLJ6svSEpvudA4P5L6oCR2b5uOsDPrvu89yu XOiZMXyK/1vCo8MOFk1uTKyK3l"; tradeXML = tradeXML.Replace(' ', '+'); string xmlData = new AllPay.ShareLib.Crypt().AES_DeCrypt(deHashKey, deHashIV, tradeXML); //xmlData = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Root><Data><MerchantID>1020258</MerchantID><MerchantTradeN>1234567</MerchantTradeN><MerchantTradeDate>2013/08/03 05:00:00</MerchantTradeDate><TradeAmount>200</TradeAmount><TradeType>CVS_IBON</TradeType><TradeDesc>credit</TradeDesc><Desc_1></Desc_1><Desc_2></Desc_2><Desc_3></Desc_3><Desc_4></Desc_4><ReplyURL>http://173.255.242.213/buy/allpayPaidData.php</ReplyURL><Remark></Remark></Data></Root>\n\n\n\n\n\n\n\n\n\n"; try { XDocument xDoc = XDocument.Parse(xmlData); XmlSchemaSet schemas = new XmlSchemaSet(); schemas.Add(string.Empty, HttpContext.Server.MapPath("~/App_Data/XSD/PaymentCenterCVSTrade.xsd")); xDoc.Validate(schemas, null); } catch (Exception exception) { string exceptionMsg = exception.Message.Replace("'", " "); } return View(); }
public ActionResult Index() { string amount = "1500.00"; int intAmount = Convert.ToInt32(string.Format("{0}",amount)); BasePaymentService baseBouandaryPayment = new BasePaymentService(); string omgXml = "4ynaiU+eFpsqSzr2/DfFbJo/uitfotYn197jNrb+xN8hk43n7xBLLmY+e1/9BHCEaAkhmlDlm60YBGiN2AkIxDGaRaC1TtcQt2Vh++B2gx55x37xJOnZ5lphjXhRN9ut+LylG+cXnxwzMCanQ1/bfeCzJUyQ2YOSTDdhTvTVOjLQXiRkIOxW9psAW5zc5cbVtakGNjvD8SXR7AygOVHuzeWH7wUWv5lPfAikRORUcIOISKsFAv8Z34ASxeJNRFU7BMGA7Ih/81ZkShUtThEplB51tqbizsYKkoQnUBu1D36uTJ5FemB7yGq/lZA5YKzUZpELSseGWBcS/OrPa/NSPSTlVh/vAV/oyPQOSGnO2YHz4vfd7VJ9OLHFTPdRM25e"; string desXml = new AllPay.ShareLib.Crypt().AES_DeCrypt("HD5pZKkuG9DxrHfR", "XVqza2PuFnCHwWwM", omgXml); string xmlData = "4ynaiU+eFpsqSzr2/DfFbJo/uitfotYn197jNrb+xN8hk43n7xBLLmY+e1/9BHCEaAkhmlDlm60YBGiN2AkIxDGaRaC1TtcQt2Vh++B2gx55x37xJOnZ5lphjXhRN9utFZqQpk3x9yrBX1M+IepqVW4nfWQ1whxmElKe21Le+HLoVMQO+s63YocF6e56yn++PEwbQilaMopEeSpmTpZg/B2t+/78wmxqEnmqflisa4KQ6tpzdM7U03whkMXYXB7yO56EVgwDp+GEz+3/zDYRCfFbh9jCILyiCiNE7UCiO1oEuEdq0QnUEIVM4QGKuU2Hw4mcFs0W/3kSjoZzzEtbjA=="; Hashtable postData = new Hashtable(); postData.Add("XMLData", xmlData); //string postURL = "https://pay.omg.com.tw/Code/Purchase/Allpay/returnGoods.ashx"; //string response = new AllPay.ShareLib.Network().FormPost(postURL, "?XMLData=" + xmlData); //string postStatus = baseBouandaryPayment.DoRequest(postURL, postData); //避免ShareLib有https錯誤,暫時使用DoRequest //string response = new AllPay.ShareLib.Network().FormPost(postURL, "?XMLData=" + xmlData); string exchangeUrl = "https://pay.omg.com.tw/Code/Purchase/Allpay/noticeExchangeSNO.ashx"; return null; }
// // GET: /MockPayment/ public ActionResult Index() { //### 建立KeyCrypt物件 AllPay.ShareLib.KeyCrypt _keyCrypt = new AllPay.ShareLib.KeyCrypt(); string deHashKey = _keyCrypt.DeCrypt("U61Dp2UxllJxYTyvq00xe0rhSIc/i2qVvTtLYwiny3f="); string deHashIV = _keyCrypt.DeCrypt("YP/phIyry/qEcPg2uqKkiHkk1Z747MVHJmE5/V3Uy64="); string enHashKey = _keyCrypt.EnCrypt("wWqsaMYYWgVZkWYn"); string enHashIV = _keyCrypt.EnCrypt("vEwoJCs04n6ta9DZ"); string merchantTradeNo = DateTime.Now.ToString("yyyyMMddHHmmss"); string cvsXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Root><Data><MerchantID>2000132</MerchantID><MerchantTradeNo>138310514400643</MerchantTradeNo><MerchantTradeDate>2013/10/30 11:52:25</MerchantTradeDate><TradeAmount>100</TradeAmount><ExpireTime>2013/10/31 11:52:25</ExpireTime><ServerReplyURL>https%3A%2F%2Fgate.pepay.com.tw%2Fpepay%2Fpaysys%2Fallpay%2Frcv.php</ServerReplyURL><ClientReplyURL>https%3A%2F%2Fgate.pepay.com.tw%2Fpepay%2Fpaysys%2Fallpay%2Frtn.php</ClientReplyURL><Remark></Remark></Data></Root>"; string encryptString = new AllPay.ShareLib.Crypt().AES_EnCrypt("ejCk326UnaZWKisg", "q9jcZX8Ib9LM8wYk", cvsXml); string encryptXml = "XeMYbI2/9Z1p4Xj3XHf96OeHkKBIj5iKGUCZ8OTBo57/DxPzItfiCApy6cywurnWOkvh/8f0varOy/5hlZ3gVD7aAgklGeFhONCAqcdRwORAS1ZCmv14tN141PZc2UkdsOrMiLeYxeLG2jD8NQcPz4Sj+xJRMzASSvtiatPnjqXgP8OpgRlsp/LmdRcKwzMCFCi0JQbbnqaaaKHgbsKffLrVQXU9hhAyzQHSJ1nEzKMxG470fkzE44DJC6/pPvhs0OJCxWxz5tSARYhgGkn8iubpWktloaQXdgWUC2ntEdGcrxiW4ww6GUM+tiZtWnOId5gfSFAu+b35Owewy9TwZmgM9lvPLJRFhacNXpy0qODdt5XOYUHwn69R/avYKevyDfjhbbB/6XlzhjsReAJrmZWB/l3NDWRRjdQWMBoDtvAX74ugqHEpWspQpp8clCjdSJjNjeI2QJiuvyfo9HxZZtsJ4tL4JZzdRlLzc8fYND3EJm5PUNxUHwuAxfDoGiy3tNPE0ytn4FuqHthjNBlb2N89d9W/Iqr7d97TkHdYfWNtCecXFQUkWjLD56gpWBThyirvcn1P/5peDDWo5/vpHsQWvemSyYZ5X4lr7GETeaU4kSDqaUjw+k3va8PJVrirAMGQw5ajGECtqyd3pA2Vfd1JmPFZNFdSiZjspJYJK4Rq3Af8C3IdqHmuv57k9GQZ"; encryptXml = encryptXml.Replace(' ', '+'); string xml = new AllPay.ShareLib.Crypt().AES_DeCrypt("ejCk326UnaZWKisg", "q9jcZX8Ib9LM8wYk", encryptXml); string testString = "AllPayTest"; //string encryptString = new AllPay.ShareLib.Crypt().AES_EnCrypt("A123456789012345", "B123456789012345", testString); string decryptString = new AllPay.ShareLib.Crypt().AES_DeCrypt("A123456789012345", "B123456789012345", encryptString); string urlEncodeString = HttpUtility.UrlEncode("_"); return View(); }
// // GET: /MockTinyURL/ public ActionResult AddUrl() { string testHashKey = "J1d9jJos0duyn1oP"; //stage環境 string testHashIv = "xYeufjniLEJH8FJW"; string postUrl = "http://p-stage.allpay.com.tw/tinyurl/Add"; string XMLData = "Http://www.allpay.com.tw"; string encryXMLData = new AllPay.ShareLib.Crypt().AES_EnCrypt(testHashKey, testHashIv, XMLData); Dictionary<string, string> postCollection = new Dictionary<string, string>(); postCollection.Add("url", encryXMLData); Hashtable RequestTable = new Hashtable(); foreach (var item in postCollection) { RequestTable.Add(item.Key, item.Value); } //### 發送到Mp, 取得Response string ServerResponse = DoRequest(postUrl, RequestTable); ViewBag.SendResult = ServerResponse; return View(); }
private string GenerateTransIdentifyNoNew(string icpNo, string transNo, string transAmt, string atmTradeNo, string atmTradeDate, string hashKey, string atmTradeState) { string s = string.Format("{0}{1}{2}{3}{4}{5}{6}", icpNo, transNo, transAmt, atmTradeNo, atmTradeDate, hashKey, atmTradeState); //以SHA-1來產生checksum string checkSum = new AllPay.ShareLib.Crypt().SHA(s); return(checkSum); }
/// <summary> /// 測試發送簡訊的API /// </summary> /// <returns></returns> public ActionResult SendSMS() { //stage環境 //string AllPayHashKey = "ejCk326UnaZWKisg"; //string AllPayHashIV = "q9jcZX8Ib9LM8wYk"; //long AllPayMerchantID = 2000132; //string postUrl = "http://sms-stage.allpay.com.tw/SMS/Send"; //stage環境 string AllPayHashKey = "SM6zZHQvodchMaTk"; string AllPayHashIV = "zf3MhCfhzwUZoGfi"; long AllPayMerchantID = 888891; string postUrl = "https://sms.allpay.com.tw/SMS/Send"; string Phone = "0958389636"; string SmsType = "0"; string TimeStamp = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString(); string MsgData = "測試簡訊"; string postData = "&MerchantID=" + AllPayMerchantID + "&Phone=" + Phone + "&SmsType=" + SmsType + "&TimeStamp=" + TimeStamp; string lowerDataToUrlEncode = HttpUtility.UrlEncode("HashKey=" + AllPayHashKey + postData + "&HashIV=" + AllPayHashIV); lowerDataToUrlEncode = "HashKey%3DA123456789012345%26MerchantID%3D999990001%26Phone%3D0917234601%26SmsType%3D0%26TimeStamp%3D1381302739%26HashIV%3DB123456789012345"; string md5DataToLower = lowerDataToUrlEncode.ToLower(); string CheckMacValue = new AllPay.ShareLib.Crypt().MD5(md5DataToLower); Hashtable RequestTable = new Hashtable(); RequestTable.Add("MerchantID", AllPayMerchantID.ToString()); RequestTable.Add("Phone", Phone); RequestTable.Add("SmsType", SmsType); RequestTable.Add("TimeStamp", TimeStamp); RequestTable.Add("MsgData", MsgData); RequestTable.Add("CheckMacValue", CheckMacValue); //### 發送到Mp, 取得Response string ServerResponse = DoRequest(postUrl, RequestTable); ViewBag.SendResult = ServerResponse; return View(); }
// // GET: /Tenpay/ public ActionResult Index() { string AllPayHashKey = "ejCk326UnaZWKisg"; string AllPayHashIV = "q9jcZX8Ib9LM8wYk"; long MerchantID = 2000132; string PaymentType = "TENPAY"; //設定MP的Post網址 string postURL = "http://pay-stage.allpay.com.tw/payment/gateway"; string MerchantTradeNo = DateTime.Now.ToString("yyyyMMddHHmmss"); string MerchantTradeDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); string TradeAmount = "20"; string ExpireTime = ""; string ServerReplyURL = HttpUtility.UrlEncode("http://www.allpay.com.tw/atm/success.aspx"); string ClientReplyURL = HttpUtility.UrlEncode("http://www.allpay.com.tw/atm/success.aspx"); string Remark = HttpUtility.UrlEncode("xxx"); string tradeXML = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<Root><Data>" + "<MerchantID>" + MerchantID + "</MerchantID>" + "<MerchantTradeNo>" + MerchantTradeNo + "</MerchantTradeNo>" + "<MerchantTradeDate>" + MerchantTradeDate + "</MerchantTradeDate>" + "<TradeAmount>" + TradeAmount + "</TradeAmount>" + "<ExpireTime>" + ExpireTime + "</ExpireTime>" + "<ServerReplyURL>" + ServerReplyURL + "</ServerReplyURL>" + "<ClientReplyURL>" + ClientReplyURL + "</ClientReplyURL>" + "<Remark>" + Remark + "</Remark>" + "</Data></Root>"; //設定要Post的資料 Dictionary<string, string> postCollection = new Dictionary<string, string>(); //將要丟給payment center的xml做AES加密 string xmlData = new AllPay.ShareLib.Crypt().AES_EnCrypt(AllPayHashKey, AllPayHashIV, tradeXML); postCollection.Add("MerchantID", MerchantID.ToString()); postCollection.Add("PaymentType", PaymentType); postCollection.Add("XMLData", xmlData); TempData["PostCollection"] = postCollection; TempData["PostURL"] = postURL; return RedirectToAction("AutoSubmitForm", "Common"); }
// // GET: /CreditActuon/ public ActionResult Index() { string AllPayHashKey = "ejCk326UnaZWKisg"; string AllPayHashIV = "q9jcZX8Ib9LM8wYk"; long MerchantID = 2000132; //設定MP的Post網址 string postURL = "http://pay-stage.allpay.com.tw/CreditDetail/DoAction"; string MerchantTradeNo = "123456789"; string TradeNo = "201203151740582564"; string TotalAmount = "22000"; string Action = "C"; string tradeXML = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<Root><Data>" + "<MerchantID>" + MerchantID + "</MerchantID>" + "<MerchantTradeNo>" + MerchantTradeNo + "</MerchantTradeNo>" + "<TradeNo>" + TradeNo + "</TradeNo>" + "<Action>" + Action + "</Action>" + "<TotalAmount>" +TotalAmount+ "</TotalAmount>" + "</Data></Root>"; //設定要Post的資料 Dictionary<string, string> postCollection = new Dictionary<string, string>(); //將要丟給payment center的xml做AES加密 string xmlData = new AllPay.ShareLib.Crypt().AES_EnCrypt(AllPayHashKey, AllPayHashIV, tradeXML); postCollection.Add("MerchantID", MerchantID.ToString()); postCollection.Add("XMLData", xmlData); TempData["PostCollection"] = postCollection; TempData["PostURL"] = postURL; return RedirectToAction("AutoSubmitForm", "Common"); }
public ActionResult PartnerMemberRegister() { //DEV環境 string allpayHashKey = devHashKey; string allpayHashIv = devHashIv; string merchantId = "1000070"; string tradePostUrl = "http://devmember.allpay.com.tw:12004/MerchantMemberApi/Register"; ////beta環境 //string allpayHashKey = betaHashKey; //string allpayHashIv = betaHashIv; //string merchantId = "1000039"; //string tradePostUrl = "http://member-beta.allpay.com.tw/MerchantMemberApi/Register"; PartnerMemberRegister partnerMemberModel = new PartnerMemberRegister(); partnerMemberModel.MerchantID = merchantId; partnerMemberModel.MerchantMemberID = DateTime.Now.ToString("yyyyMMddHHmmss"); partnerMemberModel.ServerReplyURL = "http://devmockmerchant.allpay.com.tw:12020/AllPayPayment/ReceiveOrderResult"; partnerMemberModel.ClientBackURL = "http://devmockmerchant.allpay.com.tw:12020/AllPayPayment/ReceiveOrderResult"; partnerMemberModel.TimeStamp = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000; string json = JsonConvert.SerializeObject(partnerMemberModel); string encodeJson = HttpUtility.UrlEncode(json, System.Text.Encoding.UTF8); //string tradePostUrl = "http://member-stage.allpay.com.tw/MerchantMemberApi/Register"; string PostUrl = tradePostUrl; string Contents = new AllPay.ShareLib.Crypt().AES_EnCrypt(allpayHashKey, allpayHashIv, encodeJson); string jsonData = new AllPay.ShareLib.Crypt().AES_DeCrypt(allpayHashKey, allpayHashIv, Contents.Replace(" ", "+")); jsonData = HttpUtility.UrlDecode(jsonData, System.Text.Encoding.UTF8); //設定要Post的資料 Dictionary<string, string> PostDictionary = new Dictionary<string, string>(); PostDictionary.Add("MerchantID", merchantId.ToString()); PostDictionary.Add("Contents", Contents); //設定要送到MP的資料 TempData["PostCollection"] = PostDictionary; TempData["PostURL"] = PostUrl; //將要送給MP的資料,透過autoSubmitForm.cshtml傳給MP return RedirectToAction("AutoSubmitForm", "Common"); }
// // GET: /TestBarcode/ public string Index() { string TradePostUrl = "http://devpayment.allpay.com.tw:12005/App/Barcode/CreateBarcode"; string AllPayHashKey = "BICfVOb61OogBe9l"; string AllPayHashIV = "6XP1ATqYaEmE9wAp"; string str = "{\"MID\":\"1000277\",\"LoginTokenID\":\"819328C8945248D2BE3BDD79BAB2BD19\",\"TimeStamp\":\"1438847402\",\"TradeType\":\"3\",\"CardID\":\"2\"}"; //TradeData model = new TradeData(); //model.CardID = ""; //model.LoginTokenID = ""; //model.MID = ""; //model.TimeStamp = ""; //model.TradeType = ""; //string JsonStr = JsonConvert.SerializeObject(model); string d = new AllPay.ShareLib.Crypt().AES_EnCrypt(AllPayHashKey,AllPayHashIV,str); //post方法 Dictionary<string, string> PostDictionary = new Dictionary<string, string>(); PostDictionary.Add("d", d); Hashtable RequestTable = new Hashtable(); RequestTable.Add("d", d); //### 發送到Mp, 取得Response string ServerResponse = DoRequest(TradePostUrl, RequestTable); return ServerResponse; //TempData["PostCollection"] = PostDictionary; //TempData["PostURL"] = TradePostUrl; ////將要送給MP的資料,透過autoSubmitForm.cshtml傳給MP //return RedirectToAction("AutoSubmitForm", "Common"); }
public ActionResult TestEsunMemberAuth() { string postURL = "https://mtest.esunbank.com.tw/epay/esunAuth.aspx"; string IcpConfirmTransURL = "http://member-stage.allpay.com.tw"; string HashKey = "2iQEK29jdeMSZV0NIzymRPeuOQ6yCv"; string AccNo = "8801953188059"; string AccName = HttpUtility.UrlEncode("葉炳棋"); string AccCell = "0958389636"; string AccMail = "*****@*****.**"; string CommAddress = HttpUtility.UrlEncode("台北市南港路三重路"); string HomeAddress = HttpUtility.UrlEncode("台北市南港路三重路"); string BirthDate = "19800101"; string IDN = "N123756874"; string PicFree = "1"; string IssueDate = "20030101"; //會員統編領補換日 string IssueType = "3"; //"1":初發 "2": 補發 "3": 換發 string IssueLoc = "10007000"; //領補換地點 string IDType = "C3"; //"C1" :電子簽章認證/"C2" :金融連結認證/C3" :手機、EMAIL認證 string IcpNo = "O2G5M1"; string HashKeyNo = "1"; string IdentifyNo = new AllPay.ShareLib.Crypt().SHA1(AccNo + AccName + AccCell + AccMail + CommAddress + HomeAddress + BirthDate + IDN + PicFree + IssueDate + IssueType + IssueLoc + IDType + IcpNo + HashKeyNo + HashKey); //驗證碼 Dictionary<string, string> postCollection = new Dictionary<string, string>(); postCollection.Add("AccNo", AccNo); postCollection.Add("AccName", AccName); postCollection.Add("AccCell", AccCell); postCollection.Add("AccMail", AccMail); postCollection.Add("CommAddress", CommAddress); postCollection.Add("HomeAddress", HomeAddress); postCollection.Add("BirthDate", BirthDate); postCollection.Add("IDN", IDN); postCollection.Add("PicFree", PicFree); postCollection.Add("IssueDate", IssueDate); postCollection.Add("IssueType", IssueType); postCollection.Add("IssueLoc", IssueLoc); postCollection.Add("IDType", IDType); postCollection.Add("IcpNo", IcpNo); postCollection.Add("IcpConfirmTransURL", IcpConfirmTransURL); postCollection.Add("HashKeyNo", HashKeyNo); postCollection.Add("IdentifyNo", IdentifyNo); TempData["PostCollection"] = postCollection; TempData["PostURL"] = postURL; return RedirectToAction("AutoSubmitForm", "Common"); }
/// <summary> /// 建立Web ATM的訂單 /// </summary> /// <returns></returns> public ActionResult CreateWebAtmTradeToPaymentCenter() { string AllPayHashKey = devHashKey; string AllPayHashIV = devHashIv; long AllPayMerchantID = 1000070; //string AllPayHashKey = "fugvqTnG3ROx81MO"; //開發機:999999999 //string AllPayHashIV = "WkSfnqIaHLbUMV5X"; //long AllPayMerchantID = 999999999; //string AllPayHashKey = stageHashKey; //string AllPayHashIV = stageHashIv; //long AllPayMerchantID = 2000132; //2000132:stage的測試店家 //long AllPayMerchantID = 1018778; string totalAmount = "30"; string orderTradeNo = DateTime.Now.ToString("yyyyMMddHHmmss"); string orderDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); //設定MP的Post網址 //string postURL = "http://devpaymentcenter.allpay.com.tw:12003/Payment/Gateway"; //string postURL = "http://pay-stage.allpay.com.tw/Payment/Gateway"; string postURL = "https://pay.allpay.com.tw/Payment/Gateway"; string tradeXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<Root><Data>" + "<MerchantID>" + AllPayMerchantID + "</MerchantID>" + "<MerchantTradeNo>" + orderTradeNo + "</MerchantTradeNo>" + "<MerchantTradeDate>" + orderDate + "</MerchantTradeDate>" + "<TotalAmount>" + totalAmount + "</TotalAmount>" + "<TradeDesc>%e8%a8%82%e5%96%ae%e6%8f%8f%e8%bf%b0-MacBook+Air</TradeDesc>" + "<TradeCategory>1</TradeCategory>" + "<BankName>CATHAY</BankName>" + "<CharSet>utf-8</CharSet>" + "<ReplyURL>" + HttpUtility.UrlEncode("http://pay-stage.allpay.com.tw/AllPayPayment/ReceiveOrderResult") + "</ReplyURL>" //+ "<ReplyURL>" + HttpUtility.UrlEncode("http://devmockmerchant.allpay.com.tw:12020/AllPayPayment/ReceiveOrderResult") + "</ReplyURL>" + "<BackURL>" + HttpUtility.UrlEncode("http://pay-stage.allpay.com.tw/MockMerchant/ReceiveBackUrlResult") + "</BackURL>" //+ "<BackURL>" + HttpUtility.UrlEncode("http://devmockmerchant.allpay.com.tw:12020/AllPayPayment/ReceiveOrderResult") + "</BackURL>" + "<Remark>%e4%b8%80%e8%88%ac%e5%95%86%e5%93%81%e6%b8%ac%e8%a9%a6-DEV</Remark>" + "<ServerReplyURL>" + HttpUtility.UrlEncode("http://pay-stage.allpay.com.tw/MockMerchant/ReceiveBackUrlResult") + "</ServerReplyURL>" //+ "<ServerReplyURL>" + HttpUtility.UrlEncode("http://devmockmerchant.allpay.com.tw:12020/AllPayPayment/ReceiveOrderResult") + "</ServerReplyURL>" + "</Data></Root>"; //設定要Post的資料 Dictionary<string, string> postCollection = new Dictionary<string, string>(); //將要丟給payment center的xml做AES加密 string xmlData = new AllPay.ShareLib.Crypt().AES_EnCrypt(AllPayHashKey, AllPayHashIV, tradeXML); postCollection.Add("MerchantID", AllPayMerchantID.ToString()); postCollection.Add("PaymentType", "WEB_ATM"); postCollection.Add("XMLData", xmlData); TempData["PostCollection"] = postCollection; TempData["PostURL"] = postURL; return RedirectToAction("AutoSubmitForm", "Common"); }
//測試回傳給payment 支付寶付款成功的動作 public ActionResult TestAlipayReturn() { string merchantTradeNo = "42244"; //payment的tradeID string tradeNo = "20121212170719279614"; //payment center的tradeNo string tradeAmount = "350"; string merchantId = "999999999"; string AesHashKey = "fugvqTnG3ROx81MO"; string AesHashIv = "WkSfnqIaHLbUMV5X"; string relpyUrl = "http://devpayment.allpay.com.tw:12005/bank/paymentcenter/cnt/alipay/result"; string serverReplyUrl = "http://devpayment.allpay.com.tw:12005/bank/paymentcenter/srv/alipay/result"; XmlDocument XML = new XmlDocument(); XML.Load(HttpContext.Server.MapPath("~/App_Data/PaymentReceiveAlipay.xml")); //###取得XML的節點 XmlElement eleMerchantID = (XmlElement)XML.SelectSingleNode("Root/Data/MerchantID"); XmlElement eleMerchantTradeNo = (XmlElement)XML.SelectSingleNode("Root/Data/MerchantTradeNo"); XmlElement eleRtnCode = (XmlElement)XML.SelectSingleNode("Root/Data/RtnCode"); XmlElement eleRtnMsg = (XmlElement)XML.SelectSingleNode("Root/Data/RtnMsg"); XmlElement eleTradeNo = (XmlElement)XML.SelectSingleNode("Root/Data/TradeNo"); XmlElement eleTradeDate = (XmlElement)XML.SelectSingleNode("Root/Data/TradeDate"); XmlElement eleTradeAmount = (XmlElement)XML.SelectSingleNode("Root/Data/TradeAmount"); XmlElement eleAlipayID = (XmlElement)XML.SelectSingleNode("Root/Data/AlipayID"); XmlElement eleAlipayTradeNo = (XmlElement)XML.SelectSingleNode("Root/Data/AlipayTradeNo"); XmlElement eleTimeStamp = (XmlElement)XML.SelectSingleNode("Root/Data/TimeStamp"); //### 設定XML內容 eleMerchantID.InnerText = merchantId; eleMerchantTradeNo.InnerText = merchantTradeNo; eleRtnCode.InnerText = "1"; eleRtnMsg.InnerText = "success"; eleTradeNo.InnerText = tradeNo; eleTradeDate.InnerText = "2012/12/12 17:07:18"; eleTradeAmount.InnerText = tradeAmount; eleAlipayID.InnerText = "2088002260834144"; eleAlipayTradeNo.InnerText = "2012121202863314"; long epoch = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000; eleTimeStamp.InnerText = epoch.ToString(); //### 將XML透過AES加密 string XMLData = new AllPay.ShareLib.Crypt().AES_EnCrypt(AesHashKey, AesHashIv, XML.OuterXml); //先server端回傳 string serverReponse = new AllPay.ShareLib.Network().FormPost(serverReplyUrl, "XMLData=" + XMLData, "", 0, 65001); //再client端回傳 string response = new AllPay.ShareLib.Network().FormPost(relpyUrl, "XMLData=" + XMLData, "", 0, 65001); //DoRequest(relpyUrl, XMLData); return null; }
//測試回傳給payment ATM付款成功的動作 public ActionResult TestAtmHncbReturn() { //string merchantId = "999999999"; //string merchantTradeNo = "100050"; //payment的tradeID //string tradeNo = "20121204134122541156"; //payment center的tradeNo //string AesHashKey = "fugvqTnG3ROx81MO"; //string AesHashIv = "WkSfnqIaHLbUMV5X"; //string serverReplyUrl = "http://devpayment.allpay.com.tw:12005/bank/paymentcenter/srv/atm/result"; string merchantId = "2000132"; string merchantTradeNo = "100050"; //payment的tradeID string tradeNo = "20121204134122541156"; //payment center的tradeNo string AesHashKey = "ejCk326UnaZWKisg"; string AesHashIv = "q9jcZX8Ib9LM8wYk"; string serverReplyUrl = "http://linda.sunup.net/test/pay_info.php"; //也必需更新payment center的訂單,因為payment會反查 /* update Payment_TradeNo set PaymentStatus = '1' ,PaymentDate = GETDATE() where TradeID = 12153 update Payment_TradeDetail_ATM set RtnCode = '1' ,RtnPaymentDate= GETDATE() ,RtnBankCode = '008' ,RtnBankAcc = '168371' where TradeID = 12153 * */ XmlDocument XML = new XmlDocument(); XML.Load(HttpContext.Server.MapPath("~/App_Data/NoticeMerchantATM.xml")); //###取得XML的節點 XmlElement eleMerchantID = (XmlElement)XML.SelectSingleNode("Root/Data/MerchantID"); XmlElement eleMerchantTradeNo = (XmlElement)XML.SelectSingleNode("Root/Data/MerchantTradeNo"); XmlElement eleRtnCode = (XmlElement)XML.SelectSingleNode("Root/Data/RtnCode"); XmlElement eleRtnMsg = (XmlElement)XML.SelectSingleNode("Root/Data/RtnMsg"); XmlElement eleTradeNo = (XmlElement)XML.SelectSingleNode("Root/Data/TradeNo"); XmlElement elePayDate = (XmlElement)XML.SelectSingleNode("Root/Data/PayDate"); XmlElement eleTradeAmount = (XmlElement)XML.SelectSingleNode("Root/Data/TradeAmount"); XmlElement eleAccBank = (XmlElement)XML.SelectSingleNode("Root/Data/AccBank"); XmlElement eleAccNo = (XmlElement)XML.SelectSingleNode("Root/Data/AccNo"); //### 設定XML內容 eleMerchantID.InnerText = merchantId; eleMerchantTradeNo.InnerText = merchantTradeNo; eleRtnCode.InnerText = "1"; eleRtnMsg.InnerText = "success"; eleTradeNo.InnerText = tradeNo; elePayDate.InnerText = "2013/10/18 23:38:18"; eleTradeAmount.InnerText = "105"; eleAccBank.InnerText = "812"; eleAccNo.InnerText = "123123"; //### 將XML透過AES加密 string XMLData = new AllPay.ShareLib.Crypt().AES_EnCrypt(AesHashKey, AesHashIv, XML.OuterXml); //server端回傳 string serverReponse = new AllPay.ShareLib.Network().FormPost(serverReplyUrl, "XMLData=" + XMLData, "", 0, 65001); ViewBag.Response = serverReponse; ViewBag.Result = false; if (serverReponse.IndexOf("1|OK") > -1) { ViewBag.Result = true; } return View(); }
/// <summary> /// 測試到payment center建立訂單 /// </summary> /// <returns></returns> public ActionResult CreateAlipayTradeToPaymentCenter() { //string AllPayHashKey = devHashKey; //string AllPayHashIV = devHashIv; //long AllPayMerchantID = 1000070; ////設定MP的Post網址 //string postURL = "http://devpaymentcenter.allpay.com.tw:12003/Payment/Gateway"; ////string postURL = "https://pay.allpay.com.tw/Payment/Gateway"; //string AllPayHashKey = betaHashKey; //string AllPayHashIV = betaHashIv; ////long AllPayMerchantID = 1000139; //long AllPayMerchantID = 1000273; //walter特店 ////設定MP的Post網址 //string postURL = "http://pay-beta.allpay.com.tw/Payment/Gateway"; //string AllPayHashKey = stageHashKey; //string AllPayHashIV = stageHashIv; //long AllPayMerchantID = 2000132; //////設定MP的Post網址 //string postURL = "http://pay-stage.allpay.com.tw/Payment/Gateway"; //string AllPayHashKey = prodHashKey; //string AllPayHashIV = prodHashIv; //long AllPayMerchantID = 888891; //正式機 ////設定MP的Post網址 //string postURL = "https://pay.allpay.com.tw/Payment/Gateway"; //string AllPayHashKey = "kqdWBOOUvpmYltq6"; //string AllPayHashIV = "50vySfM1EWPwPa5Z"; //long AllPayMerchantID = 1016085; //范董(正式機) ////設定MP的Post網址 //string postURL = "http://pay.allpay.com.tw/Payment/Gateway"; string AllPayHashKey = "90tfJomHg20jz2Ja"; string AllPayHashIV = "85UQ17Fw9d8l8wXf"; long AllPayMerchantID = 1027174; //設定MP的Post網址 string postURL = "http://pay.allpay.com.tw/Payment/Gateway"; //string postURL = "http://devpaymentcenter.allpay.com.tw:12003/Payment/Gateway"; //string totalAmount = "3"; string orderTradeNo = DateTime.Now.ToString("yyyyMMddHHmmss"); string orderDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); string totalAmount = "20"; string tradeXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<Root><Data>" + "<MerchantID>" + AllPayMerchantID + "</MerchantID>" + "<MerchantTradeNo>" + orderTradeNo + "</MerchantTradeNo>" + "<MerchantTradeDate>" + orderDate + "</MerchantTradeDate>" + "<TradeAmount>" + totalAmount + "</TradeAmount>" + "<ItemName>入門包#超值包</ItemName>" + "<ItemCounts>1#2</ItemCounts>" + "<ItemPrice>10#10</ItemPrice>" + "<ServerReplyURL>" + HttpUtility.UrlEncode("http://devmockMerchant.allpay.com.tw:12020/AllPayPayment/ReceiveBackUrlResult") + "</ServerReplyURL>" + "<ClientReplyURL>" + HttpUtility.UrlEncode("http://www.allpay.com.tw") + "</ClientReplyURL>" + "<Remark></Remark>" + "<Email>[email protected]</Email>" + "<PhoneNo>0912345678</PhoneNo>" + "<UserName>test</UserName>" + "</Data></Root>"; //設定要Post的資料 Dictionary<string, string> postCollection = new Dictionary<string, string>(); //tradeXML = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Root><Data><MerchantID>1027469</MerchantID><MerchantTradeNo>1</MerchantTradeNo><MerchantTradeDate>2013/09/12 05:25:55</MerchantTradeDate><TradeAmount>10</TradeAmount><ItemName>%E7%89%A9%E5%93%81%E4%B8%80</ItemName><ItemCounts>1</ItemCounts><ItemPrice>1</ItemPrice><ServerReplyURL>http%3A%2F%2Fwww.apollo-chess.com.tw%2Fhzbook%2Fallpay%2Falipay_checkout_reply.rbt</ServerReplyURL><ClientReplyURL>http%3A%2F%2Fwww.apollo-chess.com.tw%2Fhzbook%2Fallpay%2Falipay_checkout_return.rbt</ClientReplyURL><Remark></Remark><Email>[email protected]</Email><PhoneNo>0953333543</PhoneNo><UserName>Teco</UserName></Data></Root>"; //將要丟給payment center的xml做AES加密 string xmlData = new AllPay.ShareLib.Crypt().AES_EnCrypt(AllPayHashKey, AllPayHashIV, tradeXML); //xmlData = "4K9D+yykBOhBtmAN5URwFVkEGf/TbjyzDOd+jmbeKbURzjkmvNU3kvygveWVm99JJcmRx9DbGTwsr4suPcReUcg5aNUr2nvI+lShmY1Hr+UJOae5c9AX+7Iu5+dvQlO+P9PdP8/s+ChrGJTl5zKz78g7DC5/Xz83C8xb2IsWjnnnVv85bf4iNKZvYaut0ZCLumrjoGzEMFOwaqT9zxzXTvF97uBsOgqm1kfMbCF9uqXLWhcigsiDGm1M5rRs6bx+un18jl6gBW6H4LetsDaLwu7PPanft6C7Emd/Hd8vwL1D4YCm1bjApCvVz9Z7t1GM7LOiC4WwCx/bQvijsfKkhBL8P3wwrvu6e77QQfNS0JM2dVCWEZIcNAvezy38SbQQAbK6Z7AD3TSIrGBH193+PzRz9bhlc+mkP3rVSn/jYoMeQ8wUvN7ISKrBRhd+nzRkhrJQWhIsggkI2/sERbiUFsTO+oJV/9wiSJx+9ZhM+GD3DcOojE1ZvjTHWcjLE9yIOepBjqwn3t1VwY8NPSVhoJB1HZIWPZAtASoDz2LpIDa1INWHfYcrSiqPMllk8igf4Nk1CeFpzsstpNJez3V7fndaL8CqNwuVkhyWgZ5x7Te3TAE/6gkOSMrtbaYJOof7kLBvNpshJG8rOSflHeRSflqHOE4ZXQolkFCFN1EDMlmOp2U/UX9lUDZJSXfC16GSBKG8oDNtxdbSDp2RqKAs76ag9jIfltoH+S3f2jUFrrFup613aWHTNA0aPIJrfNd3GsJmhoxJZs77T55jzUYq1Q4NHogXxykw4eYF99YaJaKs/jj/gf/7hVrKCCBSFp8IAGoxAvat84CpMjsU0JG3F2q/Naavh/Wib+RXvLiglnLQ4szpoxQkm8MMJU5dmcXC"; postCollection.Add("MerchantID", AllPayMerchantID.ToString()); postCollection.Add("PaymentType", "ALIPAY"); postCollection.Add("XMLData", xmlData); TempData["PostCollection"] = postCollection; TempData["PostURL"] = postURL; return RedirectToAction("AutoSubmitForm", "Common"); }
//模擬payment傳送財付通訂單資料到payment center public ActionResult TestTenpayToPaymentCenter() { string AllPayHashKey = stageHashKey; string AllPayHashIV = stageHashIv; //long AllPayMerchantID = 999999999; //dev long AllPayMerchantID = 2000132; //2000132:stage的測試店家 string totalAmount = "35"; string orderTradeNo = DateTime.Now.ToString("yyyyMMddHHmmss"); string orderDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); //string expireDate = DateTime.Now.AddDays(2).ToString("yyyy/MM/dd HH:mm:ss"); //設定MP的Post網址 string postURL = "http://pay-stage.allpay.com.tw/Payment/Gateway"; //string postURL = "http://devpaymentcenter.allpay.com.tw:12003/Payment/Gateway"; string tradeXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<Root><Data>" + "<MerchantID>" + AllPayMerchantID + "</MerchantID>" + "<MerchantTradeNo>" + orderTradeNo + "</MerchantTradeNo>" + "<MerchantTradeDate>" + orderDate + "</MerchantTradeDate>" + "<TradeAmount>" + totalAmount + "</TradeAmount>" + "<ExpireTime></ExpireTime>" //+ "<ServerReplyURL>" + HttpUtility.UrlEncode("http://mockMerchant-stage.allpay.com.tw/AllPayPayment/ReceiveOrderResult") + "</ServerReplyURL>" //+ "<ClientReplyURL>" + HttpUtility.UrlEncode("http://mockMerchant-stage.allpay.com.tw/AllPayPayment/ReceiveOrderResult") + "</ClientReplyURL>" + "<ServerReplyURL>" + HttpUtility.UrlEncode("http://devmockmerchant.allpay.com.tw:12020/AllPayPayment/ReceiveOrderResult") + "</ServerReplyURL>" + "<ClientReplyURL>" + HttpUtility.UrlEncode("http://devmockmerchant.allpay.com.tw:12020/AllPayPayment/ReceiveOrderResult") + "</ClientReplyURL>" + "<Remark>%e4%b8%80%e8%88%ac%e5%95%86%e5%93%81%e6%b8%ac%e8%a9%a6-DEV</Remark>" + "</Data></Root>"; Dictionary<string, string> postCollection = new Dictionary<string, string>(); postCollection.Add("MerchantID", AllPayMerchantID.ToString()); postCollection.Add("PaymentType", "TENPAY"); string xmlData = new AllPay.ShareLib.Crypt().AES_EnCrypt(AllPayHashKey, AllPayHashIV, tradeXML); postCollection.Add("XMLData", xmlData); TempData["PostCollection"] = postCollection; TempData["PostURL"] = postURL; return RedirectToAction("AutoSubmitForm", "Common"); }
//模擬查詢超商條碼的資料到payment center public ActionResult TestCvsQueryBarcodeToPaymentCenter() { string AllPayHashKey = "ejCk326UnaZWKisg"; //for stage 2000132 string AllPayHashIV = "q9jcZX8Ib9LM8wYk"; long AllPayMerchantID = 2000132; string MerchantTradeNo = "201309141807"; //設定MP的Post網址 string postURL = "http://pay-stage.allpay.com.tw/barcode/getbarcode"; //string postURL = "http://devpaymentcenter.allpay.com.tw:12003/barcode/getbarcode"; //string postURL = "https://pay.allpay.com.tw/barcode/getbarcode"; string AesMerchantTradeNo = new AllPay.ShareLib.Crypt().AES_EnCrypt(AllPayHashKey, AllPayHashIV, MerchantTradeNo); Dictionary<string, string> postCollection = new Dictionary<string, string>(); postCollection.Add("MerchantID", AllPayMerchantID.ToString()); postCollection.Add("MerchantTradeNo", AesMerchantTradeNo); Hashtable RequestTable = new Hashtable(); foreach (var item in postCollection) { RequestTable.Add(item.Key, item.Value); } //### 發送到Mp, 取得Response string ServerResponse = DoRequest(postURL, RequestTable); ViewBag.ServerResponse = ServerResponse; return View(); }
//模擬payment傳送CVS訂單資料到payment center public ActionResult TestCvsToPaymentCenter() { string AllPayHashKey = devHashKey; string AllPayHashIV = devHashIv; long AllPayMerchantID = 1000070; //long AllPayMerchantID = 999999999; string postURL = "http://devpaymentcenter.allpay.com.tw:12003/Payment/Srv/Gateway"; //string AllPayHashKey = stageHashKey; //string AllPayHashIV = stageHashIv; //long AllPayMerchantID = 2000132; //2000132:stage的測試店家 ////設定MP的Post網址 //string postURL = "http://pay-stage.allpay.com.tw/Payment/Srv/Gateway"; string totalAmount = "50"; string orderTradeNo = DateTime.Now.ToString("yyyyMMddHHmmss"); string orderDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); string paymentType = "BARCODE_BARCODE"; // "CVS_CVS"; // "BARCODE_BARCODE"; string tradeXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<Root><Data>" + "<MerchantID>" + AllPayMerchantID + "</MerchantID>" + "<MerchantTradeNo>" + orderTradeNo + "</MerchantTradeNo>" + "<MerchantTradeDate>" + orderDate + "</MerchantTradeDate>" + "<TradeAmount>" + totalAmount + "</TradeAmount>" + "<TradeType>" + paymentType + "</TradeType>" + "<TradeDesc>allpay-test</TradeDesc>" + "<Desc_1>10</Desc_1>" + "<Desc_2>10</Desc_2>" + "<Desc_3>10</Desc_3>" + "<Desc_4>10</Desc_4>" //+ "<ReplyURL>" + HttpUtility.UrlEncode("http://mockMerchant-stage.allpay.com.tw/AllPayPayment/ReceiveOrderResult") + "</ReplyURL>" + "<ReplyURL>" + HttpUtility.UrlEncode("http://devmockmerchant.allpay.com.tw:12020/AllPayPayment/ReceiveOrderResult") + "</ReplyURL>" + "<Remark>%e4%b8%80%e8%88%ac%e5%95%86%e5%93%81%e6%b8%ac%e8%a9%a6-DEV</Remark>" + "</Data></Root>"; Dictionary<string, string> postCollection = new Dictionary<string, string>(); postCollection.Add("MerchantID", AllPayMerchantID.ToString()); postCollection.Add("PaymentType", paymentType); string xmlData = new AllPay.ShareLib.Crypt().AES_EnCrypt(AllPayHashKey, AllPayHashIV, tradeXML); postCollection.Add("XMLData", xmlData); Hashtable RequestTable = new Hashtable(); foreach (var item in postCollection) { RequestTable.Add(item.Key, item.Value); } //string postURL = "http://devpaymentcenter.allpay.com.tw:12003/Payment/Srv/Gateway"; //### 發送到Mp, 取得Response string ServerResponse = DoRequest(postURL, RequestTable); ViewBag.ServerResponse = ServerResponse; return View(); }
public ActionResult StageQueryTrade(string MerchantID, string MerchantTradeNo) { StageAllpayWs.AllPaySoapClient ws = new StageAllpayWs.AllPaySoapClient(); string HashKey = "Zf1AjVRlwE4XjlF9"; //stage string HashIV = "Ps8hPWGtUW0PE3Gk"; string TimeStamp = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString(); string XML = string.Format("<?xml version=\"1.0\" encoding=\"utf-8\" ?><Root><Data><MerchantID>{0}</MerchantID><MerchantTradeNo>{1}</MerchantTradeNo><TimeStamp>{2}</TimeStamp></Data></Root>", MerchantID, MerchantTradeNo, TimeStamp); string EnXML = new AllPay.ShareLib.Crypt().AES_EnCrypt(HashKey, HashIV, XML); string Result = ws.QueryTrade(MerchantID, EnXML); string DeXML = new AllPay.ShareLib.Crypt().AES_DeCrypt(HashKey, HashIV, Result); ViewBag.Result = HttpUtility.HtmlDecode(DeXML); return View("StageQueryTrade_Receive"); }
/// <summary> /// 模擬傳送ATM訂單資料到payment center /// </summary> /// <returns></returns> public ActionResult TestAtmToPaymentCenter() { //string AllPayHashKey = devHashKey; //string AllPayHashIV = devHashIv; //long AllPayMerchantID = 1000070; //string postURL = "http://devpaymentcenter.allpay.com.tw:12003/Payment/Srv/Gateway"; string AllPayHashKey = stageHashKey; string AllPayHashIV = stageHashIv; //long AllPayMerchantID = 999999999; long AllPayMerchantID = 2000132; //2000132:stage的測試店家 string postURL = "http://pay-stage.allpay.com.tw/Payment/Srv/Gateway"; string totalAmount = "35"; string orderTradeNo = DateTime.Now.ToString("yyyyMMddHHmmss"); string orderDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); string expireDate = "2"; string tradeXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<Root><Data>" + "<MerchantID>" + AllPayMerchantID + "</MerchantID>" + "<MerchantTradeNo>" + orderTradeNo + "</MerchantTradeNo>" + "<MerchantTradeDate>" + orderDate + "</MerchantTradeDate>" + "<TradeAmount>" + totalAmount + "</TradeAmount>" + "<ExpireDate>" + expireDate + "</ExpireDate>" + "<BankName>TAISHIN</BankName>" //+ "<ReplyURL>" + HttpUtility.UrlEncode("http://mockMerchant-stage.allpay.com.tw/AllPayPayment/ReceiveOrderResult") + "</ReplyURL>" + "<ReplyURL>" + HttpUtility.UrlEncode("http://devmockmerchant.allpay.com.tw:12020/AllPayPayment/ReceiveOrderResult") + "</ReplyURL>" + "<Remark>%e4%b8%80%e8%88%ac%e5%95%86%e5%93%81%e6%b8%ac%e8%a9%a6-DEV</Remark>" + "</Data></Root>"; Dictionary<string, string> postCollection = new Dictionary<string, string>(); postCollection.Add("MerchantID", AllPayMerchantID.ToString()); postCollection.Add("PaymentType", "vAccount"); //tradeXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Root><Data><MerchantID>2000132</MerchantID><MerchantTradeNo>test2013110811</MerchantTradeNo><MerchantTradeDate>2013/11/08 15:46:52</MerchantTradeDate> <TradeAmount>30000</TradeAmount><ExpireDate>3</ExpireDate><BankName>TAISHIN</BankName><ReplyURL>http://latebird.tw.59.127.35.26.xip.io/api/allpay_notify.json</ReplyURL><Remark/></Data></Root>"; string xmlData = new AllPay.ShareLib.Crypt().AES_EnCrypt(AllPayHashKey, AllPayHashIV, tradeXML); //xmlData = "H266LJHL3XdawK5JprWAWFe1tkLrGB1WBKaiiYcNP74vWmkudvM4k3iaVpN+IU5EKvgQDht4wWj6iSPUPJoFb6HwjZFXUsWDOFnG71XUiT6sAWRR9f/EAq+/k9U5BsJnFlDN+lBfYzJuNEIihbuZQTZmvmLbR41D6lQEBuw1VGHz77jGWhTQuRK4EuVfq6ltnuSMl+FpP9R51sdmTrQLENkeUvMqTiY5vFVBPDmT/a0m0CqN638oXWYTiaL31punwnxa4A649L8uigqFFmd+tnGKB1K0mtIsO5q6camVKWPE1lNJp2D4P7zQqALe3U2+MsrZpGfeOwI/zkE3CwHYgP9YxvXcwTL1kQ6wi1h+1Y52wCh62MaxD5GBplzDPAq9RGGdqxjrKy0+UYgbpZ57IBrhMUnFCfpK+23HvPjTpUZskyzggT9dIeD/KrQfrlW6FknjiDsWPdob2DeFL1EBMn3vtiAl0yRCAw850fNKt6018NGFYWiRf+Abqho56kKQ"; postCollection.Add("XMLData", xmlData); Hashtable RequestTable = new Hashtable(); foreach (var item in postCollection) { RequestTable.Add(item.Key, item.Value); } //string postURL = "http://devpaymentcenter.allpay.com.tw:12003/Payment/Srv/Gateway"; //### 發送到Mp, 取得Response string ServerResponse = DoRequest(postURL, RequestTable); ViewBag.ServerResponse = ServerResponse; return View(); }
/// <summary> /// 測試stage的post版訂單查詢 /// </summary> public ActionResult StageQueryPostTrade() { StageAllpayWs.AllPaySoapClient ws = new StageAllpayWs.AllPaySoapClient(); //string testHashKey = "yWsdQjr33vV7IFw1"; //for beta:888888889 //string testHashIv = "6vvUZQaZXm11GATD"; //string MerchantID = "888888889"; //string testHashKey = "fugvqTnG3ROx81MO"; //for 1000070 //string testHashIv = "WkSfnqIaHLbUMV5X"; //string MerchantID = "1000070"; string testHashKey = "A123456789012345"; //for stage:999990001 string testHashIv = "B123456789012345"; string MerchantID = "999990001"; //string testHashKey = "B12prXew9mbTySf5"; //for prod:999990001 //string testHashIv = "VCUrz5Tyda0gpqPN"; //string MerchantID = "999990001"; string MerchantTradeNo = "13081209216343"; string TimeStamp = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString(); string postData = "&MerchantID=" + MerchantID + "&MerchantTradeNo=" + MerchantTradeNo + "&TimeStamp=" + TimeStamp; string lowerDataToUrlEncode = HttpUtility.UrlEncode("HashKey=" + testHashKey + postData + "&HashIV=" + testHashIv); string md5DataToLower = lowerDataToUrlEncode.ToLower(); string CheckMacValue = new AllPay.ShareLib.Crypt().MD5(md5DataToLower); string Result = ws.QueryTradeInfo(MerchantID, MerchantTradeNo, Convert.ToInt32(TimeStamp), CheckMacValue); ViewBag.Result = Result; return View("StageQueryTrade_Receive"); }
//模擬payment傳送支付寶訂單資料到payment center public ActionResult TestAlipayToPaymentCenter() { string AllPayHashKey = devHashKey; string AllPayHashIV = devHashIv; long AllPayMerchantID = 999999999; //dev string totalAmount = "35"; string orderTradeNo = DateTime.Now.ToString("yyyyMMddHHmmss"); string orderDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); //string expireDate = DateTime.Now.AddDays(2).ToString("yyyy/MM/dd HH:mm:ss"); //設定MP的Post網址 //string postURL = "http://pay-stage.allpay.com.tw/Payment/Gateway"; //string postURL = "http://devpaymentcenter.allpay.com.tw:12003/Payment/Gateway"; string postURL = "https://pay.allpay.com.tw/Payment/Gateway"; string tradeXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<Root><Data>" + "<MerchantID>" + AllPayMerchantID + "</MerchantID>" + "<MerchantTradeNo>" + orderTradeNo + "</MerchantTradeNo>" + "<MerchantTradeDate>" + orderDate + "</MerchantTradeDate>" + "<TradeAmount>" + totalAmount + "</TradeAmount>" + " <ItemName>入門包#超值包</ItemName><ItemCounts>1#2</ItemCounts><ItemPrice>15#20</ItemPrice>" //+ "<ServerReplyURL>" + HttpUtility.UrlEncode("http://mockMerchant-stage.allpay.com.tw/AllPayPayment/ReceiveOrderResult") + "</ServerReplyURL>" //+ "<ClientReplyURL>" + HttpUtility.UrlEncode("http://mockMerchant-stage.allpay.com.tw/AllPayPayment/ReceiveOrderResult") + "</ClientReplyURL>" + "<ServerReplyURL>" + HttpUtility.UrlEncode("http://devmockmerchant.allpay.com.tw:12020/AllPayPayment/ReceiveOrderResult") + "</ServerReplyURL>" + "<ClientReplyURL>" + HttpUtility.UrlEncode("http://devmockmerchant.allpay.com.tw:12020/AllPayPayment/ReceiveOrderResult") + "</ClientReplyURL>" + "<Remark>%e4%b8%80%e8%88%ac%e5%95%86%e5%93%81%e6%b8%ac%e8%a9%a6-DEV</Remark>" + "<Email>[email protected]</Email>" + "<PhoneNo>0958389636</PhoneNo>" + "<UserName>葉炳棋</UserName>" + "</Data></Root>"; tradeXML = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Root><Data><MerchantID>1031026</MerchantID><MerchantTradeNo>138355833153339</MerchantTradeNo><MerchantTradeDate>2013/11/04 17:45:32</MerchantTradeDate><TradeAmount>100</TradeAmount><ItemName>gfhgfhgf</ItemName><ItemCounts>1</ItemCounts><ItemPrice>100</ItemPrice><ServerReplyURL>https%3A%2F%2Fgate.pepay.com.tw%2Fpepay%2Fpaysys%2Fallpay%2Fal_rcv.php</ServerReplyURL><ClientReplyURL>https%3A%2F%2Fgate.pepay.com.tw%2Fpepay%2Fpaysys%2Fallpay%2Fal_rtn.php</ClientReplyURL><Remark></Remark><Email></Email><PhoneNo></PhoneNo><UserName></UserName></Data></Root>"; Dictionary<string, string> postCollection = new Dictionary<string, string>(); postCollection.Add("MerchantID", AllPayMerchantID.ToString()); postCollection.Add("PaymentType", "ALIPAY"); string xmlData = new AllPay.ShareLib.Crypt().AES_EnCrypt(AllPayHashKey, AllPayHashIV, tradeXML); postCollection.Add("XMLData", xmlData); TempData["PostCollection"] = postCollection; TempData["PostURL"] = postURL; return RedirectToAction("AutoSubmitForm", "Common"); }
/// <summary> /// 測試stage的post版訂單查詢 /// </summary> public ActionResult StageQueryPostTrade_2() { //string testHashKey = "yWsdQjr33vV7IFw1"; //for beta:888888889 //string testHashIv = "6vvUZQaZXm11GATD"; //string MerchantID = "888888889"; //string testHashKey = "fugvqTnG3ROx81MO"; //for 1000070 //string testHashIv = "WkSfnqIaHLbUMV5X"; //string MerchantID = "1000070"; string testHashKey = "A123456789012345"; //for stage:999990001 string testHashIv = "B123456789012345"; string MerchantID = "999990001"; string postUrl = "http://payment-stage.allpay.com.tw/Cashier/QueryTradeInfo"; //string postUrl = "http://devpayment.allpay.com.tw:12005/Cashier/QueryTradeInfo"; //string testHashKey = "B12prXew9mbTySf5"; //for prod:999990001 //string testHashIv = "VCUrz5Tyda0gpqPN"; //string MerchantID = "999990001"; string MerchantTradeNo = "13081209216343"; string TimeStamp = ((DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000).ToString(); string postData = "&MerchantID=" + MerchantID + "&MerchantTradeNo=" + MerchantTradeNo + "&TimeStamp=" + TimeStamp; string lowerDataToUrlEncode = HttpUtility.UrlEncode("HashKey=" + testHashKey + postData + "&HashIV=" + testHashIv); string md5DataToLower = lowerDataToUrlEncode.ToLower(); string CheckMacValue = new AllPay.ShareLib.Crypt().MD5(md5DataToLower); Dictionary<string, string> postCollection = new Dictionary<string, string>(); postCollection.Add("MerchantID", MerchantID); postCollection.Add("MerchantTradeNo", MerchantTradeNo); postCollection.Add("TimeStamp", TimeStamp); postCollection.Add("CheckMacValue", CheckMacValue); Hashtable RequestTable = new Hashtable(); foreach (var item in postCollection) { RequestTable.Add(item.Key, item.Value); } //TempData["PostCollection"] = postCollection; //TempData["PostURL"] = postUrl; //return RedirectToAction("AutoSubmitForm", "Common"); ////### 發送到Mp, 取得Response string ServerResponse = DoRequest(postUrl, RequestTable); ViewBag.Result = ServerResponse; return View("StageQueryTrade_Receive"); }
//測試回傳給payment WebATM付款成功的動作 public ActionResult TestWebAtmReturn() { string merchantId = "999999999"; string merchantTradeNo = "40964"; //payment的tradeID string tradeNo = "20121202033318643476"; //payment center的tradeNo(隨便填,可以不用改) string tradeAmount = "1000"; string AesHashKey = "fugvqTnG3ROx81MO"; string AesHashIv = "WkSfnqIaHLbUMV5X"; //string serverRelpyUrl = "http://devpayment.allpay.com.tw:12005/bank/paymentcenter/srv/webatm/result"; //string clientReplyUrl = "http://devpayment.allpay.com.tw:12005/bank/paymentcenter/cnt/webatm/result"; string serverRelpyUrl = "https://payment.allpay.com.tw/bank/paymentcenter/srv/webatm/result"; string clientReplyUrl = "https://payment.allpay.com.tw/bank/paymentcenter/cnt/webatm/result"; //也必需更新payment center的訂單,因為payment會反查 /* update Payment_TradeNo set PaymentStatus = '1' ,PaymentDate = GETDATE() where TradeID = 12153 update Payment_TradeDetail_WebATM set RtnCode = '1' ,RtnPaymentDate= GETDATE() ,RtnBankCode = '008' ,RtnBankAcc = '168371' where TradeID = 12153 * */ XmlDocument XML = new XmlDocument(); XML.Load(HttpContext.Server.MapPath("~/App_Data/ReturnMerchantWebATM.xml")); //###取得XML的節點 XmlElement eleMerchantID = (XmlElement)XML.SelectSingleNode("Root/Data/MerchantID"); XmlElement eleMerchantTradeNo = (XmlElement)XML.SelectSingleNode("Root/Data/MerchantTradeNo"); XmlElement eleRtnCode = (XmlElement)XML.SelectSingleNode("Root/Data/RtnCode"); XmlElement eleRtnMsg = (XmlElement)XML.SelectSingleNode("Root/Data/RtnMsg"); XmlElement eleTradeNo = (XmlElement)XML.SelectSingleNode("Root/Data/TradeNo"); XmlElement eleTradeDate = (XmlElement)XML.SelectSingleNode("Root/Data/TradeDate"); XmlElement eleTradeAmount = (XmlElement)XML.SelectSingleNode("Root/Data/TradeAmount"); XmlElement eleAccBank = (XmlElement)XML.SelectSingleNode("Root/Data/AccBank"); XmlElement eleAccNo = (XmlElement)XML.SelectSingleNode("Root/Data/AccNo"); XmlElement eleBankName = (XmlElement)XML.SelectSingleNode("Root/Data/BankName"); //### 設定XML內容 eleMerchantID.InnerText = merchantId; eleMerchantTradeNo.InnerText = merchantTradeNo; eleRtnCode.InnerText = "1"; eleRtnMsg.InnerText = "success"; eleTradeNo.InnerText = tradeNo; eleTradeDate.InnerText = "2012/12/02 03:33:18"; // DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); eleTradeAmount.InnerText = tradeAmount; eleAccBank.InnerText = "808"; eleAccNo.InnerText = "17962"; eleBankName.InnerText = "ESUN"; //### 將XML透過AES加密 string XMLData = new AllPay.ShareLib.Crypt().AES_EnCrypt(AesHashKey, AesHashIv, XML.OuterXml); string serverResponse = new AllPay.ShareLib.Network().FormPost(serverRelpyUrl, "XMLData=" + XMLData, "", 0, 65001); //再client端回傳 string clientResponse = new AllPay.ShareLib.Network().FormPost(clientReplyUrl, "XMLData=" + XMLData, "", 0, 65001); ViewBag.ServerResponse = serverResponse; ViewBag.ServerResult = false; if (serverResponse.IndexOf("1|OK") > -1) { ViewBag.Result = true; } ViewBag.ClientResponse = clientResponse; return View(); }
//public ActionResult testProdSms() { // AllPaySharedWSSoapClient WS = new AllPaySharedWSSoapClient(); // string RtnCode = WS.SendSMS("0958389636", "matt test", 0); // return View(); //} /// <summary> /// 測試簡易API的商品異常處理通知 /// </summary> /// <returns></returns> public ActionResult TestOrderChangeNotify() { //string testHashKey = "yWsdQjr33vV7IFw1"; //for beta:888888889 //string testHashIv = "6vvUZQaZXm11GATD"; //string MerchantID = "888888889"; string testHashKey = "0xurqKTafMeETeB9"; //for stage:2000031 string testHashIv = "DXn12MB9Qa9pBpsj"; string MerchantID = "2000031"; string MerchantTradeNo = "130626204228130"; string TradeNo = "1306262042286797"; string InfoType = "1"; //1:退部份金額/2:退全部金額/3:換貨後已重新出貨/4:商品無異常 string RefundAmount = "10"; string Remark = "matt"; string postData = "&InfoType=" + InfoType + "&MerchantID=" + MerchantID + "&MerchantTradeNo=" + MerchantTradeNo + "&RefundAmount=" + RefundAmount + "&Remark=" + Remark + "&TradeNo=" + TradeNo; string CheckMacValue = new AllPay.ShareLib.Crypt().MD5("HashKey=" + testHashKey + postData + "&HashIV=" + testHashIv); string createTradePostDomain = ConfigurationManager.AppSettings["AllPayPaymentDomain"].ToString(); //string postUrl = createTradePostDomain + "/cashier/OrderChangeNotify"; //接收商品異常訂單結果通知網址 string postUrl = "http://payment-stage.allpay.com.tw/cashier/OrderChangeNotify"; Dictionary<string, string> postCollection = new Dictionary<string, string>(); postCollection.Add("MerchantID", MerchantID); postCollection.Add("MerchantTradeNo", MerchantTradeNo); postCollection.Add("TradeNo", TradeNo); postCollection.Add("InfoType", InfoType); postCollection.Add("RefundAmount", RefundAmount); postCollection.Add("Remark", Remark); postCollection.Add("CheckMacValue", CheckMacValue); Hashtable RequestTable = new Hashtable(); foreach (var item in postCollection) { RequestTable.Add(item.Key, item.Value); } //### 發送到Mp, 取得Response string ServerResponse = DoRequest(postUrl, RequestTable); ViewBag.SendResult = ServerResponse; return View("SendDeliveryNotify_Receive"); }
//測試回傳給payment 超商付款成功的動作 public ActionResult TestCVSReturnToPayment() { string merchantId = "999999999"; string merchantTradeNo = "13837"; //payment的tradeID(必改) string tradeNo = "20121018101322793733"; //payment center的tradeNo(可不改) string payDate = "2012-10-18 19:25:27"; string payAmount = "30"; string paymentNo = "GW121018919930"; //繳費代碼 string payForm = "okmart"; //繳費平台 string AesHashKey = "fugvqTnG3ROx81MO"; //開發環境的key string AesHashIv = "WkSfnqIaHLbUMV5X"; string serverReplyUrl = "http://devpayment.allpay.com.tw:12005/bank/paymentcenter/srv/cvs/result"; XmlDocument xml = new XmlDocument(); xml.Load(HttpContext.Server.MapPath("~/App_Data/ReturnCVSPaidTrade.xml")); XmlElement eleMerchantID = (XmlElement)xml.SelectSingleNode("Root/Data/MerchantID"); XmlElement eleMerchantTradeNo = (XmlElement)xml.SelectSingleNode("Root/Data/MerchantTradeNo"); XmlElement eleRtnCode = (XmlElement)xml.SelectSingleNode("Root/Data/RtnCode"); XmlElement eleRtnMsg = (XmlElement)xml.SelectSingleNode("Root/Data/RtnMsg"); XmlElement eleTradeNo = (XmlElement)xml.SelectSingleNode("Root/Data/TradeNo"); XmlElement elePayDate = (XmlElement)xml.SelectSingleNode("Root/Data/PayDate"); XmlElement eleTradeAmount = (XmlElement)xml.SelectSingleNode("Root/Data/TradeAmount"); XmlElement elePaymentNo = (XmlElement)xml.SelectSingleNode("Root/Data/PaymentNo"); XmlElement elePayFrom = (XmlElement)xml.SelectSingleNode("Root/Data/PayFrom"); //### 設定XML內容 eleMerchantID.InnerText = merchantId; eleMerchantTradeNo.InnerText = merchantTradeNo; eleRtnCode.InnerText = "1"; eleRtnMsg.InnerText = "Succeeded"; eleTradeNo.InnerText = tradeNo; elePayDate.InnerText = payDate; eleTradeAmount.InnerText = payAmount; elePaymentNo.InnerText = paymentNo; elePayFrom.InnerText = payForm; //long epoch = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000; //eleTimeStamp.InnerText = epoch.ToString(); ////### 將XML透過AES加密 string XMLData = new AllPay.ShareLib.Crypt().AES_EnCrypt(AesHashKey, AesHashIv, xml.OuterXml); //server端回傳 string serverReponse = new AllPay.ShareLib.Network().FormPost(serverReplyUrl, "XMLData=" + XMLData, "", 0, 65001); ViewBag.Reponse = serverReponse; ViewBag.Result = false; if (serverReponse.IndexOf("1|OK") > -1) { ViewBag.Result = true; } return View(); }
/// <summary> /// 測試使用PaymentType = pay的方式建立訂單 /// (無履約,但要登入會員) /// </summary> /// <returns></returns> public ActionResult TestPayCreateOrder() { //string testHashKey = "yWsdQjr33vV7IFw1"; //for beta:888888889 //string testHashIv = "6vvUZQaZXm11GATD"; //string MerchantID = "888888889"; //string testHashKey = "fugvqTnG3ROx81MO"; //for 1000070 //string testHashIv = "WkSfnqIaHLbUMV5X"; //string MerchantID = "1000070"; //string testHashKey = "A123456789012345"; //for stage:999990001 //string testHashIv = "B123456789012345"; //string MerchantID = "999990004"; //string testHashKey = "B12prXew9mbTySf5"; //for prod:999990001 //string testHashIv = "VCUrz5Tyda0gpqPN"; //string MerchantID = "999990001"; //string testHashKey = "B12prXew9mbTySf5"; //for prod:1031342 //string testHashIv = "VCUrz5Tyda0gpqPN"; //string MerchantID = "1031342"; string testHashKey = "SM6zZHQvodchMaTk"; //for prod:888891 string testHashIv = "zf3MhCfhzwUZoGfi"; string MerchantID = "888891"; string MerchantTradeNo = DateTime.Now.ToString("yyyyMMddHHmmss"); string MerchantTradeDate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"); string PaymentType = "pay"; string TotalAmount = "35"; //string TradeDesc = "支付寶卡面額人民幣(CNY)100元X2張+支付寶卡面額人民幣(CNY)500元X1張"; //string ItemName = "支付寶卡面額人民幣(CNY)100元X2張+支付寶卡面額人民幣(CNY)500元X1張"; string TradeDesc = "BOX1_Online_Shop"; string ItemName = "M-02"; string ReturnURL = "http://devmockmerchant.allpay.com.tw:12020/AllPayPayment/TestReceivePayResult"; string Remark = "matt"; string ClientBackURL = "http://www.allpay.com.tw"; string Currency = "CNY"; string ExchangeRate = "2.0"; string BuyerChargeFee = "0"; //string ChoosePayment = "TopUpUsed_AllPay"; //string ChoosePayment = "TopUpUsed_ESUN"; string ChoosePayment = "CVS"; string ChooseSubPayment = ""; string OrderCreateNotifyURL = "http://devmockmerchant.allpay.com.tw:12020/AllPayPayment/ReceiveOrderResult"; string postData = "&BuyerChargeFee=" + BuyerChargeFee + "&ChoosePayment=" + ChoosePayment + "&ChooseSubPayment=" + ChooseSubPayment + "&ClientBackURL=" + ClientBackURL + "&Currency=" + Currency + "&ExchangeRate=" + ExchangeRate + "&ItemName=" + ItemName + "&MerchantID=" + MerchantID + "&MerchantTradeDate=" + MerchantTradeDate + "&MerchantTradeNo=" + MerchantTradeNo //+ "&OrderCreateNotifyURL=" + OrderCreateNotifyURL + "&PaymentType=" + PaymentType //+ "&Remark=" + Remark + "&ReturnURL=" + ReturnURL + "&TotalAmount=" + TotalAmount + "&TradeDesc=" + TradeDesc; string lowerDataToUrlEncode = HttpUtility.UrlEncode("HashKey=" + testHashKey + postData + "&HashIV=" + testHashIv); //string lowerDataToUrlEncode = HttpUtility.UrlEncode("HashKey=NkeqESxlDNONHVIp&AlipayItemCounts=2#1&AlipayItemName=電子鍋#皮衣&AlipayItemPrice=100#250&CheckMacValue=&ChoosePayment=ATM&ClientBackURL=http://vmall2.sunup.net/&CreditInstallment=3&Desc_4=付款完請保留繳費收据&[email protected]&ExpireDate=3&ExpireTime=2013/11/07+17:45:35&InstallmentAmount=150&ItemName=A001商品001+100元x2#A002商品002+100元x2#&MerchantID=1012077&MerchantTradeDate=2013/11/04+17:44:47&MerchantTradeNo=1383557665&PaymentType=aio&PhoneNo=0919253377&ReturnURL=http://vmall2.sunup.net/ecart/allpay_bk_roturl.php&TotalAmount=100&TradeDesc=anow購物商城&UserName=張虔銘&HashIV=pMXD78k3iwaTpO2v"); string md5DataToLower = lowerDataToUrlEncode.ToLower(); //md5DataToLower = "hashkey%3dnkeqesxldnonhvip%26alipayitemcounts%3d2%231%26alipayitemname%3d%e9%9b%bb%e5%ad%90%e9%8d%8b%23%e7%9a%ae%e8%a1%a3%26alipayitemprice%3d100%23250%26choosepayment%3datm%26clientbackurl%3dhttp%3a%2f%2fvmall2.sunup.net%2f%26creditinstallment%3d3%26desc_4%3d%e4%bb%98%e6%ac%be%e5%ae%8c%e8%ab%8b%e4%bf%9d%e7%95%99%e7%b9%b3%e8%b2%bb%e6%94%b6%e6%8d%ae%26email%3dover.chang%40allpay.com.tw%26expiredate%3d3%26expiretime%3d2013%2f11%2f07%2b17%3a45%3a35%26installmentamount%3d150%26itemname%3da001%e5%95%86%e5%93%81001%2b100%e5%85%83x2%23a002%e5%95%86%e5%93%81002%2b100%e5%85%83x2%23%26merchantid%3d1012077%26merchanttradedate%3d2013%2f11%2f04%2b17%3a44%3a47%26merchanttradeno%3d1383557665%26paymenttype%3daio%26phoneno%3d0919253377%26returnurl%3dhttp%3a%2f%2fvmall2.sunup.net%2fecart%2fallpay_bk_roturl.php%26totalamount%3d100%26tradedesc%3danow%e8%b3%bc%e7%89%a9%e5%95%86%e5%9f%8e%26username%3d%e5%bc%b5%e8%99%94%e9%8a%98%26hashiv%3dpmxd78k3iwatpo2v"; string CheckMacValue = new AllPay.ShareLib.Crypt().MD5(md5DataToLower); string createTradePostDomain = ConfigurationManager.AppSettings["AllPayPaymentDomain"].ToString(); //string postUrl = "http://devpayment.allpay.com.tw:12005/cashier/checkout"; //string postUrl = "http://payment-stage.allpay.com.tw/cashier/checkout"; string postUrl = "https://payment.allpay.com.tw/cashier/checkout"; //string postUrl = "http://test-alicard.allpay.com.tw/main/payment_gateway/trade_notify_page"; Dictionary<string, string> postCollection = new Dictionary<string, string>(); postCollection.Add("BuyerChargeFee", BuyerChargeFee); postCollection.Add("Currency", Currency); postCollection.Add("ChoosePayment", ChoosePayment); postCollection.Add("ChooseSubPayment", ChooseSubPayment); postCollection.Add("ExchangeRate", ExchangeRate); postCollection.Add("MerchantID", MerchantID); postCollection.Add("MerchantTradeNo", MerchantTradeNo); postCollection.Add("MerchantTradeDate", MerchantTradeDate); postCollection.Add("PaymentType", PaymentType); postCollection.Add("TotalAmount", TotalAmount); postCollection.Add("TradeDesc", TradeDesc); postCollection.Add("ItemName", ItemName); postCollection.Add("ReturnURL", ReturnURL); //postCollection.Add("Remark", Remark); //postCollection.Add("OrderCreateNotifyURL", OrderCreateNotifyURL); postCollection.Add("ClientBackURL", ClientBackURL); postCollection.Add("CheckMacValue", CheckMacValue); TempData["PostCollection"] = postCollection; TempData["PostURL"] = postUrl; return RedirectToAction("AutoSubmitForm", "Common"); }
//測試回傳給payment 財付通付款成功的動作 public ActionResult TestTenpayReturn() { //string merchantId = "999999999"; //string merchantTradeNo = "41047"; //payment的tradeID //string tradeNo = "20121202161509134918"; //payment center的tradeNo ////string relpyUrl = "http://devpayment.allpay.com.tw:12005/bank/paymentcenter/cnt/tenpay/result"; ////string serverReplyUrl = "http://devpayment.allpay.com.tw:12005/bank/paymentcenter/srv/tenpay/result"; //string relpyUrl = "https://payment.allpay.com.tw/bank/paymentcenter/cnt/tenpay/result"; //string serverReplyUrl = "https://payment.allpay.com.tw/bank/paymentcenter/srv/tenpay/result"; string merchantId = "2000132"; string merchantTradeNo = "100051"; //payment的tradeID string tradeNo = "20131018144107463317"; //payment center的tradeNo string AesHashKey = "ejCk326UnaZWKisg"; string AesHashIv = "q9jcZX8Ib9LM8wYk"; string serverReplyUrl = "http://linda.sunup.net/test/pay_info.php"; XmlDocument XML = new XmlDocument(); XML.Load(HttpContext.Server.MapPath("~/App_Data/PaymentReceiveTenpay.xml")); //###取得XML的節點 XmlElement eleMerchantID = (XmlElement)XML.SelectSingleNode("Root/Data/MerchantID"); XmlElement eleMerchantTradeNo = (XmlElement)XML.SelectSingleNode("Root/Data/MerchantTradeNo"); XmlElement eleRtnCode = (XmlElement)XML.SelectSingleNode("Root/Data/RtnCode"); XmlElement eleRtnMsg = (XmlElement)XML.SelectSingleNode("Root/Data/RtnMsg"); XmlElement eleTradeNo = (XmlElement)XML.SelectSingleNode("Root/Data/TradeNo"); XmlElement eleTradeDate = (XmlElement)XML.SelectSingleNode("Root/Data/TradeDate"); XmlElement eleTradeAmount = (XmlElement)XML.SelectSingleNode("Root/Data/TradeAmount"); XmlElement eleTenpayTradeNo = (XmlElement)XML.SelectSingleNode("Root/Data/TenpayTradeNo"); XmlElement eleTimeStamp = (XmlElement)XML.SelectSingleNode("Root/Data/TimeStamp"); //### 設定XML內容 eleMerchantID.InnerText = merchantId; eleMerchantTradeNo.InnerText = merchantTradeNo; eleRtnCode.InnerText = "1"; eleRtnMsg.InnerText = "success"; eleTradeNo.InnerText = tradeNo; eleTradeDate.InnerText = "2013/10/18 23:24:00"; eleTradeAmount.InnerText = "200.0"; eleTenpayTradeNo.InnerText = "12141540012012120201"; long epoch = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000; eleTimeStamp.InnerText = epoch.ToString(); //### 將XML透過AES加密 string XMLData = new AllPay.ShareLib.Crypt().AES_EnCrypt(AesHashKey, AesHashIv, XML.OuterXml); //先server端回傳 string serverReponse = new AllPay.ShareLib.Network().FormPost(serverReplyUrl, "XMLData=" + XMLData, "", 0, 65001); //再client端回傳 //string response = new AllPay.ShareLib.Network().FormPost(relpyUrl, "XMLData=" + XMLData, "", 0, 65001); //DoRequest(relpyUrl, XMLData); return null; }
/// <summary> /// 測試使用PaymentType = pay的方式退款 /// </summary> /// <returns></returns> public ActionResult TestPayChargeBack() { //string testHashKey = "yWsdQjr33vV7IFw1"; //for beta:888888889 //string testHashIv = "6vvUZQaZXm11GATD"; //string MerchantID = "888888889"; //string testHashKey = "fugvqTnG3ROx81MO"; //for 1000070 //string testHashIv = "WkSfnqIaHLbUMV5X"; //string MerchantID = "1000070"; //string testHashKey = "A123456789012345"; //for stage:999990001 //string testHashIv = "B123456789012345"; //string MerchantID = "999990004"; //string testHashKey = "B12prXew9mbTySf5"; //for prod:999990001 //string testHashIv = "VCUrz5Tyda0gpqPN"; //string MerchantID = "999990001"; string testHashKey = "LYTAue8Hm0CotSnO"; //for prod:1031095 string testHashIv = "wyyA9QEilAqGE9di"; string MerchantID = "1031095"; //string testHashKey = "SM6zZHQvodchMaTk"; //for prod:888891 //string testHashIv = "zf3MhCfhzwUZoGfi"; //string MerchantID = "888891"; string MerchantTradeNo = "2106"; string allpayTradeNo = "1311120453580056"; string ChargeBackTotalAmount = "990"; string Remark = "allpay fix"; string postData = "&ChargeBackTotalAmount=" + ChargeBackTotalAmount + "&MerchantID=" + MerchantID + "&MerchantTradeNo=" + MerchantTradeNo + "&Remark=" + Remark + "&TradeNo=" + allpayTradeNo; string lowerDataToUrlEncode = HttpUtility.UrlEncode("HashKey=" + testHashKey + postData + "&HashIV=" + testHashIv); string md5DataToLower = lowerDataToUrlEncode.ToLower(); string CheckMacValue = new AllPay.ShareLib.Crypt().MD5(md5DataToLower); string createTradePostDomain = ConfigurationManager.AppSettings["AllPayPaymentDomain"].ToString(); //string postUrl = "http://devpayment.allpay.com.tw:12005/cashier/Chargeback"; //string postUrl = "http://payment-stage.allpay.com.tw/cashier/Chargeback"; string postUrl = "https://payment.allpay.com.tw/cashier/Chargeback"; Dictionary<string, string> postCollection = new Dictionary<string, string>(); postCollection.Add("ChargeBackTotalAmount", ChargeBackTotalAmount); postCollection.Add("MerchantID", MerchantID); postCollection.Add("MerchantTradeNo", MerchantTradeNo); postCollection.Add("TradeNo", allpayTradeNo); postCollection.Add("CheckMacValue", CheckMacValue); postCollection.Add("Remark", Remark); TempData["PostCollection"] = postCollection; TempData["PostURL"] = postUrl; return RedirectToAction("AutoSubmitForm", "Common"); }
public ActionResult TestEticketCreateGuarantee() { long merchantId = 1000139; string hashKey = "Zf1AjVRlwE4XjlF9"; //beta string hashIv = "Ps8hPWGtUW0PE3Gk"; string tradePostUrl = "http://payment-beta.allpay.com.tw/api/Guarantee/CreateGuarantee"; //long merchantId = 1000139; //string hashKey = "Zf1AjVRlwE4XjlF9"; //stage //string hashIv = "Ps8hPWGtUW0PE3Gk"; //string tradePostUrl = "http://payment-stage.allpay.com.tw/api/Guarantee/CreateGuarantee"; //long merchantId = 888891; //string hashKey = "SM6zZHQvodchMaTk"; //正式 //string hashIv = "zf3MhCfhzwUZoGfi"; //string tradePostUrl = "https://payment.allpay.com.tw/api/Guarantee/CreateGuarantee"; string merchantTradeNo = "20130514112749"; // "Matt" + DateTime.Now.ToString("yyyyMMddHHmmss"); string tradeNo = "1305141127592819"; // DateTime.Now.ToString("yyyyMMddHHmmss"); int guaranteeTotalAmount = 90; GuaranteeCreateGuaranteePost ETicketModel = new GuaranteeCreateGuaranteePost(); List<GuaranteeCreateGuaranteePostItem> ListItemData = new List<GuaranteeCreateGuaranteePostItem>(); ETicketModel.MerchantID = merchantId; ETicketModel.MerchantTradeNo = merchantTradeNo; ETicketModel.TradeNo = tradeNo; ETicketModel.PaymentType = "eticket"; ETicketModel.UserName = "******"; ETicketModel.Phone = "0958389636"; ETicketModel.GuaranteeTotalAmount = guaranteeTotalAmount; GuaranteeCreateGuaranteePostItem guaranteeCreateGuaranteePostItem = new GuaranteeCreateGuaranteePostItem(); guaranteeCreateGuaranteePostItem.ItemNo = "A123"; guaranteeCreateGuaranteePostItem.ItemName = "喜來登住宿券"; guaranteeCreateGuaranteePostItem.ItemType = 0; guaranteeCreateGuaranteePostItem.Quantity = 3; guaranteeCreateGuaranteePostItem.Amount = 30; guaranteeCreateGuaranteePostItem.SubTotalAmount = 90; guaranteeCreateGuaranteePostItem.GuaranteeQuantity = 3; guaranteeCreateGuaranteePostItem.GuaranteeAmount = 90; ListItemData.Add(guaranteeCreateGuaranteePostItem); ETicketModel.ItemData = ListItemData; string Json = HttpUtility.UrlEncode(JsonConvert.SerializeObject(ETicketModel), System.Text.Encoding.UTF8); string PostUrl = tradePostUrl; string Contents = new AllPay.ShareLib.Crypt().AES_EnCrypt(hashKey, hashIv, Json); Hashtable postHashTable = new Hashtable(); postHashTable.Add("MerchantID", merchantId); postHashTable.Add("Contents", Contents); string postReturnData = DoRequest(PostUrl, postHashTable); string decryptXml = new AllPay.ShareLib.Crypt().AES_DeCrypt(hashKey, hashIv, postReturnData); ; ViewBag.returnEncryptXml = HttpUtility.UrlDecode(decryptXml); return View(); }
/// <summary> /// 測試eticket退款 /// </summary> /// <returns></returns> public ActionResult TestEticketChargeBack() { long merchantId = 1000070; string hashKey = "fugvqTnG3ROx81MO"; //dev string hashIv = "WkSfnqIaHLbUMV5X"; string tradePostUrl = "http://devpayment.allpay.com.tw:12005/api/Guarantee/Chargeback"; //long merchantId = 1000139; //string hashKey = "Zf1AjVRlwE4XjlF9"; //stage //string hashIv = "Ps8hPWGtUW0PE3Gk"; //string tradePostUrl = "http://payment-stage.allpay.com.tw/api/Guarantee/Chargeback"; string merchantTradeNo = "20130412113131"; string tradeNo = "1304121131338757"; int chargebackTotalAmount = 10; int chargebackQuantity = 1; string itemNo = "A123"; int chargebackAmount = 10; GuaranteeChargebackPost ETicketModel = new GuaranteeChargebackPost(); List<GuaranteeChargebackPostItem> ListItemData = new List<GuaranteeChargebackPostItem>(); ETicketModel.MerchantID = merchantId; ETicketModel.MerchantTradeNo = merchantTradeNo; ETicketModel.TradeNo = tradeNo; ETicketModel.ChargebackTotalAmount = chargebackTotalAmount; GuaranteeChargebackPostItem chargeBackPostItem = new GuaranteeChargebackPostItem(); chargeBackPostItem.ItemNo = itemNo; chargeBackPostItem.ChargebackQuantity = chargebackQuantity; chargeBackPostItem.ChargebackAmount = chargebackAmount; ListItemData.Add(chargeBackPostItem); //ListItemData.Add(chargeBackPostItem); ETicketModel.ItemData = ListItemData; string Json = HttpUtility.UrlEncode(JsonConvert.SerializeObject(ETicketModel), System.Text.Encoding.UTF8); string PostUrl = tradePostUrl; string Contents = new AllPay.ShareLib.Crypt().AES_EnCrypt(hashKey, hashIv, Json); Hashtable postHashTable = new Hashtable(); postHashTable.Add("MerchantID", merchantId); postHashTable.Add("Contents", Contents); string postReturnData = DoRequest(PostUrl, postHashTable); ////設定要Post的資料 //Dictionary<string, string> PostDictionary = new Dictionary<string, string>(); //PostDictionary.Add("MerchantID", merchantId.ToString()); //PostDictionary.Add("Contents", Contents); ////設定要送到MP的資料 //TempData["PostCollection"] = PostDictionary; //TempData["PostURL"] = PostUrl; ////將要送給MP的資料,透過autoSubmitForm.cshtml傳給MP //return RedirectToAction("AutoSubmitForm", "Common"); string decryptXml = new AllPay.ShareLib.Crypt().AES_DeCrypt(hashKey, hashIv, postReturnData); ViewBag.returnEncryptXml = HttpUtility.UrlDecode(decryptXml); return View(); }