PHP code example of starkbank / sdk

1. Go to this page and download the library: Download starkbank/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/ */

    

starkbank / sdk example snippets


use StarkBank\Key;

list($privateKey, $publicKey) = Key::create();

# or, to also save .pem files in a specific path
list($privateKey, $publicKey) = Key::create("file/keys/");

use StarkBank\Project;

// Get your private key from an environment variable or an encrypted database.
// This is only an example of a private key content. You should use your own key.
$privateKeyContent = "
-----BEGIN EC PARAMETERS-----
BgUrgQQACg==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIMCwW74H6egQkTiz87WDvLNm7fK/cA+ctA2vg/bbHx3woAcGBSuBBAAK
oUQDQgAE0iaeEHEgr3oTbCfh8U2L+r7zoaeOX964xaAnND5jATGpD/tHec6Oe9U1
IF16ZoTVt1FzZ8WkYQ3XomRD4HS13A==
-----END EC PRIVATE KEY-----
";

$project = new Project([
    "environment" => "sandbox",
    "id" => "5656565656565656",
    "privateKey" => $privateKeyContent
]);

use StarkBank\Organization;

// Get your private key from an environment variable or an encrypted database.
// This is only an example of a private key content. You should use your own key.
privateKeyContent = "
-----BEGIN EC PARAMETERS-----
BgUrgQQACg==
-----END EC PARAMETERS-----
-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIMCwW74H6egQkTiz87WDvLNm7fK/cA+ctA2vg/bbHx3woAcGBSuBBAAK
oUQDQgAE0iaeEHEgr3oTbCfh8U2L+r7zoaeOX964xaAnND5jATGpD/tHec6Oe9U1
IF16ZoTVt1FzZ8WkYQ3XomRD4HS13A==
-----END EC PRIVATE KEY-----
";

$organization = new Organization([
    "environment" => "sandbox",
    "id" => "5656565656565656",
    "privateKey" => $privateKeyContent,
    "workspaceId" => null // You only need to set the workspaceId when you are operating a specific workspaceId
]);

// To dynamically use your organization credentials in a specific workspaceId,
// you can use the Organization::replace() method:
$balance = Balance::get(Organization::replace($organization, "4848484848484848"));

use StarkBank\Balance;

$balance = Balance::get($project);  # or organization

use StarkBank\Settings;
use StarkBank\Balance;

Settings::setUser($project);  # or organization

$balance = Balance::get();

use StarkBank\Settings;

Settings::setLanguage("en-US");

use StarkBank\Transaction;

$transactions = Transaction::query([
    "after" => "2020-01-01",
    "before" => "2020-03-01"
]);

foreach($transactions as $transaction){
    print_r($transaction);
}

use StarkBank\Transaction;

$cursor = null;
while (true) { 
    list($page, $cursor) = Transaction::page($options = ["limit" => 5, "cursor" => $cursor]);
    foreach ($page as $transaction) {
        print_r($transaction);
    }
    if ($cursor == null) {
        break;
    }
}

use StarkBank\Transaction;

$transactions = Transaction::create([
    new Transaction([
        "amount" => 100,  # (R$ 1.00)
        "receiverId" => "1029378109327810",
        "description" => "Transaction to dear provider",
        "externalId" => "12345",  # so we can block anything you send twice by mistake
        "tags" => ["provider"]
    ]),
    new Transaction([
        "amount" => 234,  # (R$ 2.34)
        "receiverId" => "2093029347820947",
        "description" => "Transaction to the other provider",
        "externalId" => "12346",  # so we can block anything you send twice by mistake
        "tags" => ["provider"]
    ]),
]);

foreach($transactions as $transaction){
    print_r($transaction);
}

use StarkBank\Transaction;

$transactions = Transaction::query([
    "after" => "2020-01-01",
    "before" => "2020-03-01"
]);

foreach($transactions as $transaction){
    print_r($transaction);
}

use StarkBank\Transaction;

$transaction = Transaction::get("5155165527080960");

print_r($transaction);

use StarkBank\Balance;

$balance = Balance::get();

