Table Of Contents

2.2. Partner Event Messaging System (EMS)

The SysPay Event Messaging System will call the URL you provided us anytime an event occurs. By default the data will be encoded in application/x-www-form-urlencoded.

2.2.1. EMS message content

The data provided will contain the following keys:

  • type: The event type. The currently supported events are:
  • data: The event-specific data

2.2.2. EMS callback validation

A callback will be provided with the following HTTP headers that will let you validate that the call is genuine:

  • X-Partner: Your Partner ID
  • X-Checksum: A checksum computed from the request body and the shared passphrase
  • X-Event-Id: Event unique ID
  • X-Event-Date: Event creation date, as timestamp

The checksum is computed the following way:

HEX_SHA1(REQUEST_BODY + PASSPHRASE)

Example code (PHP)

<?php

$keys = array(
    9000 => 'passphrase1',
    42   => 'passphrase2'
);

$partner   = $_SERVER['HTTP_X_PARTNER'];
$checksum  = $_SERVER['HTTP_X_CHECKSUM'];
$eventId   = $_SERVER['HTTP_X_EVENT_ID'];
$eventDate = $_SERVER['HTTP_X_EVENT_DATE'];

$body = file_get_contents('php://input');

if (!isset($keys[$partner])) {
    die("Unknown partner id");
}

$shouldBe = sha1($body . $keys[$partner]);

if ($checksum === $shouldBe) {
    // Request is validated
}

2.2.3. Event types

Referral registration

Whenever a referral you sent to us has finished registering, you will receive a notification containing the syspay user id and your own reference for this user (that was given when referring the user to our page). You should use that notification to map the SysPay user id to this user in your system for further use.

Event parameters

Name Type Mandatory Description
type string Y user_created
data.syspay_id int Y The SysPay user id of the referral
data.reference string Y Your own reference for this referral
data.registration_date int Y The user registration date (unix timestamp)

Raw sample of HTTP body content (application/x-www-form-urlencoded)

type=user_created&data%5Bsyspay_id%5D=339&data%5Breference%5D=1372860895&data%5Bregistration_date%5D=1372860953

This decodes to:

Array
(
    [type] => user_created
    [data] => Array
        (
            [syspay_id] => 339
            [reference] => 1372860895
            [registration_date] => 1372860953
        )
)