Implementation, Preparing the Application to Transact: Managing Application Configuration Data

The next step in preparing the application to transact is to retrieve, update (if necessary), and save the appropriate characteristics and configuration information associated with your payment-enabled application.

Note: This is a one-time event that should be performed upon initial installation or launch of the application.

For more information, refer to Managing Application Configuration Data.

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

Application Configuration Operations  
GetApplicationData SaveApplicationData
DeleteApplicationData  

 


 

GetApplicationData

The GetApplicationData operation retrieves all current application configuration data associated with the Service Key.

Note: applicationProfileId is required. Failure to include applicationProfileId in the request will return a CWSValidationResultFault.

SOAP

Operation

ApplicationData GetApplicationData(string sessionToken, string applicationProfileId);

Parameters

Parameter Data Type Description
sessionToken String The short-lived token used to authenticate to CWS.
applicationProfileId String A token representing the PTLS Socket ID unique to each Service Key and configuration data combination. Required. Returned by the SaveApplicationData operation.

Note: Contact your NAB Velocity Sales Engineer for a PTLS Socket ID to use for application testing purposes.

Return Type

Data Type Description
ApplicationData Application configuration data associated with the sessionToken specified.

Exceptions

CWSFault AuthenticationFault
ExpiredTokenFault CWSServiceInformationUnavailableFault
InvalidTokenFault CWSValidationResultFault

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

C# Code Sample

public ApplicationData GetApplicationData(string sessionToken, string applicationProfileId)
{
	using (var client = new CWSServiceInformationClient(ConfigurationManager.AppSettings["Bindings.StsSoap"]))
	{
		try
		{
			return client.GetApplicationData(sessionToken, applicationProfileId);
		}
		catch (FaultException ex)
		{
			if (ex.Message.Contains("No application data has been saved yet")) // Application data does not exist...deleted or not created.
				return null;
			SoapFaultHandler.HandleFaultException(ex);
		}
	}
}

REST

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

Operation

URL https://api.cert.nabcommerce.com/REST/2.0.18/SvcInfo/appProfile/{applicationProfileId}
Action GET

Parameters

Parameter Data Type Description
applicationProfileId String A token representing the PTLS Socket ID unique to each Service Key and configuration data combination. Required. Returned by the SaveApplicationData operation.

Message Body Type

None.

Return Type

Data Type Description
ApplicationData Application configuration data.

Exceptions

CWSFault AuthenticationFault
ExpiredTokenFault CWSServiceInformationUnavailableFault
InvalidTokenFault CWSValidationResultFault

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

C# Code Sample

public ApplicationData GetApplicationData(string sessionToken, string applicationProfileId)
{
	var isJson = string.Equals(_msgFormat, MessageFormat.JSON.ToString());
	var requestString = RestBaseUri + "/appProfile/" + applicationProfileId;
 
	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)
	{
		if (ex.Message.Contains("No application data has been saved yet")) // Application data does not exist...deleted or not created.
			return null;
		RestFaultHandler.HandleFaultException(ex, isJson);
	}
}

 


 

SaveApplicationData

The SaveApplicationData operation initializes and saves application configuration data and returns an applicationProfileId.

SOAP

Operation

string SaveApplicationData(string sessionToken, ApplicationData applicationData);

Parameters

Parameter Data Type Description
sessionToken String The short-lived token used to authenticate to CWS.
applicationData ApplicationData Application configuration data.

Return Type

Data Type Description
String Returns applicationProfileId.

Important! The returned applicationProfileId value should be securely stored by the application and recalled/cached during each application session for inclusion in all subsequent transaction requests. Refer to Sign-On Authentication for additional information.

Exceptions

CWSFault AuthenticationFault
ExpiredTokenFault CWSServiceInformationUnavailableFault
InvalidTokenFault CWSValidationResultFault

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

public function saveApplicationData($appData)
{
	if (! $this->signOn ())
		return false;
	try
	{
		$ad = new SaveApplicationData ();
		$ad->sessionToken = $this->session_token;
		$ad->applicationData = $appData;
		$response = $this->serviceInfo->SaveApplicationData ( $ad );
		return $response->SaveApplicationDataResult; //application profile id
	}
	catch ( SoapFault $e )
	{
		echo '
SERVER ERROR: Error Retrieving Merchant Profiles.
'; $xmlFault = $this->serviceInfo->__getLastResponse (); $errors = handleSvcInfoFault ( $e, $xmlFault ); echo $errors; exit (); } }

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

REST

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

Operation

URL https://api.cert.nabcommerce.com/REST/2.0.18/SvcInfo/appProfile
Action PUT

Parameters

None.

Message Body Type

Data Type Description
ApplicationData Application configuration data.

Return Type

Data Type Description
String Returns ApplicationProfileId.

Important! The returned applicationProfileId value should be securely stored by the application and recalled/cached during each application session for inclusion in all subsequent transaction requests. Refer to Sign-On Authentication for additional information.

Exceptions

CWSFault AuthenticationFault
ExpiredTokenFault CWSServiceInformationUnavailableFault
InvalidTokenFault CWSValidationResultFault

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

public function saveApplicationData($appData)
{
	if (! $this->signOn ())
		return false;
 
	$msgBody = $appData;
	$action = 'PUT';
	$url = $this->svcInfo.'/appProfile';
	$msgBody = (string)json_encode($msgBody);
	$response = curl_json($msgBody, $url, $action, $this->session_token);
	if(isset($response->body->ErrorId))
	{
		handleRestFault($response);
		return false;
	}
	if(isset($response[2]))
		return $response[2]->id;
	return false;
}
public string SaveApplicationData(string sessionToken, ApplicationData applicationData)
{
	var isJson = string.Equals(_msgFormat, MessageFormat.JSON.ToString());
	var requestString = RestBaseUri + "/appProfile";
 
	var request = RestHelper.CreateRestRequest(applicationData, requestString, HttpMethod.PUT, sessionToken, isJson);
	try
	{
		return RestHelper.GetResponse(request, isJson);
	}
	catch(Exception ex)
	{
		RestFaultHandler.HandleFaultException(ex, isJson);
	}
}

 


 

DeleteApplicationData

The DeleteApplicationData operation is used to delete one or more sets of application configuration data by applicationProfileId.

SOAP

Operation

void DeleteApplicationData(string sessionToken, string applicationProfileId);

Parameters

Parameter Data Type Description
sessionToken String The short-lived token used to authenticate to CWS.
applicationProfileId String A token representing the PTLS Socket ID unique to each Service Key and configuration data combination. Returned by the SaveApplicationData operation.

Return Type

None.

Exceptions

CWSFault AuthenticationFault
ExpiredTokenFault CWSServiceInformationUnavailableFault
InvalidTokenFault CWSValidationResultFault

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

C# Code Sample

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

REST

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

Operation

URL https://api.cert.nabcommerce.com/REST/2.0.18/SvcInfo/appProfile/{applicationProfileId}
Action DELETE

Parameters

Parameter Data Type Description
applicationProfileId String A token representing the PTLS Socket ID unique to each Service Key and configuration data combination. Returned by the SaveApplicationData operation.

Message Body Type

None.

Exceptions

CWSFault AuthenticationFault
ExpiredTokenFault CWSServiceInformationUnavailableFault
InvalidTokenFault CWSValidationResultFault

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

C# Code Sample

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

Comments