Our SOAP API allows full integration of Number services with a high degree of customization. You can use our SOAP API reference to learn about specific methods in the API.
The easiest way to get started using Number's SOAP API is to generate the CardProcessClient service. Following the steps below, you'll learn how to generate that service for applications using the Windows Communication Foundation (WCF) framework.
Generate CardProcessService using the command line
1
Install .NET Framework SDK
Download and install the Windows SDK that corresponds with the version of the .NET Framework you're using. You can find the SDK installer on the Microsoft website.
Alternatively, you can install Visual Studio Community, Professional, or Enterprise, which include the SDK alongside with other .NET development tools.
SvcUtil.exe is used to generate service model code from metadata documents such as WSDL files. For .NET Framework 4.x, it is usually located in 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\'.
3
Use the tool to generate the CardProcessService model
Open a Command Prompt window and navigate to the directory where SvcUtil.exe is located or add the directory to your system's PATH environment variable for easier access.
By default, svcutil.exe will generate C# code. You can specify a language option by adding /language:VB or /language:CPP at the end of the command if you wish to generate a service class for Visual Basic or C++.
Make sure to run the command as an administrator. If you receive network errors, you can try downloading the single WSDL with the full service description and provide the file path as an argument to the command.
This will generate a configuration file with the name of output.config and a C# code file named CardProcAPI.cs that contains the client class. Both of the files should appear inside of the folder with the tool.
Add the two files to your application and use the generated client class to call the service.
Here's a brief example of creating and disposing of the service client:
class Test
{
static void Main()
{
CardProcessClient client = new CardProcessClient();
// Use the 'client' variable to call operations on the service.
// Always close the client.
client.Close();
}
}
Class Test
Shared Sub Main()
Dim client As CardProcessClient = New CardProcessClient()
' Use the 'client' variable to call operations on the service.
' Always close the client.
client.Close()
End Sub
End Class
private void Authenticate(string acctCode, string token)
{
CardProc.api_AuthResponse authResp;
// Using statement is recommended to release resources
using (CardProc.CardProcessClient cardClient =
new CardProc.CardProcessClient())
{
// Try-catch block will catch communication errors
try
{
// WARNING: 6 UNSUCCESSFUL ATEMPTS CAUSE IP LOCK OUT
authResp = cardClient.Authenticate(acctCode, token);
}
catch (Exception ex)
{
MessageBox.Show("Problem communicating with service:" + ex.Message);
// <Insert your Logging function here>
return;
}
// Check for null response for any critical error
if (authResp == null)
{
MessageBox.Show("Critical error");
// <Insert your Logging function here>
return;
}
// Check for unexpected error on server
if (!authResp.FunctionOk)
{
MessageBox.Show(authResp.ErrMsg + "ErrorCode:" + authResp.ErrCode);
// <Insert your Logging function here>
return;
}
// Check for expected problems such as invalid
// or expired credentials and inactive account.
if (!authResp.AuthSuccess)
{
MessageBox.Show(authResp.RespMsg);
// <Insert your Logging function here>
return;
}
/* Arriving here means that the Authentication was successful.
* You will retrieve a SessionKey and
* a list of Merchant Records associated with this account.
* The session key should be used for all subsequent API calls */
string sessKey = authResp.SessKey;
CardProc.api_MerchantInfo[] merchList = authResp.MerchantList;
// <Store the Session Key and the Merchant List>
}
}
private void ProcessConsentAnnual(string sessKey,
int consentId, decimal amount, int merchantId)
{
/* Pass in the Session Key obtained from Authentication call,
* the ConsentID ( saved Card ), the $ Amount that needs to be processed,
* and (optional) MerchantID to process */
CardProc.api_CCSaleResponse response;
// Using statement is recommended to release resources
using (CardProc.CardProcessClient cardClient =
new CardProc.CardProcessClient())
{
// Try-catch block will catch communication errors
try
{
response = cardClient.ConsentAnnual_ProcPayment_Alt(
sessKey, consentId, amount, merchantId);
}
catch (Exception ex)
{
MessageBox.Show("Problem communicating with service: " + ex.Message);
// <Insert your Logging function here>
return;
}
// Check for null response for any critical error
if (response == null)
{
MessageBox.Show("Critical error");
// <Insert your Logging function here>
return;
}
// Check for unexpected errors on server
if (!response.FunctionOk)
{
MessageBox.Show("Error : " + response.ErrMsg
+ " ErrorCode: " + response.ErrCode);
// <Insert your Logging function here>
return;
}
if (!response.TxApproved)
{
MessageBox.Show("TRANSACTION DECLINED: "
+ response.RespMsg + " Decline Code: " + response.TxnCode);
// <Insert your Logging function here>
return;
}
else
{
MessageBox.Show("TRANSACTION SUCCESS: "
+ response.RespMsg + " TxID: " + response.TxID);
// <Insert your Logging function here>
string approvalCode = response.TxnCode;
// <Do something with the response if needed>
return;
}
}
}
private void Void(string sessKey, int txID)
{
/* Pass in the Session Key obtained from Authentication call
* and TransactionID of the transaction to be voided. */
CardProc.api_TransactionVoidResponse response;
// Using statement is recommended to release resources
using (CardProc.CardProcessClient cardClient =
new CardProc.CardProcessClient())
{
// Try-catch block will catch communication errors
try
{
response = cardClient.Transaction_Void(sessKey, txID);
}
catch (Exception ex)
{
MessageBox.Show("Problem communicating with service: " + ex.Message);
// <Insert your Logging function here>
return;
}
// Check for null response for any critical error
if (response == null)
{
MessageBox.Show("Critical error");
// <Insert your Logging function here>
return;
}
// Check for unexpected errors on server
if (!response.FunctionOk)
{
MessageBox.Show("Error: " + response.ErrMsg
+ " ErrorCode: " + response.ErrCode);
// <Insert your Logging function here>
return;
}
if (!response.TxApproved)
{
MessageBox.Show(response.RespMsg
+ " Decline Code: " + response.TxnCode);
// <Insert your Logging function here>
return;
}
else
{
MessageBox.Show(response.RespMsg
+ " TxID: " + response.TxID.ToString());
// <Insert your Logging function here>
return;
}
}
}
private void Credit(string sessKey, int txID, decimal creditAmount)
{
/* Pass in the Session Key obtained from Authentication call
* and TransactionID of the Transaction to be credited,
* and the Amount of the credit */
CardProc.api_TransactionCreditResponse response;
// Using statement is recommended to release resources
using (CardProc.CardProcessClient cardClient =
new CardProc.CardProcessClient())
{
// Try-catch block will catch communication errors
try
{
response = cardClient.Transaction_ApplyCredit(
sessKey, txID, creditAmount);
}
catch (Exception ex)
{
MessageBox.Show("Problem communicating with service:" + ex.Message);
// <Insert your Logging function here>
return;
}
// Check for null response for any critical error
if (response == null)
{
MessageBox.Show("Critical error");
// <Insert your Logging function here>
return;
}
// Check for unexpected errors on server
if (!response.FunctionOk)
{
MessageBox.Show("Error: " + response.ErrMsg
+ " ErrorCode: " + response.ErrCode);
// <Insert your Logging function here>
return;
}
if (!response.TxApproved)
{
MessageBox.Show(response.RespMsg);
// <Insert your Logging function here>
return;
}
else
{
MessageBox.Show(response.RespMsg + " TX ID: "
+ response.TxID.ToString());
// <Insert your Logging function here>
return;
}
}
}
private void TransactionQuery(string sessKey, string query)
{
/* Pass in the Session Key obtained from Authentication call
* and Query used for filtering the list of transactions */
/* Sample Query: (A=1)&&(C>='6/1/2021')&&(C<'7/1/2021')&&(B=2)
* this will return all records from merchant record 1
* which were created in JUNE and are SETTLED. */
CardProc.api_TransactionQryResponse response;
// Using statement is recommended to release resources
using (CardProc.CardProcessClient cardClient =
new CardProc.CardProcessClient())
{
// Try-catch block will catch communication errors
try
{
response = cardClient.Transaction_Query(sessKey, query);
}
catch (Exception ex)
{
MessageBox.Show("Problem communicating with service: " + ex.Message);
// <Insert your Logging function here>
return;
}
// Check for null response for any critical error
if (response == null)
{
MessageBox.Show("Critical error");
// <Insert your Logging function here>
return;
}
// Check for unexpected errors on servers
if (!response.FunctionOk)
{
MessageBox.Show("Error: " + response.RespMsg
+ " ErrorCode: " + response.ErrCode);
// <Insert your Logging function here>
return;
}
CardProc.api_Transaction[] transactions = response.Transactions;
// <Display your transactions here>
}
}
private void ConsentGeneralQuery(string sessKey, string query)
{
/* Pass in the Session Key obtained from Authentication call
* and Query used for filtering the list of transactions */
/* Sample Query: (D='SMITH')&&(E>'10/20/2020')
* all Consent records from cardholder SMITH created after 10/20/2020 */
CardProc.api_ConsentGeneralQryResponse response;
// Using statement is recommended to release resources
using (CardProc.CardProcessClient cardClient =
new CardProc.CardProcessClient())
{
// Try-catch block will catch communication errors
try
{
response = cardClient.ConsentGeneral_Query(sessKey, query);
}
catch (Exception ex)
{
MessageBox.Show("Problem communicating with service: " + ex.Message);
// <Insert your Logging function here>
return;
}
// Check for null response for any critical error
if (response == null)
{
MessageBox.Show("Critical error");
// <Insert your Logging function here>
return;
}
// Check for unexpected errors on servers
if (!response.FunctionOk)
{
MessageBox.Show("Error: " + response.RespMsg
+ "ErrorCode: " + response.ErrCode);
// <Insert your Logging function here>
return;
}
CardProc.api_ConsentGeneral[] MyConsents = response.Consents;
// <Display your consent (card-on-file) records here>
}
}