2017 © Pedro Peláez
 

library bank-id

Library for Swedish BankID

image

dimafe6/bank-id

Library for Swedish BankID

  • Monday, November 13, 2017
  • by dimafe6
  • Repository
  • 3 Watchers
  • 7 Stars
  • 212 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 4 Versions
  • 25 % Grown

The README.md

Bank-ID

Library for connect Swedish BankID to your application. This library implements BankID API V5. If your needed library for a BankID API V4 please use version 1.*, (*1)

codecov Latest Stable Version Latest Unstable Version Total Downloads license Build Status, (*2)

Requirements

  • PHP 5.6+ or 7.0+
  • curl

Install

Via Composer, (*3)

``` bash $ composer require dimafe6/bank-id, (*4)


## Usage Either you let the user enter their personal number and pass to BankID or you only pass the order ref and receive the personal number from the response from BankID. ```php <?php // Create BankIDService $bankIDService = new BankIDService( 'https://appapi2.test.bankid.com/rp/v5/', $_SERVER["REMOTE_ADDR"], [ 'verify' => false, 'cert' => 'PATH_TO_TEST_CERT.pem', ] ); // OR Create BankIDService with ssl verification $bankIDService = new BankIDService( 'https://appapi2.test.bankid.com/rp/v5/', $_SERVER["REMOTE_ADDR"], [ 'verify' => 'PATH_TO_TEST_CERT.ca', 'cert' => 'PATH_TO_TEST_CERT.crt', 'ssl_key' => 'PATH_TO_TEST_CERT.key', ] );
Example with personal number
// Signing. Step 1 - Get orderRef
/** @var OrderResponse $response */
$response = $bankIDService->getSignResponse('PERSONAL_NUMBER', 'User visible data');

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

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

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

// Cancel auth or collect order
// Authorize. Step 1 - Get orderRef
$response = $bankIDService->getAuthResponse('PERSONAL_NUMBER');

// Cancel authorize order
if($bankIDService->cancelOrder($response->orderRef)) {
    return 'Authorization canceled';
}
Example without personal number
// Authorize. Step 1 - Get orderRef
$response = $bankIDService->getAuthResponse();

// Authorize. Step 2 - Collect orderRef. 
// Repeat until $authResponse->status !== CollectResponse::STATUS_COMPLETED
$authResponse = $bankIDService->collectResponse($response->orderRef);
if($authResponse->status == CollectResponse::STATUS_COMPLETED) {
    echo $authResponse->completionData->user->personalNumber;
    return true; //Authorized
}

Testing

  1. Copy phpunit.xml.dist to phpunit.xml ``` bash $ cp phpunit.xml.dist phpunit.xml

2. Execute ``` bash $ ./vendor/bin/phpunit

License

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

The Versions

13/11 2017

dev-dev

dev-dev https://github.com/dimafe6/bank-id

Library for Swedish BankID

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-soap *

 

The Development Requires

by Dmitry Feshchenko
by Oleg Davudyuk
by Anders Fajerson
by Puggan

dimafe6 bank-id

13/11 2017

dev-master

9999999-dev https://github.com/dimafe6/bank-id

Library for Swedish BankID

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-soap *

 

The Development Requires

by Dmitry Feshchenko
by Oleg Davudyuk
by Anders Fajerson
by Puggan

dimafe6 bank-id

13/11 2017

1.0.1

1.0.1.0 https://github.com/dimafe6/bank-id

Library for Swedish BankID

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-soap *

 

The Development Requires

by Dmitry Feshchenko
by Oleg Davudyuk
by Anders Fajerson
by Puggan

dimafe6 bank-id

07/11 2017

v1.0

1.0.0.0 https://github.com/dimafe6/bank-id

Library for Swedish BankID

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-soap *

 

The Development Requires

by Dmitry Feshchenko
by Oleg Davudyuk
by Anders Fajerson
by Puggan

dimafe6 bank-id