Add H2H authentication service and new example flows
- Implement H2H authentication service for secure client authentication - Add new examples for authorization code flow and H2H auth service - Include example for generating client secret - Update core connector and token request functionality - Enhance README with new features Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -11,10 +11,36 @@ use Apoloz\AlfaBank\Core\AlfaConfig;
|
||||
use Apoloz\AlfaBank\Enums\Environment;
|
||||
use Apoloz\AlfaBank\Services\OpenSslCmsSigner;
|
||||
use Apoloz\AlfaBank\Sbp\SbpConnector;
|
||||
use Apoloz\AlfaBank\Services\H2HAuthService;
|
||||
use Apoloz\AlfaBank\Requests\Accounts\GetAccountsRequest;
|
||||
|
||||
class AlfaBank
|
||||
{
|
||||
/**
|
||||
* Creates a helper service for H2H Authorization (Authorization Code Flow).
|
||||
*/
|
||||
public static function auth(
|
||||
string $clientId,
|
||||
string $clientSecret,
|
||||
string $redirectUri,
|
||||
string $certificatePath,
|
||||
string $privateKeyPath,
|
||||
Environment $environment = Environment::SANDBOX
|
||||
): H2HAuthService {
|
||||
$config = new \Apoloz\AlfaBank\Core\AlfaConfig(
|
||||
baseUrl: $environment->value,
|
||||
certificatePath: $certificatePath,
|
||||
privateKeyPath: $privateKeyPath,
|
||||
clientId: $clientId,
|
||||
clientSecret: $clientSecret
|
||||
);
|
||||
|
||||
$signer = new \Apoloz\AlfaBank\Services\OpenSslCmsSigner($certificatePath, $privateKeyPath);
|
||||
$connector = new \Apoloz\AlfaBank\Core\AlfaBankConnector($config, $signer);
|
||||
|
||||
return new H2HAuthService($connector, $clientId, $redirectUri, $environment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a health check on the connection.
|
||||
* Throws an exception if authentication or account listing fails.
|
||||
|
||||
Reference in New Issue
Block a user