Quick Start

STEP 1: Create TecsWeb Request Token

As the first step, TecsWebRequestToken has to be generated. This token is built as a URL to which customer has to be redirected. Merchant’s Secret Key must be stored in the safe way on the back-end. Therefore this procedure should happen on the back-end side.

Following requirements are necessary to build up the TecsWebRequestToken:


/**
 * File: step-1-create-payment-url.php
 */
require '/path-to/tecsweb-php-lib/loader.php'; // if you use composer you do not have to do this
$tecs = new \Tecs\TecsWeb(
    'MerchantSecretKey', // Private Secret Key provided by CNG
    '12345678',      // Merchant ID provided by CNG
    'https://test.tecs.at/tecsweb/tecswebmvc_start.do' // URL of CNG - TecsWeb payment portal
);
// place for creating transaction...
try {
    $tecsWebRequestToken = $tecs->createSignedUrl([
        \Tecs\TecsWeb::AMOUNT         => '100', // amount in cents (mandatory)
        \Tecs\TecsWeb::TX_ID          => '1000010165', // Unique Transaction ID (mandatory)
        \Tecs\TecsWeb::TX_CURRENCY    => 'EUR', // Currency (mandatory)
        \Tecs\TecsWeb::TX_DESC        => 'Transaction Description', // mandatory
        \Tecs\TecsWeb::RECEIPT_NUMBER => '123456', // Order or Invoice number (mandatory)
        \Tecs\TecsWeb::RETURN_URL     => 'https://www.your-page.com/step-3-payment-response.php', // mandatory
    ]);
    // Provide the value of $tecsWebRequestToken to HTML/JS template
    echo($tecsWebRequestToken);
    // OR Make redirection
    // header("Location: {$tecsWebRequestToken}");
    // die();
} catch (\Exception $e) {
    // ... Handle exception
}

STEP 2: Embed PayPage

There are 3 ways to embed PayPage to the webpage. Please update script source path before going to PROD environment.

<html>
	<head>
		
		<script src="https://test.tecs.at/tecsweb/js/tecsweb.js">
        </script>
	</group>
	</head>
		<body>
        <script>
        TecsWeb.redirect(
               {$tecsWebRequestToken} // value of $tecsWebRequestToken from Step 1
            );
		</script>
        </body>
	</html>
    
<html>
	<head>
		
		<script src="https://test.tecs.at/tecsweb/js/tecsweb.js">
        </script>
	</group>
	</head>
		<body>
        <script>
        TecsWeb.redirect(
               {$tecsWebRequestToken} // value of $tecsWebRequestToken from Step 1
            );
		</script>
        </body>
	</html>
    
<html>
	<head>
		
		<script src="https://test.tecs.at/tecsweb/js/tecsweb.js">
        </script>
	</group>
	</head>
		<body>
        <script>
        TecsWeb.redirect(
               {$tecsWebRequestToken} // value of $tecsWebRequestToken from Step 1
            );
		</script>
        </body>
	</html>
    

STEP 3: Processing the Response

Customer is redirected back to the URL defined as a return URL in the request parameters of STEP 1 after payment is performed. Landing URL of customer after redirection is considered as a TecsWebResponseToken. Tokens validity has to be verified by PHP, JAVA or C# library on the back-end where secret key is securely stored.

IMPORTANT: Every response from TecsWeb has to be logged by your system to be able to check it out if any problems occurs!

NOTE: TecsWeb Response may contain several different response codes, but explaining them is not part of this guide. Full list of codes and their meanings you get in separate documentation when integration process will start. The examples bellow only show you how you can read TecsWeb Response via the helpers.


/**
 * File: step-3-payment-response.php
 */
 
require __DIR__ . '/../tecsweb-php-lib/loader.php'; // you do not nedd this if you are using composer
$tecsWebResponseToken = $_GET;
$tecsWebResponse = new \Tecs\TecsWebResponse(
    'MerchantServetKey'   // Merchant Secret Key
    $tecsWebResponseToken
);

// FIRST WE CHECK IF THE RESPONSE HAS VALID SIGNATURE.
// IF NOT THEN CREATE LOG AND REDIRECT TO OR INCLUDE ERROR PAGE
if (!$tecsWebResponse->isSignedCorrectly()) {
    $payloadToLog = $tecsWebResponse->getAllData();
    // instead of echoing you place the message to your HTML
    echo ('The result of payment has been incorrect! Please contact support.');
}

// IF THE RESPONSE WAS SIGNED CORRECTLY, LOG TRANSACTION RESULT AND SHOW RESULT PAGE BASED ON RESPONSE CODE
// FOR AVAILABLE RESPONSE CODES AND MESSAGES, SEE CNG TECSWEB DOCUMENTATION
// YOU HAVE ACCESS TO THE RESPONSE VALUES WITH GETTERS
else {
    $payloadToLog = $tecsWebResponse->getAllData();
    $txid = $tecsWebResponse->getTXID();
    $responseMessage = $tecsWebResponse->getResponseText();
    $responseCode = $tecsWebResponse->getResponseCode();
    // instead of echoing you place the message to your HTML.
    echo ('Transaction id ' . $txid . '; responseCode: ' . $responseCode 
          . '; authorization result: ' . $responseMessage);
}