Skip to main content
This page provides a detailed sample code flow for integrating Spark’s authentication mechanism into your third-party application. The core requirement for all API calls to the Spark DMZ is to ensure security and integrity by generating an encrypted payload (Cipher) and authenticating the request with a Signature header.
Samples in C#The following code snippets are provided in C# for example purposes. Developers should implement the same logic (e.g., AES-256 ECB encryption, SHA-256 hashing) in their chosen programming language to successfully communicate with the Spark DMZ.

Step 1: Generating the Cipher

The Cipher field is a securely encrypted payload that must be included in the request body. It serves as a strong mechanism to prove that you possess the necessary secret token without transmitting it openly. This function creates the final, encrypted Cipher string to be included in the request body.
C#
Where:
  • sparkTransactionId: Transaction identifier (use “1234” for testing)
  • tokenSecretString: Your secret token (key) which is used as the AES-256 ECB encryption key.
  • random: 17-digit random number.
  • timestamp: UTC time in format yyMMddHHmm (optional)

Step 2: Create Signature

The signature authenticates each request by combining the serialized request body with your header hash key and computing a SHA-256 hash. This signature is sent in the HTTP headers, along with your integrator ID, to verify the request’s origin and integrity. This function calculates the signature string and packages it into the required HTTP headers.
C#
Where:
  • request: The whole request body object (StartAuthenticationRequest3rdParty in this case)
  • integratorId: Your unique integrator ID.
  • IntegratorValue: A secret HeaderHashKey used to authenticate the integrator.
The output will be a dictionary containing the two mandatory HTTP request headers: IntegratorId and Signature.

Request Model

The request model defines the structure of data sent to initiate authentication with Spark. Each authentication request must include your token ID, terminal identification details, and the encrypted cipher (created using the CreateCipher() method), and the random 17-digit number used in cipher generation.
C#

Response Model

The response model defines the structure of data returned after initiating authentication with Spark. It includes the hashed transaction ID and status information.
C#