forked from apoloz/alfa-bank-sdk
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ca3f14485a | |||
| 86f50eed6a |
@@ -31,18 +31,23 @@ try {
|
||||
|
||||
// METHOD B: Authorization Code Flow (H2H) (REQUIRED for Nominal Accounts)
|
||||
// See examples/13_h2h_auth_service.php for the full setup
|
||||
$auth = \Apoloz\AlfaBank\AlfaBank::auth(
|
||||
clientId: 'your-client-id',
|
||||
clientSecret: 'your-client-secret',
|
||||
redirectUri: 'https://...',
|
||||
|
||||
// We re-initialize with auth credentials if we didn't pass them initially
|
||||
$baas = AlfaBank::baas(
|
||||
certificatePath: __DIR__ . '/certs/client.cer',
|
||||
privateKeyPath: __DIR__ . '/certs/private.key',
|
||||
environment: Environment::SANDBOX
|
||||
environment: Environment::SANDBOX,
|
||||
clientId: 'your-client-id',
|
||||
clientSecret: 'your-client-secret',
|
||||
redirectUri: 'https://...'
|
||||
);
|
||||
// Assuming you have a saved refresh token:
|
||||
// $auth->refreshToken('saved_refresh_token');
|
||||
|
||||
// Now you can use OAuth methods:
|
||||
// $url = $baas->getAuthorizationUrl();
|
||||
// or
|
||||
// $baas->refreshAccessToken('saved_refresh_token');
|
||||
|
||||
echo "Authentication Successful!\n";
|
||||
echo "Authentication Configured!\n";
|
||||
|
||||
// 2. Create a Beneficiary (Counterparty)
|
||||
echo "Creating Beneficiary...\n";
|
||||
|
||||
@@ -9,7 +9,6 @@ namespace Apoloz\AlfaBank\Core;
|
||||
use Apoloz\AlfaBank\Contracts\SignerInterface;
|
||||
use Apoloz\AlfaBank\Http\Middleware\RequestIdMiddleware;
|
||||
use Apoloz\AlfaBank\Http\Pagination\AlfaOffsetPaginator;
|
||||
use Apoloz\AlfaBank\Requests\Auth\GetTokenRequest; // Will be removed
|
||||
use Apoloz\AlfaBank\Traits\HasAlfaErrorHandling;
|
||||
use Saloon\Helpers\OAuth2\OAuthConfig;
|
||||
use Saloon\Http\Connector;
|
||||
@@ -19,11 +18,10 @@ use Saloon\PaginationPlugin\OffsetPaginator;
|
||||
use Saloon\Traits\Plugins\AlwaysThrowOnErrors;
|
||||
use Saloon\Traits\RequestProperties\HasTries;
|
||||
use Saloon\Traits\Plugins\HasTimeout;
|
||||
use Saloon\Contracts\OAuth2\OAuth2Api;
|
||||
use Saloon\Traits\OAuth2\AuthorizationCodeGrant;
|
||||
use Apoloz\AlfaBank\Enums\Environment;
|
||||
|
||||
class AlfaBankConnector extends Connector implements HasPagination, OAuth2Api
|
||||
class AlfaBankConnector extends Connector implements HasPagination
|
||||
{
|
||||
use HasTimeout;
|
||||
use HasTries;
|
||||
@@ -44,7 +42,7 @@ class AlfaBankConnector extends Connector implements HasPagination, OAuth2Api
|
||||
return $this->alfaConfig->baseUrl;
|
||||
}
|
||||
|
||||
protected function resolveOauth2Config(): OAuthConfig
|
||||
protected function defaultOauthConfig(): OAuthConfig
|
||||
{
|
||||
$idUrl = $this->alfaConfig->baseUrl === Environment::PRODUCTION->value
|
||||
? Environment::ID_PRODUCTION->value
|
||||
@@ -67,7 +65,7 @@ class AlfaBankConnector extends Connector implements HasPagination, OAuth2Api
|
||||
];
|
||||
|
||||
if ($this->alfaConfig->caBundlePath) {
|
||||
$config['verify'] = $this->alfaConfig->caBundlePath;
|
||||
$config['verify'] = $this->alfaConfig->caBundlePath === 'false' ? false : $this->alfaConfig->caBundlePath;
|
||||
}
|
||||
|
||||
return $config;
|
||||
|
||||
@@ -44,6 +44,7 @@ class AlfaBankServiceProvider extends ServiceProvider
|
||||
caBundlePath: $conf['ca_bundle'] ?? null,
|
||||
clientId: $conf['client_id'],
|
||||
clientSecret: $conf['client_secret'],
|
||||
redirectUri: $conf['redirect_uri'] ?? null,
|
||||
signingCertificatePath: $conf['signing_certificate_path'] ?? null,
|
||||
signingPrivateKeyPath: $conf['signing_private_key_path'] ?? null,
|
||||
);
|
||||
@@ -87,7 +88,7 @@ class AlfaBankServiceProvider extends ServiceProvider
|
||||
$config = $app['config']['alfa-bank.sbp'];
|
||||
return new SbpConnector(
|
||||
alfaConfig: $app->make('alfa.sbp.config'),
|
||||
keyNameAlias: $config['key_name_alias']
|
||||
keyNameAlias: $config['key_name_alias'] ?? null
|
||||
);
|
||||
});
|
||||
$this->app->alias(SbpConnector::class, 'alfa.sbp');
|
||||
|
||||
@@ -27,7 +27,7 @@ class SbpConnector extends Connector implements HasPagination
|
||||
|
||||
public function __construct(
|
||||
protected AlfaConfig $alfaConfig,
|
||||
protected string $keyNameAlias
|
||||
protected ?string $keyNameAlias = null
|
||||
) {
|
||||
$this->tries = 3;
|
||||
$this->retryInterval = 500;
|
||||
|
||||
Reference in New Issue
Block a user