forked from apoloz/alfa-bank-sdk
56 lines
1.9 KiB
PHP
56 lines
1.9 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
|
|
use Apoloz\AlfaBank\AlfaBank;
|
|
use Apoloz\AlfaBank\Enums\Environment;
|
|
|
|
/**
|
|
* This example shows how to initialize the SDK with the Sandbox files provided by the bank.
|
|
*
|
|
* IMPORTANT: You must first convert the .pfx file to .pem format using OpenSSL:
|
|
*
|
|
* 1. Extract signing key:
|
|
* openssl pkcs12 -in certificate_for_requests_sign_with_password_1234.pfx -nocerts -out signing_key.pem -nodes -password pass:1234
|
|
*
|
|
* 2. Extract signing certificate:
|
|
* openssl pkcs12 -in certificate_for_requests_sign_with_password_1234.pfx -clcerts -nokeys -out signing_cert.pem -password pass:1234
|
|
*
|
|
* 3. Ensure transport certs are in PEM format if they aren't already.
|
|
*/
|
|
|
|
// --- 1. BaaS / Main API Initialization ---
|
|
$baas = AlfaBank::baas(
|
|
// Transport (mTLS) - use the sandbox_cert/key files
|
|
certificatePath: __DIR__ . '/certs/sandbox_cert_2026.cer',
|
|
privateKeyPath: __DIR__ . '/certs/sandbox_key_2026.key',
|
|
|
|
// Signing (Business Logic) - use the extracted PEM files from PFX
|
|
signingCertificatePath: __DIR__ . '/certs/signing_cert.pem',
|
|
signingPrivateKeyPath: __DIR__ . '/certs/signing_key.pem',
|
|
|
|
environment: Environment::SANDBOX,
|
|
caBundlePath: __DIR__ . '/certs/apica_2022_chain.cer' // Trust chain
|
|
);
|
|
|
|
echo "BaaS Connector Initialized.\n";
|
|
|
|
|
|
// --- 2. SBP (Faster Payments) Initialization ---
|
|
$sbp = AlfaBank::sbp(
|
|
// SBP usually uses its own mTLS pair found in the sbp_payout/mtls folder
|
|
certificatePath: __DIR__ . '/certs/sbp_payout/mtls/9728109955_test_mtls.crt',
|
|
privateKeyPath: __DIR__ . '/certs/sbp_payout/mtls/9728109955_test_mtls.key',
|
|
|
|
// Terminal ID from terminal_num.txt
|
|
keyNameAlias: '9728109955',
|
|
|
|
environment: Environment::SANDBOX,
|
|
caBundlePath: __DIR__ . '/certs/sbp_payout/sandbox_root/root-ca-test.crt'
|
|
);
|
|
|
|
echo "SBP Connector Initialized.\n";
|
|
|
|
// Now you can use $baas->login(...) or $sbp->send(...)
|
|
|