Пример #1
0
        public ActionResult GMOPamentGateway(string uniqueId, PGModuleEnum pgModule)
        {
            GMOPaymentRequest paymentRequest = new GMOPaymentRequest();

            try
            {
                if (String.IsNullOrEmpty(pgModule.ToString()))
                {
                    throw new Exception("Invalid payment module selected");
                }
                if (String.IsNullOrEmpty(uniqueId))
                {
                    throw new Exception("Invalid unique referrence id.");
                }
                Dictionary <string, string> parameters = new Dictionary <string, string>();
                paymentModule = pgModule.ToString();
                BookedPassInformation bookedPassInformations = _context.BookedPassInformations.FirstOrDefault(t => t.UniqueReferrenceNumber.ToLower() == uniqueId.ToLower());
                if (bookedPassInformations == null)
                {
                    throw new Exception("No booking information found.");
                }
                // Get configuaration by ApplicationName,ModuleName,GroupEntityID,PaymentGateWay
                GMOPGConfiguration pgConfig = _context.GMOPGConfigurations.FirstOrDefault(p => p.PaymentGateway.ToLower() == paymentGateway.ToLower() &&
                                                                                          p.PaymentModule.ToLower() == paymentModule.ToLower() && p.IsActive);

                if (pgConfig == null)
                {
                    throw new Exception("Payment for this module has not been enabled.");
                }
                parameters = getPaymentRequestParamsInfo(pgConfig, bookedPassInformations, paymentModule);
                if (parameters == null)
                {
                    throw new Exception("Invalid payment option selected.");
                }
                paymentRequest.PGForm = generatePGForm(pgConfig.GMOPGPaymentUrl, parameters);
                return(View(paymentRequest));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Пример #2
0
        public ActionResult GMOPamentGateway(string uniqueId, string agent = null)
        {
            Random            generator      = new Random();
            String            randomNumber   = generator.Next(0, 999999).ToString("D6");
            String            randomNumber1  = generator.Next(0, 9999).ToString("D6");
            GMOPaymentRequest PaymentRequest = new GMOPaymentRequest();

            //PaymentRequest.SiteID = "tsite00034783";
            //PaymentRequest.SitePassword = "******";
            //PaymentRequest.MemberID = "300028";
            PaymentRequest.ShopID       = "tshop00039254";
            PaymentRequest.ShopPassword = "******";
            PaymentRequest.OrderID      = "3845384583548";
            PaymentRequest.Amount       = "10000"; //Convert.ToDecimal("10000").ToString("N");
            //PaymentRequest.Currency = "JPY";
            PaymentRequest.Tax        = "800";     //Convert.ToDecimal("200").ToString("N");
            PaymentRequest.DateTime   = DateTime.Now.ToString("yyyyMMddHHmmss");
            PaymentRequest.JobCd      = "CHECK";
            PaymentRequest.UseCredit  = "1";
            PaymentRequest.RetURL     = "http://localhost:63661/Payment/PaymentResponse" + "?interimOrderDeatilsId=" + "aaaaa";
            PaymentRequest.PaymentUrl = "https://pt01.mul-pay.jp/link/tshop00039254/Multi/Entry";

            Dictionary <string, string> parameters = new Dictionary <string, string>();

            //parameters.Add("SiteID", PaymentRequest.SiteID);
            //parameters.Add("SitePassword", PaymentRequest.SitePassword);
            //parameters.Add("MemberID", PaymentRequest.MemberID);
            parameters.Add("ShopID", PaymentRequest.ShopID);
            //parameters.Add("ShopPassword", PaymentRequest.ShopPassword);
            parameters.Add("OrderID", PaymentRequest.OrderID);

            parameters.Add("Amount", PaymentRequest.Amount);
            parameters.Add("Tax", PaymentRequest.Tax);
            parameters.Add("DateTime", PaymentRequest.DateTime);
            //parameters.Add("Currency", PaymentRequest.Currency);
            //parameters.Add("Currency", PaymentRequest.Currency);
            parameters.Add("RetURL", PaymentRequest.RetURL); //This parameter is not mandatory. Use this to pass the callback url dynamically.
            parameters.Add("UseCredit", PaymentRequest.UseCredit);
            parameters.Add("JobCd", PaymentRequest.JobCd);
            string shop_hash_string   = string.Empty;
            string member_hash_string = string.Empty;

            //[Shop ID+ Order ID+ Amount of money+ Tax/shipping+ Shop password+ Date information] in
            // MD5 hashed character string.
            // shop information
            shop_hash_string = PaymentRequest.ShopID + "|" + PaymentRequest.OrderID + "|" + PaymentRequest.Amount + "|" + PaymentRequest.Tax + "|" + PaymentRequest.ShopPassword + "|" + PaymentRequest.DateTime;
            string shopPassString = GenerateMD5SignatureForGMO(shop_hash_string).ToLower();

            //[Site ID+ Member ID+ Site password+ Date information] in MD5 hashed character string.
            // member information
            //member_hash_string = PaymentRequest.SiteID + PaymentRequest.MemberID + PaymentRequest.SitePassword + PaymentRequest.DateTime;
            //string memberPassString = GenerateMD5SignatureForPayU(member_hash_string).ToLower();

            PaymentRequest.ShopPassString = shopPassString;
            //PaymentRequest.MemberPassString = memberPassString;
            parameters.Add("ShopPassString", shopPassString);

            //parameters.Add("MemberPassString", memberPassString);
            string outputHTML = "<html>";

            outputHTML += "<head>";
            outputHTML += "<title>Merchant Check Out Page</title>";
            outputHTML += "</head>";
            outputHTML += "<body>";
            outputHTML += "<center><h1>Please do not refresh this page...</h1></center>";
            outputHTML += "<form method='post' action='" + PaymentRequest.PaymentUrl + "' name='f1'>";
            outputHTML += "<table border='1'>";
            outputHTML += "<tbody>";
            foreach (string key in parameters.Keys)
            {
                outputHTML += "<input type='hidden' name='" + key + "' value='" + parameters[key] + "'>";
            }
            //outputHTML += "<input type='hidden' name='SHOPPASSSTRING' value='" + shopPassString + "'>";
            outputHTML += "</tbody>";
            outputHTML += "</table>";
            outputHTML += "<script type='text/javascript'>";
            outputHTML += "document.f1.submit();";
            outputHTML += "</script>";
            outputHTML += "</form>";
            outputHTML += "</body>";
            outputHTML += "</html>";

            PaymentRequest.PGPaymentUrl = outputHTML;
            ViewBag.PGPaymentUrl        = outputHTML;
            return(View(PaymentRequest));
        }
Пример #3
0
        private Dictionary <string, string> getPaymentRequestParamsInfo(GMOPGConfiguration pgConfig, BookedPassInformation bookedPassInformations, string paymentModule)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();
            Random            generator            = new Random();
            String            randomNumber         = generator.Next(0, 999999).ToString("D6");
            GMOPaymentRequest paymentRequest       = new GMOPaymentRequest();

            paymentRequest.ShopID       = pgConfig.ShopID;
            paymentRequest.ShopPassword = pgConfig.ShopPassword;
            paymentRequest.OrderID      = randomNumber + DateTime.Now.Millisecond;
            paymentRequest.Amount       = bookedPassInformations.TotalAmout.ToString(); //Convert.ToDecimal("10000").ToString("N");
            paymentRequest.Tax          = taxAmount;                                    //Convert.ToDecimal("200").ToString("N");
            paymentRequest.DateTime     = DateTime.Now.ToString("yyyyMMddHHmmss");
            paymentRequest.RetURL       = pgConfig.CallbackURL + "?uniqueId=" + bookedPassInformations.UniqueReferrenceNumber;
            paymentRequest.PaymentUrl   = pgConfig.GMOPGPaymentUrl;

            parameters.Add("ShopID", paymentRequest.ShopID);
            parameters.Add("OrderID", paymentRequest.OrderID);
            parameters.Add("Amount", paymentRequest.Amount);
            parameters.Add("Tax", paymentRequest.Tax);
            parameters.Add("DateTime", paymentRequest.DateTime);
            parameters.Add("RetURL", paymentRequest.RetURL); //This parameter is not mandatory. Use this to pass the callback url dynamically.

            if (paymentModule == PGModuleEnum.UseCredit.ToString())
            {
                paymentRequest.JobCd     = pgConfig.JobCd;
                paymentRequest.UseCredit = pgConfig.UseCredit;
                parameters.Add("UseCredit", paymentRequest.UseCredit);
                parameters.Add("JobCd", paymentRequest.JobCd);
                string shop_hash_string   = string.Empty;
                string member_hash_string = string.Empty;

                //[Shop ID+ Order ID+ Amount of money+ Tax/shipping+ Shop password+ Date information] in
                // MD5 hashed character string.
                // shop information
                shop_hash_string = paymentRequest.ShopID + "|" + paymentRequest.OrderID + "|" + paymentRequest.Amount + "|" + paymentRequest.Tax + "|" + paymentRequest.ShopPassword + "|" + paymentRequest.DateTime;
                string shopPassString = GenerateMD5SignatureForGMO(shop_hash_string).ToLower();

                //[Site ID+ Member ID+ Site password+ Date information] in MD5 hashed character string.
                // member information
                //member_hash_string = PaymentRequest.SiteID + PaymentRequest.MemberID + PaymentRequest.SitePassword + PaymentRequest.DateTime;
                //string memberPassString = GenerateMD5SignatureForPayU(member_hash_string).ToLower();

                paymentRequest.ShopPassString = shopPassString;
                //PaymentRequest.MemberPassString = memberPassString;
                parameters.Add("ShopPassString", shopPassString);
            }
            else if (paymentModule == PGModuleEnum.UseDocomo.ToString())
            {
                paymentRequest.UseDocomo = "1";
                parameters.Add("UseDocomo", paymentRequest.UseDocomo);
                // parameters = getDocomoMobileRequestParam(paymentRequest);
            }
            else if (paymentModule == PGModuleEnum.UseAu.ToString())
            {
                string s_unicode = "バスサービス";
                // Convert a string to utf-8 bytes.
                byte[] utf8Bytes = System.Text.Encoding.UTF8.GetBytes(s_unicode);
                paymentRequest.UseAu       = "1";
                paymentRequest.Commodity   = utf8Bytes;
                paymentRequest.ServiceName = utf8Bytes;
                paymentRequest.ServiceTel  = utf8Bytes;
                parameters.Add("UseAu", paymentRequest.UseAu);
                parameters.Add("Commodity", "");
                parameters.Add("ServiceName", "");
                parameters.Add("ServiceName", "");
                //parameters = getKantanKessaiRequestParam(paymentRequest);
            }
            else if (paymentModule == PGModuleEnum.UseSb.ToString())
            {
                paymentRequest.UseSb = "1";
                //parameters = getSoftbankMatometeShiharaiRequestParam(paymentRequest);
            }
            else
            {
                return(null);
            }
            return(parameters);
        }