Code Monkey home page Code Monkey logo

bank-id's Introduction

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.

bank-id's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.