PHP code example of starkinfra / sdk

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

    

starkinfra / sdk example snippets


use StarkInfra;

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

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

use StarkInfra;

// 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 StarkInfra\Project([
    "environment" => "sandbox",
    "id" => "5656565656565656",
    "privateKey" => $privateKeyContent
]);

use StarkInfra;

// 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 StarkInfra\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 = StarkInfra\IssuingBalance::get(StarkInfra\Organization::replace($organization, "4848484848484848"));

use StarkInfra;

$balance = StarkInfra\IssuingBalance::get($project);  # or organization

use StarkInfra;

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

$balance = StarkInfra\IssuingBalance::get();  # or organization

use StarkInfra;

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

use StarkInfra;

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

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

use StarkInfra;

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

use StarkInfra\IssuingProduct;

$products = IssuingProduct::query();

foreach ($products as $product) {
    print_r($product);
}

use StarkInfra\IssuingHolder;

$holders = IssuingHolder::create([
    new IssuingHolder([
        "name" => "Iron Bank S.A.",
        "taxId" => "012.345.678-90",
        "externalId" => "1234",
        "tags" => [
            "Traveler Employee"
        ],
        "rules" => [
            new StarkInfra\IssuingRule([
                "name" => "General USD",
                "interval" => "day",
                "amount" => 100000,
                "currencyCode" => "USD"
            ])
        ]
    ]),
]);

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

use StarkInfra\IssuingHolder;

$holders = IssuingHolder::query();

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

use StarkInfra\IssuingHolder;

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

print_r($holder);

use StarkInfra\IssuingHolder;

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

print_r($holder);

use StarkInfra\IssuingHolder;

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

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

use StarkInfra\\IssuingHolder;

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

print_r($log);

use StarkInfra\IssuingCard;

$cards = IssuingCard::create([
    new IssuingCard([
        "holdeNname" => "Developers",
        "holderTaxId" => "012.345.678-90",
        "holderExternalId" => "1234",
        "rules" => [
            new StarkInfra\IssuingRule([
                "name" => "general",
                "interval" => "week",
                "amount" => 50000,
                "currencyCode" => "USD"
            ])
        ]
    ]),
]);

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

use StarkInfra\IssuingCard;

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

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

use StarkInfra\IssuingCard;

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

print_r($card);

use StarkInfra\IssuingCard;

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

print_r($card);

use StarkInfra\IssuingCard;

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

print_r($card);

use StarkInfra\IssuingCard;

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

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

use StarkInfra\IssuingCard;

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

print_r($log);

use StarkInfra\IssuingDesign;

$designs = IssuingDesign::query(["limit" => 1]);

foreach ($designs as $design) {
    print_r($design);
}

use StarkInfra\IssuingDesign;

$design = IssuingDesign::get("5155165527080960");

print_r($design);

use StarkInfra\IssuingEmbossingKit;

$kits = IssuingEmbossingKit::query([
    "after" => "2022-11-01",
    "before" => "2022-12-01"
]);

foreach ($kits as $kit) {
    print_r($kit);
}

use StarkInfra\IssuingEmbossingKit;

$kit = IssuingEmbossingKit::get("5155165527080960");

print_r($kit);

use StarkInfra\IssuingStock;

$stocks = IssuingStock::query(["limit" => 1]);

foreach ($stocks as $stock) {
    print_r($stock);
}

use StarkInfra\IssuingStock;

$stock = IssuingStock::get("5155165527080960");

print_r($stock);

use StarkInfra\IssuingStock;

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

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

use StarkInfra\IssuingStock;

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

print_r($log);

use StarkInfra\IssuingRestock;

$restocks = IssuingRestock::create([
    new IssuingRestock([
        "count" => 100,
        "stockId" => "5136459887542272"
    ]),
]);

foreach ($restocks as $restock) {
    print_r($restock);
}

use StarkInfra\IssuingRestock;

$restocks = IssuingRestock::query(["limit" => 1]);

foreach ($restocks as $restock) {
    print_r($restock);
}

use StarkInfra\IssuingRestock;

