nicklasw/bankid-sdk

BankID SDK API客户端

1.1.0 2019-01-04 09:36 UTC

This package is not auto-updated.

Last update: 2024-09-21 16:38:35 UTC


README

一个作为RP(依赖方)提供BankID服务的SDK。支持最新v5功能。

PHP7.1 Ready Latest Stable Version Latest Unstable Version Build Status License

安装

可以通过composer安装此库

composer require nicklasw/bankid-sdk

功能

  • 支持所有v5功能
  • 支持异步和并行请求

示例

发起认证请求

$client = new Client(new Config(<CERTFICATE>));

$authenticationResponse = $client->authenticate(new AuthenticationPayload(<PERSONAL NUMBER>, <IP ADDRESS>));

if (!$authenticationResponse->isSuccess()) {
    var_dump($authenticationResponse->getErrorCode(), $authenticationResponse->getDetails());

    return;
}

$collectResponse = $authenticationResponse->collect(); 

执行并行请求

$client = new ClientAsynchronous(new Config(<CERTFICATE>));

$promises[] = $client->authenticate(new AuthenticationPayload(<PERSONAL NUMBER>, <IP ADDRESS>));
$promises[] = $client->authenticate(new AuthenticationPayload(<PERSONAL NUMBER>, <IP ADDRESS>));

// Parallel requests, authenticate users
foreach (unwrap($promises) as $result) {
    /**
     * @var AuthenticationResponse $result
     */
    var_dump($result->isSuccess());
}

证书

只有拥有有效SSL客户端证书的RP才能访问Web服务API。RP证书是从RP购买的BankID服务的银行获得的。

生成PEM证书

openssl pkcs12 -in <filename>.pfx -out <cert>.pem -nodes

Docker

make && make bash

单元测试

composer run test

贡献

  • Fork它!
  • 创建你的功能分支: git checkout -b my-new-feature
  • 提交你的更改: git commit -am '关于你新功能的有用信息'
  • 推送到分支: git push origin my-new-feature
  • 提交pull请求

贡献者