Skip to content

pete1854/bank-id

Repository files navigation

Bank-ID

Library for connect Swedish BankID to your application.

Latest Stable Version Latest Unstable Version Total Downloads license Build Status

Requirements

Install

Via Composer

$ composer require dimafe6/bank-id

Usage

<?php
// Create BankIDService
$bankIDService = new BankIDService(
    'https://appapi2.test.bankid.com/rp/v4?wsdl',
    ['local_cert' => 'PATH_TO_TEST_CERT.pem'],
    false
);

// Signing. Step 1 - Get orderRef
$response = $bankIDService->getSignResponse('PERSONAL_NUMBER', 'Test user data');

// Signing. Step 2 - Collect orderRef. 
// Repeat until $collectResponse->progressStatus == CollectResponse::PROGRESS_STATUS_COMPLETE
$collectResponse = $bankIDService->collectResponse($response->orderRef);
if($collectResponse->progressStatus == CollectResponse::PROGRESS_STATUS_COMPLETE) {
    return true; //Signed successfully
}

// Authorize. Step 1 - Get orderRef
$response = $bankIDService->getAuthResponse('PERSONAL_NUMBER');

// Authorize. Step 2 - Collect orderRef. 
// Repeat until $authResponse->progressStatus == CollectResponse::PROGRESS_STATUS_COMPLETE
$authResponse = $bankIDService->collectResponse($response->orderRef);
if($authResponse->progressStatus == CollectResponse::PROGRESS_STATUS_COMPLETE) {
    return true; //Authorized
}

Testing

  1. Copy phpunit.xml.dist to phpunit.xml
$ cp phpunit.xml.dist phpunit.xml
  1. Create and add test personal number to mobile app. Demo BankID site

  2. Set personal number in phpunit.xml:

<env name="personalNumber" value=""/>
  1. Execute
$ ./vendor/bin/phpunit

License

The MIT License (MIT). Please see License File for more information.

About

BankID

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%