$restock = IssuingRestock::get("5664445921492992");
    
print_r($restock);

use StarkInfra\IssuingRestock;

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

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

use StarkInfra\IssuingRestock;

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

print_r($log);

use StarkInfra\IssuingEmbossingRequest;

$requests = IssuingEmbossingRequest::create([
    new IssuingEmbossingRequest([
        "kitId" => "5648359658356736", 
        "cardId" => "5714424132272128", 
        "displayName1" => "Antonio Stark", 
        "shippingCity" => "Sao Paulo",
        "shippingCountryCode" => "BRA",
        "shippingDistrict" => "Bela Vista",
        "shippingService" => "loggi",
        "shippingStateCode" => "SP",
        "shippingStreetLine1" => "Av. Paulista, 200",
        "shippingStreetLine2" => "10 andar",
        "shippingTrackingNumber" => "My_custom_tracking_number",
        "shippingZipCode" => "12345-678",
        "embosserId" => "5746980898734080"
    ])
]);

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

use StarkInfra\IssuingEmbossingRequest;

$requests = IssuingEmbossingRequest::query(["limit" => 10]);

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

use StarkInfra\IssuingEmbossingRequest;

$request = IssuingEmbossingRequest::get("5664445921492992");
    
print_r($request);

use StarkInfra\IssuingEmbossingRequest;

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

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

use StarkInfra\IssuingEmbossingRequest;

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

print_r($log);

use StarkInfra\IssuingTokenRequest;

$requests = IssuingTokenRequest::create([
    new IssuingTokenRequest([
        "cardId" => "5189831499972623", 
        "walletId" => "google", 
        "methodCode" => "app"
    ])
]);

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

use StarkInfra\IssuingToken;

$request = listen();  # this is your handler to listen for authorization requests

$token = IssuingToken::parse(
    $request->content, 
    $request->headers["Digital-Signature"]
);

# after parsing you should analyse the authorization request and then respond

# To approve:
sendResponse(  # you should also implement this method to respond the read request
    IssuingToken::response([
        "status" => "approved",
        "activation_methods" =>[
            {
                "type" => "app",
                "value" => "com.subissuer.android"
            },
            {
                "type" => "text",
                "value" => "** *****-5678"
            }
        ],
        "designId" => "4584031664472031",
        "tags" => ["token", "user/1234"]
    ]);
);

# To deny:
sendResponse(  # you should also implement this method to respond the read request
    IssuingToken::response([
        "status" => "denied",
        "reason" => "other",
    ]);
);

use StarkInfra\IssuingToken;

$request = listen();  # this is the method you made to get the events posted to your tokenAuthorizationUrl endpoint

$token = IssuingToken::parse(
    $request->content, 
    $request->headers["Digital-Signature"]
);

use StarkInfra\IssuingToken;

$request = listen();  # this is the method you made to get the events posted to your tokenAuthorizationUrl endpoint

sendResponse(  # you should also implement this method to respond the read request
    IssuingToken::response([
        "status" => "approved",
        "tags" => ["token", "user/1234"]
    ]);
);

# To deny:
sendResponse(  # you should also implement this method to respond the read request
    IssuingToken::response([
        "status" => "denied",
        "reason" => "other",
        "tags" => ["token", "user/1234"]
    ]);
);

use StarkInfra\IssuingToken;

$token = IssuingToken::get("5749080709922816");
    
print_r($token);

use StarkInfra\IssuingToken;

$tokens = IssuingToken::query(["limit" => 10]);

foreach ($tokens as $token) {
    print_r($token);
}

use StarkInfra\IssuingToken;

$token = IssuingToken::update(
    "5155165527080960",
    "status" => "blocked"
);

print_r($token);

use StarkInfra\IssuingToken;

$token = IssuingToken::cancel("5155165527080960");

print_r($token);

use StarkInfra\IssuingTokenDesign;

$design = IssuingTokenDesign::get("5749080709922816");
    
print_r($design);

use StarkInfra\IssuingTokenDesign;

$designs = IssuingTokenDesign::query(["limit" => 5]);

