コード例 #1
0
        internal string DoApiSaleTransaction(string sAction, PostingVM vm, string API_URL_Pay)
        {
            string autoHtml = "";
            //Create Api Helper Instance. Don't use static methods inside  ApiHelper or use them anywhere
            ApiHelper apiCaller = new ApiHelper();

            //Calling the api caller Sale Transaction initiate with data
            var returnData   = apiCaller.saleTxn(vm);
            var errorCode    = returnData.ToList().Find(a => a.Key == "ERROR_CODE").Value;
            var errorMessage = returnData.ToList().Find(a => a.Key == "ERROR_MSG").Value;
            var tranUuid     = "";

            if (errorCode == "000")
            {
                //Extract UUID from the Data budnle. these lines can be writen in same line. but for demostration purpose we keep it separated
                var dataDic = ReadFromXmlString(returnData.ToList().Find(a => a.Key == "PTRECEIPT").Value, sAction);
                tranUuid = dataDic["txn_uuid"];

                //Add the UUID to the session so it can be used when trns verifying
                _Session["ipay_out__txn_uuid"] = tranUuid;

                autoHtml = GenarateBrowserRedirectionHTML(API_URL_Pay, tranUuid);
            }
            else
            {
                throw new Exception(errorMessage);
            }
            return(autoHtml);
        }
コード例 #2
0
        public ActionResult Index()
        {
            List <PostingVM> postings = new List <PostingVM>();
            List <Posting>   list     = repo.GetPostings();

            foreach (var post in list)
            {
                PostingVM vm = new PostingVM();
                vm.Posting  = post;
                vm.Hashtags = post.Hashtag.Split(' ').ToList();
                postings.Add(vm);
            }
            return(View(postings));
        }
コード例 #3
0
        public ActionResult IndexPost()
        {
            gHelper = new GenaralHelpers(Session);
            try
            {
                ViewBag.Message = "Your application description page.";
                PostingVM vm      = new PostingVM();
                string    sAmount = "10.00";
                string    Mer_ref = GenaralHelpers.GetRandomNumber().ToString();
                Session["ipay_in__mer_ref_id"] = Mer_ref;
                //Set session Data
                vm.TxnAmount    = sAmount;
                vm.Action       = SalesTransactionType;
                vm.CurrencyCode = "LKR";
                vm.LanguageCode = "eng";
                vm.MerRefID     = Mer_ref;
                vm.ItemList     = "";
                vm.ReturnURL    = Return_Url;
                vm.MerVar1      = "";
                vm.MerVar2      = "";
                vm.MerVar3      = "";
                vm.MerVar4      = "";

                string autoHtml = "";

                switch (SalesTransactionType)
                {
                case "SaleTxn":
                    autoHtml = gHelper.DoApiSaleTransaction(SalesTransactionType, vm, API_URL_Pay);
                    break;

                case "saleTxnGroup":
                    autoHtml = gHelper.DoApiSaleTransaction(SalesTransactionType, vm, API_URL_Pay);
                    break;
                }

                return(Content(autoHtml));
            }
            catch (Exception ex) {
                //Need to include your error handling code here. just for demostration purpose we direct the full error message to view
                var errorMessage = ex.Message;
                ViewBag.Error = errorMessage;
                return(View());
            }
        }
コード例 #4
0
        public ActionResult ApproveUpdate(Posting posting)
        {
            posting            = repo.GetPostings().FirstOrDefault(x => x.PostingID == posting.PostingID);
            posting.IsApproved = !posting.IsApproved;
            repo.EditPosting(posting);

            List <PostingVM> posts = new List <PostingVM>();
            List <Posting>   list  = repo.GetPostings();

            foreach (var post in list)
            {
                PostingVM vm = new PostingVM();
                vm.Posting  = post;
                vm.Hashtags = post.Hashtag.Split(' ').ToList();
                posts.Add(vm);
            }
            return(RedirectToAction("Index", posts));
        }
コード例 #5
0
ファイル: ApiHelper.cs プロジェクト: asachanxxx/IPSClient
        public Dictionary <string, string> saleTxn(PostingVM vm)
        {
            Dictionary <string, string> SalesData = new Dictionary <string, string>();

            string PTInvoice = "<req>" +
                               "<mer_id>" + MerchantId + "</mer_id>" +
                               "<mer_txn_id>" + vm.MerRefID + "</mer_txn_id>" +
                               "<action>" + vm.Action + "</action>" +
                               "<txn_amt>" + vm.TxnAmount + "</txn_amt>" +
                               "<cur>" + vm.CurrencyCode + "</cur>" +
                               "<lang>" + vm.LanguageCode + "</lang>";

            if ((vm.ReturnURL != null) && (vm.ReturnURL.Length > 0))
            {
                PTInvoice = PTInvoice + "<ret_url>" + vm.ReturnURL + "</ret_url>";
            }

            if ((vm.MerVar1 != null) && (vm.MerVar1.Length > 0))
            {
                PTInvoice = PTInvoice + "<mer_var1>" + vm.MerVar1 + "</mer_var1>";
            }

            if ((vm.MerVar2 != null) && (vm.MerVar2.Length > 0))
            {
                PTInvoice = PTInvoice + "<mer_var2>" + vm.MerVar2 + "</mer_var2>";
            }

            if ((vm.MerVar3 != null) && (vm.MerVar3.Length > 0))
            {
                PTInvoice = PTInvoice + "<mer_var3>" + vm.MerVar3 + "</mer_var3>";
            }

            if ((vm.MerVar4 != null) && (vm.MerVar4.Length > 0))
            {
                PTInvoice = PTInvoice + "<mer_var4>" + vm.MerVar4 + "</mer_var4>";
            }
            PTInvoice = PTInvoice + "</req>";

            var finalHex = Cryptographer.ByteArrayToString(Encoding.UTF8.GetBytes(PTInvoice));

            return(PearToPear(finalHex, false, vm.Action));
        }