forked from apoloz/alfa-bank-sdk
refactor
This commit is contained in:
574
README.md
574
README.md
@@ -16,6 +16,96 @@ This is an unofficial PHP SDK for the [Alfa Bank API](https://developers.alfaban
|
||||
composer require apoloz/alfa-bank-sdk
|
||||
```
|
||||
|
||||
## Architecture & Data Flow
|
||||
|
||||
The SDK abstracts complex banking protocols into a clean, object-oriented interface.
|
||||
|
||||
### 1. Unified Request Architecture
|
||||
Every request follows a strict "Input DTO -> Request -> Connector -> Output DTO" pipeline.
|
||||
|
||||
```mermaid
|
||||
graph LR
|
||||
User[Client App] --> DTO_IN[Request DTO]
|
||||
DTO_IN --> REQ[Request Class]
|
||||
REQ --> CON[Connector]
|
||||
CON -->|mTLS + Signature| API((Alfa Bank))
|
||||
API -->|Raw JSON| CON
|
||||
CON --> REQ
|
||||
REQ -->|Data Mapping| DTO_OUT[Response DTO/Collection]
|
||||
DTO_OUT --> User
|
||||
|
||||
style CON fill:#f96,stroke:#333,stroke-width:2px
|
||||
style DTO_IN fill:#bbf,stroke:#333
|
||||
style DTO_OUT fill:#9f6,stroke:#333
|
||||
```
|
||||
|
||||
### 2. Authentication & Security Flow (BaaS)
|
||||
The BaaS API requires a two-step handshake: mTLS for the tunnel and OAuth 2.0 for authorization.
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant App as Client Application
|
||||
participant SDK as AlfaBank SDK
|
||||
participant API as Alfa Bank Gateway
|
||||
|
||||
Note over App, API: 1. Connection (mTLS)
|
||||
SDK->>API: Client Hello (X.509 Certificate)
|
||||
API-->>SDK: Server Hello & Encrypted Tunnel established
|
||||
|
||||
Note over App, API: 2. Authorization (OAuth 2.0)
|
||||
App->>SDK: login(id, secret)
|
||||
SDK->>API: POST /token (Client Credentials)
|
||||
API-->>SDK: Access Token (JWT)
|
||||
SDK->>SDK: Store Token in Authenticator
|
||||
|
||||
Note over App, API: 3. Business Requests
|
||||
App->>SDK: send(CreatePaymentRequest)
|
||||
SDK->>API: POST /payments (Header: Bearer Token)
|
||||
API-->>SDK: 201 Created
|
||||
```
|
||||
|
||||
### 3. SBP Security (JCS & Body Signing)
|
||||
Unlike BaaS, SBP requires signing the actual JSON body using a recursive key-sorting algorithm (JCS).
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
A["Raw Data (Array)"] -->|Recursive ksort| B("Canonical Array")
|
||||
B -->|JSON_UNESCAPED_UNICODE| C("JCS JSON String")
|
||||
C -->|RSA-SHA256 Sign| D("Binary Signature")
|
||||
D -->|Base64 Encode| E["'Authorization' Header"]
|
||||
E -->|HTTPS + mTLS| F((Alfa Bank SBP Gateway))
|
||||
|
||||
subgraph SDK Automatics
|
||||
B
|
||||
C
|
||||
D
|
||||
end
|
||||
```
|
||||
|
||||
### 4. Webhook Pipeline (Laravel Integration)
|
||||
The SDK acts as a security firewall for incoming bank notifications.
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant Bank as Alfa Bank
|
||||
participant Mid as VerifyAlfaWebhook (Middleware)
|
||||
participant Fact as WebhookFactory
|
||||
participant Event as AlfaWebhookReceived (Event)
|
||||
participant Listener as Your Listener
|
||||
|
||||
Bank->>Mid: POST /webhooks/alfa
|
||||
Mid->>Mid: 1. Validate Credentials
|
||||
alt Authorized
|
||||
Mid->>Fact: 2. Parse Raw JSON
|
||||
Fact->>Fact: 3. Detect Type (BaaS/SBP)
|
||||
Fact->>Event: 4. Dispatch(Typed DTO)
|
||||
Event->>Listener: 5. Handle Business Logic
|
||||
Mid-->>Bank: 200 OK
|
||||
else Unauthorized
|
||||
Mid-->>Bank: 401 Unauthorized
|
||||
end
|
||||
```
|
||||
|
||||
## Security & Setup (Crucial)
|
||||
|
||||
Alfa Bank uses a comprehensive security model requiring **two distinct sets of keys**:
|
||||
@@ -23,13 +113,13 @@ Alfa Bank uses a comprehensive security model requiring **two distinct sets of k
|
||||
2. **Signing (JWS/CMS):** To digitally sign the request body.
|
||||
|
||||
### Where to get keys?
|
||||
- **Sandbox:** Provided by the bank support or downloaded from the Developer Portal (usually as `.pfx` or `.zip`).
|
||||
- **Sandbox:** Provided by the bank support or downloaded from the Developer Portal.
|
||||
- **Production:**
|
||||
- **Transport (mTLS):** Generate a private key and CSR using OpenSSL (`openssl genrsa`, `openssl req`). Send the CSR to `alfa_api@alfabank.ru`. The bank will reply with your Certificate.
|
||||
- **Signing:** Generated by you (the client). The public certificate must be registered in "Alfa Business Online" or sent to your onboarding manager.
|
||||
- **Transport (mTLS):** Generate a private key and CSR using OpenSSL. Send the CSR to `alfa_api@alfabank.ru`.
|
||||
- **Signing:** Generated by you (the client). Register the public certificate in "Alfa Business Online".
|
||||
|
||||
### 1. Converting PFX to PEM
|
||||
If the bank provided a `.pfx` file for signing, you must convert it to PEM format:
|
||||
If the bank provided a `.pfx` file for signing, convert it to PEM:
|
||||
```bash
|
||||
# Extract Private Key
|
||||
openssl pkcs12 -in signing.pfx -nocerts -out signing_key.pem -nodes
|
||||
@@ -39,39 +129,21 @@ openssl pkcs12 -in signing.pfx -clcerts -nokeys -out signing_cert.pem
|
||||
```
|
||||
|
||||
### 2. Initialization
|
||||
You can now initialize the SDK with both key pairs:
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\AlfaBank;
|
||||
use Apoloz\AlfaBank\Enums\Environment;
|
||||
|
||||
$baas = AlfaBank::baas(
|
||||
// Transport Keys (mTLS)
|
||||
certificatePath: '/path/to/transport_cert.pem',
|
||||
privateKeyPath: '/path/to/transport_key.pem',
|
||||
|
||||
// Signing Keys (Business Logic) - Optional, defaults to transport keys if not set
|
||||
signingCertificatePath: '/path/to/signing_cert.pem',
|
||||
signingPrivateKeyPath: '/path/to/signing_key.pem',
|
||||
|
||||
environment: Environment::SANDBOX,
|
||||
caBundlePath: '/path/to/root_ca_bundle.crt'
|
||||
environment: Environment::SANDBOX
|
||||
);
|
||||
```
|
||||
|
||||
## Core Usage
|
||||
|
||||
### Authentication (BaaS)
|
||||
|
||||
Use the `login` method to perform OAuth Client Credentials flow:
|
||||
|
||||
```php
|
||||
$baas->login(
|
||||
clientId: 'your-client-id',
|
||||
clientSecret: 'your-client-secret'
|
||||
);
|
||||
```
|
||||
|
||||
### Making Requests
|
||||
|
||||
#### SBP: Generate QR Code
|
||||
@@ -79,13 +151,6 @@ $baas->login(
|
||||
use Apoloz\AlfaBank\Sbp\Requests\GetQrCodeRequest;
|
||||
use Apoloz\AlfaBank\Sbp\Data\QrCodeRequestData;
|
||||
|
||||
$sbp = AlfaBank::sbp(
|
||||
certificatePath: '...',
|
||||
privateKeyPath: '...',
|
||||
keyNameAlias: '9728109955', // Terminal ID
|
||||
signingPrivateKeyPath: '/path/to/signing_key.pem' // Specific signing key for SBP body
|
||||
);
|
||||
|
||||
$response = $sbp->send(new GetQrCodeRequest(
|
||||
new QrCodeRequestData(TermNo: '...', amount: '100')
|
||||
));
|
||||
@@ -93,464 +158,37 @@ $response = $sbp->send(new GetQrCodeRequest(
|
||||
$link = $response->dto()->payload;
|
||||
```
|
||||
|
||||
#### Nominal Accounts
|
||||
```php
|
||||
$response = $baas->send(new CreateBeneficiaryRequest($payload));
|
||||
```
|
||||
|
||||
### Self-Employed (Payouts & Status)
|
||||
|
||||
The SDK supports managing self-employed beneficiaries, checking their FTS status, and processing payouts.
|
||||
|
||||
#### Check Taxpayer Status
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\SelfEmployed\GetTaxpayerStatusRequest;
|
||||
use Apoloz\AlfaBank\Data\SelfEmployed\TaxpayerStatusRequestData;
|
||||
|
||||
$payload = new TaxpayerStatusRequestData(
|
||||
externalId: 'unique-id',
|
||||
selfemployedVatinList: ['123456789012']
|
||||
);
|
||||
|
||||
$response = $baas->send(new GetTaxpayerStatusRequest($payload));
|
||||
$status = $response->dto()->taxpayerStatusList[0];
|
||||
```
|
||||
|
||||
#### Process Payout
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\SelfEmployed\CreatePayoutRequest;
|
||||
use Apoloz\AlfaBank\Data\SelfEmployed\PayoutRequestData;
|
||||
|
||||
$payload = new PayoutRequestData(
|
||||
externalId: 'ext-id-456',
|
||||
company: ['vatin' => '7700000000'],
|
||||
requisite: [
|
||||
['amount' => 1000, 'vatin' => '112233445566']
|
||||
]
|
||||
);
|
||||
$response = $baas->send(new CreatePayoutRequest($payload));
|
||||
```
|
||||
|
||||
### File Exchange
|
||||
|
||||
Upload and download files securely.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\FileExchange\UploadFileRequest;
|
||||
use Apoloz\AlfaBank\Requests\FileExchange\DownloadFileRequest;
|
||||
|
||||
// Upload
|
||||
$stream = fopen('path/to/file', 'r');
|
||||
$baas->send(new UploadFileRequest($uploadUrl, $stream, $fileSize));
|
||||
|
||||
// Download
|
||||
$response = $baas->send(new DownloadFileRequest($downloadUrl));
|
||||
$content = $response->body();
|
||||
```
|
||||
|
||||
### Payments (RUR Payment Orders)
|
||||
|
||||
Create standard payment orders and check their status.
|
||||
|
||||
#### Standard Payments
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\Payments\CreatePaymentRequest;
|
||||
use Apoloz\AlfaBank\Data\Payments\PaymentData;
|
||||
|
||||
$payload = new PaymentData(
|
||||
amount: 100.50,
|
||||
date: '2023-10-25',
|
||||
externalId: 'order-12345',
|
||||
operationCode: '01',
|
||||
payeeAccount: '40702...',
|
||||
payeeBankBic: '044525225',
|
||||
payeeName: 'Partner LLC',
|
||||
payerAccount: '40702...',
|
||||
payerBankBic: '044525593',
|
||||
payerBankCorrAccount: '30101...',
|
||||
payerInn: '7700000000',
|
||||
payerName: 'My Company',
|
||||
priority: '5',
|
||||
purpose: 'Payment for services'
|
||||
);
|
||||
|
||||
// Create Payment
|
||||
$baas->send(new CreatePaymentRequest($payload));
|
||||
|
||||
// Check State
|
||||
use Apoloz\AlfaBank\Requests\Payments\GetPaymentStateRequest;
|
||||
$state = $baas->send(new GetPaymentStateRequest('order-12345'))->dto();
|
||||
echo $state->bankStatus; // e.g. ACCEPTED
|
||||
$payload = new PaymentData(amount: 100.50, ...);
|
||||
$response = $baas->send(new CreatePaymentRequest($payload));
|
||||
echo $response->dto()->id;
|
||||
```
|
||||
|
||||
### Cards
|
||||
### Advanced Features
|
||||
|
||||
Retrieve a list of client cards.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\Cards\GetCardsRequest;
|
||||
|
||||
$response = $baas->send(new GetCardsRequest());
|
||||
foreach ($response->dto() as $card) {
|
||||
echo $card->maskedNumber . ' - ' . $card->status;
|
||||
}
|
||||
```
|
||||
|
||||
### B2C Payouts (SBP via Phone)
|
||||
|
||||
Send money to individuals using their phone number through SBP.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\B2C\CreateB2CPaymentRequest;
|
||||
use Apoloz\AlfaBank\Data\B2C\B2CPaymentRequestData;
|
||||
use Apoloz\AlfaBank\Data\B2C\B2CClientData;
|
||||
use Apoloz\AlfaBank\Data\B2C\B2CPaymentRecipientData;
|
||||
|
||||
$payload = new B2CPaymentRequestData(
|
||||
client: new B2CClientData(b2cClientId: '...', partnerId: 123),
|
||||
inn: '7700000000',
|
||||
account: '40702...',
|
||||
total: 100.53,
|
||||
signedBody: '...base64_signature...',
|
||||
payments: B2CPaymentRecipientData::collect([
|
||||
[
|
||||
'phone' => '79001112233',
|
||||
'amount' => 100.53,
|
||||
'nspkBankId' => '100000000001',
|
||||
'sequence' => 'unique-seq-1',
|
||||
'name' => ['first' => 'Ivan', 'last' => 'Ivanov']
|
||||
]
|
||||
], DataCollection::class)
|
||||
);
|
||||
|
||||
$baas->send(new CreateB2CPaymentRequest($payload));
|
||||
```
|
||||
|
||||
### Payment Registries (Batch Ruble Payments)
|
||||
|
||||
Create a registry for multiple ruble payments and sign it.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\Registries\CreateRegistryRequest;
|
||||
use Apoloz\AlfaBank\Data\Registries\RegistryRequestData;
|
||||
use Apoloz\AlfaBank\Data\Registries\RegistryPaymentData;
|
||||
|
||||
$payload = new RegistryRequestData(
|
||||
payments: RegistryPaymentData::collect([
|
||||
[
|
||||
'amount' => 1000.0,
|
||||
'date' => '2023-11-01',
|
||||
'payeeAccount' => '40702...',
|
||||
'payeeBankBic' => '044525225',
|
||||
'payeeInn' => '7700000000',
|
||||
'payeeName' => 'Vendor LLC',
|
||||
'payerAccount' => '40702...',
|
||||
'purpose' => 'Batch payment part 1'
|
||||
]
|
||||
], DataCollection::class),
|
||||
description: 'Weekly payroll'
|
||||
);
|
||||
|
||||
$response = $baas->send(new CreateRegistryRequest($payload));
|
||||
$registryId = $response->json('id');
|
||||
|
||||
// Sign Registry
|
||||
use Apoloz\AlfaBank\Requests\Registries\SignRegistryRequest;
|
||||
use Apoloz\AlfaBank\Data\Registries\RegistrySignatureData;
|
||||
use Spatie\LaravelData\DataCollection;
|
||||
|
||||
$signatures = RegistrySignatureData::collect([
|
||||
[
|
||||
'base64Encoded' => '...', // Base64 signature
|
||||
'signatureType' => 'RSA',
|
||||
'certificateUuid' => '...'
|
||||
]
|
||||
], DataCollection::class);
|
||||
|
||||
$baas->send(new SignRegistryRequest($registryId, $signatures));
|
||||
```
|
||||
|
||||
### Customer Info
|
||||
|
||||
Get organization profile.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\CustomerInfo\GetCustomerInfoRequest;
|
||||
|
||||
$info = $baas->send(new GetCustomerInfoRequest())->dto();
|
||||
echo $info->fullName;
|
||||
```
|
||||
|
||||
### Limits
|
||||
|
||||
Get client's operation limits.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\Limits\GetGeneralLimitsRequest;
|
||||
|
||||
$response = $baas->send(new GetGeneralLimitsRequest());
|
||||
$limits = $response->json();
|
||||
```
|
||||
|
||||
### Debit Cards
|
||||
|
||||
Apply for a new debit card.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\DebitCards\CreateDebitCardApplicationRequest;
|
||||
use Apoloz\AlfaBank\Data\DebitCards\DebitCardApplicationData;
|
||||
|
||||
$payload = new DebitCardApplicationData(
|
||||
embossingName: 'IVAN IVANOV',
|
||||
firstName: 'Иван',
|
||||
lastName: 'Иванов',
|
||||
middleName: 'Иванович',
|
||||
mobilePhone: '79001112233',
|
||||
passportBirthDate: '1990-01-01',
|
||||
sex: 'm',
|
||||
sopdConfirmed: true
|
||||
);
|
||||
|
||||
$baas->send(new CreateDebitCardApplicationRequest($payload));
|
||||
```
|
||||
|
||||
### User Compliance
|
||||
|
||||
Check user compliance for loans.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\Compliance\GetUserComplianceRequest;
|
||||
|
||||
$baas->send(new GetUserComplianceRequest());
|
||||
```
|
||||
|
||||
### DFA (Digital Financial Assets)
|
||||
|
||||
List initial placements.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\DFA\GetDfaInitialPlacementListRequest;
|
||||
|
||||
$baas->send(new GetDfaInitialPlacementListRequest(limit: 5));
|
||||
```
|
||||
|
||||
### Currency Rates
|
||||
|
||||
Get currency rates by office.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\Rates\GetOfficeRatesRequest;
|
||||
|
||||
$baas->send(new GetOfficeRatesRequest());
|
||||
```
|
||||
|
||||
### Escrow Accounts
|
||||
|
||||
Manage construction projects and escrow orders.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\Escrow\GetBuildProjectsRequest;
|
||||
|
||||
$projects = $baas->send(new GetBuildProjectsRequest())->json();
|
||||
```
|
||||
|
||||
### Power of Attorney (Poa)
|
||||
|
||||
Request and check status of digital POAs.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\Poa\CreatePoaRequest;
|
||||
|
||||
$response = $baas->send(new CreatePoaRequest('poa-123', '7700000000'));
|
||||
$uuid = $response->json('requestUuid');
|
||||
```
|
||||
|
||||
### Loyalty
|
||||
|
||||
Access bonus accounts and transaction history.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\Loyalty\GetLoyaltyAccountsRequest;
|
||||
|
||||
$accounts = $baas->send(new GetLoyaltyAccountsRequest())->json();
|
||||
```
|
||||
|
||||
### Reports
|
||||
|
||||
Order certificates and reports.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\Reports\CreateAccountBalanceReportRequest;
|
||||
|
||||
$baas->send(new CreateAccountBalanceReportRequest(['40702...'], 'eng'));
|
||||
```
|
||||
|
||||
### Crypto Service
|
||||
|
||||
Manage encryption and signing certificates.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\Crypto\GetCertificatesRequest;
|
||||
|
||||
$certificates = $baas->send(new GetCertificatesRequest())->json();
|
||||
```
|
||||
|
||||
### Partner (MMB)
|
||||
|
||||
Access partner program data and applications.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\Partner\GetPartnerApplicationsRequest;
|
||||
|
||||
$apps = $baas->send(new GetPartnerApplicationsRequest())->json();
|
||||
```
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- **Bonus Numbers**: `$baas->send(new GetBonusNumbersRequest());`
|
||||
- **Credit Offers**: `$baas->send(new GetCreditOffersRequest());`
|
||||
- **Self-encashment**: `$baas->send(new CreateSelfEncashmentRegistryRequest($data));`
|
||||
- **Business Lounge**: `$baas->send(new GetLoungeBalanceRequest());`
|
||||
- **Scoring**: `$baas->send(new GetComplianceScoreRequest('7700000000'));`
|
||||
- **Security**: `$baas->send(new GetSubscriptionsRequest());`
|
||||
- **Logistics**: `$baas->send(new GetDeliveriesRequest('...'));`
|
||||
- **Webhooks**: `$baas->send(new GetWebhooksRequest());`
|
||||
- **1C Integration**: `$baas->send(new CheckMerchantRequest('MF123', 'Basic ...'));`
|
||||
- **Claims**: `$baas->send(new ResolveClaimRequest('ID', $data));`
|
||||
- **Orders (Travel/Afisha)**: `$baas->send(new CreateTravelOrderRequest($data));`
|
||||
- **Salary Project**: `$baas->send(new CreatePayrollApplicationRequest($payload));`
|
||||
- **Cloud Signature**: `$baas->send(new SubmitSigningRequest('REQ-ID'));`
|
||||
- **Aff Integration**: `$baas->send(new CheckComplianceRequest('INN', 'Name'));`
|
||||
- **Digital Ruble**: `$sbp->send(new CreateUniQrRequest($uniQrData));`
|
||||
|
||||
### Signing Data (CMS)
|
||||
|
||||
For requests requiring a digital signature (e.g., Payments), you must canonicalize and sign the data manually.
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Utils\CmsSigner;
|
||||
use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData;
|
||||
use Spatie\LaravelData\DataCollection;
|
||||
|
||||
// 1. Prepare data
|
||||
$fields = [
|
||||
'amount' => 100.50,
|
||||
// ... other fields
|
||||
];
|
||||
|
||||
// 2. Canonicalize & Sign
|
||||
$json = CmsSigner::canonicalize($fields);
|
||||
$cert = file_get_contents('/path/to/signing_cert.pem');
|
||||
$key = file_get_contents('/path/to/signing_key.pem');
|
||||
$signature = CmsSigner::sign($json, $cert, $key);
|
||||
|
||||
// 3. Attach to DTO
|
||||
$paymentData->digestSignatures = DigestSignatureData::collect([
|
||||
[
|
||||
'base64Encoded' => $signature,
|
||||
'signatureType' => 'CMS'
|
||||
]
|
||||
], DataCollection::class);
|
||||
```
|
||||
|
||||
## Advanced Features
|
||||
|
||||
### Pagination
|
||||
The SDK supports automatic pagination for list endpoints:
|
||||
#### Pagination
|
||||
The SDK supports automatic pagination for all list endpoints:
|
||||
|
||||
```php
|
||||
use Apoloz\AlfaBank\Requests\Accounts\GetAccountsRequest;
|
||||
|
||||
$paginator = $baas->paginate(new GetAccountsRequest());
|
||||
|
||||
foreach ($paginator as $account) {
|
||||
// Each item is processed automatically
|
||||
foreach ($paginator->items() as $account) {
|
||||
echo $account->number; // Typed AccountData object
|
||||
}
|
||||
```
|
||||
|
||||
## Laravel Integration
|
||||
|
||||
The package supports auto-discovery. Publish the config file:
|
||||
|
||||
```bash
|
||||
php artisan vendor:publish --tag=alfa-bank-config
|
||||
```
|
||||
|
||||
Configure your `.env`:
|
||||
```env
|
||||
ALFA_BAAS_CERT_PATH=/path/to/transport_cert.pem
|
||||
# ... other settings
|
||||
ALFA_WEBHOOK_USER=your_webhook_user
|
||||
ALFA_WEBHOOK_PASSWORD=your_webhook_password
|
||||
```
|
||||
|
||||
### Webhook Handling (Laravel)
|
||||
|
||||
The SDK provides a built-in controller and route macro to handle incoming webhooks and dispatch Laravel events.
|
||||
|
||||
1. **Register the route** in `routes/api.php`:
|
||||
```php
|
||||
Route::alfaWebhooks('/webhooks/alfa');
|
||||
```
|
||||
|
||||
2. **Listen for the event** in `app/Providers/EventServiceProvider.php`:
|
||||
```php
|
||||
use Apoloz\AlfaBank\Laravel\Events\AlfaWebhookReceived;
|
||||
|
||||
protected $listen = [
|
||||
AlfaWebhookReceived::class => [
|
||||
\App\Listeners\HandleAlfaWebhook::class,
|
||||
],
|
||||
];
|
||||
```
|
||||
|
||||
3. **Handle the DTO** in your listener:
|
||||
```php
|
||||
public function handle(AlfaWebhookReceived $event)
|
||||
{
|
||||
$webhook = $event->webhook; // BaseWebhookData DTO
|
||||
|
||||
if ($webhook->object === 'ul_transaction_default') {
|
||||
$transaction = $webhook->data;
|
||||
// ...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
The SDK throws `Apoloz\AlfaBank\Exceptions\AlfaBankException` when the API returns an error.
|
||||
|
||||
```php
|
||||
try {
|
||||
$baas->send($request);
|
||||
} catch (\Apoloz\AlfaBank\Exceptions\AlfaBankException $e) {
|
||||
echo $e->getErrorCode(); // e.g. "invalid_token" or "RQ05014"
|
||||
echo $e->getMessage();
|
||||
}
|
||||
```
|
||||
|
||||
## Utilities
|
||||
|
||||
- **Card PAN Encryption**: `CardEncryptor::encrypt($pan, $pubKey)`
|
||||
- **CMS Signing**: `CmsSigner::sign($data, $cert, $key)`
|
||||
- **JWS/JWE**: `JwsSigner` and `JweEncryptor` for transport security.
|
||||
|
||||
## Diagnostics
|
||||
|
||||
### Health Check (Laravel)
|
||||
Run the built-in Artisan command to verify your mTLS certificates and connection:
|
||||
|
||||
#### Diagnostics
|
||||
Run the built-in Artisan command to verify your configuration:
|
||||
```bash
|
||||
php artisan alfa:check
|
||||
```
|
||||
|
||||
### Logging
|
||||
Attach a PSR-3 logger to debug requests (sensitive data redacted):
|
||||
|
||||
```php
|
||||
$baas->withLogging(Log::getLogger());
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Provides a user-friendly, static factory for instantiating API connectors.
|
||||
// RESPONSIBILITY: To simplify the creation of `AlfaBankConnector` and `SbpConnector` instances by abstracting away the underlying DTO and service instantiation.
|
||||
// INPUTS: Certificate paths, environment, and other configuration primitives.
|
||||
// OUTPUTS: Fully configured Connector instances.
|
||||
// LINKS: Core/AlfaBankConnector.php, Sbp/SbpConnector.php
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank;
|
||||
|
||||
@@ -16,14 +11,28 @@ use Apoloz\AlfaBank\Core\AlfaConfig;
|
||||
use Apoloz\AlfaBank\Enums\Environment;
|
||||
use Apoloz\AlfaBank\Services\OpenSslCmsSigner;
|
||||
use Apoloz\AlfaBank\Sbp\SbpConnector;
|
||||
// </SECTION>
|
||||
use Apoloz\AlfaBank\Requests\Accounts\GetAccountsRequest;
|
||||
|
||||
// <SECTION name="class_definition" intent="Define a static factory class to act as the primary entry point for the SDK.">
|
||||
// <BELIEF_STATE "A static factory provides a simple and clean entry point for users of the SDK. Instead of manually wiring up dependencies, they can call a simple method like `AlfaBank::baas(...)`, which improves developer experience.">
|
||||
class AlfaBank
|
||||
{
|
||||
// <SECTION name="baas_connector_factory" intent="Create a fully configured connector for the Core Banking (BaaS) API.">
|
||||
// <BELIEF_STATE "This static method encapsulates the business logic of creating a BaaS connector. It correctly instantiates the `AlfaConfig` DTO and the default `OpenSslCmsSigner`, hiding this complexity from the end-user.">
|
||||
/**
|
||||
* Performs a health check on the connection.
|
||||
* Throws an exception if authentication or account listing fails.
|
||||
*/
|
||||
public static function check(
|
||||
string $certificatePath,
|
||||
string $privateKeyPath,
|
||||
string $clientId,
|
||||
string $clientSecret,
|
||||
Environment $environment = Environment::SANDBOX,
|
||||
?string $caBundlePath = null
|
||||
): bool {
|
||||
$baas = self::baas($certificatePath, $privateKeyPath, $environment, $caBundlePath);
|
||||
$baas->login($clientId, $clientSecret);
|
||||
$baas->send(new GetAccountsRequest());
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function baas(
|
||||
string $certificatePath,
|
||||
string $privateKeyPath,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Contracts;
|
||||
|
||||
interface EncryptorInterface
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the abstract contracts (interfaces) for all security-related operations.
|
||||
// RESPONSIBILITY: To establish a common, swappable interface for different signing and encryption implementations, enabling Inversion of Control.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Contracts;
|
||||
|
||||
interface SignerInterface
|
||||
|
||||
@@ -1,29 +1,21 @@
|
||||
<?php
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the primary transport layer for the Alfa Bank BaaS API.
|
||||
// RESPONSIBILITY: To manage mTLS configuration, authentication state, retries, and middleware for all BaaS API interactions.
|
||||
// INPUTS: AlfaConfig (DTO), SignerInterface (service).
|
||||
// OUTPUTS: An authenticated Saloon Connector instance capable of sending requests.
|
||||
// NOTES:
|
||||
// - Supports separate keys for Transport (mTLS) and Signing (JWS/CMS).
|
||||
// - Uses `login` method for OAuth 2.0 Client Credentials flow.
|
||||
// - Compatible with Saloon v3.
|
||||
// LINKS: AlfaBankServiceProvider.php#bind_connector
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Core;
|
||||
|
||||
// <SECTION name="module_imports" intent="Import necessary contracts, services, and base framework components for the connector's operation.">
|
||||
// <BELIEF_STATE "Saloon's plugin architecture requires importing traits for features like retries and timeouts. Local contracts (SignerInterface) are imported for dependency injection.">
|
||||
use Apoloz\AlfaBank\Contracts\SignerInterface;
|
||||
use Apoloz\AlfaBank\Http\Middleware\AlfaResponseMiddleware;
|
||||
use Apoloz\AlfaBank\Http\Middleware\RequestIdMiddleware;
|
||||
use Apoloz\AlfaBank\Http\Pagination\AlfaOffsetPaginator;
|
||||
use Apoloz\AlfaBank\Requests\Auth\GetTokenRequest;
|
||||
use Apoloz\AlfaBank\Traits\HasAlfaErrorHandling;
|
||||
use Saloon\Http\Connector;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\PaginationPlugin\Contracts\HasPagination;
|
||||
use Saloon\PaginationPlugin\OffsetPaginator;
|
||||
use Saloon\Traits\Plugins\AlwaysThrowOnErrors;
|
||||
use Saloon\Traits\RequestProperties\HasTries;
|
||||
use Saloon\Traits\Plugins\HasTimeout;
|
||||
|
||||
@@ -31,6 +23,8 @@ class AlfaBankConnector extends Connector implements HasPagination
|
||||
{
|
||||
use HasTimeout;
|
||||
use HasTries;
|
||||
use AlwaysThrowOnErrors;
|
||||
use HasAlfaErrorHandling;
|
||||
|
||||
public function __construct(
|
||||
protected AlfaConfig $alfaConfig,
|
||||
@@ -62,13 +56,14 @@ class AlfaBankConnector extends Connector implements HasPagination
|
||||
|
||||
protected function defaultMiddleware(): array
|
||||
{
|
||||
return [];
|
||||
return [
|
||||
new RequestIdMiddleware(),
|
||||
];
|
||||
}
|
||||
|
||||
public function boot(\Saloon\Http\PendingRequest $pendingRequest): void
|
||||
{
|
||||
$pendingRequest->middleware()->onResponse(new AlfaResponseMiddleware());
|
||||
$pendingRequest->middleware()->onRequest(new RequestIdMiddleware());
|
||||
//
|
||||
}
|
||||
|
||||
public function paginate(Request $request): OffsetPaginator
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines a strongly-typed, immutable Data Transfer Object (DTO) for all connector configurations.
|
||||
// RESPONSIBILITY: To hold and validate critical configuration parameters like certificate paths and API credentials.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Accounts;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
@@ -8,9 +10,9 @@ class AccountData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public string $number,
|
||||
public string $dateCreated,
|
||||
public string $openDate,
|
||||
public string $type,
|
||||
public ?string $mnemonic = null,
|
||||
public ?array $balance = null, // Can be refined later with BalanceData
|
||||
public ?array $balance = null,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Aff;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Aff;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Aff;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Auth;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for an OAuth 2.0 token response.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the access token, refresh token, ID token, expiry, and token type returned by the OAuth provider.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a paginated collection of client consent records.
|
||||
// RESPONSIBILITY: To provide a structured, type-safe container for lists of client consents returned by the API, including pagination metadata.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a single client consent record.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the details of a user's consent given to a client application.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for OpenID Connect UserInfo claims.
|
||||
// RESPONSIBILITY: To hold and type-safely represent details about the authenticated end-user.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\B2B_1C;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\B2B_1C;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\B2B_1C;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\B2C;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\B2C;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\B2C;
|
||||
|
||||
use Spatie\LaravelData\Attributes\DataCollectionOf;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\B2C;
|
||||
|
||||
use Spatie\LaravelData\Attributes\DataCollectionOf;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Bonus;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Cards;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Claims;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\CloudSignature;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\CloudSignature;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Compliance;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
@@ -7,7 +9,7 @@ use Spatie\LaravelData\Data;
|
||||
class UserComplianceData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
public bool $isCompliant,
|
||||
public bool $checkPassed,
|
||||
public ?int $score = null,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Crypto;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\CustomerInfo;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\DFA;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\DebitCards;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\DebitCards;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Escrow;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Escrow;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the response of a file download request.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the links necessary to perform a file download.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a single file link, typically for upload or download.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the URL, HTTP method, and optional detached signature link for file operations.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the response of a file upload request.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the links necessary to perform a file upload.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Limits;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Limits;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Loans;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Logistics;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Logistics;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Lounge;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Loyalty;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Loyalty;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Loyalty;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for an address.
|
||||
// RESPONSIBILITY: To hold and type-safely represent address details.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a specific beneficiary's balance.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the financial balance details of a beneficiary for a given account and date.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines a paginated collection of beneficiary transaction data.
|
||||
// RESPONSIBILITY: To provide a strongly-typed, paginatable structure for lists of transactions associated with a beneficiary, integrating pagination metadata and a collection of individual transaction DTOs.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a single beneficiary transaction record.
|
||||
// RESPONSIBILITY: To provide a strongly-typed structure for individual transaction details related to a beneficiary, ensuring consistency and ease of consumption for API responses.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the request payload when creating a new beneficiary.
|
||||
// RESPONSIBILITY: To hold and validate all necessary information for beneficiary registration, including personal details, addresses, and signatures.
|
||||
@@ -13,6 +15,8 @@ namespace Apoloz\AlfaBank\Data\NominalAccounts\Beneficiaries;
|
||||
// <BELIEF_STATE "This DTO has several nested DTOs and collections (`AddressData`, `DigestSignatureData`, `DocumentData`, `PersonalInformationData`). `DataCollectionOf` and `Data` ensure that these are all correctly typed and mapped.">
|
||||
use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData;
|
||||
use Spatie\LaravelData\Attributes\DataCollectionOf;
|
||||
use Spatie\LaravelData\Attributes\Validation\Email;
|
||||
use Spatie\LaravelData\Attributes\Validation\Numeric;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\DataCollection;
|
||||
// </SECTION>
|
||||
@@ -36,11 +40,15 @@ class CreateBeneficiaryRequestData extends Data
|
||||
public ?bool $financialActivities = null,
|
||||
public ?string $name = null,
|
||||
public ?string $registrationDate = null,
|
||||
#[Numeric]
|
||||
public ?string $inn = null,
|
||||
#[Numeric]
|
||||
public ?string $kpp = null,
|
||||
#[Numeric]
|
||||
public ?string $ogrn = null,
|
||||
public ?PersonalInformationData $personalInformation = null,
|
||||
public ?string $phoneNumber = null,
|
||||
#[Email]
|
||||
public ?string $email = null,
|
||||
#[DataCollectionOf(DocumentData::class)]
|
||||
public ?DataCollection $documents = null,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the response when creating a new beneficiary.
|
||||
// RESPONSIBILITY: To provide a structured, type-safe object representing the outcome of a beneficiary creation request.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for an identification document.
|
||||
// RESPONSIBILITY: To hold and type-safely represent details of a document like passport or ID card.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a beneficiary's personal identification information.
|
||||
// RESPONSIBILITY: To hold and type-safely represent an individual's personal details like name, INN, birthdate, etc.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the request payload when creating a new requisite.
|
||||
// RESPONSIBILITY: To hold and validate all necessary information for registering a new payment requisite for a beneficiary.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a single payment requisite.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the details of a registered payment method (e.g., bank account, card, phone).
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the request payload when updating an existing requisite.
|
||||
// RESPONSIBILITY: To hold and validate necessary information for modifying a payment requisite.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the request payload when updating an existing beneficiary.
|
||||
// RESPONSIBILITY: To hold and validate all necessary information for updating a beneficiary, including partial changes.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a specific wallet's balance.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the free and held amounts within a financial wallet.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Represents a paginated collection of BeneficiaryData objects.
|
||||
// RESPONSIBILITY: To provide a structured, type-safe container for lists of beneficiaries returned by the API, including pagination metadata.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the core data structure for a single beneficiary.
|
||||
// RESPONSIBILITY: To hold and type-safely represent all attributes of a beneficiary, as returned by the API.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the status of a counterparty-related request.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the outcome and details of an asynchronous operation involving counterparties (beneficiaries or universal recipients).
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a paginated collection of DealData objects.
|
||||
// RESPONSIBILITY: To provide a structured, type-safe container for lists of deals returned by the API, including pagination metadata.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a single deal.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the core attributes of a deal, such as its ID, status, and expiration.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a single payoff within a deal.
|
||||
// RESPONSIBILITY: To hold and type-safely represent a specific payment made as part of a deal.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the status of a deal-related request.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the outcome and details of an asynchronous operation related to deals.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the request payload to perform an action on a deal contractor.
|
||||
// RESPONSIBILITY: To hold and validate all necessary information for actions such as adding or managing contractors within a deal step.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a specific amount allocated to a contractor's wallet.
|
||||
// RESPONSIBILITY: To hold and type-safely represent an amount designated for a particular wallet type (e.g., nominal, tax).
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the request payload to perform an action on a deal step.
|
||||
// RESPONSIBILITY: To hold and validate all necessary information for actions such as completing or canceling a step within a deal.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the response of a step action request within a deal.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the outcome and status of an action performed on a deal step.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a contractor associated with a deal step.
|
||||
// RESPONSIBILITY: To hold and type-safely represent details of a beneficiary acting as a contractor within a specific deal step.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a single step within a deal.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the details of a specific stage in a multi-step deal process.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the response of a deal validation request.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the outcome of checking a deal's validity.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for distributing an amount to a beneficiary.
|
||||
// RESPONSIBILITY: To hold and type-safely represent how a specific portion of a transaction amount is allocated to a beneficiary.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the request payload when identifying an unidentified transaction.
|
||||
// RESPONSIBILITY: To hold and validate all necessary information for associating an unidentified transaction with specific beneficiaries.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the response of a transaction identification request.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the outcome and status of an identification operation.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for payer information within an unidentified transaction.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the details of the party who initiated a transaction that needs identification.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the request payload when refunding an unidentified transaction.
|
||||
// RESPONSIBILITY: To hold and validate all necessary information for initiating a refund for an unidentified transaction.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the response of a refund request for an unidentified transaction.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the outcome and status of an initiated refund operation.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a paginated collection of unidentified transactions.
|
||||
// RESPONSIBILITY: To provide a structured, type-safe container for lists of unidentified transactions, including pagination metadata.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a single unidentified transaction.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the details of a transaction that requires further identification.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a single nominal account.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the core details of a nominal account, such as its number and active status.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a detailed payoff record.
|
||||
// RESPONSIBILITY: To hold and type-safely represent comprehensive information about a payoff, including payer, recipient, and financial details.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a cryptographic digest signature.
|
||||
// RESPONSIBILITY: To hold and type-safely represent a base64-encoded signature and its type.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the request payload when creating a new payoff.
|
||||
// RESPONSIBILITY: To hold and validate all necessary information for initiating a payment from a nominal account.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the response of a payoff request.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the outcome and status of an initiated payment.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for payment requisite information within a payoff.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the specific details of how a payment should be directed (e.g., card, account, phone number).
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for recipient information within a payoff.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the details of the party receiving a payment.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a tax refund request payload.
|
||||
// RESPONSIBILITY: To provide a strongly-typed structure for initiating a tax refund for a beneficiary, including financial details, purpose, handling of remaining funds, and cryptographic signatures.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for a tax refund response payload.
|
||||
// RESPONSIBILITY: To provide a strongly-typed structure for the API's response to tax refund requests, including the unique identifier for the refund, its current status, and an optional descriptive message.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the request payload when creating a new universal recipient.
|
||||
// RESPONSIBILITY: To hold and validate all necessary information for registering a universal recipient.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the core data structure for a single universal recipient.
|
||||
// RESPONSIBILITY: To hold and type-safely represent the core details of a universal recipient, such as its ID, type, and active status.
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for the response when creating a new universal recipient.
|
||||
// RESPONSIBILITY: To provide a structured, type-safe object representing the outcome of a universal recipient creation request.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Orders;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Orders;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/*
|
||||
// MODULE_CONTRACT: Defines the data structure for pagination metadata.
|
||||
// RESPONSIBILITY: To hold and type-safely represent common pagination parameters like offset, limit, and total count.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Partner;
|
||||
|
||||
use Spatie\LaravelData\Data;
|
||||
|
||||
@@ -1,34 +1,75 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Apoloz\AlfaBank\Data\Payments;
|
||||
|
||||
use Apoloz\AlfaBank\Data\NominalAccounts\Payouts\DigestSignatureData;
|
||||
use Spatie\LaravelData\Attributes\DataCollectionOf;
|
||||
use Spatie\LaravelData\Attributes\MapOutputName;
|
||||
use Spatie\LaravelData\Attributes\Validation\Numeric;
|
||||
use Spatie\LaravelData\Attributes\Validation\Size;
|
||||
use Spatie\LaravelData\Data;
|
||||
use Spatie\LaravelData\DataCollection;
|
||||
|
||||
class PaymentData extends Data
|
||||
{
|
||||
public function __construct(
|
||||
#[MapOutputName('Amount')]
|
||||
public float $amount,
|
||||
|
||||
#[MapOutputName('DocDate')]
|
||||
public string $date,
|
||||
|
||||
#[MapOutputName('DocNo')]
|
||||
public string $externalId,
|
||||
|
||||
#[MapOutputName('OperationCode')]
|
||||
public string $operationCode,
|
||||
|
||||
#[MapOutputName('PayeeAccount')]
|
||||
public string $payeeAccount,
|
||||
|
||||
#[MapOutputName('PayeeBankBic'), Numeric, Size(9)]
|
||||
public string $payeeBankBic,
|
||||
|
||||
#[MapOutputName('PayeeName')]
|
||||
public string $payeeName,
|
||||
|
||||
#[MapOutputName('PayerAccount')]
|
||||
public string $payerAccount,
|
||||
|
||||
#[MapOutputName('PayerBankBic'), Numeric, Size(9)]
|
||||
public string $payerBankBic,
|
||||
|
||||
#[MapOutputName('PayerBankCorrAccount')]
|
||||
public string $payerBankCorrAccount,
|
||||
|
||||
#[MapOutputName('PayerInn'), Numeric]
|
||||
public string $payerInn,
|
||||
|
||||
#[MapOutputName('PayerName')]
|
||||
public string $payerName,
|
||||
|
||||
#[MapOutputName('Priority')]
|
||||
public string $priority,
|
||||
|
||||
#[MapOutputName('Purpose')]
|
||||
public string $purpose,
|
||||
|
||||
#[MapOutputName('Number')]
|
||||
public ?string $number = null,
|
||||
|
||||
#[MapOutputName('PayeeKpp')]
|
||||
public ?string $payeeKpp = null,
|
||||
|
||||
#[MapOutputName('PayeeBankCorrAccount')]
|
||||
public ?string $payeeBankCorrAccount = null,
|
||||
|
||||
#[MapOutputName('PaymentType')]
|
||||
public ?string $paymentType = null,
|
||||
#[DataCollectionOf(DigestSignatureData::class)]
|
||||
|
||||
#[MapOutputName('DigestSignatures'), DataCollectionOf(DigestSignatureData::class)]
|
||||
public ?DataCollection $digestSignatures = null,
|
||||
) {}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user