foreach ($designs as $design) {
    print_r($design);
}

use StarkInfra\IssuingTokenDesign;

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

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

use StarkInfra\IssuingPurchase;

$request = listen();  # this is your handler to listen for authorization requests

$purchase = IssuingPurchase::parse(
    $request->content, 
    $request->headers["Digital-Signature"]
);

# after parsing you should analyse the authorization request and then respond

# To approve:
sendResponse(  # you should also implement this method to respond the read request
    IssuingPurchase::response([
        "status" => "approved",
    ]);
);

# To deny:
sendResponse(  # you should also implement this method to respond the read request
    IssuingPurchase::response([
        "status" => "denied",
        "reason" => "stolenCard",
    ]);
);

use StarkInfra\IssuingPurchase;

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

foreach ($purchases as $purchase) {
    print_r($purchase);
}

use StarkInfra\IssuingPurchase;

$log = IssuingPurchase::get("5155165527080960");

print_r($log);

use StarkInfra\IssuingPurchase;

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

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

use StarkInfra\IssuingPurchases;

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

print_r($log);

use StarkInfra\IssuingInvoice;

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

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

use StarkInfra\IssuingInvoice;

$invoice = IssuingInvoice::get("5155165527080960");

print_r($invoice);

use StarkInfra\IssuingInvoice;

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

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

use StarkInfra\IssuingInvoice;

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

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

use StarkInfra\IssuingInvoice;

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

print_r($log);

use StarkInfra\IssuingWithdrawal;

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

foreach ($withdrawals as $withdrawal) {
    print_r($withdrawal);
}

use StarkInfra\IssuingWithdrawal;

$withdrawal = IssuingWithdrawal::get("5155165527080960");

print_r($withdrawal);

use StarkInfra\IssuingWithdrawal;

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

foreach ($withdrawals as $withdrawal) {
    print_r($withdrawal);
}

use StarkInfra\IssuingBalance;

$balance = IssuingBalance::get();

print_r($balance);

use StarkInfra\IssuingTransaction;

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

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

use StarkInfra\IssuingTransaction;

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

print_r($transaction);

use StarkInfra\MerchantCategory;

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

foreach ($categories as $category) {
    print_r($category);
}

use StarkInfra\MerchantCountry;

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

foreach ($countries as $country) {
    print_r($country);
}

use StarkInfra\CardMethod;

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

foreach ($methods as $method) {
    print_r($method);
}

use StarkInfra\PixRequest;
use StarkInfra\Utils\EndToEndId;

$requests = PixRequest::create([
    new PixRequest([
        "amount" => 1000,
        "externalId" => "my-external-id:1",
        "senderAccountNumber" => "76543-8",
        "senderBranchCode" => "2201",
        "senderAccountType" => "checking",
        "senderName" => "Tony Stark",
        "senderTaxId" => "594.739.480-42",
        "receiverBankCode" => "341",
        "receiverAccountNumber" => "00000-0",
        "receiverBranchCode" => "0001",
        "receiverAccountType" => "checking",
        "receiverName" => "Daenerys Targaryen Stormborn",
        "receiverTaxId" => "012.345.678-90",
        "endToEndId" => EndToEndId::create("20018183"),
    ]),
    new PixRequest([
        "amount" => 200,
        "externalId" => "my-external-id:2",
        "senderAccountNumber" => "76543-8",
        "senderBranchCode" => "2201",
        "senderAccountType" => "checking",
        "senderName" => "Tony Stark",
        "senderTaxId" => "594.739.480-42",
        "receiverBankCode" => "341",
        "receiverAccountNumber" => "00000-0",
        "receiverBranchCode" => "0001",
        "receiverAccountType" => "checking",
        "receiverName" => "Daenerys Targaryen Stormborn",
        "receiverTaxId" => "012.345.678-90",
        "endToEndId" => EndToEndId::create("20018183"),
    ]);
]);

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

use StarkInfra\PixRequest;

