Skip to content

Instantly share code, notes, and snippets.

@allsecure-pay
Last active December 19, 2018 10:01
Show Gist options
  • Save allsecure-pay/709273644c8807f9ce082d8804b4c67f to your computer and use it in GitHub Desktop.
Save allsecure-pay/709273644c8807f9ce082d8804b4c67f to your computer and use it in GitHub Desktop.
SecurePay-VB (PA)
Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Partial Class _Default
Inherits System.Web.UI.Page
Public CheckoutId As String = ""
Protected Sub Page_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
CheckoutId = prepareCheckout()
End Sub
Public Function prepareCheckout() As String
Dim url As String = "https://test.oppwa.com/v1/checkouts"
Dim data As String = "authentication.userId=8a8294184f45ce7e014f4b1d16cc12df" +
"&authentication.password=j3zCJ2ENaD" +
"&authentication.entityId=8a8294184f45ce7e014f4b1d16bd12db" +
"&paymentType=PA" +
"&amount=499.99" +
"&currency=RSD"
Dim request As WebRequest = WebRequest.Create(url)
request.Method = "POST"
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(data)
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length
Dim dataStream As Stream = request.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim webresponse As WebResponse = request.GetResponse()
dataStream = webresponse.GetResponseStream()
Dim reader As New StreamReader(dataStream)
Dim response As String = reader.ReadToEnd()
reader.Close()
dataStream.Close()
webresponse.Close()
Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer()
Dim dict As Dictionary(Of String, Object) = jss.Deserialize(Of Dictionary(Of String, Object))(response)
Return dict("id")
End Function
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment