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\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\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;
$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;
$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);