print_r($balance);

use StarkBank\Transfer;

$transfers = Transfer::create([
    new Transfer([
        "amount" => 100,
        "bankCode" => "033",  # TED
        "branchCode" => "0001",
        "accountNumber" => "10000-0",
        "taxId" => "012.345.678-90",
        "name" => "Tony Stark",
        "tags" => ["iron", "suit"]
    ]),
    new Transfer([
        "amount" => 200,
        "bankCode" => "20018183",  # Pix
        "branchCode" => "1234",
        "accountNumber" => "123456-7",
        "accountType" => "salary",
        "externalId" => "my-internal-id-12345",
        "taxId" => "012.345.678-90",
        "name" => "Jon Snow",
        "scheduled" => (new DateTime("now"))->add(new DateInterval("P1D")),
        "description" => "Transaction to dear provider",
        "tags" => [],
        "rules" => [
            new Transfer\Rule([
                "key" => "resendingLimit",  # Set maximum number of retries if Transfer fails due to systemic issues at the receiver bank
                "value" => 5                # Our resending limit is 10 by default
            ])
        ]
    ])
]);

foreach($transfers as $transfer){
    print_r($transfer);
}

use StarkBank\Transfer;

$transfers = Transfer::query([
    "after" => "2020-01-01",
    "before" => "2020-04-01"
]);

foreach($transfers as $transfer){
    print_r($transfer->name);
}

use StarkBank\Transfer;

$transfer = Transfer::get("5155165527080960");

print_r($transfer);

use StarkBank\Transfer;

$transfer = Transfer::delete("5155165527080960");

print_r($transfer);

use StarkBank\Transfer;

$pdf = Transfer::pdf("5155165527080960");

$fp = fopen('transfer.pdf', 'w');
fwrite($fp, $pdf);
fclose($fp);

use StarkBank\Transfer;

$logs = Transfer\Log::query(["limit" => 50]);

foreach($logs as $log){
    print_r($log->id);
}

use StarkBank\Transfer;

$log = Transfer\Log::get("5155165527080960");

print_r($log);

use StarkBank\DictKey;

$dictKey = DictKey::get();

print_r($dictKey);

use StarkBank\DictKey;

$dictKeys = iterator_to_array(DictKey::query(["limit" => 1, "type" => "evp", "status" => "registered"]));

foreach($dictKeys as $dictKey) {
    print_r($dictKey);
}

use StarkBank\Institution;

$institutions = Institution::query(["search" => "stark"]);

foreach($institutions as $institution){
    print_r($institution);
}

use StarkBank\Invoice;

$invoices = [
    new Invoice([
        "amount" => 400000,
        "due" => ((new DateTime("now"))->add(new DateInterval("P5D"))),
        "taxId" => "012.345.678-90",
        "name" => "Mr Meeseks",
        "expiration" => new DateInterval("P2D"),
        "fine" => 2.5,
        "interest" => 1.3,
        "discounts" => [
            [
                "percentage" => 5,
                "due" => ((new DateTime("now"))->add(new DateInterval("P1D")))
            ],
            [
                "percentage" => 3,
                "due" => ((new DateTime("now"))->add(new DateInterval("P2D")))
            ]
        ],
        "rules" => [
            new Invoice\Rule([
                "key" => "allowedTaxIds",       # Set TaxIds allowed to receive this Invoice
                "value" => [
                    "012.345.678-90"
                ]
            ])
        ],
        "tags" => [
            'War supply',
            'Invoice #1234'
        ],
        "descriptions" => [
            [
                "key" => "product A",
                "value" => "big"
            ],
            [
                "key" => "product B",
                "value" => "medium"
            ],
            [
                "key" => "product C",
                "value" => "small"
            ]
        ],
    ])
];

$invoice = Invoice::create($invoices)[0];

print_r($invoice);

use StarkBank\Invoice;

$invoice = Invoice::get("5656565656565656");

print_r($invoice);

use StarkBank\Invoice;

$png = Invoice::qrcode("5881614903017472");

$fp = fopen('qrcode.png', 'w');
fwrite($fp, $png);
fclose($fp);

use StarkBank\Invoice;

$pdf = Invoice::pdf("5656565656565656");

$fp = fopen('invoice.pdf', 'w');
fwrite($fp, $pdf);
fclose($fp);

use StarkBank\Invoice;

$invoice = Invoice::update("5656565656565656", ["status" => "canceled"]);

print_r($invoice);

use StarkBank\Invoice;

$updatedInvoice = Invoice::update(
    "5656565656565656",
    [
        "amount" => 4321,
        "due" => (new DateTime("now"))->add(new DateInterval("P5D")),
        "expiration" => 123456789
    ]
);

print_r($updatedInvoice);

use StarkBank\Invoice;

$invoices = iterator_to_array(Invoice::query(["limit" => 10, "before" => new DateTime("now")]));

foreach($invoices as $invoice) {
    print_r($invoice);
}

use StarkBank\Invoice\Log;

$pdf = Log::pdf("5155165527080960");

$fp = fopen('invoice-log.pdf', 'w');
fwrite($fp, $pdf);
fclose($fp);

use StarkBank\Invoice;

$paymentInformation = Invoice::payment("5656565656565656");

print_r($paymentInformation);

use StarkBank\Invoice\Log;

$invoiceLogs = iterator_to_array(Log::query(["limit" => 10, "types" => ["created"]]));

foreach($invoiceLogs as $log) {
    print_r($log);
}

use StarkBank\Invoice\Log;

$invoiceLog = Log::get("5656565656565656");

print_r($invoice);

use StarkBank\DynamicBrcode;

$brcodes = DynamicBrcode::create([
    new DynamicBrcode([
        "amount" => 23571,  # R$ 235,71 
        "expiration" => 12345
    ]),
    new DynamicBrcode([
        "amount" => 23571,  # R$ 235,71 
        "expiration" => 12345
    ])
]);

foreach($brcodes as $brcode) {
    print_r($brcode);
}

use StarkBank\DynamicBrcode;

$brcode = DynamicBrcode::get("e09e6c5293a5485d9777cc29582e3ecf");

print_r($brcode);

use StarkBank\DynamicBrcode;

$brcodes = iterator_to_array(DynamicBrcode::query(
    [
        "limit" => 10, 
        "after" => "2023-01-01",
        "before" => "2023-01-30",
    ]
));

foreach($brcodes as $brcode) {
    print_r($brcode);
}

use StarkBank\Deposit;

$deposits = iterator_to_array(Deposit::query(["limit" => 10, "before" => new DateTime("now")]));

foreach($deposits as $deposit) {
    print_r($deposit);
}

use StarkBank\Deposit;

$deposit = Deposit::get("5656565656565656");

print_r($deposit);

use StarkBank\Deposit

$updatedDeposit = Deposit::update(
    "5656565656565656",
    [
        "amount" => 4321
    ]
);

print_r($updatedDeposit);

use StarkBank\Deposit\Log;

$depositLogs = iterator_to_array(Log::query(["limit" => 10, "types" => ["created"]]));

foreach($depositLogs as $log) {
    print_r($log);
}

use StarkBank\Deposit\Log;

$depositLog = Log::get("5656565656565656");

print_r($deposit);

use StarkBank\Boleto;


$boletos = Boleto::create([
    new Boleto([
        "amount" => 23571,  # R$ 235,71
        "name" => "Buzz Aldrin",
        "taxId" => "012.345.678-90",
        "streetLine1" => "Av. Paulista, 200",
        "streetLine2" => "10 andar",
        "district" => "Bela Vista",
        "city" => "São Paulo",
        "stateCode" => "SP",
        "zipCode" => "01310-000",
        "due" => (new DateTime("now"))->add(new DateInterval("P30D")),
        "fine" => 5,  # 5%
        "interest" => 2.5  # 2.5% per month
    ])
]);

foreach($boletos as $boleto){
    print_r($boleto);
}

use StarkBank\Boleto;

$boleto = Boleto::get("5155165527080960");

print_r($boleto);

use StarkBank\Boleto;

