Imports System.Data.SqlClient Imports System.Data Imports System.Net.Mail Imports System.Web.Script.Serialization Imports System.Net Imports System.IO Partial Class Usr_rechargecard Inherits System.Web.UI.Page Protected WithEvents lblAvailableAmt As System.Web.UI.WebControls.Label Protected WithEvents cvAmount As System.Web.UI.WebControls.CompareValidator Protected WithEvents rfvtxtCreditCardNo As System.Web.UI.WebControls.RequiredFieldValidator Protected WithEvents revCreditCardNo As System.Web.UI.WebControls.RegularExpressionValidator Dim strSql As String Dim connMyLine As SqlConnection Dim cmdRecharge As SqlCommand Dim drRecharge As SqlDataReader Dim strUserName As String Dim strinvoiceno As String Dim CCValidate As New CreditCardValidation Protected WithEvents rfvAmount As System.Web.UI.WebControls.RequiredFieldValidator Public strAgentId As String Dim strFields As String Dim strWhere As String Public strReChargeAmt As String Public strEmailAddress As String ' Public SM As SendMail Protected WithEvents revEmail As System.Web.UI.WebControls.RegularExpressionValidator 'Following are used to validate the creditcard using CyberSource and Fraud Detection. Dim objFraudCheck As New Object() Dim objCharge As New Object() Dim CSCode As New GTCybersource Public strReason As String Public strServerPort As String Public strKeysDir As String Public strMerchantId As String Public strServerHost As String Public strServerId As String Public strLogFileLocation As String Public strDebug As String Public strMerchantRefNo As String Public intFraudLimit As Integer Public strFraudScore As String Public strFraudMessage As String Public strInfoCode As String Public strFactorCode As String Public strReplyDecision As String Public strReplyReasonCode As String Public strReplyRequestID As String Public strReplyRequestToken As String Public strCCCaptureReplyReasonCode As String Public strCCEnvironment As String 'Public FraudCheck As String Public strIpAddress As String Public strSelectedCountry As String Public CreditMask As New MaskCreditcard Public strSessionID As String Public strAmount As String Public strChargedAmount As String Public strTransactionFee As String Function ProcessCreditCard(ByVal strProcesserType As String, ByVal strAmount As String, ByVal strCardNum As String, ByVal strCardCode As String, ByVal strExpMonth As String, ByVal strExpYear As String, ByVal strFirstName As String, ByVal strLastName As String, ByVal strAddress As String, ByVal strCity As String, ByVal strState As String, ByVal strPostalCode As String, ByVal strCountryCode As String, ByVal strEmail As String, ByVal strPhoneNo As String, ByVal strIP As String, ByVal strCVN As String) ProcessCreditCard = "N" Select Case strProcesserType Case "S" 'Stripe Dim StripeKey, postData As String Dim APIResponse As HttpWebResponse Dim APIRequest As HttpWebRequest Dim httpresponse As HttpWebResponse = Nothing Dim reader As StreamReader Dim data As StringBuilder Dim byteData() As Byte Dim postStream As Stream = Nothing Dim str_response As String Dim RESTEndpoint As Uri StripeKey = ConfigurationManager.AppSettings("StripeAPIKey").ToString() 'attempt to create charge RESTEndpoint = New Uri("https://api.stripe.com/v1/charges") APIRequest = WebRequest.Create(RESTEndpoint) Dim networkCredential As New NetworkCredential(StripeKey, "") Dim credentialcache As New CredentialCache() credentialcache.Add(RESTEndpoint, "Basic", networkCredential) APIRequest.Credentials = credentialcache APIRequest.UserAgent = ".NET Framework Client" APIRequest.Method = "POST" APIRequest.ContentType = "application/x-www-form-urlencoded" postData = HttpUtility.UrlEncode("amount") + "=" + HttpUtility.UrlEncode(Replace(strAmount, ".", "")) + "&" + HttpUtility.UrlEncode("currency") + "=" + HttpUtility.UrlEncode("usd") + "&" + HttpUtility.UrlEncode("description") + "=" + HttpUtility.UrlEncode("MyLine.com") + "&" + HttpUtility.UrlEncode("capture") + "=" + HttpUtility.UrlEncode(True) + "&" + HttpUtility.UrlEncode("statement_descriptor") + "=" + HttpUtility.UrlEncode("MyLine.com") + "&" + HttpUtility.UrlEncode("source[exp_month]") + "=" + HttpUtility.UrlEncode(strExpMonth) + "&" + HttpUtility.UrlEncode("source[exp_year]") + "=" + HttpUtility.UrlEncode(strExpYear) + "&" + HttpUtility.UrlEncode("source[number]") + "=" + HttpUtility.UrlEncode(strCardNum) + "&" + HttpUtility.UrlEncode("source[cvc]") + "=" + HttpUtility.UrlEncode(strCardCode) + "&" + HttpUtility.UrlEncode("source[address_city]") + "=" + HttpUtility.UrlEncode(strCity) + "&" + HttpUtility.UrlEncode("source[address_country]") + "=" + HttpUtility.UrlEncode(strCountryCode) + "&" + HttpUtility.UrlEncode("source[address_line1]") + "=" + HttpUtility.UrlEncode(strAddress) + "&" + HttpUtility.UrlEncode("source[name]") + "=" + HttpUtility.UrlEncode(Me.txtNameOnCreditCard.Text) + "&" + HttpUtility.UrlEncode("source[address_state]") + "=" + HttpUtility.UrlEncode(strState) + "&" + HttpUtility.UrlEncode("source[address_zip]") + "=" + HttpUtility.UrlEncode(strPostalCode) byteData = UTF8Encoding.UTF8.GetBytes(postData) ' Set the content length in the request headers APIRequest.ContentLength = byteData.Length ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls postStream = APIRequest.GetRequestStream() postStream.Write(byteData, 0, byteData.Length) postStream.Close() Try ' Get response httpresponse = DirectCast(APIRequest.GetResponse(), HttpWebResponse) ' Get the response stream into a reader reader = New StreamReader(httpresponse.GetResponseStream()) str_response = reader.ReadToEnd.ToString Dim jss = New JavaScriptSerializer() Dim json_returned_charge As Stripe_Returned_Charge ProcessCreditCard = str_response json_returned_charge = jss.Deserialize(Of Stripe_Returned_Charge)(str_response) If json_returned_charge.status = "succeeded" And json_returned_charge.failure_code = "" = True Then ProcessCreditCard = "Y" strReplyRequestID = json_returned_charge.id strReplyRequestToken = json_returned_charge.id Else strReplyReasonCode = json_returned_charge.failure_message strCCCaptureReplyReasonCode = json_returned_charge.failure_message ProcessCreditCard = "Failed" + json_returned_charge.failure_message End If Catch webexception As WebException ProcessCreditCard = webexception.Message.ToString Dim text As String Dim error_httpResponse As HttpWebResponse Dim error_data As Stream Dim error_reader As StreamReader Using response As WebResponse = webexception.Response error_httpResponse = DirectCast(response, HttpWebResponse) Console.WriteLine("Error code: {0}", error_httpResponse.StatusCode) error_data = response.GetResponseStream() error_reader = New StreamReader(error_data) text = error_reader.ReadToEnd() ProcessCreditCard = text Dim jsserror As Stripe_Returned_Errors Dim jss_error = New JavaScriptSerializer() jsserror = jss_error.Deserialize(Of Stripe_Returned_Errors)(text) ProcessCreditCard = jsserror.error.message End Using Finally If Not httpresponse Is Nothing Then httpresponse.Close() End Try Case "A" ProcessCreditCard = CCValidate.ProcessAuthNetAVSCC(Application("MerchantId"), Application("MerchantPassword"), FormatNumber(strAmount, 2), strCardNum, strCardCode, strExpMonth & "/" & Mid(strExpYear, 3, 2), strFirstName, strLastName, strAddress, strCity, strState, strPostalCode, strCountryCode) Case "L" ProcessCreditCard = CCValidate.ProcessLinkpoint(strCardNum, strExpMonth, strExpYear, CInt(strAmount), "Chargetype_Sale") Case "C" 'for CyberSource ' strKeysDir = Application("AltKeysDir") strKeysDir = ConfigurationManager.AppSettings("AltKeysDir").ToString() strMerchantId = ConfigurationManager.AppSettings("AltMerchantId").ToString() strLogFileLocation = ConfigurationManager.AppSettings("LogFileLocation").ToString() strDebug = ConfigurationManager.AppSettings("Debug").ToString() intFraudLimit = ConfigurationManager.AppSettings("FraudLimit").ToString() strCCEnvironment = ConfigurationManager.AppSettings("CCProcessorEnvType").ToString() 'strMerchantId = Application("AltMerchantId") 'strLogFileLocation = Application("LogFileLocation") 'strDebug = Application("Debug") strMerchantRefNo = "MyLineManualRecharge" 'intFraudLimit = Application("FraudLimit") 'strCCEnvironment = Application("CCProcessorEnvType") strReplyDecision = "" strReplyReasonCode = "" strReplyRequestID = "" strReplyRequestToken = "" strCCCaptureReplyReasonCode = "" Dim ReplyRequestCharge As New Dictionary(Of String, String) 'ReplyRequestCharge = CSCode.RequestCharge(strCCEnvironment, strFirstName, strLastName, strAddress, strCity, strState, strCountryCode, strPostalCode, strEmail, strPhoneNo, strExpMonth, strExpYear, txtCreditCardNo.Text, strAmount, strLogFileLocation, strDebug, strMerchantRefNo, strIP, strMerchantId, strKeysDir) ReplyRequestCharge = CSCode.RequestCharge(strCCEnvironment, strFirstName, strLastName, strAddress, strCity, strState, strCountryCode, strPostalCode, strEmail, strPhoneNo, strExpMonth, strExpYear, strCardNum, strAmount, strLogFileLocation, strDebug, strMerchantRefNo, strIP, strMerchantId, strKeysDir, "", strCVN) If ReplyRequestCharge.ContainsKey("reply.decision") = True Then strReplyDecision = ReplyRequestCharge.Item("reply.decision") End If If ReplyRequestCharge.ContainsKey("reply.reasonCode") = True Then strReplyReasonCode = ReplyRequestCharge.Item("reply.reasonCode") End If If ReplyRequestCharge.ContainsKey("reply.requestID") = True Then strReplyRequestID = ReplyRequestCharge.Item("reply.requestID") End If If ReplyRequestCharge.ContainsKey("reply.requestToken") = True Then strReplyRequestToken = ReplyRequestCharge.Item("reply.requestToken") End If If ReplyRequestCharge.ContainsKey("reply.ccCaptureReply.reasonCode") = True Then strCCCaptureReplyReasonCode = ReplyRequestCharge.Item("reply.ccCaptureReply.reasonCode") End If If strReplyDecision = "ACCEPT" Then ProcessCreditCard = "Y" ElseIf strReplyDecision = "REJECT" Then ProcessCreditCard = CSCode.DisplayErrorMessage(strReplyReasonCode) ElseIf strReplyDecision = "ERROR" Then ProcessCreditCard = CSCode.DisplayErrorMessage(strReplyReasonCode) End If End Select Return ProcessCreditCard End Function Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Put user code to initialize the page here 'Session("UserName") = "amar2" If Request.QueryString("logout") = "1" Then Session.Abandon() Response.Redirect("index.aspx") End If strUserName = Trim(Session("UserName")) If strUserName = "" Then Response.Redirect("index.aspx") End If UCStates.UCStates.TabIndex = 5 UCStatesC.UCStatesC.TabIndex = 5 UCStateBr.UCStateBr.TabIndex = 5 ddlstOthers.TabIndex = 5 Me.UCddlstCountry.UCddlstCountry.TabIndex = 7 UCCreditCardType.UCCreditCardType.TabIndex = 10 'Me.ExtAmount.ExtAmount.TabIndex = 21 ddlRechargeAmount.TabIndex = 17 UCExpiryMonth.UCMonth.TabIndex = 13 UCExpiryYear.UCYear.TabIndex = 14 strIpAddress = Request.ServerVariables("REMOTE_HOST") If ddlRechargeAmount.SelectedItem.Value = "5.50" Then strAmount = "5.00" strTransactionFee = "0.50" strChargedAmount = "5.50" ElseIf ddlRechargeAmount.SelectedItem.Value = "10.50" Then strAmount = "10.00" strTransactionFee = "0.50" strChargedAmount = "10.50" ElseIf ddlRechargeAmount.SelectedItem.Value = "15.50" Then strAmount = "15.00" strTransactionFee = "0.50" strChargedAmount = "15.50" ElseIf ddlRechargeAmount.SelectedItem.Value = "20.50" Then strAmount = "20.00" strTransactionFee = "0.50" strChargedAmount = "20.50" ElseIf ddlRechargeAmount.SelectedItem.Value = "2.50" Then strAmount = "2.00" strTransactionFee = "0.50" strChargedAmount = "2.50" ElseIf ddlRechargeAmount.SelectedItem.Value = "30.50" Then strAmount = "30.00" strTransactionFee = "0.50" strChargedAmount = "30.50" ElseIf ddlRechargeAmount.SelectedItem.Value = "50.50" Then strAmount = "50.00" strTransactionFee = "0.50" strChargedAmount = "50.50" ElseIf ddlRechargeAmount.SelectedItem.Value = "100.50" Then strAmount = "100.00" strTransactionFee = "0.50" strChargedAmount = "100.50" End If If Not IsPostBack Then strSql = "S_RechargePhoneCard" connMyLine = New SqlConnection(ConfigurationManager.ConnectionStrings("MyLine").ConnectionString) cmdRecharge = New SqlCommand(strSql, connMyLine) cmdRecharge.CommandType = CommandType.StoredProcedure Try cmdRecharge.CommandType = CommandType.StoredProcedure cmdRecharge.Parameters.Add(New SqlParameter("@Operation", SqlDbType.VarChar, 20)) cmdRecharge.Parameters("@Operation").Value = "SELECT" cmdRecharge.Parameters.Add(New SqlParameter("@UserName", SqlDbType.NVarChar, 25)) cmdRecharge.Parameters("@UserName").Value = Trim(strUserName) cmdRecharge.Parameters.Add(New SqlParameter("@DNISPrefix", SqlDbType.VarChar, 10)) cmdRecharge.Parameters("@DNISPrefix").Value = "508" cmdRecharge.Parameters.Add(New SqlParameter("@AccountCat", SqlDbType.VarChar, 10)) cmdRecharge.Parameters("@AccountCat").Value = "VRTL" cmdRecharge.Connection.Open() drRecharge = cmdRecharge.ExecuteReader() If drRecharge.Read() Then Dim strText = drRecharge("Authcode") Dim strValue = drRecharge("BatchSeq") 'ddlstAuthCode.Items.Add(New ListItem(strText, strValue)) If Not IsDBNull(drRecharge("TypeOfCreditCard")) Then If Not drRecharge("TypeOfCreditCard") = "" Then Dim strCreditCardType As String = drRecharge("TypeOfCreditCard") Dim I As Long For I = 0 To UCCreditCardType.UCCreditCardType.Items.Count - 1 If UCCreditCardType.UCCreditCardType.Items.Item(I).Value = strCreditCardType Then UCCreditCardType.UCCreditCardType.SelectedIndex = I Exit For End If Next End If End If If Not IsDBNull(drRecharge("NameOnCreditCard")) Then Me.txtNameOnCreditCard.Text = drRecharge("NameOnCreditCard") End If If Not IsDBNull(drRecharge("CreditCardNo")) Then ViewState("creditorig") = drRecharge("CreditCardNo") Me.txtCreditCardNo.Text = CreditMask.Mask(drRecharge("CreditCardNo")) 'viewstate("creditorig") = drRecharge("CreditCardNo") 'Me.txtCreditCardNo.Text = CardNumber(drRecharge("CreditCardNo")) Else ViewState("creditorig") = "" Me.txtCreditCardNo.Text = "" End If If Not IsDBNull(drRecharge("CardCodeNo")) Then ViewState("cardcodeorig") = drRecharge("CardCodeNo") Me.txtCVV.Text = drRecharge("CardCodeNo") Else ViewState("cardcodeorig") = "" Me.txtCVV.Text = "" End If If Not IsDBNull(drRecharge("ExpiryDate")) Then UCExpiryMonth.UCMonth.SelectedIndex = Month(drRecharge("ExpiryDate")) - 1 UCExpiryYear.UCYear.Items.FindByValue(CType(Year(drRecharge("ExpiryDate")), String)).Selected = True End If If Not IsDBNull(drRecharge("cFirstName")) Then Me.txtFName.Text = drRecharge("cFirstName") End If If Not IsDBNull(drRecharge("CLastName")) Then Me.txtLName.Text = drRecharge("CLastName") End If If Not IsDBNull(drRecharge("Address")) Then Me.txtAddress.Text = drRecharge("Address") End If If Not IsDBNull(drRecharge("City")) Then Me.txtCity.Text = drRecharge("City") End If If Not IsDBNull(drRecharge("PromotionalCode")) Then Me.txtporpcode.Text = "" End If If IsDBNull(drRecharge("Country")) Then UCddlstCountry.UCddlstCountry.SelectedIndex = -1 Else Try UCddlstCountry.UCddlstCountry.Items.FindByValue(drRecharge("Country")).Selected = True Catch exp As Exception UCddlstCountry.UCddlstCountry.SelectedIndex = -1 End Try End If If Not IsDBNull(drRecharge("State")) Then If Not drRecharge("State") = "" Then Dim strState As String = drRecharge("State") Dim I As Long If UCddlstCountry.UCddlstCountry.SelectedItem.Value = "United States" Then UCStates.Visible = True UCStatesC.Visible = False UCStateBr.Visible = False ddlstOthers.Visible = False UCStatesC.UCStatesC.SelectedIndex = -1 ddlstOthers.SelectedIndex = -1 UCStateBr.UCStateBr.SelectedIndex = -1 For I = 0 To UCStates.UCStates.Items.Count - 1 If UCStates.UCStates.Items.Item(I).Value = strState Then UCStates.UCStates.SelectedIndex = I Exit For End If Next ElseIf UCddlstCountry.UCddlstCountry.SelectedItem.Value = "Canada" Then UCStates.Visible = False UCStatesC.Visible = True UCStateBr.Visible = False ddlstOthers.Visible = False UCStates.UCStates.SelectedIndex = -1 UCStateBr.UCStateBr.SelectedIndex = -1 ddlstOthers.SelectedIndex = -1 For I = 0 To UCStatesC.UCStatesC.Items.Count - 1 If UCStatesC.UCStatesC.Items.Item(I).Value = strState Then UCStatesC.UCStatesC.SelectedIndex = I Exit For End If Next ElseIf UCddlstCountry.UCddlstCountry.SelectedItem.Value = "Brazil" Then UCStates.Visible = False UCStatesC.Visible = False UCStateBr.Visible = True ddlstOthers.Visible = False UCStates.UCStates.SelectedIndex = -1 UCStatesC.UCStatesC.SelectedIndex = -1 ddlstOthers.SelectedIndex = -1 For I = 0 To UCStateBr.UCStateBr.Items.Count - 1 If UCStateBr.UCStateBr.Items.Item(I).Value = strState Then UCStateBr.UCStateBr.SelectedIndex = I Exit For End If Next Else UCStates.Visible = False UCStatesC.Visible = False UCStateBr.Visible = False ddlstOthers.Visible = True UCStates.UCStates.SelectedIndex = -1 UCStatesC.UCStatesC.SelectedIndex = -1 UCStateBr.UCStateBr.SelectedIndex = -1 End If Else UCStates.Visible = False UCStatesC.Visible = False UCStateBr.Visible = False ddlstOthers.Visible = True UCStates.UCStates.SelectedIndex = -1 UCStatesC.UCStatesC.SelectedIndex = -1 UCStateBr.UCStateBr.SelectedIndex = -1 End If End If Call setZip(UCddlstCountry.UCddlstCountry.SelectedItem.Value) If Not IsDBNull(drRecharge("ZipCode")) Then Me.txtZip.Text = drRecharge("ZipCode") End If If Not IsDBNull(drRecharge("EmailAddress")) Then txtEmail.Text = drRecharge("EmailAddress") End If If Not IsDBNull(drRecharge("PhoneNo")) Then txtPhone.Text = drRecharge("PhoneNo") End If If Not IsDBNull(drRecharge("FraudCheck")) Then If drRecharge("FraudCheck") = "0" Then Session("FraudCheck") = "N" Else Session("FraudCheck") = "Y" End If Else Session("FraudCheck") = "Y" End If End If While drRecharge.Read() Dim strText = drRecharge("AuthCode") Dim strValue = drRecharge("BatchSeq") 'ddlstAuthCode.Items.Add(New ListItem(strText, strValue)) End While Catch exp As Exception Response.Write(exp) Finally If Not (connMyLine Is Nothing) Then If (connMyLine.State = ConnectionState.Open) Then connMyLine.Close() End If connMyLine.Dispose() End If If Not (drRecharge Is Nothing) Then If Not (drRecharge.IsClosed) Then drRecharge.Close() End If End If If Not (cmdRecharge Is Nothing) Then cmdRecharge.Dispose() End If End Try Else strSelectedCountry = UCddlstCountry.UCddlstCountry.SelectedItem.Value Call setZip(UCddlstCountry.UCddlstCountry.SelectedItem.Value) If strSelectedCountry = "United States" Then UCStates.Visible = True UCStatesC.Visible = False UCStateBr.Visible = False ddlstOthers.Visible = False UCStatesC.UCStatesC.SelectedIndex = -1 UCStateBr.UCStateBr.SelectedIndex = -1 ddlstOthers.SelectedIndex = -1 ElseIf strSelectedCountry = "Canada" Then UCStates.Visible = False UCStatesC.Visible = True UCStateBr.Visible = False ddlstOthers.Visible = False UCStates.UCStates.SelectedIndex = -1 ddlstOthers.SelectedIndex = -1 UCStateBr.UCStateBr.SelectedIndex = -1 ElseIf strSelectedCountry = "Brazil" Then UCStates.Visible = False UCStatesC.Visible = False UCStateBr.Visible = True ddlstOthers.Visible = False UCStates.UCStates.SelectedIndex = -1 ddlstOthers.SelectedIndex = -1 UCStatesC.UCStatesC.SelectedIndex = -1 Else UCStates.Visible = False UCStatesC.Visible = False UCStateBr.Visible = False ddlstOthers.Visible = True UCStates.UCStates.SelectedIndex = -1 UCStatesC.UCStatesC.SelectedIndex = -1 UCStateBr.UCStateBr.SelectedIndex = -1 End If End If End Sub Function setZip(ByVal country As String) If country = "United States" Then Me.txtZip.MaxLength = "9" Me.rfvtxtZip.Enabled = True Me.revZip.Enabled = True Me.revZip.ValidationExpression = "^\d{5,}" 'Me.revZip.ValidationExpression = "^.{5,}$" ElseIf country = "Canada" Then Me.txtZip.MaxLength = "7" Me.rfvtxtZip.Enabled = True Me.revZip.Enabled = True 'Me.revZip.ValidationExpression = "^\d{3,}" Me.revZip.ValidationExpression = "^.{3,}$" Else Me.txtZip.MaxLength = "10" Me.rfvtxtZip.Enabled = False Me.revZip.Enabled = False 'Me.revZip.ValidationExpression = "^\d{3,}" End If End Function Function GetAgentWebsite(ByVal agent As String) As String Dim strAgentWebSite As String Dim connMyLine As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("MyLine").ConnectionString) Dim strSql As String = "s_GetAgentWebSite" Dim drMail As SqlDataReader Dim cmdMail As New SqlCommand(strSql, connMyLine) cmdMail.CommandType = CommandType.StoredProcedure cmdMail.Parameters.Add(New SqlParameter("@AgentId", SqlDbType.VarChar, 8)) cmdMail.Parameters("@AgentId").Value = Session("AgentId") cmdMail.Connection.Open() Try drMail = cmdMail.ExecuteReader() If drMail.Read() Then If Not IsDBNull(drMail("WEBSITE")) Then GetAgentWebsite = Trim(drMail("WEBSITE")) Else GetAgentWebsite = "MyLine.com" End If End If Catch Exp As Exception Response.Write(Exp.Message) Finally 'Close The Connection cmdMail.Connection.Close() End Try End Function Function ValidateCCNumber(ByVal CreditCardNo As String) As Integer Dim intReturnValue As Integer 'ValidateCCNumber = 1 connMyLine = New SqlConnection(ConfigurationManager.ConnectionStrings("MyLine").ConnectionString) strSql = "S_BuyNewPhoneCardPIN" cmdRecharge = New SqlCommand(strSql, connMyLine) cmdRecharge.CommandType = CommandType.StoredProcedure cmdRecharge.CommandTimeout = 180 Try cmdRecharge.Parameters.Add(New SqlParameter("@Operation", SqlDbType.VarChar, 20)) cmdRecharge.Parameters("@Operation").Value = "VALIDATECCNO" cmdRecharge.Parameters.Add(New SqlParameter("@UserName", SqlDbType.VarChar, 25)) cmdRecharge.Parameters("@UserName").Value = CreditCardNo cmdRecharge.Parameters.Add(New SqlParameter("@CreditCardNo", SqlDbType.VarChar, 25)) cmdRecharge.Parameters("@CreditCardNo").Value = CreditCardNo Dim prmReturnValue As SqlParameter = cmdRecharge.Parameters.Add("RETURN_VALUE", SqlDbType.Int) prmReturnValue.Direction = ParameterDirection.ReturnValue cmdRecharge.Connection.Open() cmdRecharge.ExecuteNonQuery() intReturnValue = cmdRecharge.Parameters("RETURN_VALUE").Value ValidateCCNumber = intReturnValue Catch ex As Exception Response.Write(ex.Message) Finally If Not (connMyLine Is Nothing) Then If (connMyLine.State = ConnectionState.Open) Then connMyLine.Close() End If connMyLine.Dispose() End If If Not (cmdRecharge Is Nothing) Then cmdRecharge.Dispose() End If End Try End Function Protected Sub PleaseWaitButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PleaseWaitButton2.Click Dim strState, strCCNo, strCCCode, strInvoiceNo As String If UCddlstCountry.UCddlstCountry.SelectedItem.Value = "United States" Then strState = Trim(UCStates.UCStates.SelectedItem.Value) ElseIf UCddlstCountry.UCddlstCountry.SelectedItem.Value = "Canada" Then strState = Trim(UCStatesC.UCStatesC.SelectedItem.Value) ElseIf UCddlstCountry.UCddlstCountry.SelectedItem.Value = "Brazil" Then strState = Trim(UCStateBr.UCStateBr.SelectedItem.Value) Else strState = Trim(ddlstOthers.SelectedItem.Value) End If strCCNo = ViewState("creditorig") strCCCode = ViewState("cardcodeorig") If (Trim(ViewState("creditorig")) = "") Or (CreditMask.Mask(Trim(ViewState("creditorig"))) <> CreditMask.Mask(Me.txtCreditCardNo.Text.Trim)) Then strCCNo = Me.txtCreditCardNo.Text.Trim End If strCCCode = Me.txtCVV.Text.Trim 'If ValidateCCNumber(ViewState("creditorig")) = 1 Then If ValidateCCNumber(Session("UserName")) = 1 Then lblMessage.Text = "Error while processing your credit card. Please check your credit card information." lblMessage.Visible = True Else 'If Trim(ViewState("creditorig")) = "" Then ' ViewState("creditorig") = Me.txtCreditCardNo.Text.Trim 'End If Dim blnValid As Boolean = False Dim intReturnValue As Integer Dim dblTotalAmount As Double strSql = "S_RechargePhoneCard" connMyLine = New SqlConnection(ConfigurationManager.ConnectionStrings("MyLine").ConnectionString) cmdRecharge = New SqlCommand(strSql, connMyLine) Dim decAmount As Decimal decAmount = System.Convert.ToDecimal(ddlRechargeAmount.SelectedItem.Value * 1.0) strReChargeAmt = decAmount.ToString("##,###0.00") 'strReChargeAmt = ExtAmount.ExtAmount.SelectedItem.Value If CType(strReChargeAmt, Double) > 101 Then lblMessage.Text = "You have exceeded the recharge amount." lblMessage.Visible = True Else Dim strCardStatus As String strCardStatus = ProcessCreditCard("S", strReChargeAmt, strCCNo, strCCCode, UCExpiryMonth.UCMonth.SelectedItem.Value, UCExpiryYear.UCYear.SelectedItem.Value, Trim(txtFName.Text), Trim(txtLName.Text), Trim(txtAddress.Text), Trim(txtCity.Text), strState, Trim(txtZip.Text), UCddlstCountry.UCddlstCountry.SelectedItem.Value, Trim(txtEmail.Text), Trim(txtPhone.Text), strIpAddress, strCCCode) 'strCardStatus = "Y" If strCardStatus <> "Y" Then 'lblMessage.Text = "Error while processing your credit card. Please check your credit card information." lblMessage.Text = strCardStatus lblMessage.Visible = True ''''''''''''''' New Update on 22-02-06 '''''''''''''''''''''''''''''''''''''' connMyLine = New SqlConnection(ConfigurationManager.ConnectionStrings("MyLine").ConnectionString) strSql = "S_RechargePhoneCard" cmdRecharge = New SqlCommand(strSql, connMyLine) cmdRecharge.CommandType = CommandType.StoredProcedure cmdRecharge.CommandTimeout = 180 Try cmdRecharge.Parameters.Add(New SqlParameter("@UserName", SqlDbType.NVarChar, 25)) cmdRecharge.Parameters("@UserName").Value = Session("UserName") cmdRecharge.Parameters.Add(New SqlParameter("@Rechargeamount", SqlDbType.Money)) cmdRecharge.Parameters("@Rechargeamount").Value = ddlRechargeAmount.SelectedItem.Value cmdRecharge.Parameters.Add(New SqlParameter("@AccountCat", SqlDbType.VarChar, 10)) cmdRecharge.Parameters("@AccountCat").Value = "VRTL" cmdRecharge.Parameters.Add(New SqlParameter("@CustNo", SqlDbType.VarChar, 12)) cmdRecharge.Parameters("@CustNo").Value = "91300000" cmdRecharge.Parameters.Add(New SqlParameter("@Operation", SqlDbType.VarChar, 20)) cmdRecharge.Parameters("@Operation").Value = "REJECTED" cmdRecharge.Parameters.Add(New SqlParameter("@AgentId", SqlDbType.VarChar, 8)) cmdRecharge.Parameters("@AgentId").Value = Session("AgentId") cmdRecharge.Parameters.Add(New SqlParameter("@Authcode", SqlDbType.VarChar, 25)) cmdRecharge.Parameters("@Authcode").Value = Trim(Session("PIN")) cmdRecharge.Parameters.Add(New SqlParameter("@CtrlStartNo", SqlDbType.BigInt)) cmdRecharge.Parameters("@CtrlStartNo").Value = CType(Trim(Session("PIN").ToString), Int64) cmdRecharge.Parameters.Add(New SqlParameter("@Reason", SqlDbType.VarChar, 200)) cmdRecharge.Parameters("@Reason").Value = Left(lblMessage.Text, 200) Dim prmReturnValue As SqlParameter = cmdRecharge.Parameters.Add("RETURN_VALUE", SqlDbType.Int) prmReturnValue.Direction = ParameterDirection.ReturnValue cmdRecharge.Connection.Open() cmdRecharge.ExecuteNonQuery() intReturnValue = cmdRecharge.Parameters("RETURN_VALUE").Value Catch ex As Exception Response.Write(ex.Message) Finally If Not (connMyLine Is Nothing) Then If (connMyLine.State = ConnectionState.Open) Then connMyLine.Close() End If connMyLine.Dispose() End If If Not (cmdRecharge Is Nothing) Then cmdRecharge.Dispose() End If End Try '''''''''''''''''''''''''''''''''''''' Else Try '-------------- Store Approved order in a text file----------------------- Dim strInput As String strInput = "exec S_RechargePhoneCard @Operation='UPDATE', @UserName=" & Session("UserName") & " , @Authcode=" & Trim(Session("PIN")) & "," strInput = strInput & "@cFirstName= " & Trim(txtFName.Text) & ", @cLastName= " & Trim(txtLName.Text) & " , @Address=" & Trim(txtAddress.Text) & " , " strInput = strInput & "@City= " & Trim(txtCity.Text) & ", @State= " & strState & ", @ZipCode=" & Trim(txtZip.Text) & ", @Country=" & Trim(UCddlstCountry.UCddlstCountry.SelectedItem.Value) & " ," strInput = strInput & "@TypeOfCreditCard=" & UCCreditCardType.UCCreditCardType.SelectedItem.Value & " ," strInput = strInput & "@CreditCardNo= " & Trim(txtCreditCardNo.Text) & ",@CVV= " & Trim(txtCVV.Text) & ", @ExpiryDate=" & UCExpiryMonth.UCMonth.SelectedItem.Value & "/01/" & UCExpiryYear.UCYear.SelectedItem.Value & " , @RechargeAmount=" & CType(strReChargeAmt, Double) & " , " strInput = strInput & "@NameOnCC=" & Trim(txtNameOnCreditCard.Text) & "," strInput = strInput & "@AgentId=" & ViewState("AgentId") & " , @IPAddress= " & strIpAddress & " , @CreatedDate=" & Date.Now & "" 'CSCode.LogError(strInput, strLogFileLocation) '-------------- Store Approved order ends----------------------- cmdRecharge.CommandType = CommandType.StoredProcedure cmdRecharge.Parameters.Add(New SqlParameter("@Operation", SqlDbType.VarChar, 20)) cmdRecharge.Parameters("@Operation").Value = "UPDATE" cmdRecharge.Parameters.Add(New SqlParameter("@UserName", SqlDbType.NVarChar, 25)) cmdRecharge.Parameters("@UserName").Value = Session("UserName") cmdRecharge.Parameters.Add(New SqlParameter("@RechargeAmount", SqlDbType.Money)) cmdRecharge.Parameters("@RechargeAmount").Value = CType(strReChargeAmt, Double) cmdRecharge.Parameters.Add(New SqlParameter("@Authcode", SqlDbType.VarChar, 25)) cmdRecharge.Parameters("@Authcode").Value = Trim(Session("PIN")) cmdRecharge.Parameters.Add(New SqlParameter("@DNISPrefix", SqlDbType.VarChar, 10)) cmdRecharge.Parameters("@DNISPrefix").Value = "508" cmdRecharge.Parameters.Add(New SqlParameter("@AccountCat", SqlDbType.VarChar, 10)) cmdRecharge.Parameters("@AccountCat").Value = "VRTL" cmdRecharge.Parameters.Add(New SqlParameter("@FirstName", SqlDbType.NVarChar, 30)) cmdRecharge.Parameters("@FirstName").Value = Trim(txtFName.Text) cmdRecharge.Parameters.Add(New SqlParameter("@LastName", SqlDbType.NVarChar, 30)) cmdRecharge.Parameters("@LastName").Value = Trim(txtLName.Text) cmdRecharge.Parameters.Add(New SqlParameter("@Address", SqlDbType.NVarChar, 50)) cmdRecharge.Parameters("@Address").Value = Trim(txtAddress.Text) cmdRecharge.Parameters.Add(New SqlParameter("@City", SqlDbType.NVarChar, 50)) cmdRecharge.Parameters("@City").Value = Trim(txtCity.Text) cmdRecharge.Parameters.Add(New SqlParameter("@State", SqlDbType.NVarChar, 20)) cmdRecharge.Parameters("@State").Value = strState cmdRecharge.Parameters.Add(New SqlParameter("@ZipCode", SqlDbType.NVarChar, 10)) cmdRecharge.Parameters("@ZipCode").Value = Trim(txtZip.Text) cmdRecharge.Parameters.Add(New SqlParameter("@Country", SqlDbType.NVarChar, 25)) cmdRecharge.Parameters("@Country").Value = UCddlstCountry.UCddlstCountry.SelectedItem.Value.Trim cmdRecharge.Parameters.Add(New SqlParameter("@NameOnCC", SqlDbType.NVarChar, 30)) cmdRecharge.Parameters("@NameOnCC").Value = Trim(txtNameOnCreditCard.Text) cmdRecharge.Parameters.Add(New SqlParameter("@TypeOfCreditCard", SqlDbType.NVarChar, 25)) cmdRecharge.Parameters("@TypeOfCreditCard").Value = UCCreditCardType.UCCreditCardType.SelectedItem.Value.Trim cmdRecharge.Parameters.Add(New SqlParameter("@CreditCardNo", SqlDbType.VarChar, 25)) cmdRecharge.Parameters("@CreditCardNo").Value = strCCNo cmdRecharge.Parameters.Add(New SqlParameter("@CardCodeNo", SqlDbType.VarChar, 4)) cmdRecharge.Parameters("@CardCodeNo").Value = strCCCode cmdRecharge.Parameters.Add(New SqlParameter("@ExpiryDate", SqlDbType.VarChar, 10)) cmdRecharge.Parameters("@ExpiryDate").Value = UCExpiryMonth.UCMonth.SelectedItem.Value + "/" + "01" + "/" + UCExpiryYear.UCYear.SelectedItem.Value cmdRecharge.Parameters.Add(New SqlParameter("@CustNo", SqlDbType.VarChar, 12)) cmdRecharge.Parameters("@CustNo").Value = "91300000" cmdRecharge.Parameters.Add(New SqlParameter("@CtrlStartNo", SqlDbType.BigInt)) cmdRecharge.Parameters("@CtrlStartNo").Value = CType(Trim(Session("PIN").ToString), Int64) cmdRecharge.Parameters.Add(New SqlParameter("@CtrlEndNo", SqlDbType.BigInt)) cmdRecharge.Parameters("@CtrlEndNo").Value = CType(Trim(Session("PIN").ToString), Int64) cmdRecharge.Parameters.Add(New SqlParameter("@Details", SqlDbType.VarChar, 100)) cmdRecharge.Parameters("@Details").Value = 1 & "*" & "VRTL" & "*" & Trim(strReChargeAmt) & "(" & Trim(Session("PIN")) & ")" cmdRecharge.Parameters.Add(New SqlParameter("@DiscountPercentage", SqlDbType.Float)) cmdRecharge.Parameters("@DiscountPercentage").Value = 0.0 cmdRecharge.Parameters.Add(New SqlParameter("@AgentId", SqlDbType.VarChar, 8)) cmdRecharge.Parameters("@AgentId").Value = Session("AgentId") cmdRecharge.Parameters.Add(New SqlParameter("@IPAddress", SqlDbType.VarChar, 15)) cmdRecharge.Parameters("@IPAddress").Value = strIpAddress cmdRecharge.Parameters.Add(New SqlParameter("@PromoCode", SqlDbType.VarChar, 50)) cmdRecharge.Parameters("@PromoCode").Value = txtporpcode.Text Dim prmReturnValue As SqlParameter = cmdRecharge.Parameters.Add("RETURN_VALUE", SqlDbType.Int) prmReturnValue.Direction = ParameterDirection.ReturnValue cmdRecharge.Connection.Open() 'cmdRecharge.ExecuteNonQuery() drRecharge = cmdRecharge.ExecuteReader() intReturnValue = cmdRecharge.Parameters("RETURN_VALUE").Value If drRecharge.Read() Then strInvoiceNo = drRecharge("invoiceno") End If Catch exp As Exception Response.Write(exp.Message) Finally connMyLine.Close() End Try If intReturnValue = 3 Then lblMessage.Text = "System Error: Recharge Card. Please contact Support@MyLine.com. " Else blnValid = True End If ' blnValid = True If blnValid Then Dim dt As New DateTime dt = Now Dim strAgentWebSite As String = "MyLine.com" Dim strDisplayAgentWebsite As String If strAgentWebSite.StartsWith("http://www.") Then strDisplayAgentWebsite = strAgentWebSite.Remove(0, 10) Else strDisplayAgentWebsite = strAgentWebSite End If Dim strMailText As String = "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "
 
" strMailText &= "                 " strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "
 
" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "
" strMailText &= "Click Here to Chat" strMailText &= "
" strMailText &= "
Thank you for Recharging Your MyLine.com Account!
" strMailText &= "
This transaction will be listed on your bank statement as MyLine.com
" strMailText &= "
" strMailText &= "

Invoice

" strMailText &= "
" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= " " strMailText &= "" strMailText &= "" strMailText &= "
" strMailText &= "
Billed To:
" strMailText &= "
" & txtFName.Text & " " & txtLName.Text & "
" strMailText &= "
" & txtEmail.Text & "
" strMailText &= "
" & txtAddress.Text & "
" strMailText &= "
" & txtCity.Text & "," & strState & " " & txtZip.Text & "," & UCddlstCountry.UCddlstCountry.SelectedItem.Value.Trim & "
" strMailText &= "
" strMailText &= "
Issued by:
" strMailText &= "" strMailText &= "
7999 N. Federal Highway,
" strMailText &= "
Suite 400, Boca Raton, FL - 33487
" strMailText &= "
United States
" strMailText &= "
" strMailText &= "
" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= " " strMailText &= "" strMailText &= "" strMailText &= "
" strMailText &= "

Invoice No. " & strInvoiceNo & "

" strMailText &= "

Date: " & dt.ToString & "" strMailText &= "

" strMailText &= "

Status. Successful

" strMailText &= "

Paid via your credit card ending in " & Right(ViewState("creditorig"), 4) & " " strMailText &= "

" strMailText &= "
" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "" strMailText &= "
" strMailText &= "

Product

" strMailText &= "
" strMailText &= "

Amount

" strMailText &= "
" strMailText &= "

Recharged PIN " & Session("PIN") & "

" strMailText &= "

Transaction Fee

" strMailText &= "

Tax

" strMailText &= "
" strMailText &= "

" & FormatCurrency(strReChargeAmt - 0.5, 2) & "

" strMailText &= "

$0.50

" strMailText &= "

$0.00

" strMailText &= "
" strMailText &= "

Total

" strMailText &= "
" strMailText &= "

$" & strReChargeAmt & "

" strMailText &= "
" strMailText &= "
" strMailText &= "                " strMailText &= "
For more information, please contact us
" strMailText &= "

Thank You,
Your MyLine.com Team.

" strMailText &= "
" strMailText &= "" strMailText &= "" Dim strSubject As String strSubject = ConfigurationManager.AppSettings("smtpsubject").ToString() & " - Recharge Confirmation" If Trim(txtEmail.Text) <> "" Then Try Dim mailClient As SmtpClient = New SmtpClient(ConfigurationManager.AppSettings("smtpserver").ToString()) mailClient.Port = ConfigurationManager.AppSettings("smtpport").ToString() mailClient.EnableSsl = True Dim cred As System.Net.NetworkCredential = New System.Net.NetworkCredential(ConfigurationManager.AppSettings("smtpusername").ToString(), ConfigurationManager.AppSettings("smtppassword").ToString()) mailClient.Credentials = cred Dim message As MailMessage = New MailMessage() message.From = New MailAddress(ConfigurationManager.AppSettings("smtpfromemail").ToString(), ConfigurationManager.AppSettings("smtpfromname").ToString()) message.To.Add(txtEmail.Text) message.Subject = strSubject message.Body = strMailText message.IsBodyHtml = True mailClient.Send(message) Catch ex As Exception Response.Redirect("Usr_viewaccounts.aspx?Recharged=True") End Try End If Response.Redirect("Usr_viewaccounts.aspx?Recharged=True") End If End If End If End If ' End Of ValidateCCNo End Sub Private Sub ddlRechargeAmount_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlRechargeAmount.SelectedIndexChanged If ddlRechargeAmount.SelectedItem.Value = "5.50" Then strAmount = "5.00" strTransactionFee = "0.50" strChargedAmount = "5.50" ElseIf ddlRechargeAmount.SelectedItem.Value = "10.50" Then strAmount = "10.00" strTransactionFee = "0.50" strChargedAmount = "10.50" ElseIf ddlRechargeAmount.SelectedItem.Value = "15.50" Then strAmount = "15.00" strTransactionFee = "0.50" strChargedAmount = "15.50" ElseIf ddlRechargeAmount.SelectedItem.Value = "20.50" Then strAmount = "20.00" strTransactionFee = "0.50" strChargedAmount = "20.50" ElseIf ddlRechargeAmount.SelectedItem.Value = "30.50" Then strAmount = "30.00" strTransactionFee = "0.50" strChargedAmount = "30.50" ElseIf ddlRechargeAmount.SelectedItem.Value = "50.50" Then strAmount = "50.00" strTransactionFee = "0.50" strChargedAmount = "50.50" ElseIf ddlRechargeAmount.SelectedItem.Value = "100.50" Then strAmount = "100.00" strTransactionFee = "0.50" strChargedAmount = "100.50" End If End Sub End Class