示例#1
0
        ResultMessageModel Isbank()
        {
            try
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
                ePayment.cc5payment mycc5pay = new ePayment.cc5payment();

                #region Pos Configuration
                mycc5pay.name        = "";
                mycc5pay.password    = "";
                mycc5pay.clientid    = "";
                mycc5pay.orderresult = 0; // 0 : gercek islem, 1 : test islem
                mycc5pay.host        = "https://sanalpos.isbank.com.tr/servlet/cc5ApiServer";
                #endregion


                string order_code = Util.CreateRandomValue(10, true, true, true, false);

                mycc5pay.oid        = order_code;
                mycc5pay.cardnumber = CreditCard.CardNumber;
                mycc5pay.expmonth   = CreditCard.Month;
                mycc5pay.expyear    = CreditCard.Year;
                mycc5pay.cv2        = CreditCard.Cvc;
                mycc5pay.taksit     = "";
                mycc5pay.subtotal   = PaymentAmount.ToString().Replace(",", ".");
                mycc5pay.currency   = "949";
                mycc5pay.chargetype = "Auth";
                mycc5pay.bname      = NameSurname;
                mycc5pay.email      = Email;

                if (Instalment > 1)
                {
                    mycc5pay.taksit = Instalment.ToString();
                }


                if (mycc5pay.processorder() == "1" && mycc5pay.appr == "Approved")
                {
                    return(new ResultMessageModel {
                        Status = true
                    });
                }
                else
                {
                    return(new ResultMessageModel {
                        Status = false, Code = mycc5pay.err, Message = mycc5pay.errmsg
                    });
                }
            }
            catch (Exception ex)
            {
                return(new ResultMessageModel {
                    Status = false, Message = ex.Message
                });
            }
        }
示例#2
0
        ResultMessageModel Garanti()
        {
            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

            #region Pos Configuration
            string strMode              = "PROD";
            string strVersion           = "v0.01";
            string strTerminalID        = ""; //8 Haneli TerminalID yazılmalı.
            string _strTerminalID       = "0" + strTerminalID;
            string strProvUserID        = "PROVAUT";
            string strProvisionPassword = ""; //TerminalProvUserID şifresi
            string strUserID            = ""; //
            string strMerchantID        = ""; //Üye İşyeri Numarası
            string strHostAddress       = "https://sanalposprov.garanti.com.tr/VPServlet";
            #endregion

            string order_code  = Util.CreateRandomValue(10, true, true, true, false);
            string amount_send = PaymentAmount.ToString();

            if (amount_send.Contains(","))
            {
                string[] split_amount = PaymentAmount.ToString().Split(',');

                if (split_amount[1].Length > 2)
                {
                    amount_send = split_amount[0] + "" + split_amount[1].Substring(0, 2);
                }
                else
                {
                    amount_send = split_amount[0] + "" + split_amount[1];
                }
            }
            else if (amount_send.Contains("."))
            {
                string[] split_amount = PaymentAmount.ToString().Split('.');

                if (split_amount[1].Length > 2)
                {
                    amount_send = split_amount[0] + "" + split_amount[1].Substring(0, 2);
                }
                else
                {
                    amount_send = split_amount[0] + "" + split_amount[1];
                }
            }


            string strIPAddress             = HttpContext.Current.Request.UserHostAddress;
            string strEmailAddress          = Email;
            string strOrderID               = order_code;
            string strNumber                = CreditCard.CardNumber;
            string strExpireDate            = CreditCard.Month + "" + CreditCard.Year;
            string strCVV2                  = CreditCard.Cvc;
            string strAmount                = amount_send;
            string strType                  = "sales";
            string strCurrencyCode          = "949";
            string strCardholderPresentCode = "0";
            string strMotoInd               = "N";
            string strInstallmentCount      = String.Empty;
            if (Instalment > 1)
            {
                strInstallmentCount = Instalment.ToString();
            }


            string SecurityData = Util.GetSHA1(strProvisionPassword + _strTerminalID).ToUpper();
            string HashData     = Util.GetSHA1(strOrderID + strTerminalID + strNumber + strAmount + SecurityData).ToUpper();

            string strXML = null;
            strXML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<GVPSRequest>" + "<Mode>" + strMode + "</Mode>" + "<Version>" + strVersion + "</Version>" + "<Terminal><ProvUserID>" + strProvUserID + "</ProvUserID><HashData>" + HashData + "</HashData><UserID>" + strUserID + "</UserID><ID>" + strTerminalID + "</ID><MerchantID>" + strMerchantID + "</MerchantID></Terminal>" + "<Customer><IPAddress>" + strIPAddress + "</IPAddress><EmailAddress>" + strEmailAddress + "</EmailAddress></Customer>" + "<Card><Number>" + strNumber + "</Number><ExpireDate>" + strExpireDate + "</ExpireDate><CVV2>" + strCVV2 + "</CVV2></Card>" + "<Order><OrderID>" + strOrderID + "</OrderID><GroupID></GroupID><AddressList><Address><Type>S</Type><Name></Name><LastName></LastName><Company></Company><Text></Text><District></District><City></City><PostalCode></PostalCode><Country></Country><PhoneNumber></PhoneNumber></Address></AddressList></Order>" + "<Transaction>" + "<Type>" + strType + "</Type><InstallmentCnt>" + strInstallmentCount + "</InstallmentCnt><Amount>" + strAmount + "</Amount><CurrencyCode>" + strCurrencyCode + "</CurrencyCode><CardholderPresentCode>" + strCardholderPresentCode + "</CardholderPresentCode><MotoInd>" + strMotoInd + "</MotoInd>" + "</Transaction>" + "</GVPSRequest>";

            try
            {
                string     data        = "data=" + strXML;
                WebRequest _WebRequest = WebRequest.Create(strHostAddress);
                _WebRequest.Method = "POST";
                byte[] byteArray = Encoding.UTF8.GetBytes(data);
                _WebRequest.ContentType   = "application/x-www-form-urlencoded";
                _WebRequest.ContentLength = byteArray.Length;
                Stream dataStream = _WebRequest.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();
                WebResponse _WebResponse = _WebRequest.GetResponse();
                dataStream = _WebResponse.GetResponseStream();
                StreamReader reader             = new StreamReader(dataStream);
                string       responseFromServer = reader.ReadToEnd();
                string       XML  = responseFromServer;
                XmlDocument  xDoc = new XmlDocument();
                xDoc.LoadXml(XML);
                XmlElement xElement1 = xDoc.SelectSingleNode("//GVPSResponse/Transaction/Response/ReasonCode") as XmlElement;
                XmlElement xElement3 = xDoc.SelectSingleNode("//GVPSResponse/Transaction/Response/ErrorMsg") as XmlElement;

                if (xElement1.InnerText == "00")
                {
                    return(new ResultMessageModel {
                        Status = true
                    });
                }
                else
                {
                    return(new ResultMessageModel {
                        Status = false, Message = xElement3.InnerText, Code = xElement1.InnerText
                    });
                }
            }
            catch (Exception ex)
            {
                return(new ResultMessageModel {
                    Status = false, Message = ex.Message
                });
            }
        }