Advertisement
Advertisement
| 06.01.2008 at 11:49AM PDT, ID: 23448352 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: |
Private Sub CreditCardPayment()
Dim result As WebResponse
Try
Dim req As WebRequest
Dim reqStream, recStream As Stream
Dim tStamp As Long
Dim encode As Encoding
Dim sr As StreamReader
Dim num As String
Dim exp As String
Dim url As String
Dim responseText As String
url = "https://secure.appsgateway.com/api/transact.php" 'TESTURL
num = "4111111111111111"
exp = "0711"
req = WebRequest.Create(url)
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
Dim SomeBytes() As Byte
Dim UrlEncoded As New StringBuilder
Dim reserved() As Char = {ChrW(63), ChrW(61), ChrW(38)}
Dim data As String 'post data
data = "username=demo" & _
"&password=password" & _
"&amount=10.00" & _
"&payment=creditcard" & _
"&type=sale" & _
"&orderdescription=" & _
"&ccnumber=" & num & _
"&ccexp=" & exp & _
"&address1=Test Lane" & _
"&zip=84065" & _
"&firstname=some" & _
"&lastname=guy" & _
"&email=j@hotmail.com" & _
"&orderid=5555" & _
"&cvv=999"
If data <> Nothing Then
Dim i As Integer = 0
Dim j As Integer
While i < data.Length
j = data.IndexOfAny(reserved, i)
If j = -1 Then
UrlEncoded.Append(HttpUtility.UrlEncode(data.Substring(i, data.Length - i)))
Exit While
End If
UrlEncoded.Append(HttpUtility.UrlEncode(data.Substring(i, j - i)))
UrlEncoded.Append(data.Substring(j, 1))
i = j + 1
End While
SomeBytes = System.Text.Encoding.UTF8.GetBytes(UrlEncoded.ToString())
req.ContentLength = SomeBytes.Length
reqStream = req.GetRequestStream()
reqStream.Write(SomeBytes, 0, SomeBytes.Length)
reqStream.Close()
Else
req.ContentLength = 0
End If
result = req.GetResponse()
recStream = result.GetResponseStream()
encode = System.Text.Encoding.GetEncoding("utf-8")
sr = New StreamReader(recStream, encode)
Dim read(256) As Char
Dim count As Integer = sr.Read(read, 0, 256)
Dim theString As New StringBuilder
Do While count > 0
Dim str As String = New String(read, 0, count)
theString.Append(str)
count = sr.Read(read, 0, 256)
Loop
Dim responses() As String = theString.ToString
\\ TO D0: Get values from web response and assign them to variables
|