$requests = PixRequest::query([
    "limit" => 10,
    "after" => "2020-04-01",
    "before" => "2020-04-30",
    "status" => "success",
    "tags" => ['iron', 'suit'],
    "endToEndIds" => ['E79457883202101262140HHX553UPqeq'],
]);

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

use StarkInfra\PixRequest;

$request = PixRequest::get("5155966664310784");

print_r($request);

use StarkInfra\PixRequest;

$request = listen();  # this is your handler to listen for authorization requests

$request = PixRequest::parse(
    $request->content, 
    $request->headers["Digital-Signature"]
);

# after parsing you should analyse the authorization request and then respond

# To approve:
sendResponse(  # you should also implement this method to respond the read request
    PixRequest::response([
        "status" => "approved",
    ]);
);

# To deny:
sendResponse(  # you should also implement this method to respond the read request
    PixRequest::response([
        "status" => "denied",
        "reason" => "invalidAccountNumber",
    ]);
);

use StarkInfra\PixRequest;

$logs = PixRequest\Log::query([
    "limit" => 10,
    "types" => "created",
    "after" => "2020-04-30",
]);

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

use StarkInfra\PixRequest;

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

print_r($log);

use StarkInfra\PixReversal;

$reversals = PixReversal::create([
    new PixReversal([
        "amount" => 100,
        "externalId" => "my-external-id:3",
        "endToEndId" => "E00000000202201060100rzsJzG9PzMg",
        "reason" => "fraud",
    ]),
    new PixReversal([
        "amount" => 200,
        "externalId" => "my-external-id:4",
        "endToEndId" => "E00000000202201060100rzsJzG9P1GH",
        "reason" => "fraud",
    ]);
]);

foreach($reversals as $reversal){
    print_r($reversal);
}

use StarkInfra\PixReversal;

$reversals = PixReversal::query([
    "fields" => ['amount', 'senderName'],
    "limit" => 10,
    "after" => "2020-04-01",
    "before" => "2020-04-30",
    "status" => "success",
    "tags" => ['iron', 'suit'],
    "returnIds" => ['D20018183202202030109X3OoBHG74wo'],
]);

foreach($reversals as $reversal){
    print_r($reversals);
}

use StarkInfra\PixReversal;

$reversal = PixReversal::get("5155966664310784");

print_r($reversal);

use StarkInfra\PixReversal;

$request = listen();  # this is your handler to listen for authorization requests

$reversal = PixReversal::parse(
    $request->content, 
    $request->headers["Digital-Signature"]
);

# after parsing you should analyse the authorization request and then respond

# To approve:
sendResponse(  # you should also implement this method to respond the read request
    PixReversal::response([
        "status" => "approved",
    ]);
);

# To deny:
sendResponse(
    PixReversal::response([
        "status" => "denied",
        "reason" => "invalidAccountNumber",
    ]);
);


use StarkInfra\PixReversal;

$logs = PixReversal\Log::query([
    "limit" => 10,
    "after" => "2020-04-01",
    "before" => "2020-04-30",
]);

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

use StarkInfra\PixReversal;

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

print_r($log);

use StarkInfra\PixBalance;

$balance = PixBalance::get();

print_r($balance);

use StarkInfra\PixStatement;

$statement = PixStatement::create(
    new PixStatement([
        "after" => "2022-01-01",
        "before" => "2022-01-01",
        "type" => "transaction",
    ]);
);

print_r($statement)

use StarkInfra\PixStatement;

$statements = PixStatement::query([
    "limit" => 10,
    "ids" => ["5155165527080960"],
]);

foreach($statements as $statement){
    print_r($statement);
}

use StarkInfra\PixStatement;

$statement = PixStatement::get("5155966664310784");

print_r($statement);

use StarkInfra\PixStatement;

$csv = PixStatement::csv("5656565656565656");

$fp = fopen('statement.zip', 'w');
fwrite($fp, $csv);
fclose($fp);

use StarkInfra\PixKey;

$keys = PixKey::create(
    new PixKey([
        "accountCreated" => "2022-01-01",
        "accountNumber" => "76543",
        "accountType" => "salary",
        "branchCode" => "1234",
        "name" => "Jamie Lannister",    
        "taxId" => "012.345.678-90"
    ]);
);

