forked from apoloz/alfa-bank-sdk
refactor(core): enhance SDK structure and documentation
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
46
examples/06_sbp_b2c_payout.php
Normal file
46
examples/06_sbp_b2c_payout.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use Apoloz\AlfaBank\AlfaBank;
|
||||
use Apoloz\AlfaBank\Requests\B2C\CreateB2CPaymentRequest;
|
||||
use Apoloz\AlfaBank\Data\B2C\B2CPaymentRequestData;
|
||||
use Apoloz\AlfaBank\Data\B2C\B2CClientData;
|
||||
use Apoloz\AlfaBank\Data\B2C\B2CPaymentRecipientData;
|
||||
use Spatie\LaravelData\DataCollection;
|
||||
|
||||
/**
|
||||
* Example: B2C Payout via SBP (Phone Number).
|
||||
*/
|
||||
|
||||
$baas = AlfaBank::baas(
|
||||
certificatePath: 'path/to/cert.pem',
|
||||
privateKeyPath: 'path/to/key.pem'
|
||||
);
|
||||
|
||||
$payload = new B2CPaymentRequestData(
|
||||
client: new B2CClientData(b2cClientId: 'your-uuid', partnerId: 123),
|
||||
inn: '7700000000',
|
||||
account: '40702810...',
|
||||
total: 100.00,
|
||||
signedBody: 'BASE64_SIGNATURE_HERE', // Signature of the payments data
|
||||
payments: B2CPaymentRecipientData::collect([
|
||||
[
|
||||
'phone' => '79001112233',
|
||||
'amount' => 100.00,
|
||||
'nspkBankId' => '100000000001',
|
||||
'sequence' => 'unique-payout-id-1'
|
||||
]
|
||||
], DataCollection::class)
|
||||
);
|
||||
|
||||
$baas->login('client-id', 'client-secret');
|
||||
$response = $baas->send(new CreateB2CPaymentRequest($payload));
|
||||
|
||||
if ($response->successful()) {
|
||||
$data = $response->dto(); // B2CPaymentResponseData
|
||||
echo "Payout request sent. Status: {$data->status}\n";
|
||||
} else {
|
||||
echo "Error: " . $response->body() . "\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user