$pdf = Boleto::pdf("5155165527080960", ["layout" => "default"]);

$fp = fopen('boleto.pdf', 'w');
fwrite($fp, $pdf);
fclose($fp);

use StarkBank\Boleto;

$boleto = Boleto::delete("5155165527080960");

print_r($boleto);

use StarkBank\Boleto;

$boletos = Boleto::query([
    "after" => "2020-01-01",
    "before" => (new DateTime("now"))->add(new DateInterval("P1D"))
]);

foreach($boletos as $boleto){
    print_r($boleto);
}

use StarkBank\Boleto;

$logs = Boleto\Log::query(["limit" => 150]);

foreach($logs as $log){
    print_r($log);
}

use StarkBank\Boleto;

$log = Boleto\Log::get("5155165527080960");

print_r($log);

use StarkBank\BoletoHolmes;

$holmes = [new BoletoHolmes([
    "boletoId" => "5976467733217280"
])];

$sherlock = BoletoHolmes::create($holmes)[0];

foreach($holmes as $sherlock){
    print_r($sherlock);
}

use StarkBank\BoletoHolmes;
$sherlock = Boleto::get("5976467733217280");
print_r($sherlock)

use StarkBank\BoletoHolmes;
$holmes = iterator_to_array(Boleto::query(["limit" => 10, "before" => new DateTime("now")]));

foreach($holmes as $sherlock){
    print_r($sherlock);
}

use StarkBank\BoletoHolmes\Log;
$logs = iterator_to_array(Log::query(["limit" => 10, "types" => ["solving"]]));

foreach($logs as $log){
    print_r($log);
}

use StarkBank\BoletoHolmes\Log;
$log = Log::get("5976467733217280");
print_r($log)

use StarkBank\BrcodePayment;

$payments = BrcodePayment::create([
    new BrcodePayment([
        "brcode" => "00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5908T'Challa6009Sao Paulo62090505123456304B14A",
        "taxId" => "20.018.183/0001-80",
        "description" => "Tony Stark's Suit",
        "amount" => 7654321,
        "scheduled" => (new DateTime("now"))->add(new DateInterval("P5D")),
        "tags" => ["Stark", "Suit"],
        "rules" => [
            new BrcodePayment\Rule([
                "key" => "resendingLimit",  # Set maximum number of retries if BrcodePayment fails due to systemic issues at the receiver bank
                "value" => 5                # Our resending limit is 10 by default
            ])
        ]
    ])
]);

foreach($payments as $payment){
    print_r($payment);
}

use StarkBank\BrcodePayment;

$payment = BrcodePayment::get("19278361897236187236");

print_r($payment);

use StarkBank\BrcodePayment;

$pdf = BrcodePayment::pdf("5155165527080960");

$fp = fopen('brcodePayment.pdf', 'w');
fwrite($fp, $pdf);
fclose($fp);

use StarkBank\BrcodePayment;

$payments = BrcodePayment::query([
    "tags" => ["company_1", "company_2"]
]);

foreach($payments as $payment){
    print_r($payment);
}

use StarkBank\BrcodePayment;

$logs = BrcodePayment\Log::query([
    "paymentIds" => ["5155165527080960", "76551659167801921"],
]);

foreach($logs as $log){
    print_r($log);
}

use StarkBank\BrcodePayment;

$log = BrcodePayment\Log::get("5155165527080960");

print_r($log);

use StarkBank\BoletoPayment;

$payments = BoletoPayment::create([
    new BoletoPayment([
        "line" => "34191.09008 64694.017308 71444.640008 1 96610000014500",
        "taxId" => "012.345.678-90",
        "scheduled" => (new DateTime("now"))->add(new DateInterval("P2D")),
        "description" => "take my money",
        "tags" => ["take", "my", "money"],
    ]),
    new BoletoPayment([
        "barCode" => "34191972300000289001090064694197307144464000",
        "taxId" => "012.345.678-90",
        "scheduled" => (new DateTime("now"))->add(new DateInterval("P1D")),
        "description" => "take my money one more time",
        "tags" => ["again"],
    ]),
]);