foreach($keys as $key){
    print_r($key);
}

use StarkInfra\PixKey;

$keys = PixKey::query([
    "after" => "2020-04-01",
    "before" => "2020-04-30"
]);

foreach($keys as $key){
    print_r($key);
}

use StarkInfra\PixKey;
use StarkInfra\Utils\EndToEndId;

$key = PixKey::get(
    "5915632394567680",
    "20.018.183/0001-80",
    [
        "endToEndId" => EndToEndId::create("20018183")
    ]
);

print_r($key);


use StarkInfra\PixKey;

$key = PixKey::update(
    "6203417408045056",
    "reconciliation"
    [
        "name" => "Tony Stark"
    ]
);

print_r($key);

use StarkInfra\PixKey;

$key = PixKey::cancel("5915632394567680");

print_r($key);

use StarkInfra\PixKey;

$logs = PixKey\Log::query([
    "limit" => 50, 
    "after" => "2022-01-01",
    "before" => "2022-01-20",
    "types" => [
        "created"
    ]
]);

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

use StarkInfra\PixKey;

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

print_r($log);

use StarkInfra\PixClaim;

$claim = PixClaim::create(
    new PixClaim([
        "accountCreated" => "2022-01-01",
        "accountNumber" => "76549", 
        "accountType" => "salary", 
        "branchCode" => "1234",
        "name" => "Random Name",
        "taxId" => "012.345.678-90",
        "keyId" => "+551165857989",
    ]);
);

print_r($claim)

use StarkInfra\PixClaim;

$claims = PixClaim::query([
    "limit" => 1,
    "after" => "2022-01-01",
    "before" => "2022-01-12",
    "status" => "delivered",
    "ids" => ["5729405850615808"],
    "type" => "ownership",
    "flow" => "in",
    "keyType" => "phone",
    "keyId" => "+5511989898989"
]);

foreach ($claims as $claim){
    print_r($claim);
}


use StarkInfra\PixClaim;

$claim = PixClaim::get("5155165527080960");

print_r($claim);

use StarkInfra\PixClaim;

$claim = PixClaim::update(
    "5155165527080960",
    "canceled"
);

print_r($claim);

use StarkInfra\PixClaim;

$logs = PixClaim\Log::query([
    "limit" => 50, 
    "ids" => ["5729405850615808"],
    "after" => "2022-01-01",
    "before" => "2022-01-20",
    "types" => ["created"],
    "claimIds" => ["5719405850615809"]
]);

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

use StarkInfra\PixClaim;

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

print_r($log);
sh
php
use StarkInfra\PixDirector;

$director = PixDirector::create(
    new PixDirector ([
        "name" => "Edward Stark",
        "taxId" => "03.300.300/0001-00",
        "phone" => "+55-11999999999",
        "email" => "[email protected]",
        "password" => "12345678",
        "teamEmail" => "[email protected]",
        "teamPhones" => [
            "+55-11988889999", "+55-11988889998"
        ]
    ]);
);

print_r($director);
php
use StarkInfra\PixInfraction;

$infractions = PixInfraction::create([
    new PixInfraction([
        "referenceId" => "E20018183202201201450u34sDGd19lz",
        "type" => "fraud",
    ]);
]);

foreach ($infractions as $infraction){
    print_r($infraction);
}
php
use StarkInfra\PixInfraction;

$infractions = PixInfraction::query([
    "limit" => 1,
    "after" => "2022-01-01",
    "before" => "2022-01-12",
    "status" => "delivered",
    "ids" => ["5155165527080960"],
]);

foreach ($infractions as $infraction){
    print_r($infraction);
}
php
use StarkInfra\PixInfraction;

$logs = PixInfraction\Log::query([
    "limit" => 50, 
    "ids" => ["5729405850615808"],
    "after" =>"2022-01-01",
    "before" =>"2022-01-20",
    "types" => ["created"],
    "infractionIds" => ["5155165527080960"]
]);

