예제 #1
0
        public ActionResult Verify(BatchPaymentVerifyResults result)
        {
            BatchPaymentResult batchPaymentResult = new BatchPaymentResult();

            batchPaymentResult.BatchPaymentVerifyResults.Add(result);

            return(View(batchPaymentResult));
        }
예제 #2
0
        public ActionResult VerifyRequest(BatchPaymentResult result)
        {
            try
            {
                BatchPaymentVerifyResults verifyResult = result.BatchPaymentVerifyResults[0];

                var cookie = Request.Cookies["BillPayData"].Value;
                var model  = JsonConvert.DeserializeObject <BatchPaymentRequest>(cookie);

                var dataBytes = Encoding.UTF8.GetBytes(verifyResult.Token);

                var symmetric = SymmetricAlgorithm.Create("TripleDes");
                symmetric.Mode    = CipherMode.ECB;
                symmetric.Padding = PaddingMode.PKCS7;

                var encryptor = symmetric.CreateEncryptor(Convert.FromBase64String(model.MerchantKey), new byte[8]);

                var signedData = Convert.ToBase64String(encryptor.TransformFinalBlock(dataBytes, 0, dataBytes.Length));

                var data = new
                {
                    Token    = verifyResult.Token,
                    SignData = signedData
                };

                var ipgUri = string.Format("{0}/api/v0/BatchVerify", model.PurchasePage);

                var res = CallApi <List <BatchPaymentVerifyResults> >(ipgUri, data);
                if (res != null && res.Result != null)
                {
                    if (res.Result[0].ResCode == "0")
                    {
                        result.BatchPaymentVerifyResults[0] = res.Result[0];
                        res.Result[0].Succeed = true;
                        ViewBag.Success       = res.Result[0].Description;
                        return(View("Verify", result));
                    }
                    ViewBag.Message = res.Result[0].Description;
                    return(View("Verify"));
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.ToString();
            }

            return(View("Verify", result));
        }