Send SMS to ozeki Message Server from Website - asp.net

I have created a website and I want to send sms to my users. The sms is sent correctly to 0zeki server message but the problem is that it is being redirecting to the server URL, while I only want the sms to be sent and that there is no response redirect to the server can someone help please
Dim con As New SqlConnection(_start)
con.Open()
Dim sql1 As String = "SELECT TOP (1) Member.PhoneNumber FROM (SELECT TOP (2) BidID, Date, BiddingPrice, Status, AuctionID, BuyerID, WinningPrice from BID ORDER BY BidID DESC) AS tabel1 INNER JOIN Buyer ON tabel1.BuyerID = Buyer.BuyerID INNER JOIN Member ON Buyer.MemberID = Member.MemberID INNER JOIN Auction ON tabel1.AuctionID = Auction.AuctionID WHERE(Auction.AuctionID = #auction) ORDER BY tabel1.BidID"
Dim auction1 As Integer = Convert.ToInt32(lblauction.Text)
Dim sqlcommand As New SqlCommand(sql1, con)
sqlcommand.Parameters.AddWithValue("#auction", auction1)
Dim phone As String = sqlcommand.ExecuteScalar
Dim sql2 As String = "SELECT Item.Name FROM Item INNER JOIN Auction ON Item.ItemID = Auction.ItemID WHERE (Auction.AuctionID = #auction)"
Dim cmd As New SqlCommand(sql2, con)
cmd.Parameters.AddWithValue("#auction", auction1)
Dim name As String = cmd.ExecuteScalar
Dim message As String = "Your bid has been overbid please, Visit the Website to bid against on auction " + name + "thanks you"
Response.Redirect("http://localhost:9333/Ozeki?login=admin&password=abc123&action=sendMessage&messagetype=SMS&recepient=" + phone + "&messageData=" + message)

Just replace Response.Redirect with
WebRequest.Create("http://localhost:9333/Ozeki?login=admin&password=abc123&action=sendMessage&messagetype=SMS&recepient=" + phone + "&messageData=" + message)
.GetResponse();
It will call the service and won't redirect the page.

Related

Paypal Express Payment Execution

I'm developing in vb.net and as of right now I am not using any API's to receive transaction details I have only been using IPN and PDT variables to get my details however I began to notice that, when using Paypal Sandbox to test, after I go through the process of check out, I do receive all the variables of the details but in my test account, there are no transactions shown.
Do I need to be using the REST API in order to actually approve and execute the payment for the transaction in order to complete a transaction? I had assumed that the entire transaction had been completed successful since I was getting all of the details back but now that I noticed there aren't any transactions showing in my account I'm not so sure whats going on?
Here is the code I have been using to view transaction details
Dim authToken As String = "c37yqZU7UdVWesSoipRHFOwB3fFLv1CfOKWz10hqp0ULz6dYKrlCNuxp9d0"
Dim txToken As String = Request.QueryString("tx")
txToken = "2F816064M1280054A" '"6AX4295820157674V" '"5PD1935338742763G" ' '"70Y83841KE749971T" '"74C31896AA9005743""2RY90202U2008611C" '"0F824628H9566062P" '"5ET57654YS955312K" '
Dim strRequest As String = "cmd=_notify-synch&tx=" & txToken & "&at=" & authToken
'Dim Payerinfo As New PayerInfo
'Dim trans As New Transaction
'Dim tra As New PayPal.PayPalAPIInterfaceService.Model.GetTransactionDetailsReq
'post back to either sandbox or live
Dim strSandbox As String = "https://www.sandbox.paypal.com/cgi-bin/webscr"
Dim strLive As String = "https://www.paypal.com/cgi-bin/webscr"
Dim req As HttpWebRequest = CType(WebRequest.Create(strSandbox), HttpWebRequest)
'req.Headers = valHeader
'Set values for the request back
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
req.ContentLength = strRequest.Length
'Send the request to PayPal and get the response
Dim streamOut As StreamWriter = New StreamWriter(req.GetRequestStream(), Encoding.ASCII)
streamOut.Write(strRequest)
streamOut.Close()
Dim streamIn As StreamReader = New StreamReader(req.GetResponse().GetResponseStream())
Dim strResponse As String = streamIn.ReadToEnd()
streamIn.Close()
If Not String.IsNullOrEmpty(strResponse) Then
Dim results As New Dictionary(Of String, String)
Dim reader As New StringReader(strResponse)
Dim line As String = reader.ReadLine()
If line = "SUCCESS" Then
'FormView1.Visible = False
While True
Dim aLine As String
aLine = reader.ReadLine
If aLine IsNot Nothing Then
Dim strArr() As String
strArr = aLine.Split("=")
results.Add(strArr(0), strArr(1))
Else
Exit While
End If
End While
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'when code below is uncommented remove these two end if's below
Response.Write("<li> " + results("payer_id") + "</li>")
Response.Write("<li> " + results("txn_id") + "</li>")
' Displays all the keys for results, helps to see what the keys are named for writing to text file
For Each kvp As KeyValuePair(Of String, String) In results
Dim v1 As String = kvp.Key
Dim v2 As String = kvp.Value
Response.Write(v1.ToString _
+ ": " + v2 + "<br /> ")
Next
End If