foreach($payments as $payment){
    print_r($payment);
}

use StarkBank\BoletoPayment;

$payment = BoletoPayment::get("19278361897236187236");

print_r($payment);

use StarkBank\BoletoPayment;

$pdf = BoletoPayment::pdf("5155165527080960");

$fp = fopen('boletoPayment.pdf', 'w');
fwrite($fp, $pdf);
fclose($fp);

use StarkBank\BoletoPayment;

$payment = BoletoPayment::delete("5155165527080960");

print_r($payment);

use StarkBank\BoletoPayment;

$payments = BoletoPayment::query([
    "tags" => ["company_1", "company_2"]
]);

foreach($payments as $payment){
    print_r($payment);
}

use StarkBank\BoletoPayment;

$logs = BoletoPayment\Log::query([
    "paymentIds" => ["5155165527080960", "76551659167801921"],
]);

foreach($logs as $log){
    print_r($log);
}

use StarkBank\BoletoPayment;

$log = BoletoPayment\Log::get("5155165527080960");

print_r($log);

use StarkBank\UtilityPayment;

$payments = UtilityPayment::create([
    new UtilityPayment([
        "line" => "83680000001 7 08430138003 0 71070987611 8 00041351685 7",
        "scheduled" => (new DateTime("now"))->add(new DateInterval("P2D")),
        "description" => "take my money",
        "tags" => ["take", "my", "money"],
    ]),
    new UtilityPayment([
        "barCode" => "83600000001522801380037107172881100021296561",
        "scheduled" => (new DateTime("now"))->add(new DateInterval("P1D")),
        "description" => "take my money one more time",
        "tags" => ["again"],
    ]),
]);

foreach($payments as $payment){
    print_r($payment);
}

use StarkBank\UtilityPayment;

$payments = UtilityPayment::query([
    "tags" => ["electricity", "gas"]
]);

foreach($payments as $payment){
    print_r($payment);
}

use StarkBank\UtilityPayment;

$payment = UtilityPayment::get("5155165527080960");

print_r($payment);

use StarkBank\UtilityPayment;

$pdf = UtilityPayment::pdf("5155165527080960");

$fp = fopen('electricity.pdf', 'w');
fwrite($fp, $pdf);
fclose($fp);

use StarkBank\UtilityPayment;

$payment = UtilityPayment::delete("5155165527080960");

print_r($payment);

use StarkBank\UtilityPayment;

$logs = UtilityPayment\Log::query([
    "paymentIds" => ["102893710982379182", "92837912873981273"],
]);

foreach($logs as $log){
    print_r($log);
}

use StarkBank\UtilityPayment;

$log = UtilityPayment\Log::get("1902837198237992");

print_r($log);

use StarkBank\TaxPayment;

$payments = [
    new TaxPayment([
        "barCode" => "85660000001549403280074119002551100010601813",
        "description" => "33ff6f90de30c7f60526dbe6a1bb3d0cd1f751c89a2fc9a8aad087d4efdc0bce",
        "tags" => ["test2"],
        "scheduled" => "2021-07-13"
    ])];
$payments = TaxPayment::create($payment);
foreach($payments as $payment){
    print_r($payment);
}

use StarkBank\TaxPayment;

$payments = iterator_to_array(TaxPayment::query(["limit" => 10]));

print_r($payments);

use StarkBank\TaxPayment;

$payment = TaxPayment::get("5155165527080960");

print_r($payment);

use StarkBank\TaxPayment;

$pdf = TaxPayment::pdf("5155165527080960");

$fp = fopen('taxPayment.pdf', 'w');
fwrite($fp, $pdf);
fclose($fp);

use StarkBank\TaxPayment;

$payment = TaxPayment::delete("5155165527080960");

print_r($payment);

use StarkBank\TaxPayment\Log;

$paymentLogs = iterator_to_array(Log::query(["limit" => 10, "types" => ["created"]]));

print_r($paymentLogs);

use StarkBank\TaxPayment\Log;

$paymentLog = Log::get("1902837198237992");

print_r($paymentLog);

