Implementation, Preparing the Application to Transact: Retrieving Service Information

After the application has retrieved a session token using the SignOnWithToken/SignOn operation and all necessary application configuration data has been saved, the application must retrieve Service Information to determine what services have been authorized for a specific Service Key.

Service Information includes:

  • Payment services available, such as Credit, PIN Debit, and/or ACH services.
  • Operations supported, such as payment account verification, authorize and capture, etc.
  • Payment service features supported, such as daily automated settlement or Managed Billing.
  • Specific transaction workflows supported by the Service Key.

Refer to Understanding Service Information for more information.

The following operations are used to facilitate the retrieval of Service Information for both SOAP and REST implementations:

Service Information Operations
GetServiceInformation

Important! All parameters in each operation are considered "required" unless otherwise noted.

 


 

GetServiceInformation

The GetServiceInformation operation provides information about the services that are available to a specific Service Key. This operation should be automatically invoked during initial application configuration, and manually by an application administrator if/when available services are updated.

Refer to Understanding Service Information for more information.

SOAP

Operation

ServiceInformation GetServiceInformation(string sessionToken);

Parameters

Parameter Data Type Description
sessionToken String The short-lived token used to authenticate to CWS.

Return Type

Data Type Description
ServiceInformation Contains information about the features, workflows, and operations associated with all available services for a specific Service Key.

Exceptions

CWSFault AuthenticationFault
ExpiredTokenFault CWSServiceInformationUnavailableFault
InvalidTokenFault   

For additional details about each fault, refer to Service Information Faults in the CWS Developer API Reference.

Note: The HTTP Authorization Header must contain the required sessionToken value.

Operation

URL https://api.nabcommerce.com/REST/2.0.18/SvcInfo/serviceInformation
Action GET

Parameters

None.

Message Body Type

None.

Return Type

Data Type Description
ServiceInformation Contains information about the features, workflows, and operations associated with all available services for a specific Service Key.

Exceptions

CWSFault AuthenticationFault
ExpiredTokenFault CWSServiceInformationUnavailableFault
InvalidTokenFault   

For additional details about each fault, refer to Service Information Faults in the CWS Developer API Reference.

PHP Code Samples

public function getServiceInformation()
{
	if (! $this->signOn ())
		return false;
	try
	{
		$si = new GetServiceInformation ();
		$si->sessionToken = $this->session_token;
		$response = $this->serviceInfo->GetServiceInformation ( $si );
		if ($response)
		//echo $this->serviceInfo->__getLastResponse();
		//return $response->GetServiceInformationResult->BankcardServices->BankcardService;
		return $response->GetServiceInformationResult;
 
	}
	catch ( SoapFault $e )
	{
		echo 'SERVER ERROR: Error Retrieving Service Information.
'; $xmlFault = $this->serviceInfo->__getLastResponse (); $errors = handleSvcInfoFault ( $e, $xmlFault ); echo $errors; exit (); } } // Return only the ServiceId public function getServiceID() { $response = $this->getServiceInformation (); if ($response) //return $response->GetServiceInformationResult->BankcardServices->BankcardService->ServiceId; return $response->GetServiceInformationResponse; return false; }

C# Code Samples

public ServiceInformation GetServiceInformation(string sessionToken)
{
	using (var client = new CWSServiceInformationClient(ConfigurationManager.AppSettings["Bindings.StsSoap"]))
	{
		try
		{
			return client.GetServiceInformation(sessionToken);
		}
		catch (FaultException ex)
		{
			SoapFaultHandler.HandleFaultException(ex);
		}
	}
}

REST

Note: The HTTP Authorization Header must contain the required sessionToken value.

Operation

URL https://api.nabcommerce.com/REST/2.0.18/SvcInfo/serviceInformation
Action GET

Parameters

None.

Message Body Type

None.

Return Type

Data Type Description
ServiceInformation Contains information about the features, workflows, and operations associated with all available services for a specific Service Key.

Exceptions

CWSFault AuthenticationFault
ExpiredTokenFault CWSServiceInformationUnavailableFault
InvalidTokenFault   

For additional details about each fault, refer to Service Information Faults in the CWS Developer API Reference.

PHP Code Samples

public function getServiceInformation()
{
	if (! $this->signOn ())
		return false;
 
	$msgBody = '';
	$url = $this->svcInfo.'/serviceInformation';
	$action = 'GET';
	$siResponse = curl_json($msgBody, $url, $action, $this->session_token);
	if(isset($response->body->ErrorId))
	{
		handleRestFault($response);
		return false;
	}
	if(isset($siResponse[2]))
	{
		//This section will parse the response and create the required object for each service. It will only grab the first of each, a foreach would be needed to grab all.
		$si = new stdClass();
		if(count($siResponse[2]->BankcardServices))
			$si->BankcardServices->BankcardService = $siResponse[2]->BankcardServices[0];
		if(count($siResponse[2]->ElectronicCheckingServices))
			$si->ElectronicCheckingServices->ElectronicCheckingService = $siResponse[2]->ElectronicCheckingServices[0];
		if(count($siResponse[2]->StoredValueServices))
			$si->StoredValueServices->StoredValueService = $siResponse[2]->StoredValueServices[0];
		if(count($siResponse[2]->Workflows))
			$si->Workflows->Workflow = $siResponse[2]->Workflows[0];
		return $si;
	}
	return false;
}
 
// Return only the ServiceId
 
public function getServiceID()
{
	$si = getServiceInformation();
	return $si->BankcardServices->BankcardService->ServiceId;
}

C# Code Samples

public ServiceInformation GetServiceInformation(string sessionToken)
{
	var isJson = string.Equals(_msgFormat, MessageFormat.JSON.ToString());
	// No body is required for GetServiceInformation in the HttpWebRequest.
	var requestString = RestBaseUri + "/serviceInformation";
 
	HttpWebRequest request = WebRequest.Create(requestString) as HttpWebRequest;
	request.Method = HttpMethod.GET.ToString();
	request.Credentials = new NetworkCredential(sessionToken, "");
 
	request.ContentType = isJson ? "application/json" : "application/xml";
	try
	{
		return RestHelper.GetResponse(request, isJson);
	}
	catch (Exception ex)
	{
		RestFaultHandler.HandleFaultException(ex, isJson);
	}
}

Comments