Signature

Required Class: Signature Class

Generating a Signature

Smile ID requires you to transmit a unique signature and timestamp with every job you run. While running jobs using any of our libraries automatically calculates the signature, there might be situations where you need to execute a job using our REST API or generate signatures manually. For these instances, you can utilise the sample code below to calculate a signature:

<?php
require 'vendor/autoload.php';

// Initialise
$partner_id = "<Put your partner ID here>"; // Log in to the Smile ID portal to find your partner ID
$api_key = "<Put your API key here>"; // Retrieve your API key from the Smile ID portal

$sig_class = new \SmileIdentityCore\Signature($partner_id, $api_key);

// Generate a signature
$signature_array = $sig_class->generate_signature("<put your custom timestamp>"); // Timestamp is optional
?>

Response

The response will be an associative array:

[
  'signature' => '<the generated signature>',
  'timestamp' => '2022-04-03T21:31:47.296Z'
]

Confirming an Incoming Signature

To confirm the authenticity of the response received from your callback as genuinely originating from Smile ID, you can validate the returned signature and timestamp. The sample code provided below can be used for confirmation:

<?php
require 'vendor/autoload.php';

// Initialise
$partner_id = "<Put your partner ID here>"; // Log in to the Smile ID portal to view your partner ID
$api_key = "<Put your API key here>"; // Retrieve your API key from the Smile ID portal

$sig_class = new \SmileIdentityCore\Signature($partner_id, $api_key);

// Confirm a signature
$is_valid_signature = $sig_class->confirm_signature("<put the received timestamp>", "<put the received signature>");
?>

Response

The response will be a boolean value:

true or false

Here, true is represented by 1 and false by an empty string "".

Last updated