use StarkBank\DarfPayment;
use \DateTime;
use \DateInterval;

$payments = [
    new DarfPayment([
        "description" => "Darf Payment Example",
        "tags" => ["Darf"],
        "due" => "2023-02-08",
        "competence" => "2020-04-03",
        "fineAmount" => 100,
        "interestAmount" => 100,
        "nominalAmount" => 1000,
        "revenueCode" => "0201",
        "taxId" => "45678350005",
        "scheduled" => "2023-02-05",
    ])];
$payments = DarfPayment::create($payment);
foreach($payments as $payment){
    print_r($payment);
}

use StarkBank\DarfPayment;

$payments = iterator_to_array(DarfPayment::query(["limit" => 10]));

print_r($payments);

use StarkBank\DarfPayment;

$payment = DarfPayment::get("5155165527080960");

print_r($payment);

use StarkBank\DarfPayment;

$pdf = DarfPayment::pdf("5155165527080960");

$fp = fopen('darfPayment.pdf', 'w');
fwrite($fp, $pdf);
fclose($fp);

use StarkBank\DarfPayment;

$paymentLog = Log::get("1902837198237992");

print_r($paymentLog);

use StarkBank\DarfPayment\Log;

$paymentLogs = iterator_to_array(Log::query(["limit" => 10, "types" => ["created"]]));

print_r($paymentLogs);

use StarkBank\DarfPayment\Log;

$paymentLog = Log::get("1902837198237992");

print_r($paymentLog);

use StarkBank\PaymentPreview;

$previews = PaymentPreview::create([
    new PaymentPreview(["id" => "00020126580014br.gov.bcb.pix0136a629532e-7693-4846-852d-1bbff817b5a8520400005303986540510.005802BR5908T'Challa6009Sao Paulo62090505123456304B14A", "scheduled" => "2021-02-10"]),
    new PaymentPreview(["id" => "34191.09008 61207.727308 71444.640008 5 81310001234321"])
]);
foreach ($previews as $preview) {
    print_r($preview);
}

use StarkBank\PaymentRequest;


$requests = PaymentRequest::create([
    new PaymentRequest([
        "centerId" => "5967314465849344",
        "payment" => new Transfer([
            "amount" => 100,
            "bankCode" => "033",
            "branchCode" => "0001",
            "accountNumber" => "10000-0",
            "taxId" => "012.345.678-90",
            "name" => "Tony Stark",
            "tags" => ["iron", "suit"]
        ]),
        "due" => (new DateTime("now"))->add(new DateInterval("P30D"))
    ])
]);

foreach($requests as $request){
    print_r($request);
}

use StarkBank\PaymentRequest;

$requests = PaymentRequest::query(["centerId" => "5967314465849344", "limit" => 10]);

foreach($requests as $request){
    print_r($request);
}

use StarkBank\CorporateHolder;

$holders = CorporateHolder::create([
    new CorporateHolder([
        "name" => "Iron Bank S.A.",
        "tags" => [
            "Traveler Employee"
        ],
        "permissions" => [
                    new CorporateHolder\Permission([
                        'ownerType' => 'project',
                        'ownerId' => $_SERVER["SANDBOX_ID"],
                    ])
                ],
        "rules" => [
            new StarkBank\CorporateRule([
                "name" => "General USD",
                "interval" => "day",
                "amount" => 100000,
                "currencyCode" => "USD",
                "schedule" => "every monday, wednesday from 00:00 to 23:59 in America/Sao_Paulo"
            ])
        ]
    ]),
]);

foreach ($holders as $holder) {
    print_r($holder);
}

use StarkBank\CorporateHolder;

$holders = CorporateHolder::query();

foreach ($holders as $holder) {
    print_r($holder);
}

use StarkBank\CorporateHolder;

$holder = CorporateHolder::cancel("5155165527080960");

print_r($holder);

use StarkBank\CorporateHolder;

$holder = CorporateHolder::get("5155165527080960");

print_r($holder);

use StarkBank\CorporateHolder;

$logs = CorporateHolder\Log::query(["limit" => 50]);

