VB.Netサンプル

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' POSTされた値からURLクエリ文字を作成
Dim str_result As String = ""
Dim i As Integer = "0"

For i = 0 To Request.Form.Count - 1
    If i <> 0 Then
        str_result &= "&"
    End If
    str_result &= Request.Form.GetKey(i) & "=" & HttpUtility.UrlEncode(Request.Form(i))
Next

' リクエストを送信
Dim enc As Encoding = Encoding.GetEncoding("UTF-8")
Dim url As String = "https://gw.ccps.jp/payment.aspx?" & str_result

Dim req As WebRequest = WebRequest.Create(url)
Dim res As WebResponse = req.GetResponse()

' キックバック(戻り値)の読み取り
Dim st As System.IO.Stream = res.GetResponseStream()
Dim sr As System.IO.StreamReader = New StreamReader(st, enc)
Dim html As String = sr.ReadToEnd()
sr.Close()
st.Close()

Dim stArrayData As String() = New String() {}
stArrayData = html.Split("&"c)
Dim retv As Hashtable = New Hashtable()

For Each stData As String In stArrayData
    If stData.IndexOf("=") > -1 Then
        Dim v As String() = New String() {}
        v = stData.Split("="c)
        retv.Add(v(0), v(1))
    End If
Next

' rstの値で決済の成否判定
If retv("rst").ToString() = "1" Then
    form_result.Text = "

決済は成功しました。

" Else form_result.Text = "

決済失敗

エラーコード:" & _ retv("ec") & "

" End If End Sub