foreach ($logs as $log){
    print_r($log)
}
php
use StarkInfra\PixFraud;

$frauds = PixFraud::create([
    new PixFraud([
        "externalId" => "my_external_id_1234",
        "type" => "mule",
        "taxId" => "01234567890",
    ]);
]);

foreach ($frauds as $fraud){
    print_r($fraud);
}
php
use StarkInfra\PixFraud;

$frauds = PixFraud::query([
    "limit" => 1,
    "after" => "2022-01-01",
    "before" => "2022-01-12",
    "status" => "delivered",
    "ids" => ["6638842090094592", "4023146587080960"],
]);

foreach ($frauds as $fraud){
    print_r($fraud);
}
php
use StarkInfra\PixChargeback;

$chargebacks = PixChargeback::create([
    new PixChargeback([
        "amount" => 100,
        "referenceId" => "E20018183202201201450u34sDGd19lz",
        "reason" => "fraud"
    ]);
]);

foreach ($chargebacks as $chargeback){
    print($chargeback);
}    
php
use StarkInfra\PixChargeback;

$chargebacks = PixChargeback::query([
    "limit" => 1,
    "after" => "2022-01-01",
    "before" => "2022-01-12",
    "status" => "delivered",
    "ids" => ["5155165527080960"]
]);

foreach ($chargebacks as $chargeback){
    print($chargeback);
}    
php
use StarkInfra\PixChargeback;

$logs = PixChargeback\Log::query([
    "limit" => 50, 
    "ids" => ["5729405850615808"],
    "after" => "2022-01-01",
    "before" => "2022-01-20",
    "types" => ["created"],
    "chargebackIds" => ["5155165527080960"]
]);

foreach ($logs as $log){
    print_r($log);
}
php
use StarkInfra\StaticBrcode;

$brcodes = StaticBrcode::create([
    new StaticBrcode([
        "name" => "Jamie Lannister",
        "keyId" => "+5511988887777",
        "amount" => 100,
        "reconciliationId" => "123",
        "city" =>"Rio de Janeiro"
    ]);
]);

foreach ($brcodes as $brcode){
    print($brcode);
}
php
use StarkInfra\StaticBrcode;

$brcodes = StaticBrcode::query([
    "limit" => 50, 
    "after" => "2022-01-01",
    "before" => "2022-01-20",
    "uuids" => ["5ddde28043a245c2848b08cf315effa2"],
]);

foreach ($brcodes as $brcode){
    print_r($brcode);
}
php
use StarkInfra\DynamicBrcode;

$brcodes = DynamicBrcode::query([
    "limit" => 50, 
    "after" => "2022-01-01",
    "before" => "2022-01-20",
    "uuids" => ["5ddde28043a245c2848b08cf315effa2"],
]);

foreach ($brcodes as $brcode){
    print_r($brcode);
}
php
use StarkInfra\BrcodePreview;

$previews = BrcodePreview::create([
    new BrcodePreview([
        "id" => "00020126420014br.gov.bcb.pix0120nedstark@hotmail.com52040000530398654075000.005802BR5909Ned Stark6014Rio de Janeiro621605126674869738606304FF71",
        "payerId" => "123.456.780-01"
    ]),
    new BrcodePreview([
        "id" => "00020126430014br.gov.bcb.pix0121aryastark@hotmail.com5204000053039865406100.005802BR5910Arya Stark6014Rio de Janeiro6216051262678188104863042BA4",
        "payerId" => "123.456.780-01"
    ])
]);

foreach ($previews as $preview) {
    print_r($preview);
}
php
use StarkInfra\CreditNote;

$notes = CreditNote::query([
    "limit" => 10,
    "after" => "2020-04-01",
    "before" => "2020-04-30",
    "status" => "signed",
]);

foreach($notes as $note){
    print_r($note);
}
php
use StarkInfra\CreditNote\Log;

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

foreach($logs as $log){
    print_r($log);
}
php
use StarkInfra\CreditPreview;
use StarkInfra\CreditNote\Invoice;

