feat: Add Laravel tinker examples and update nominal accounts functionality

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
2026-01-24 23:40:20 +03:00
parent 0e66eb2859
commit fdb400d5f0
24 changed files with 571 additions and 111 deletions

View File

@@ -14,6 +14,7 @@ namespace Apoloz\AlfaBank\Services;
// <SECTION name="module_imports" intent="Import necessary classes for the signer contract.">
// <BELIEF_STATE "The `SignerInterface` is imported to ensure that `OpenSslCmsSigner` adheres to a predefined contract for digital signing, promoting interoperability and testability within the SDK.">
use Apoloz\AlfaBank\Contracts\SignerInterface;
use Apoloz\AlfaBank\Exceptions\SignerException;
// </SECTION>
// <SECTION name="class_definition" intent="Define the OpenSSL-based CMS signer service.">
@@ -34,12 +35,12 @@ class OpenSslCmsSigner implements SignerInterface
{
$privateKey = openssl_pkey_get_private(file_get_contents($this->privateKeyPath)); // assuming no passphrase for simplicity here
if (!$privateKey) {
throw new \Exception("Could not read private key for signing from {$this->privateKeyPath}.");
throw new SignerException("Could not read private key for signing from {$this->privateKeyPath}.");
}
$cert = openssl_x509_read(file_get_contents($this->certificatePath));
if (!$cert) {
throw new \Exception("Could not read certificate for signing from {$this->certificatePath}.");
throw new SignerException("Could not read certificate for signing from {$this->certificatePath}.");
}
$inFile = tempnam(sys_get_temp_dir(), 'alfa_in');
@@ -57,9 +58,9 @@ class OpenSslCmsSigner implements SignerInterface
);
if (!$status) {
unlink($inFile);
unlink($outFile);
throw new \Exception("Signing failed: " . openssl_error_string());
if (file_exists($inFile)) unlink($inFile);
if (file_exists($outFile)) unlink($outFile);
throw new SignerException("Signing failed: " . openssl_error_string());
}
$signedData = file_get_contents($outFile);