Skip to content
Rene Korss edited this page Jan 20, 2019 · 3 revisions

Request

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

    use RKD\Banklink;

    // Init protocol
    $protocol = new Banklink\Protocol\IPizza(
        'uid100010', // seller ID (SND ID)
        __DIR__ . '/../keys/seb_user_key.pem', // private key
        '', // private key password, leave empty, if not needed
        __DIR__ . '/../keys/seb_bank_cert.pem', // public key
        'http://localhost/banklink/SEB.php' // return url
    );

    // Init banklink
    $seb = new Banklink\EE\SEB($protocol);

    // Get auth request object
    $request = $seb->getAuthRequest();
?>

<form method="POST" action="<?php echo $request->getRequestUrl(); ?>">
    <?php echo $request->getRequestInputs(); ?>
    <input type="submit" value="Authenticate with SEB!" />
</form>

Response

<?php
    /**
     * Assume we have previously created $seb object
     */

    // Get response object
    $response = $seb->handleResponse($_POST);

    // Successful
    if ($response->wasSuccessful()) {
        // Get whole array of response
        $responseData    = $response->getResponseData();

        // User prefered language
        $language        = $response->getLanguage();

        // Authentication data
        $userId          = $response->getUserId(); // Person ID
        $userName        = $response->getUserName(); // Person name
        $country         = $response->getUserCountry(); // Person country
        $authDate        = $response->getAuthDate(); // Authentication response datetime

        // Method used for authentication
        // Possible values: ID Card, Mobile ID, One-off code card, PIN-calculator, Code card or unknown
        $authMethod      = $response->getAuthMethod();

    // Failed
    } else {
        // Payment data
        $orderId         = $response->getOrderId(); // Order id to cancel order etc.
    }
?>
Clone this wiki locally