$previews = CreditPreview::create([
    new CreditPreview([
        "type" => "credit-note",
        "credit" => new CreditPreview\CreditNotePreview([
            "type" => "american",
            "nominalAmount" => 100000,
            "scheduled" => "2022-10-11",
            "taxId" => "012.345.678-90",
            "initialDue" => "2022-11-11",
            "nominalInterest" => 10,
            "count" => 5,
            "interval" => "month",
        ])
    ]),
    new CreditPreview([
        "type" => "credit-note",
        "credit" => new CreditPreview\CreditNotePreview([
            "initialAmount" => 2478,
            "initialDue" => "2022-10-22",
            "nominalAmount" => 90583,
            "nominalInterest" => 3.7,
            "rebateAmount" => 23,
            "scheduled" => "2022-09-28",
            "taxId" => "477.954.506-44",
            "type" => "sac"
        ])
    ]),
    new CreditPreview([
        "type" => "credit-note",
        "credit" => new CreditPreview\CreditNotePreview([
            "initialAmount" => 4449,
            "initialDue" => "2022-09-16",
            "interval" => "year",
            "nominalAmount" => 96084,
            "nominalInterest" => 3.1,
            "rebateAmount" => 239,
            "scheduled" => "2022-09-02",
            "taxId" => "81.882.684/0001-02",
            "type" => "price"
        ])
    ]),
    new CreditPreview([
        "type" => "credit-note",
        "credit" => new CreditPreview\CreditNotePreview([
            "count" => 8,
            "initialDue" => "2022-09-18",
            "nominalAmount" => 6161,
            "nominalInterest" => 3.2,
            "scheduled" => "2022-09-03",
            "taxId" => "59.352.830/0001-20",
            "type" => "american"
        ])
    ]),
    new CreditPreview([
        "type" => "credit-note",
        "credit" => new CreditPreview\CreditNotePreview([
            "initialDue" => "2022-09-13",
            "nominalAmount" => 86237,
            "nominalInterest" => 2.6,
            "scheduled" => "2022-09-03",
            "taxId" => "37.293.955/0001-94",
            "type" => "bullet"
        ])
    ]),
    new CreditPreview([
        "type" => "credit-note",
        "credit" => new CreditPreview\CreditNotePreview([
            "invoices" => [
                new Invoice([
                    "amount" => 14500,
                    "due" => "2022-10-19"
                ]),
                new Invoice([
                    "amount" => 14500,
                    "due" => "2022-11-25"
                ])
            ],
            "nominalAmount" => 29000,
            "rebateAmount" => 900,
            "scheduled" => "2022-09-31",
            "taxId" => "36.084.400/0001-70",
            "type" => "custom"
        ])
    ]),
]);

foreach($previews as $preview){
    print_r($preview);
}
php
use StarkInfra\CreditHolmes;

$holmes = CreditHolmes::create([
    new CreditHolmes([
        "taxId" => "012.345.678-90",
        "competence" => "2022-09"
    ]),
    new CreditHolmes([
        "taxId" => "012.345.678-90",
        "competence" => "2022-08"
    ]),
    new CreditHolmes([
        "taxId" => "012.345.678-90",
        "competence" => "2022-07"
    ]);
]);

foreach($holmes as $sherlock){
    print_r($sherlock);
}
php
use StarkInfra\CreditHolmes;

$holmes = CreditHolmes::query([
    "after" => "2020-04-01",
    "before" => "2020-04-30",
    "status" => "success",
]);

foreach($holmes as $sherlock){
    print_r($sherlock);
}
php
use StarkInfra\CreditHolmes\Log;

$logs = Log::query([
    "limit" => 10,
    "ids" => ["5729405850615808"],
    "after" => "2020-04-01",
    "before" => "2020-04-30",
    "types" => ["created"]
]);

foreach($logs as $log){
    print_r($log);
}
php
use StarkInfra\IndividualIdentity;

$identities = IndividualIdentity::create([
    new IndividualIdentity([
        "name" => "Walter White",
        "taxId" => "012.345.678-90",
        "tags" =>["breaking", "bad"]
    ]);
]);