foreach ($logs as $log) {
    print_r($log);
}

use StarkBank\CorporateHolder;

$log = CorporateHolder\Log::get("5155165527080960");

print_r($log);

use StarkBank\CorporateCard;

$cards = CorporateCard::create(
    new CorporateCard(
        "holdeId" => "5155165527080960",
    ),
);

foreach ($cards as $card) {
    print_r($card);
}

use StarkBank\CorporateCard;

$cards = CorporateCard::query([
    "after" => "2020-01-01",
    "before" => "2020-03-01"
]);

foreach ($cards as $card) {
    print_r($card);
}

use StarkBank\CorporateCard;

$card = CorporateCard::get("5155165527080960");

print_r($card);

use StarkBank\CorporateCard;

$card = CorporateCard::update("5155165527080960", ["status" => "blocked"]);

print_r($card);
sh
php
use StarkBank\CorporateCard;

$card = CorporateCard::cancel("5155165527080960");

print_r($card);
php
use StarkBank\CorporateCard;

$logs = CorporateCard\Log::query(["limit" => 150]);

foreach ($logs as $log) {
    print_r($log);
}
php
use StarkBank\CorporatePurchase;

$purchases = CorporatePurchase::query([
    "after" => "2020-01-01",
    "before" => "2020-03-01"
]);

foreach ($purchases as $purchase) {
    print_r($purchase);
}
php
use StarkBank\CorporatePurchase;

$logs = CorporatePurchase\Log::query(["limit" => 150]);

foreach($logs as $log) {
    print_r($log);
}
php
use StarkBank\CorporateInvoice;

$invoices = CorporateInvoice::create(
    new CorporateInvoice([
        "amount" => 1000
    ])
);

foreach ($invoices as $invoice) {
    print_r($invoice);
}
php
use StarkBank\CorporateInvoice;

$invoices = CorporateInvoice::query(
    "after" => "2020-01-01",
    "before" => "2020-03-01"
);

foreach ($invoices as $invoice) {
    print_r($invoice);
}
php
use StarkBank\CorporateWithdrawal;

$withdrawals = CorporateWithdrawal::create(
    new CorporateWithdrawal([
        "amount" => 10000.
        "externalId" => "123",
        "description" => "Sending back"
    ])
);

foreach ($withdrawals as $withdrawal) {
    print_r($withdrawal);
}
php
use StarkBank\CorporateWithdrawal;

$withdrawals = CorporateWithdrawal::query(
    "after" => "2020-01-01",
    "before" => "2020-03-01"
);

foreach ($withdrawals as $withdrawal) {
    print_r($withdrawal);
}
php
use StarkBank\CorporateTransaction;

$transactions = CorporateTransaction::query([
    "after" => "2020-01-01",
    "before" => "2020-03-01"
]);

foreach ($transactions as $transaction) {
    print_r($transaction);
}
php
use StarkBank\MerchantCategory;

$categories = MerchantCategory::query([
    "search" => "food"
]);

foreach ($categories as $category) {
    print_r($category);
}
php
use StarkBank\MerchantCountry;

$countries = MerchantCountry::query([
    "search" => "brazil"
]);

foreach ($countries as $country) {
    print_r($country);
}
php
use StarkBank\CardMethod;

$methods = CardMethod::query([
    "search" => "token"
]);

foreach ($methods as $method) {
    print_r($method);
}
php
use StarkBank\Split;

$splits = iterator_to_array(Split::query(["limit" => 10, "before" => new DateTime("now")]));

foreach ($splits as $split) {
    print_r($split);
}
php
use StarkBank\Split;

$split = Split::get("5155165527080960");
print_r($split);
php
use StarkBank\Split\Log;

$logs = iterator_to_array(Log::query(["limit" => 10, splitIds=>["5155165527080960", "76551659167801921"]]));

foreach ($logs as $log) {
    print_r($log);
}
php
use StarkBank\SplitReceiver;

$receivers = iterator_to_array(SplitReceiver::query(["limit" => 10, "before" => new DateTime("now")]));

