B
bob garbados
I'm new to web services and I'm trying to interface with a payment gateway
for an online store. I'm trying to do this without Visual Studio and I'm
stuck...
I created my proxy class from the command line with the following statement:
wsdl
https://webservices.innovativegateway.com/igspaymentservice/igspaymentservice.asmx?WSDL
/l:vb /n:ECommerce.PaymentGateway /o:ECommerce.PaymentGateway.vb
I then compiled it into a dll along with some other classes using the
following statement:
vbc /t:library /out:..\bin\ECommerce.dll /r:System.xml.dll
/r:Microsoft.VisualBasic.dll /r:System.dll /r:System.Data.dll
/r:System.Web.dll /r:System.Web.Services.dll ECommerce.Utils.vb
Ecommerce.DataAccess.vb ECommerce.PaymentGateway.vb
The Web Service contains two methods... GetVersion and ProcessTransaction.
I can call GetVersion without a hitch, but I'm getting the following error
when I try to call ProcessTransaction:
BC30311: Value of type 'System.Collections.Hashtable' cannot be converted
to '1-dimensional array of ECommerce.PaymentGateway.IGSParameter'.
Here's the function generated by wisdl:
<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://WebServic
es.InnovativeGateway.com/IGS/IGSPaymentService/ProcessTransaction"& _
"",
RequestNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentSe
rvice/",
ResponseNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentS
ervice/", Use:=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>
_
Public Function
ProcessTransaction(<System.Xml.Serialization.XmlArrayItemAttribute(IsNullabl
e:=false)> ByVal pInput() As IGSParameter) As
<System.Xml.Serialization.XmlArrayItemAttribute(IsNullable:=false)>
IGSParameter()
Dim results() As Object = Me.Invoke("ProcessTransaction", New
Object() {pInput})
Return CType(results(0),IGSParameter())
End Function
And here's the IGSParameter class:
Public Class IGSParameter
'<remarks/>
Public Name As String
'<remarks/>
Public Value As String
End Class
I followed the C# example that the payment gateway provided... Sorry for the
length of this post, but I'm going to include some code.
Here's my vb code:
Function ProcessTransaction() as Boolean
Dim blnSuccess as Boolean
blnSuccess = True
Dim pgInnovative as IGSPaymentService
pgInnovative = new IGSPaymentService
Dim strVersion as String
strVersion = pgInnovative.GetVersion().ToString()
lblDebug.Text = strVersion
'Create a hash table to contain name/value pairs for innovative inputs
Dim htInnovativeGatewayFields as HashTable
htInnovativeGatewayFields = New HashTable()
htInnovativeGatewayFields.Add("target_app", "WebCharge_v5.06")
htInnovativeGatewayFields.Add("upg_auth", "zxcvlkjh")
If Not Session("CCType") Is Nothing Then
htInnovativeGatewayFields.Add("cardtype", Session("CCType"))
Else
blnSuccess = False
End If
....
htInnovativeGatewayFields.Add("NotifyEmail", "no")
htInnovativeGatewayFields.Add("ReceipEmail", "no")
If blnSuccess = False Then
return False
End If
CODE FAILS HERE
htInnovativeGatewayFields =
pgInnovative.ProcessTransaction(htInnovativeGatewayFields)
lblDebug.Text = htInnovativeGatewayFields.ToString()
htInnovativeGatewayFields.Clear
return blnSuccess
End Function
And here's the relevant parts of the example code:
UpgiClient uc = new UpgiClient();
// create a Hashtable object for holding the name/value pairs
Hashtable ht = new Hashtable();
private void Page_Load(object sender, System.EventArgs e)
{
// initialize the Hashtable with the transaction information
ht["cardtype"] = "visa";
ht["ccname"] = "John Smith";
ht["ccnumber"] = "4242424242424242";
ht["fulltotal"] = "2.00";
ht["month"] = "12";
ht["year"] = "05";
ht["trantype"] = "sale";
ht["baddress"] = "1001 Main";
ht["bcity"] = "Dallas";
ht["bstate"] = "TX";
ht["bzip"] = "75240";
ht["bphone"] = "2145557177";
ht["ordernumber"] = "11A442B11";
resultsgood.Visible = false;
resultsbad.Visible = false;
}
private void Go_Click(object sender, System.EventArgs e)
{
ht["username"] = user.Text;
ht["pw"] = pass.Text;
// process the transaction and retrieve the results back into the
Hashtable
ht = uc.ProcessTransaction(ht);
String Output = "";
// dump out the contents of the Hashtable just to see what's in there
foreach( string key in ht.Keys ) {
Output = Output + key + " = ";
Output = Output + ht[key] + " \n";
}
results.Text = Output;
// check for success or failure
if( ht.ContainsKey("error") )
{
results.ForeColor = System.Drawing.Color.Red;
resultsbad.Visible = true;
resultsgood.Visible = false;
}
else
{
results.ForeColor = System.Drawing.Color.Green;
resultsgood.Visible = true;
resultsbad.Visible = false;
}
}
}
}
Can anybody see what am I doing wrong here (or even follow this post)? The
example uses a hashtable, but it's not working...
thanks in advance.
for an online store. I'm trying to do this without Visual Studio and I'm
stuck...
I created my proxy class from the command line with the following statement:
wsdl
https://webservices.innovativegateway.com/igspaymentservice/igspaymentservice.asmx?WSDL
/l:vb /n:ECommerce.PaymentGateway /o:ECommerce.PaymentGateway.vb
I then compiled it into a dll along with some other classes using the
following statement:
vbc /t:library /out:..\bin\ECommerce.dll /r:System.xml.dll
/r:Microsoft.VisualBasic.dll /r:System.dll /r:System.Data.dll
/r:System.Web.dll /r:System.Web.Services.dll ECommerce.Utils.vb
Ecommerce.DataAccess.vb ECommerce.PaymentGateway.vb
The Web Service contains two methods... GetVersion and ProcessTransaction.
I can call GetVersion without a hitch, but I'm getting the following error
when I try to call ProcessTransaction:
BC30311: Value of type 'System.Collections.Hashtable' cannot be converted
to '1-dimensional array of ECommerce.PaymentGateway.IGSParameter'.
Here's the function generated by wisdl:
<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://WebServic
es.InnovativeGateway.com/IGS/IGSPaymentService/ProcessTransaction"& _
"",
RequestNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentSe
rvice/",
ResponseNamespace:="http://WebServices.InnovativeGateway.com/IGS/IGSPaymentS
ervice/", Use:=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>
_
Public Function
ProcessTransaction(<System.Xml.Serialization.XmlArrayItemAttribute(IsNullabl
e:=false)> ByVal pInput() As IGSParameter) As
<System.Xml.Serialization.XmlArrayItemAttribute(IsNullable:=false)>
IGSParameter()
Dim results() As Object = Me.Invoke("ProcessTransaction", New
Object() {pInput})
Return CType(results(0),IGSParameter())
End Function
And here's the IGSParameter class:
Public Class IGSParameter
'<remarks/>
Public Name As String
'<remarks/>
Public Value As String
End Class
I followed the C# example that the payment gateway provided... Sorry for the
length of this post, but I'm going to include some code.
Here's my vb code:
Function ProcessTransaction() as Boolean
Dim blnSuccess as Boolean
blnSuccess = True
Dim pgInnovative as IGSPaymentService
pgInnovative = new IGSPaymentService
Dim strVersion as String
strVersion = pgInnovative.GetVersion().ToString()
lblDebug.Text = strVersion
'Create a hash table to contain name/value pairs for innovative inputs
Dim htInnovativeGatewayFields as HashTable
htInnovativeGatewayFields = New HashTable()
htInnovativeGatewayFields.Add("target_app", "WebCharge_v5.06")
htInnovativeGatewayFields.Add("upg_auth", "zxcvlkjh")
If Not Session("CCType") Is Nothing Then
htInnovativeGatewayFields.Add("cardtype", Session("CCType"))
Else
blnSuccess = False
End If
....
htInnovativeGatewayFields.Add("NotifyEmail", "no")
htInnovativeGatewayFields.Add("ReceipEmail", "no")
If blnSuccess = False Then
return False
End If
CODE FAILS HERE
htInnovativeGatewayFields =
pgInnovative.ProcessTransaction(htInnovativeGatewayFields)
lblDebug.Text = htInnovativeGatewayFields.ToString()
htInnovativeGatewayFields.Clear
return blnSuccess
End Function
And here's the relevant parts of the example code:
UpgiClient uc = new UpgiClient();
// create a Hashtable object for holding the name/value pairs
Hashtable ht = new Hashtable();
private void Page_Load(object sender, System.EventArgs e)
{
// initialize the Hashtable with the transaction information
ht["cardtype"] = "visa";
ht["ccname"] = "John Smith";
ht["ccnumber"] = "4242424242424242";
ht["fulltotal"] = "2.00";
ht["month"] = "12";
ht["year"] = "05";
ht["trantype"] = "sale";
ht["baddress"] = "1001 Main";
ht["bcity"] = "Dallas";
ht["bstate"] = "TX";
ht["bzip"] = "75240";
ht["bphone"] = "2145557177";
ht["ordernumber"] = "11A442B11";
resultsgood.Visible = false;
resultsbad.Visible = false;
}
private void Go_Click(object sender, System.EventArgs e)
{
ht["username"] = user.Text;
ht["pw"] = pass.Text;
// process the transaction and retrieve the results back into the
Hashtable
ht = uc.ProcessTransaction(ht);
String Output = "";
// dump out the contents of the Hashtable just to see what's in there
foreach( string key in ht.Keys ) {
Output = Output + key + " = ";
Output = Output + ht[key] + " \n";
}
results.Text = Output;
// check for success or failure
if( ht.ContainsKey("error") )
{
results.ForeColor = System.Drawing.Color.Red;
resultsbad.Visible = true;
resultsgood.Visible = false;
}
else
{
results.ForeColor = System.Drawing.Color.Green;
resultsgood.Visible = true;
resultsbad.Visible = false;
}
}
}
}
Can anybody see what am I doing wrong here (or even follow this post)? The
example uses a hashtable, but it's not working...
thanks in advance.