foreach($identities as $identity){
    print_r($identity);
}
php
use StarkInfra\IndividualIdentity;

$identities = IndividualIdentity::query([
    "limit" => 10,
    "after" => "2020-04-01",
    "before" => "2020-04-30",
    "status" => "success",
    "tags" =>["breaking", "bad"]
]);

foreach($identities as $identity){
    print_r($identity);
}
php
use StarkInfra\IndividualIdentity\Log;

$logs = IndividualIdentity\Log::query([
    "limit" => 10,
    "after" => "2020-04-01",
    "before" => "2020-04-30"
]);

foreach($logs as $log){
    print_r($log);
}
php
use StarkInfra\IndividualDocument;

$logs = IndividualDocument::query([
    "limit" => 10,
    "after" => "2020-04-01",
    "before" => "2020-04-30",
    "status" => "success",
    "tags" => ["breaking", "bad"]
]);

foreach($logs as $log){
    print_r($log);
}
php
use StarkInfra\IndividualDocument\Log;

$logs = IndividualDocument\Log::query([
    "limit" => 10,
    "after" => "2020-04-01",
    "before" => "2020-04-30"
]);

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

$webhook = Webhook::create(
    new Webhook(
        "url" => "https://webhook.site/",
        "subscriptions" =>[
            "credit-note"
            "issuing-card", "issuing-invoice", "issuing-purchase",
            "pix-request.in", "pix-request.out", "pix-reversal.in", "pix-reversal.out", "pix-claim", "pix-key", "pix-infraction", "pix-chargeback"
        ]
    );
);

print_r($webhook);
php
use StarkInfra\Webhook;

$webhooks = Webhook::query();

foreach($webhooks as $webhook){
    print_r($webhook);
}
php
use StarkInfra\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 == "pix-request.in"){
    print_r($event->log->request);
} elseif ($event->subscription == "pix-claim"){
    print_r($event->log->claim);
} elseif ($event->subscription == "pix-key"){
    print_r($event->log->key);
} elseif ($event->subscription == "pix-infraction"){
    print_r($event->log->infraction);
} elseif ($event->subscription == "pix-chargeback"){
    print_r($event->log->chargeback);
} elseif ($event->subscription == "pix-request.out"){
    print_r($event->log->request);
} elseif ($event->subscription == "pix-reversal.in"){
    print_r($event->log->reversal);
} elseif ($event->subscription == "pix-reversal.out"){
    print_r($event->log->reversal);
} elseif ($event->subscription == "issuing-card"){
    print_r($event->log->card);
} elseif ($event->subscription == "issuing-invoice"){
    print_r($event->log->invoice);
} elseif ($event->subscription == "issuing-purchase"){
    print_r($event->log->purchase);
} 
php
use StarkInfra\Event;

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

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

$event = Event::update("1298371982371929", true);

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

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

foreach($attempts as $attempt){
    print_r($attempt);
}
php
use StarkInfra\Request;

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

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

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

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

$path = "issuing-holder/5155165527080960";
$request = Request::patch(
    $path, 
    ["tags" => ["arya", "stark"]]
)->content;
$content = json_decode($request, true);
print_r($content)
php
use StarkInfra\Request;

$path = "issuing-holder/5155165527080960";
$request = Request::delete($path)->content;
$result = json_decode($request, true);

print_r($result);
php
use StarkInfra;
use StarkInfra\Error\InputErrors;

try {
    $cards = StarkInfra\IssuingCard::create([
        new StarkInfra\IssuingCard([
            "holdeNname" => "Developers",
            "holderTaxId" => "012.345.678-90",
            "holderExternalId" => "1234",
            "rules" => [
                new StarkInfra\IssuingRule([
                    "name" => "general",
                    "interval" => "week",
                    "amount" => 50000,
                    "currencyCode" => "USD"
                ])
            ]
        ]),
    ]);
} catch (InputErrors $e) {
    foreach($e->errors as $error){
        echo "\n\ncode: " . $error->errorCode;
        echo "\nmessage: " . $error->errorMessage;
    }
}