// // 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(); }
/// <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(); }