Get Paypal Express cart Price right before checkout

I am using paypal express checkout and I'm trying to get the total value that is in the shopping cart when the user decides to checkout. My shipping rate is going to be based on the total price and although I have the shipping calculations filled out in my paypal account settings, the shipping cost is not showing up in the checkout screen. How would I grab the total shopping cart price right upon checkout so that I can add the shipping cost? What I have so far is only the values after the user has checked out and they are returned back to my website but at this point it is too late to add shipping.
Dim authToken As String = "sdf5414FdsfDFS5eEF52s336DFLLJUhhbuzek64"
Dim txToken As String = Request.QueryString("tx")
txToken = "4GGSES84eEWSS"
Dim strRequest As String = "cmd=_notify-synch&tx=" & txToken & "&at=" & authToken
'Dim Payerinfo As New PayerInfo
'Dim trans As New Transaction
'Dim tra As New PayPal.PayPalAPIInterfaceService.Model.GetTransactionDetailsReq
'post back to either sandbox or live
Dim strSandbox As String = "https://www.sandbox.paypal.com/cgi-bin/webscr"
Dim strLive As String = "https://www.paypal.com/cgi-bin/webscr"
Dim req As HttpWebRequest = CType(WebRequest.Create(strSandbox), HttpWebRequest)
'req.Headers = valHeader
'Set values for the request back
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
req.ContentLength = strRequest.Length
'Send the request to PayPal and get the response
Dim streamOut As StreamWriter = New StreamWriter(req.GetRequestStream(), Encoding.ASCII)
streamOut.Write(strRequest)
streamOut.Close()
Dim streamIn As StreamReader = New StreamReader(req.GetResponse().GetResponseStream())
Dim strResponse As String = streamIn.ReadToEnd()
streamIn.Close()
If Not String.IsNullOrEmpty(strResponse) Then
Dim results As New Dictionary(Of String, String)
Dim reader As New StringReader(strResponse)
Dim line As String = reader.ReadLine()
If line = "SUCCESS" Then
'FormView1.Visible = False
While True
Dim aLine As String
aLine = reader.ReadLine
If aLine IsNot Nothing Then
Dim strArr() As String
strArr = aLine.Split("=")
results.Add(strArr(0), strArr(1))
Else
Exit While
End If
End While
' Displays all the keys for results, helps to see what the keys are named for writing to text file
For Each kvp As KeyValuePair(Of String, String) In results
Dim v1 As String = kvp.Key
Dim v2 As String = kvp.Value
Response.Write(v1.ToString _
+ ": " + v2 + "<br /> ")
Next
End If
I have also been trying to declare a session variable and add to it every time the add to cart button is clicked but I see a problem in this because I don't know how long the items will stay in the paypal cart and if the session variable session runs out of time and is cleared, they will then receive free shipping since the shipping amount clears out. Is their any way to make this work?
Protected Sub AddToCartBtn_Click(sender As Object, e As EventArgs)
Session("CartAmount")
Dim itemNumber As String = str2
Dim itemAmount As String = price
Dim currencyCode As String = "USD"
Dim addItem As Integer = 1
Dim ppHref As StringBuilder = New StringBuilder()
ppHref.Append("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_cart")
ppHref.Append("&business=" + business)
ppHref.Append("&item_name=" + itemName)
ppHref.Append("&item_number=" + itemNumber)
ppHref.Append("&amount=" + itemAmount)
ppHref.Append("&currency_code=" + currencyCode)
Session("CartAmount") = (cartTotal + Session("CartAmount"))
End Sub
You can pass shopping cart values in the provided variable from the following url reference,
https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/#id08A6HF080O3

Paypal confirmation when the transaction has been successfully done

