stakeholderlabs / roundtable-laravel

用于集成 Laravel 与 Stakeholderlabs Roundtable 的包

1.0.5 2022-09-29 00:25 UTC

This package is auto-updated.

Last update: 2024-09-29 06:03:17 UTC


README

安装

  • 运行命令:composer require stakeholderlabs/roundtable-laravel
  • 使用提供的变量更新 .env 文件
ROUNDTABLE_URL="https://dashboard.roundtable.xyz/" #The domain of your Roundtable setup
ROUNDTABLE_API_URL="https://api.dashboard.roundtable.xyz" #The domain of your Roundtable API setup. Can be ommited.
ROUNDTABLE_SECRET_KEY=<private key from the dashboard>
ROUNDTABLE_PUBLIC_KEY=<public key from the dashboard>

用法

从 Roundtable™ API 获取令牌

要在 Roundtable™ 中获取用户授权链接,您必须通过 obtainTokenUrl 方法请求 API。结果将为每个用户生成一个唯一的链接,用户打开该链接后,将被提示输入其选择银行账户的登录名和密码。

    use Shl\RoundTable\Clients\Client as RoundtableClient;
    
    $client = app(RoundtableClient::class);
    
    if ($tokenUrl = $client->obtainTokenUrl('email@example.com', 'Joe Doe')) {
        return Redirect::to($tokenUrl);
    }

解密 Roundtable™ 有效载荷

用户授权后,将返回到应用设置中指定的 URL。如果您想验证用户的连接,则需要解密通过 GET 参数传递的有效载荷。Roundtable™ 返回一个参数:payload。要解密它,请使用 decryptRoundtablePayload 方法。

    use Shl\RoundTable\Clients\Client as RoundtableClient;

    $payload = request()->get('payload');
    
    $client = app(RoundtableClient::class);

    if($data = $client->decryptRoundtablePayload($payload)) {
        // Save roundtable customer id to the database as the confirmation of connection to Roundtable™
        // e.g. $user->update(['roundtable_id' => $data->getCustomerId()]); 
    }