PHP Code Examples
Authorisation String
// Get current time in GMT.
$time_now = new DateTime('now', new DateTimeZone('GMT'));
// Create timestamp in 'YmdHis' format. E.g. 20190812055213
$timestamp = $time_now->format('YmdHis');
// Concatenate the values for channels, currencies, total and your timestamp in that order.
$booking_vars = [
'channels' => 2,
'currencies' => 'USD',
'total' => 9999,
'timestamp' => $timestamp,
];
$string = implode('&', $booking_vars);
// SHA256 the string.
$auth_string = hash( 'sha256', $string );
// Fetch your channel secret and concatenate to string.
$secret = getenv('CHANNEL_SECRET');
$salted_auth_string = hash( 'sha256', $auth_string . $secret );
// Concatenate with timestamp.
$final_auth_string = $salted_auth_string . $timestamp;