I have redirected my website to Paypal on Buy Now button, but where should i place my code when the transaction has been successfully done.
Can someone help please? I need to change my status in my biding to paid.
Dim temp As String = Request.QueryString("user").ToString
Dim temp1 As Integer = Convert.ToInt32(temp)
Dim LastName As String
Dim WinningPrice As String
Dim email As String
Dim country As String
Dim Name As String
Dim FirstName As String
Using con1 As New SqlConnection(_start)
'Build your SQL String'
Dim sql1 As String = "SELECT Item.Name, BID.WinningPrice, Member.LastName, Member.FirstName,Member.Email, Member.Country FROM Item INNER JOIN Seller ON Item.SellerID = Seller.SellerID INNER JOIN Auction ON Item.ItemID = Auction.ItemID INNER JOIN BID ON Auction.AuctionID = BID.AuctionID INNER JOIN Member ON Seller.MemberID = Member.MemberID WHERE (Member.Status = 'Available') AND (Seller.SellerStatus = 'Available') AND (BID.Status = 'Won') AND (Auction.Status = 'Expired') and BID.BidID=#bidid"
'Open your connection'
con1.Open()
'Build your Command to execute'
Dim myCommand1 As New SqlCommand(sql1, con1)
'Grab your parameter'
'Add your parameter'
myCommand1.Parameters.Add("#bidid", SqlDbType.Int).Value = temp1
Dim reader As SqlDataReader = myCommand1.ExecuteReader()
If reader.HasRows Then
If reader.Read() Then
' etc
Name = reader.GetString(0)
WinningPrice = Convert.ToString(reader.GetDouble(1))
LastName = reader.GetString(2)
FirstName = reader.GetString(3)
email = reader.GetString(4)
country = reader.GetString(5)
Dim price As Object
'Converting String Money Value Into Decimal
price = Convert.ToDouble(WinningPrice)
'declaring empty String
Dim returnURL As String = ""
returnURL += "https://www.paypal.com/xclick/business=" + email
'Passing Item Name as dynamic
returnURL += Convert.ToString("&item_name=") & Name
'Assigning Name as Statically to Parameter
returnURL += Convert.ToString("&first_name") & FirstName
'Assigning Name as Statically to Parameter
returnURL += Convert.ToString("&last_name") & LastName
'Assigning City as Statically to Parameter
returnURL += Convert.ToString("&country") & country
'Passing Amount as Dynamic
returnURL += "&amount=" + price.ToString
'Passing Currency as your
returnURL += "&currency=USD"
'If transactioin has been successfully performed, redirect SuccessURL page- this page will be designed by developer
returnURL += "&return=" + ConfigurationManager.AppSettings("SuccessURL").ToString()
'retturn Url if Customer Wants To Cancel the Transaction
'If transactioin has been failed, redirect FailedURL page- this page will be designed by developer
returnURL += "&cancel_return=" + ConfigurationManager.AppSettings("FailedURL").ToString()
Response.Redirect(returnURL)
End If
End If
End Using
You are passing in a SuccessUrl parameter; when paypal completes it is going to send a notification to that page - so you should put code in the Page_Load event of your SuccessUrl to parse the query parms returned, and do whatever local processing you need to do there.

Refills prescriptions and Tranferring Prescriptions. How should I approach this?

I have some doubts I would like to clear.
We have two features on our website we would like to provide to our customers for dealing with prescription drugs.
One feature allows potential new customers to transfer their prescription drugs from their current providing pharmacy to our pharmacy.
Another feature allows current customers to refill their current prescriptions.
Prescriptions must be either transferred from previous provider or must have existed before they can refilled.
To achieve the prescription transfer portion, I have two tables, one called Customer (which contains customer personal info as well as current providing pharmacy name and phone number) and the other called Prescriptions. This table contains prescription info. customerId is on this table as Foreign key to customer table.
The code below inserts records into customer table and prescriptions table for customers transferring their prescriptions from one pharmacy to our pharmacy.
I am also aware that I need to perform a check to see if customer trying to transfer prescriptiosn already exists on our table. I have not done this yet but will.
My doubt is how to handle the Refill portion of this task.
Any ideas is greatly appreciated.
Here is the code that inserts Transferred prescriptions.
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim s As String
Dim sql As String
Dim connStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;data source=" & Server.MapPath("App_Data\GCP.accdb")
Try
SetRowData()
Dim table As DataTable = TryCast(ViewState("CurrentTable"), DataTable)
If table IsNot Nothing Then
s = "INSERT INTO Customer(FirstName, LastName, MiddleInitial, DOB, Email_Address, Phone, Address, City, State, ZipCode, PharmacyName, PharmacyPhone) Values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
sql = "Select Max(custId) From Customer"
'Response.Write(s)
'Response.End()
Dim con As New OleDbConnection(connStr)
Dim cmd1 As New OleDbCommand(s, con)
cmd1.Parameters.AddWithValue("", txtfName.Text)
cmd1.Parameters.AddWithValue("", txtMI.Text)
cmd1.Parameters.AddWithValue("", txtLName.Text)
cmd1.Parameters.AddWithValue("", txtDOB.Text)
cmd1.Parameters.AddWithValue("", txtemail.Text)
cmd1.Parameters.AddWithValue("", txtphone.Text)
cmd1.Parameters.AddWithValue("", txtAddress.Text)
cmd1.Parameters.AddWithValue("", txtcity.Text)
cmd1.Parameters.AddWithValue("", txtstate.Text)
cmd1.Parameters.AddWithValue("", txtzip.Text)
cmd1.Parameters.AddWithValue("", txtpharmacyName.Text)
cmd1.Parameters.AddWithValue("", txtPharmacyPhone.Text)
con.Open()
cmd1.ExecuteNonQuery()
cmd1.CommandText = sql
ID = cmd1.ExecuteScalar()
For Each row As DataRow In table.Rows
Dim txPrescription As String = TryCast(row.ItemArray(1), String)
If txPrescription IsNot Nothing Then
Try
s = "INSERT INTO Prescriptions(Prescription, custId) VALUES "
s += "('" & txPrescription & "', " & ID & ")"
'Response.Write(s)
'Response.End()
'Dim connStr As String = ConfigurationManager.ConnectionStrings("allstringconstrng").ConnectionString
Dim conn As New OleDbConnection(connStr)
Dim cmd As New OleDbCommand(s, conn)
conn.Open()
cmd.ExecuteNonQuery()
conn.Close()
'Display some feedback to the user to let them know it was processed
lblResult.ForeColor = System.Drawing.Color.Green
lblResult.Text = "Your Prescriptions Transfer Request has been sent. Prescription requests are normally processed within 24 hours!"
'Clear the form
txPrescription = ""
txtfName.Text = ""
txtMI.Text = ""
txtLName.Text = ""
txtDOB.Text = ""
txtemail.Text = ""
txtphone.Text = ""
txtAddress.Text = ""
txtcity.Text = ""
txtstate.Text = ""
txtzip.Text = ""
Catch
'If the message failed at some point, let the user know
lblResult.ForeColor = System.Drawing.Color.Red
lblResult.Text = "Your record failed to save, please try again."
End Try
End If
Next
End If
Catch ex As Exception
Throw New Exception(ex.Message)
End Try
End Sub

