예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            C_PosnetOOSTDS CPTDS = new C_PosnetOOSTDS();

            string custName = "Test TEST";            //Request.Form.Get("custName");
            string xid      = "YKB_0000120814020200"; // Request.Form.Get("XID");

            string ccno    = "5400637500005263";      //Request.Form.Get("ccno");
            string expdate = "0607";                  //Request.Form.Get("expdate");
            string cvv     = "XXX";                   //Request.Form.Get("cvv");

            string amount       = "5696";             //Request.Form.Get("amount");
            string currencyCode = "TL";               //Request.Form.Get("currency");
            string instalment   = "00";               //Request.Form.Get("instalment");
            string tranType     = "Sale";             //Request.Form.Get("tranType");
            string vftCode      = "K001";             //Request.Form.Get("vftCode");

            //this.imageField.OnClientClick = "submitFormEx(formName, " + posnettds_config.OPEN_NEW_WINDOW + ", 'YKBWindow');";

            CPTDS.SetMid(posnettds_config.MERCHANT_ID);
            CPTDS.SetTid(posnettds_config.TERMINAL_ID);
            CPTDS.SetPosnetID(posnettds_config.POSNET_ID);
            CPTDS.SetKey(posnettds_config.ENCKEY);

            this.amount.Text     = posnettds_util.CurrencyFormat(amount, currencyCode, true);
            this.instNumber.Text = instalment;
            this.XID.Text        = xid;

            if (posnettds_config.USE_OOS_PAGE)
            {
                if ((!CPTDS.CreateTranRequestDatas(custName, amount, currencyCode, instalment, xid, tranType, "", "", "")))
                {
                    Response.Write("Posnet Data 'ları olusturulamadi (" + CPTDS.GetResponseText() + ")<br>");
                    Response.Write("Error Code : " + CPTDS.GetResponseCode());
                    Response.End();
                }
            }
            else
            {
                if ((!CPTDS.CreateTranRequestDatas(custName, amount, currencyCode, instalment, xid, tranType, ccno, expdate, cvv)))
                {
                    Response.Write("Posnet Data 'ları olusturulamadi (" + CPTDS.GetResponseText() + ")<br>");
                    Response.Write("Error Code : " + CPTDS.GetResponseCode());
                    Response.End();
                }
            }

            //Hidden fields
            this.mid.Value               = posnettds_config.MERCHANT_ID;
            this.posnetID.Value          = posnettds_config.POSNET_ID;
            this.posnetData.Value        = CPTDS.GetPosnetData();
            this.posnetData2.Value       = CPTDS.GetPosnetData2();
            this.digest.Value            = CPTDS.GetSign();
            this.vftCode.Value           = vftCode;
            this.merchantReturnURL.Value = posnettds_util.GetReturnURL(Request);
            this.openANewWindow.Value    = posnettds_config.OPEN_NEW_WINDOW;
        }