foreach ($receivers as $receiver) {
    print_r($receiver);
}
php
use StarkBank\SplitReceiver\Log;

$logs = iterator_to_array(Log::query(["limit" => 10, receiverIds=>["5155165527080960", "76551659167801921"]]));

foreach ($logs as $log) {
    print_r($log);
}
php
use StarkBank\SplitProfile;

$profile = [    
            new SplitProfile([
                "interval"=> "day",
                "delay"=> 0,
                "tags"= ["john", "snow"]
            ]),
        ];
$profile = SplitProfile::put($profile);

print_r($profile)
php
use StarkBank\SplitProfile;

$profiles = iterator_to_array(SplitProfile::query(["limit" => 10, "before" => new DateTime("now")]));

foreach ($profiles as $profile) {
    print_r($profile);
}
php
use StarkBank\SplitProfile\Log;

$logs = iterator_to_array(Log::query(["limit" => 10]));

foreach ($logs as $log) {
    print_r($log);
}
php
use StarkBank\Webhook;

$webhooks = Webhook::query();

foreach($webhooks as $webhook){
    print_r($webhook);
}
php
use StarkBank\Event;

$response = listen()  # this is the method you made to get the events posted to your webhook

$event = Event::parse($response->content, $response->headers["Digital-Signature"]);

if ($event->subscription == "transfer"){
    print_r($event->log->transfer);
} elseif ($event->subscription == "deposit"){
    print_r($event->log->deposit);
} elseif ($event->subscription == "invoice"){
    print_r($event->log->invoice);
} elseif ($event->subscription == "brcode-payment"){
    print_r($event->log->payment);
} elseif ($event->subscription == "boleto"){
    print_r($event->log->boleto);
} elseif ($event->subscription == "boleto-payment"){
    print_r($event->log->payment);
} elseif ($event->subscription == "utility-payment"){
    print_r($event->log->payment);
} elseif ($event->subscription == "tax-payment"){
    print_r($event->log->payment);
}
php
use StarkBank\Event;

$events = Event::query(["after" => "2020-03-20", "isDelivered" => false]);

foreach($events as $event){
    print_r($event);
}
php
use StarkBank\Event;

$event = Event::update("129837198237192", ["isDelivered" => true]);

print_r($event);
php
use StarkBank\Event\Attempt;

$attempts = Attempt::query(["eventIds" => $event->id, "limit" => 1]);

foreach($attempts as $attempt){
    print_r($attempt);
}
php
use StarkBank\Workspace;

$workspaces = Workspace::query(["limit" => 30]);

foreach($workspaces as $workspace){
    print_r($workspace);
}
php
use StarkBank\Request;

$query = [
    "limit" => 10,
    "status" => "paid"
]
$request = Request::get(
    "invoice/log/5155165527080960",
    $query
    )->json();

print_r($request);
php
use StarkBank\Request;

$query = [
    "limit" => 10,
    "status" => "created"
]
$request = Request::get(
    "invoice/log/5155165527080960",
    $query
    )->json();

print_r($request);
php
use StarkBank\Request;

$request = Request::get(
    "invoice/log/5155165527080960/pdf",
    )->content;

$fp = fopen('invoice.pdf', 'w');
fwrite($fp, $request);
fclose($fp);
php
use StarkBank\Request;

$data = [
    "profiles" =>[
        [
            "interval" => "day",
            "delay" => 0
        ]
    ]
];

$request = Request::put(
    "split-profile",
    $data
)->json();

print_r($request)
php
use StarkBank\Transaction;
use StarkBank\Error\InputErrors;

try {
    $transactions = Transaction::create([
        new Transaction([
            "amount" => 99999999999999,  # (R$ 999,999,999,999.99)
            "receiverId" => "1029378109327810",
            "description" => ".",
            "externalId" => "12345",  # so we can block anything you send twice by mistake
            "tags" => ["provider"]
        ]),
    ]);
} catch (InputErrors $e) {
    foreach($e->errors as $error){
        echo "\n\ncode: " . $error->errorCode;
        echo "\nmessage: " . $error->errorMessage;
    }
}