Saving checked status from a checkbox into the database in asp.net

I'm working on a online test application in asp.net and i'm finding trouble in saving the checked answer status back to database, i.e once i click on next button in my aspx page these 2 things should happen
1)It should capture the currently checked option and add the value for that particular option as true into my database IS_Marked column.
2)It also should pull out the next set of question and Options
The latter is fine but i'm not getting any clue about how to save the checkd answer back into database
My aspx has 4 check boxes
and my next button click event is as follows,
protected void BtnNext_Click(object sender, EventArgs e)
{
if (qid == maxid)//checks whether current que id is equal to last que id in DB
{
BtnNext.Enabled = false; //if its last que then next button is disabled
}
else
{
BtnPrevious.Enabled = true; // if not last question next button is enabled
QuestionSet q = new QuestionSet(); //Question set is an entity to hold que text and options list
StudentB b = new StudentB(); //object of my business class
q = b.GetQuestion(1, 1, qid, 'N', 0);//passing student id, test id, question id, action taken, i.e button clicked(prev, next, last, first) and selected question(i.e any question that is present)
qid = Convert.ToInt32(q.Question_Id);
LblQStn.Text = q.Question_Text;
CheckBox1.Text = q.Options[0].Option_Text;//talking to business and model layer and getting que and ans from database and giving to checkboxes
CheckBox2.Text = q.Options[1].Option_Text;
CheckBox3.Text = q.Options[2].Option_Text;
CheckBox4.Text = q.Options[3].Option_Text;
}
}
now when he checks any answer i need to save its status as marked into the database
Any solution is highly appreciated,
thanks in advance
Well first you need to set up the connection to database. example:
//sqlString is your connectionstring//
dbconn = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("sqlString"))
dbconn.Open()
strsql = "INSERT INTO IS_Marked ([Mark]) VALUES ('" + Bedrijf + "')"
dbcomm = New SqlCommand(strsql, dbconn)
dbcomm.ExecuteNonQuery()
dbconn.Close()
This will be your basic sql command.
As you can see I ues ([yourvalue]) that what we are going to do next.
Dim dbconn As SqlConnection
Dim dbcomm As SqlCommand
Dim strsql, Checked_Mark As String
Mark = YourCheckBox.CheckedValue
So your final result will be like this:
Dim dbconn As SqlConnection
Dim dbcomm As SqlCommand
Dim strsql, Mark As String
Mark = YourCheckBox.CheckedValue
dbconn = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("sqlString"))
dbconn.Open()
strsql = "INSERT INTO IS_Marked ([Mark]) VALUES ('" + Bedrijf + "')"
dbcomm = New SqlCommand(strsql, dbconn)
dbcomm.ExecuteNonQuery()
dbconn.Close()

Resources