예제 #2
0
        public PreProcessPaymentResult PreProcessPayment(ProcessPaymentRequest processPaymentRequest)
        {
            var result = new PreProcessPaymentResult();

            String taksit = _workContext.CurrentCustomer.GetAttribute <string>("taksit");

            C_PosnetOOSTDS posnetOOSTDSObj = new C_PosnetOOSTDS();

            Random rndOid = new Random();
            int    oidRnd = rndOid.Next(111111111, 999999999);

            result.OrderId = oidRnd.ToString("00000000000000000000");

            string custName = processPaymentRequest.CreditCardName;
            string xid      = oidRnd.ToString("00000000000000000000");

            string ccno = processPaymentRequest.CreditCardNumber; //Request.Form.Get("ccno");

            string expYear  = (processPaymentRequest.CreditCardExpireYear % 100).ToString();
            string expMonth = GetMonth(processPaymentRequest.CreditCardExpireMonth.ToString());

            string expdate = expYear.ToString().Replace("20", string.Empty) + int.Parse(expMonth).ToString("00");
            string cvv     = processPaymentRequest.CreditCardCvv2; //Request.Form.Get("cvv");

            //string amount = processPaymentRequest.OrderTotal.ToString().Replace(",", "").Replace(".", "");
            String amount;

            amount        = processPaymentRequest.OrderTotal.ToString("###,###.00");
            amount        = amount.Replace(",", "");
            amount        = amount.Replace(".", "");
            result.Amount = amount;

            string currencyCode = "YT";
            string instalment   = int.Parse(taksit).ToString("00");
            string tranType     = "Sale";
            string vftCode      = _YapiKrediPaymentSettings.VftCode;



            posnetOOSTDSObj.SetMid(_YapiKrediPaymentSettings.MerchantId);
            //sbLog.AppendLine("posnetOOSTDSObj.SetMid(" + diger3dPaymentSettings.MERCHANT_ID.ToString() + ")");
            posnetOOSTDSObj.SetTid(_YapiKrediPaymentSettings.TerminalId);
            //sbLog.AppendLine("posnetOOSTDSObj.SetTid(" + diger3dPaymentSettings.TERMINAL_ID.ToString() + ")");
            posnetOOSTDSObj.SetPosnetID(_YapiKrediPaymentSettings.PosnetId);
            //sbLog.AppendLine("posnetOOSTDSObj.SetPosnetID(" + diger3dPaymentSettings.POSNET_ID.ToString() + ")");
            posnetOOSTDSObj.SetKey(_YapiKrediPaymentSettings.EncKey);
            //sbLog.AppendLine("posnetOOSTDSObj.SetKey(" + diger3dPaymentSettings.ENCKEY.ToString() + ")");



            if ((!posnetOOSTDSObj.CreateTranRequestDatas(custName, amount, currencyCode, instalment, xid, tranType, ccno, expdate, cvv)))
            {
                //TODO: HATA DURUMU ELE ALINMALI
                //Log(string.Format("CreateTranRequestDatas Hatasý - Posnet Data 'larý olusturulamadi: {0} - Error Code: {1}", posnetOOSTDSObj.GetResponseText(), posnetOOSTDSObj.GetResponseCode()));
                //sbLog.AppendLine("'posnetOOSTDSObj.CreateTranRequestDatas(custName, amount, currencyCode, instalment, xid, tranType, ccno, expdate, cvv)' metodu olumsuz sonuc donderdi.");
                //postProcessPaymentRequest.Order.OrderStatus = OrderStatus.Pending;
            }
            else
            {
                result.PaymentRequest      = processPaymentRequest;
                result.OkUrl               = _YapiKrediPaymentSettings.MerchantReturnURL;
                result.RedirectURL         = _YapiKrediPaymentSettings.HostAddress3D;
                result.MerchantId          = _YapiKrediPaymentSettings.MerchantId;
                result.PosnetID            = _YapiKrediPaymentSettings.PosnetId;
                result.PosnetData          = posnetOOSTDSObj.GetPosnetData();
                result.PosnetData2         = posnetOOSTDSObj.GetPosnetData2();
                result.Digest              = posnetOOSTDSObj.GetSign();
                result.VftCode             = _YapiKrediPaymentSettings.VftCode;
                result.Lang                = "tr";
                result.RequiresRedirection = true;



                ////var remotePostHelper = new RemotePost();
                ////remotePostHelper.FormName = "YkbForm";
                ////remotePostHelper.Url = diger3dPaymentSettings.OOS_TDS_SERVICE_URL;
                ////remotePostHelper.Add("mid", diger3dPaymentSettings.MERCHANT_ID);
                ////remotePostHelper.Add("posnetID", diger3dPaymentSettings.POSNET_ID);
                ////remotePostHelper.Add("posnetData", posnetOOSTDSObj.GetPosnetData());
                ////remotePostHelper.Add("posnetData2", posnetOOSTDSObj.GetPosnetData2());
                ////remotePostHelper.Add("digest", posnetOOSTDSObj.GetSign());
                ////remotePostHelper.Add("vftCode", diger3dPaymentSettings.vtfCode);
                ////remotePostHelper.Add("merchantReturnURL", diger3dPaymentSettings.MERCHANT_RETURN_URL);
                ////remotePostHelper.Add("lang", "tr");
                ////remotePostHelper.Add("url", diger3dPaymentSettings.OOS_TDS_SERVICE_URL);
                //var remotePostHelper = new RemotePost();
                ////sbLog.AppendLine("var remotePostHelper = new RemotePost();");

                //remotePostHelper.FormName = "YkbForm";
                ////sbLog.AppendLine("remotePostHelper.FormName = " + remotePostHelper.FormName.ToString());

                //remotePostHelper.Url = diger3dPaymentSettings.OOS_TDS_SERVICE_URL;
                ////sbLog.AppendLine("remotePostHelper.Url = " + diger3dPaymentSettings.OOS_TDS_SERVICE_URL.ToString());

                //remotePostHelper.Add("mid", diger3dPaymentSettings.MERCHANT_ID);
                ////sbLog.AppendLine("remotePostHelper.Add('mid', " + diger3dPaymentSettings.MERCHANT_ID.ToString() + ");");

                //remotePostHelper.Add("posnetID", diger3dPaymentSettings.POSNET_ID);
                ////sbLog.AppendLine("remotePostHelper.Add('posnetID', " + diger3dPaymentSettings.POSNET_ID.ToString() + ");");

                //remotePostHelper.Add("posnetData", posnetOOSTDSObj.GetPosnetData());
                ////sbLog.AppendLine("remotePostHelper.Add('posnetData', " + posnetOOSTDSObj.GetPosnetData().ToString() + ");");

                //remotePostHelper.Add("posnetData2", posnetOOSTDSObj.GetPosnetData2());
                ////sbLog.AppendLine("remotePostHelper.Add('posnetData2', " + posnetOOSTDSObj.GetPosnetData2().ToString() + ");");

                //remotePostHelper.Add("digest", posnetOOSTDSObj.GetSign());
                ////sbLog.AppendLine("remotePostHelper.Add('digest', " + posnetOOSTDSObj.GetSign().ToString() + ");");

                //remotePostHelper.Add("vftCode", diger3dPaymentSettings.vtfCode);
                ////sbLog.AppendLine("remotePostHelper.Add('vftCode', " + diger3dPaymentSettings.vtfCode.ToString() + ");");

                //remotePostHelper.Add("merchantReturnURL", diger3dPaymentSettings.MERCHANT_RETURN_URL);
                ////sbLog.AppendLine("remotePostHelper.Add('merchantReturnURL', " + diger3dPaymentSettings.MERCHANT_RETURN_URL.ToString() + ");");

                //remotePostHelper.Add("lang", "tr");
                ////sbLog.AppendLine("remotePostHelper.Add('lang', 'tr');");

                //remotePostHelper.Add("url", diger3dPaymentSettings.OOS_TDS_SERVICE_URL);
                ////sbLog.AppendLine("remotePostHelper.Add('url', " + diger3dPaymentSettings.OOS_TDS_SERVICE_URL.ToString() + ");");

                ////remotePostHelper.Add("openANewWindow", "false");
                ////sbLog.AppendLine("remotePostHelper.Add('openANewWindow', 'false');");

                ////sbLog.AppendLine("remotePostHelper.Post();");
                //postProcessPaymentRequest.Order.OrderNotes.Add(new OrderNote()
                //{
                //    Note = sbLog.ToString(),
                //    DisplayToCustomer = false,
                //    CreatedOnUtc = DateTime.UtcNow
                //});
                //_orderService.UpdateOrder(postProcessPaymentRequest.Order);

                //remotePostHelper.Post();

                ////NameValueCollection collection = new NameValueCollection();
                ////collection.Add("mid", ykb3dPaymentSettings.MERCHANT_ID);
                ////collection.Add("posnetID", ykb3dPaymentSettings.POSNET_ID);
                ////collection.Add("posnetData", posnetOOSTDSObj.GetPosnetData());
                ////collection.Add("posnetData2", posnetOOSTDSObj.GetPosnetData2());
                ////collection.Add("digest", posnetOOSTDSObj.GetSign());
                ////collection.Add("vftCode", ykb3dPaymentSettings.vtfCode);
                ////collection.Add("merchantReturnURL", ykb3dPaymentSettings.MERCHANT_RETURN_URL);

                //////FormCollection myForm = new FormCollection(collection);

                ////var builder = new StringBuilder();

                //////Errore
                ////builder.Append(ykb3dPaymentSettings.OOS_TDS_SERVICE_URL);
                //////builder.Append(_webHelper.GetStoreLocation(false) + "Plugins/PaymentGestPay/Error");
                ////builder.AppendFormat("?posnetData={0}&posnetData2={1}", posnetOOSTDSObj.GetPosnetData(), posnetOOSTDSObj.GetPosnetData2());
                ////builder.AppendFormat("&digest={0}&mid={1}", posnetOOSTDSObj.GetSign(), ykb3dPaymentSettings.MERCHANT_ID);
                ////builder.AppendFormat("&posnetID={0}&vftCode={1}", ykb3dPaymentSettings.POSNET_ID, ykb3dPaymentSettings.vtfCode);
                ////builder.AppendFormat("&merchantReturnURL={0}&lang={1}", ykb3dPaymentSettings.MERCHANT_RETURN_URL, "tr");
                ////builder.AppendFormat("&url={0}&openANewWindow={1}", "", ykb3dPaymentSettings.OPEN_NEW_WINDOW);

                ////_httpContext.Response.Redirect(builder.ToString());
            }


            return(result);



            //var currency = GetCurrency(_currencyService.GetCurrencyById(_currencySettings.PrimaryStoreCurrencyId));
            ////String amount = Decimal.Parse(GetCulturePrice(currency, processPaymentRequest.OrderTotal)).ToString("######.00"); //postProcessPaymentRequest.Order.OrderTotal.ToString("######.00");
            //String oid = processPaymentRequest.OrderGuid.ToString();

            //String rnd = DateTime.Now.ToString();


            //string pan = processPaymentRequest.CreditCardNumber; //_encryptionService.DecryptText(postProcessPaymentRequest.Order.CardNumber);
            //string cv2 = processPaymentRequest.CreditCardCvv2; //_encryptionService.DecryptText(postProcessPaymentRequest.Order.CardCvv2);
            //string Ecom_Payment_Card_ExpDate_Year = (processPaymentRequest.CreditCardExpireYear % 100).ToString(); //_encryptionService.DecryptText(postProcessPaymentRequest.Order.CardExpirationYear);
            //string Ecom_Payment_Card_ExpDate_Month = GetMonth(processPaymentRequest.CreditCardExpireMonth.ToString()); //_encryptionService.DecryptText(postProcessPaymentRequest.Order.CardExpirationMonth);
            //string cardType = processPaymentRequest.CreditCardType.ToLower().Trim(); //_encryptionService.DecryptText(postProcessPaymentRequest.Order.CardType);


            //if (processPaymentRequest.CreditCardType.ToLower().Trim() == "visa")
            //    result.CardType = "1";
            //if (processPaymentRequest.CreditCardType.ToLower().Trim() == "mastercard")
            //    result.CardType = "2";
            ////CC shall be either visa or master card!
            //if (result.CardType != "1" && result.CardType != "2")
            //    return result;
            //result.PaymentRequest = processPaymentRequest;
            //result.FailUrl = _GarantiPaymentSettings.ErrorURL;
            //result.OkUrl = _GarantiPaymentSettings.SuccessURL; ;
            //result.RandomToken = DateTime.Now.ToString();
            //result.RedirectURL = _GarantiPaymentSettings.HostAddress3D;
            //result.StoreType = "";
            //result.StoreKey = _GarantiPaymentSettings.StoreKey;
            //result.ChargeType = "Auth";
            //result.Lang = "tr";
            //result.Currency = "949";
            //result.ClientId = _GarantiPaymentSettings.MerchantId;
            //result.ApiVersion = "v0.01";
            //result.TerminalProvUserId = _GarantiPaymentSettings.ProvisionUserId;
            //result.TerminalUserId = _GarantiPaymentSettings.UserId;
            //result.TerminalId = _GarantiPaymentSettings.TerminalId;
            //result.MerchantId = _GarantiPaymentSettings.MerchantId;
            //result.CustomerEmailAddress = _workContext.CurrentCustomer.Email;
            //result.CustomerIpAddress = _workContext.CurrentCustomer.LastIpAddress;



            //Random rndOid = new Random();
            //int oidRnd = rndOid.Next(111111111, 999999999);
            //result.OrderId = oidRnd.ToString("00000000000000000000");
            //result.Installment = taksit;
            //result.CreditCardNumber = processPaymentRequest.CreditCardNumber;
            //result.CreditCardExpireYear = (processPaymentRequest.CreditCardExpireYear % 100).ToString();
            //result.CreditCardExpireMonth = GetMonth(processPaymentRequest.CreditCardExpireMonth.ToString()); ;
            //result.CreditCardCvv2 = processPaymentRequest.CreditCardCvv2;
            //result.CreditCardNumber = processPaymentRequest.CreditCardNumber;
            //result.CustomerId = processPaymentRequest.CustomerId.ToString();
            //result.Amount = amount; // GetCulturePrice(currency, processPaymentRequest.OrderTotal);



            //amount = Decimal.Parse(GetCulturePrice(currency, processPaymentRequest.OrderTotal)).ToString("###,###.00");
            //amount = amount.Replace(",", "");
            //amount = amount.Replace(".", "");
            //string SecurityData = GetSHA1(_GarantiPaymentSettings.ProvisionPassword + _GarantiPaymentSettings.TerminalId).ToUpper();
            ////sbLog.AppendLine("GetSHA1(" + _GarantiPaymentSettings.ProvisionPassword.ToString() + " + " + _GarantiPaymentSettings.TerminalId.ToString() + ").ToUpper();");
            ////sbLog.AppendLine("SecurityData: " + SecurityData);
            //string HashData = GetSHA1(_GarantiPaymentSettings.TerminalId + oid + amount + _GarantiPaymentSettings.SuccessURL + _GarantiPaymentSettings.ErrorURL + "sales" + taksit + _GarantiPaymentSettings.StoreKey + SecurityData).ToUpper();
            ////sbLog.AppendLine("GetSHA1(" + garanti3dPaymentSettings.TerminalID.ToString() + " + " + oid.ToString() + " + " + strAmount.ToString() + " + " + garanti3dPaymentSettings.SuccessURL.ToString() + " + " + garanti3dPaymentSettings.ErrorURL.ToString() + " + sales + " + taksit.ToString() + " + " + garanti3dPaymentSettings.StoreKey.ToString() + " + " + SecurityData.ToString() + ").ToUpper();");
            ////sbLog.AppendLine("HashData: " + HashData);

            //result.Hash = HashData;

            //result.RequiresRedirection = true;


            //return result;
        }