PHP code example of michaeld555 / santander-sdk
1. Go to this page and download the library: Download michaeld555/santander-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
michaeld555 / santander-sdk example snippets
use Santander\SDK\Facades\Santander;
use Santander\SDK\Exceptions\SantanderError;
try {
$transfer = Santander::pix()->transferPix(
pixKey: '[email protected] ',
value: '50.00',
description: 'Pagamento pedido #123'
);
if (! $transfer['success']) {
throw new \RuntimeException($transfer['error']);
}
$paymentId = $transfer['data']['id'] ?? null;
$status = $paymentId ? Santander::pix()->getPayment($paymentId) : null;
// use $status conforme sua regra de negocio
} catch (SantanderError $e) {
// erro de integracao Santander
} catch (\Throwable $e) {
// erro generico da aplicacao
}
use Illuminate\Http\Client\Factory;
use Santander\SDK\Auth\SantanderAuth;
use Santander\SDK\Client\SantanderApiClient;
use Santander\SDK\Client\SantanderClientConfiguration;
use Santander\SDK\PaymentReceipts;
use Santander\SDK\Pix;
use Santander\SDK\SantanderSdk;
$http = new Factory();
$config = new SantanderClientConfiguration(
clientId: 'seu_client_id',
clientSecret: 'seu_client_secret',
cert: '/caminho/para/cert.pem',
baseUrl: 'https://trust-sandbox.api.santander.com.br',
workspaceId: '',
logRequestResponseLevel: 'ERROR',
logger: null,
timeout: 60,
bankTaxId: '90400888000142'
);
$auth = SantanderAuth::fromConfig($http, $config);
$client = new SantanderApiClient($config, $auth, $http);
$sdk = new SantanderSdk(
$client,
new Pix($client),
new PaymentReceipts($client)
);
$workspaces = $sdk->workspaces()->listWorkspaces();
[
'success' => true|false,
'request_id' => '...',
'data' => [...],
'error' => ''
]
$created = Santander::pix()->createPayment([
'dictCode' => '[email protected] ',
'dictCodeType' => 'EMAIL',
'paymentValue' => '10.00',
'remittanceInformation' => 'Teste',
]);
$confirmed = Santander::pix()->confirmPayment($created['id'], [
'status' => 'AUTHORIZED',
'paymentValue' => '10.00',
]);
$one = Santander::pix()->getPayment($created['id']);
$list = Santander::pix()->listPayments(['_limit' => 100, '_offset' => 0]);
$payments = Santander::receipts()->paymentList([
'start_date' => '2025-01-01',
'end_date' => '2025-01-31',
'_limit' => '100',
]);
$paymentId = $payments[0]['payment']['paymentId'];
$create = Santander::receipts()->createReceipt($paymentId);
$receipt = Santander::receipts()->getReceipt($paymentId, $create['receipt_request_id']);
$history = Santander::receipts()->receiptCreationHistory($paymentId);
foreach (Santander::receipts()->paymentListIterByPages([
'start_date' => '2025-01-01',
'end_date' => '2025-01-31',
'_limit' => '50',
]) as $page) {
// cada pagina contem paymentsReceipts e links
}
$created = Santander::workspaces()->createWorkspaceValidated([
'type' => 'PAYMENTS',
'description' => 'Workspace API',
'mainDebitAccount' => [
'branch' => '1',
'number' => '130392838',
],
'tags' => ['client:123'],
'pixPaymentsActive' => true,
'bankSlipPaymentsActive' => true,
'bankSlipAvailableActive' => true,
]);
$list = Santander::workspaces()->listWorkspaces();
$one = Santander::workspaces()->getWorkspace('123456');
$updated = Santander::workspaces()->updateWorkspace('123456', [
'name' => 'Workspace API v2',
]);
$deleted = Santander::workspaces()->deleteWorkspace('123456');
$accounts = Santander::accounts()->listAccounts(['_limit' => 50]);
$balance = Santander::accounts()->getBalance('0000.000011112222');
$statement = Santander::accounts()->getStatement('0000.000011112222', [
'initialDate' => '2025-01-01',
'finalDate' => '2025-01-31',
'_limit' => 50,
'_offset' => 0,
]);
$accounts = Santander::accounts()->listAccounts(['_limit' => 50], '12345678000195');
$created = Santander::bankSlips()->createPayment($payload);
$confirmed = Santander::bankSlips()->confirmPayment($created['id'], ['status' => 'AUTHORIZED']);
$one = Santander::bankSlips()->getPayment($created['id']);
$list = Santander::bankSlips()->listPayments(['_limit' => 50]);
$dda = Santander::bankSlips()->listAvailableBankSlips([
'payerDocumentNumber' => '12345678000195',
]);
$created = Santander::barcodes()->createPayment($payload);
$confirmed = Santander::barcodes()->confirmPayment($created['id'], ['status' => 'AUTHORIZED']);
$one = Santander::barcodes()->getPayment($created['id']);
$list = Santander::barcodes()->listPayments(['_limit' => 50]);
$debts = Santander::vehicleTaxes()->listAvailableVehicleTaxes([
'renavam' => '12345678901',
]);
$created = Santander::vehicleTaxes()->createPayment($payload);
$confirmed = Santander::vehicleTaxes()->confirmPayment($created['id'], ['status' => 'AUTHORIZED']);
$one = Santander::vehicleTaxes()->getPayment($created['id']);
$list = Santander::vehicleTaxes()->listPayments(['_limit' => 50]);
$created = Santander::taxesByFields()->createPayment($payload);
$confirmed = Santander::taxesByFields()->confirmPayment($created['id'], ['status' => 'AUTHORIZED']);
$one = Santander::taxesByFields()->getPayment($created['id']);
$list = Santander::taxesByFields()->listPayments(['_limit' => 50]);
$created = Santander::pixAutomatic()->createLocation($payloadLocation);
$list = Santander::pixAutomatic()->listLocations([
'inicio' => '2025-03-27T00:00:00Z',
'fim' => '2025-03-28T23:59:59Z',
]);
$one = Santander::pixAutomatic()->getLocation('1001');
$unlink = Santander::pixAutomatic()->unbindLocation('2001', 'idRec');
$created = Santander::pixAutomatic()->createRecurrence($payloadRecurrence);
$list = Santander::pixAutomatic()->listRecurrences([
'inicio' => '2025-03-26T00:00:00Z',
'fim' => '2025-03-26T23:59:59Z',
]);
$one = Santander::pixAutomatic()->getRecurrence('RR904008882025021000000000001');
$updated = Santander::pixAutomatic()->updateRecurrence('RR904008882025021000000000001', $payloadUpdate);
$cancel = Santander::pixAutomatic()->cancelRecurrence('RR904008882025021000000000001', $payloadCancel);
$created = Santander::pixAutomatic()->createConfirmationRequest($payloadSolic);
$one = Santander::pixAutomatic()->getConfirmationRequest('SC904008882025031000000000201');
$review = Santander::pixAutomatic()->reviewConfirmationRequest('SC904008882025031000000000201', $payloadReview);
$created = Santander::pixAutomatic()->createRecurringCharge('txid123', $payloadCharge);
$review = Santander::pixAutomatic()->reviewRecurringCharge('txid123', $payloadReview);
$one = Santander::pixAutomatic()->getRecurringCharge('txid123');
$list = Santander::pixAutomatic()->listRecurringCharges([
'inicio' => '2025-04-25T00:00:00Z',
'fim' => '2025-04-26T23:59:59Z',
]);
$retry = Santander::pixAutomatic()->requestRecurringChargeRetry('txid123', '2025-04-30');
$cfgRec = Santander::pixAutomatic()->configureRecurrenceWebhook([
'webhookUrl' => 'https://sua-api.com/webhook/rec',
]);
$getRec = Santander::pixAutomatic()->getRecurrenceWebhook();
$delRec = Santander::pixAutomatic()->deleteRecurrenceWebhook();
$cfgCobr = Santander::pixAutomatic()->configureRecurringChargeWebhook([
'webhookUrl' => 'https://sua-api.com/webhook/cobr',
]);
$getCobr = Santander::pixAutomatic()->getRecurringChargeWebhook();
$delCobr = Santander::pixAutomatic()->deleteRecurringChargeWebhook();
use Santander\SDK\Exceptions\SantanderRequestError;
try {
$res = Santander::pix()->createPayment($payload);
} catch (SantanderRequestError $e) {
logger()->error('Santander request error', [
'status_code' => $e->getStatusCode(),
'content' => $e->getContent(),
'message' => $e->getMessage(),
]);
}
bash
php artisan vendor:publish --tag=santander-config