Download the PHP package starkinfra/sdk without Composer

On this page you can find all versions of the php package starkinfra/sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sdk

Stark Infra PHP SDK - Beta

Welcome to the Stark Infra PHP SDK! This tool is made for PHP developers who want to easily integrate with our API. This SDK version is compatible with the Stark Infra API v2.

Introduction

Index

Supported PHP Versions

This library supports the following PHP versions:

Stark Infra API documentation

Feel free to take a look at our API docs.

Versioning

This project adheres to the following versioning pattern:

Given a version number MAJOR.MINOR.PATCH, increment:

Setup

1. Install our SDK

1.1 Composer: To install the package with Composer, run:

To use the bindings, use following the command:

2. Create your Private and Public Keys

We use ECDSA. That means you need to generate a secp256k1 private key to sign your requests to our API, and register your public key with us, so we can validate those requests.

You can use one of following methods:

2.1. Check out the options in our tutorial.

2.2. Use our SDK:

NOTE: When you are creating new credentials, it is recommended that you create the keys inside the infrastructure that will use it, in order to avoid risky internet transmissions of your private-key. Then you can export the public-key alone to the computer where it will be used in the new Project creation.

3. Register your user credentials

You can interact directly with our API using two types of users: Projects and Organizations.

3.1. To create a Project in Sandbox:

3.1.1. Log into StarkInfra Sandbox

3.1.2. Go to Menu > Integrations

3.1.3. Click on the "New Project" button

3.1.4. Create a Project: Give it a name and upload the public key you created in section 2

3.1.5. After creating the Project, get its Project ID

3.1.6. Use the Project ID and private key to create the object below:

3.2. To create Organization credentials in Sandbox:

3.2.1. Log into StarkInfra Sandbox

3.2.2. Go to Menu > Integrations

3.2.3. Click on the "Organization public key" button

3.2.4. Upload the public key you created in section 2 (only a legal representative of the organization can upload the public key)

3.2.5. Click on your profile picture and then on the "Organization" menu to get the Organization ID

3.2.6. Use the Organization ID and private key to create the object below:

NOTE 1: Never hard-code your private key. Get it from an environment variable or an encrypted database.

NOTE 2: We support 'sandbox' and 'production' as environments.

NOTE 3: The credentials you registered in sandbox do not exist in production and vice versa.

4. Setting up the user

There are three kinds of users that can access our API: Organization, Project and Member.

There are two ways to inform the user to the SDK:

4.1 Passing the user as argument in all functions:

4.2 Set it as a default user in the SDK:

Just select the way of passing the user that is more convenient to you. On all following examples we will assume a default user has been set.

5. Setting up the error language

The error language can also be set in the same way as the default user:

Language options are "en-US" for english and "pt-BR" for brazilian portuguese. English is default.

Resource listing and manual pagination

Almost all SDK resources provide a query and a page function.

To simplify the following SDK examples, we will only use the query function, but feel free to use page instead.

Testing in Sandbox

Your initial balance is zero. For many operations in Stark Infra, you'll need funds in your account, which can be added to your balance by creating a starkbank.Invoice.

In the Sandbox environment, most of the created starkbank.Invoices will be automatically paid, so there's nothing else you need to do to add funds to your account. Just create a few starkbank.Invoices and wait around a bit.

In Production, you (or one of your clients) will need to actually pay this starkbank.Invoice for the value to be credited to your account.

Usage

Here are a few examples on how to use the SDK. If you have any doubts, check out the function or class docstring to get more info or go straight to our [API docs].

Issuing

Query IssuingProducts

To take a look at the sub-issuer card products available to you, just run the following:

This will tell which card products and card number prefixes you have at your disposal.

Create IssuingHolders

You can create card holders to which your cards will be bound. They support spending rules that will apply to all underlying cards.

Note: Instead of using IssuingHolder objects, you can also pass each transfer element in dictionary format

Query IssuingHolders

You can query multiple holders according to filters.

Cancel an IssuingHolder

To cancel a single Issuing Holder by its id, run:

Get an IssuingHolder

To get a single Issuing Holder by its id, run:

Query IssuingHolder logs

You can query holder logs to better understand holder life cycles.

Get an IssuingHolder log

You can also get a specific log by its id.

Create IssuingCards

You can issue cards with specific spending rules.

Query IssuingCards

You can get a list of created cards given some filters.

Get an IssuingCard

After its creation, information on a card may be retrieved by its id.

Update an IssuingCard

You can update a specific card by its id.

Cancel an IssuingCard

You can also cancel a card by its id.

Query IssuingCard logs

Logs are pretty important to understand the life cycle of a card.

Get an IssuingCard log

You can get a single log by its id.

Query IssuingDesigns

You can get a list of available designs given some filters.

Get an IssuingDesign

Information on a design may be retrieved by its id.

Query IssuingEmbossingKits

You can get a list of created embossing kits given some filters.

Get an IssuingEmbossingKit

After its creation, information on an embossing kit may be retrieved by its id.

Query IssuingStocks

You can get a list of available stocks given some filters.

Get an IssuingStock

Information on a stock may be retrieved by its id.

Query IssuingStock logs

Logs are pretty important to understand the life cycle of a stock.

Get an IssuingStock log

You can get a single log by its id.

Create IssuingRestocks

You can order restocks for a specific IssuingStock.

Query IssuingRestocks

You can get a list of created restocks given some filters.

Get an IssuingRestock

After its creation, information on a restock may be retrieved by its id.

Query IssuingRestock logs

Logs are pretty important to understand the life cycle of a restock.

Get an IssuingRestock log

You can get a single log by its id.

Create IssuingEmbossingRequests

You can create a request to emboss a physical card.

Query IssuingEmbossingRequests

You can get a list of created embossing requests given some filters.

Get an IssuingEmbossingRequest

After its creation, information on an embossing request may be retrieved by its id.

Query IssuingEmbossingRequest logs

Logs are pretty important to understand the life cycle of an embossing request.

Get an IssuingEmbossingRequest log

You can get a single log by its id.

Create an IssuingTokenRequest

You can create a request that provides the required data you must send to the wallet app.

Process Token authorizations

It's easy to process token authorizations delivered to your endpoint. Remember to pass the signature header so the SDK can make sure it's StarkInfra that sent you the event. If you do not approve or decline the authorization within 2 seconds, the authorization will be denied.

Process Token activations

It's easy to process token activation notifications delivered to your endpoint. Remember to pass the signature header so the SDK can make sure it's Stark Infra that sent you the event.

After that, you may generate the activation code and send it to the cardholder. The cardholder enters the received code in the wallet app. We'll receive and send it to tokenAuthorizationUrl for your validation. Completing the provisioning process.

Get an IssuingToken

You can get a single token by its id.

Query IssuingTokens

You can get a list of created tokens given some filters.

Update an IssuingToken

You can update a specific token by its id.

Cancel an IssuingToken

You can also cancel a token by its id.

Get an IssuingTokenDesign

You can get a single design by its id.

Query IssuingTokenDesigns

You can get a list of available designs given some filters.

Get an IssuingTokenDesign PDF

A design PDF can be retrieved by its id.

Process Purchase Authorizations

It's easy to process purchase authorizations delivered to your endpoint. Remember to pass the signature header so the SDK can make sure it's StarkInfra that sent you the event. If you do not approve or decline the authorization within 2 seconds, the authorization will be denied.

Query IssuingPurchases

You can get a list of created purchases given some filters.

Get an IssuingPurchase

After its creation, information on a purchase may be retrieved by its id.

Query IssuingPurchase logs

Logs are pretty important to understand the life cycle of a purchase.

Get an IssuingPurchase log

You can get a single log by its id.

Create IssuingInvoices

You can create Pix invoices to transfer money from accounts you have in any bank to your Issuing balance, allowing you to run your issuing operation.

Note: Instead of using Invoice objects, you can also pass each invoice element in dictionary format

Get an IssuingInvoice

After its creation, information on an invoice may be retrieved by its id. Its status indicates whether it's been paid.

Query IssuingInvoices

You can get a list of created invoices given some filters.

Query IssuingInvoice logs

Logs are pretty important to understand the life cycle of an invoice.

Get an IssuingInvoice log

You can also get a specific log by its id.

Create IssuingWithdrawals

You can create withdrawals to send cash back from your Issuing balance to your Banking balance by using the Withdrawal resource.

Note: Instead of using Withdrawal objects, you can also pass each withdrawal element in dictionary format

Get an IssuingWithdrawal

After its creation, information on a withdrawal may be retrieved by its id.

Query IssuingWithdrawals

You can get a list of created withdrawals given some filters.

Get your IssuingBalance

To know how much money you have available to run authorizations, run:

Query IssuingTransactions

To understand your balance changes (issuing statement), you can query transactions. Note that our system creates transactions for you when you make purchases, withdrawals, receive issuing invoice payments, for example.

Get an IssuingTransaction

You can get a specific transaction by its id:

Issuing Enums

Query MerchantCategories

You can query any merchant categories using this resource. You may also use MerchantCategories to define specific category filters in IssuingRules. Either codes (which represents specific MCCs) or types (code groups) will be accepted as filters.

Query MerchantCountries

You can query any merchant countries using this resource. You may also use MerchantCountries to define specific country filters in IssuingRules.

Query CardMethods

You can query available card methods using this resource. You may also use CardMethods to define specific purchase method filters in IssuingRules.

Pix

Create PixRequests

You can create a Pix request to transfer money from one of your users to anyone else:

Note: Instead of using Pix Request objects, you can also pass each element in dictionary format

Query PixRequests

You can query multiple Pix Requests according to filters.

Get a PixRequest

After its creation, information on a Pix Request may be retrieved by its id. Its status indicates whether it has been paid.

Process inbound PixRequest authorizations

It's easy to process authorization requests that arrived at your endpoint. Remember to pass the signature header so the SDK can make sure it's StarkInfra that sent you the event. If you do not approve or decline the authorization within 1 second, the authorization will be denied.

Query PixRequest logs

You can query Pix Request Logs to better understand Pix Request life cycles.

Get a PixRequest log

You can also get a specific log by its id.

Create PixReversals

You can reverse a PixRequest either partially or totally using a PixReversal.

Query PixReversals

You can query multiple Pix Reversals according to filters.

Get a PixReversal

After its creation, information on a Pix Reversal may be retrieved by its id. Its status indicates whether it has been paid.

Process inbound PixReversal authorizations

It's easy to process authorization requests that arrived at your endpoint. Remember to pass the signature header so the SDK can make sure it's StarkInfra that sent you the event. If you do not approve or decline the authorization within 1 second, the authorization will be denied.

Query PixReversal logs

You can query Pix Reversal logs to better understand Pix Reversal life cycles.

Get a PixReversal log

You can also get a specific log by its id.

Get your PixBalance

To see how much money you have in your account, run:

Create a PixStatement

Statements are generated directly by the Central Bank and are only available for direct participants. To create a statement of all the transactions that happened on your account during a specific day, run:

Query PixStatements

You can query multiple Pix Statements according to filters.

Get a PixStatement

Statements are only available for direct participants. To get a Pix Statement by its id:

Get a PixStatement .csv file

To get a .csv file of a Pix Statement using its id, run:

Create a PixKey

You can create a Pix Key to link a bank account information to a key id:

Query PixKeys

You can query multiple Pix Keys you own according to filters.

Get a PixKey

Information on a Pix Key may be retrieved by its id and the tax ID of the consulting agent. An endToEndId must be informed so you can link any resulting purchases to this query, avoiding sweep blocks by the Central Bank.

Update a PixKey

Update the account information linked to a Pix Key.

Cancel a PixKey

Cancel a specific Pix Key using its id.

Query PixKey logs

You can query Pix Key logs to better understand a Pix Key life cycle.

Get a PixKey log

You can also get a specific log by its id.

Create a PixClaim

You can create a Pix Claim to request the transfer of a Pix Key from another bank to one of your accounts:

Query PixClaims

You can query multiple Pix claims according to filters.

Get a PixClaim

After its creation, information on a Pix Claim may be retrieved by its id.

Update a PixClaim

A Pix Claim can be confirmed or canceled by patching its status. A received Pix Claim must be confirmed by the donor to be completed. Ownership Pix Claims can only be canceled by the donor if the reason is "fraud". A sent Pix Claim can also be canceled.

Query PixClaim logs

You can query Pix Claim logs to better understand Pix Claim life cycles.

Get a PixClaim log

You can also get a specific log by its id.

Create a PixDirector

To register the Pix Director contact information at the Central Bank, run the following:

Create PixInfractions

Pix Infractions are used to report transactions that raise fraud suspicion, to request a refund or to reverse a refund. Pix Infractions can be created by either participant of a transaction.

Query PixInfractions

You can query multiple Pix Infractions according to filters.

Get a PixInfraction

After its creation, information on a Pix Infraction may be retrieved by its id.

Update a PixInfraction

A received Pix Infraction can be confirmed or declined by patching its status. After a Pix Infraction is patched, its status changes to closed.

Cancel a PixInfraction

Cancel a specific Pix Infraction using its id.

Query PixInfraction logs

You can query Pix Infraction Logs to better understand their life cycles.

Get a PixInfraction log

You can also get a specific log by its id.

Create a PixFraud

Pix Frauds can be created by either participant or automatically when a Pix Infraction is accepted.

Query PixFrauds

You can query multiple Pix Frauds according to filters.

Get a PixFraud

After its creation, information on a Pix Fraud may be retrieved by its id.

Cancel a PixFraud

Cancel a specific Pix Fraud using its id.

Get a PixUser

You can get a specific fraud statistics of a user with his taxId.

Create PixChargebacks

A Pix Chargeback can be created when fraud is detected on a transaction or a system malfunction results in an erroneous transaction.

Query PixChargebacks

You can query multiple Pix Chargebacks according to filters.

Get a PixChargeback

After its creation, information on a Pix Chargeback may be retrieved by its.

Update a PixChargeback

A received Pix Chargeback can be approved or denied by patching its status. After a Pix Chargeback is patched, its status changes to closed.

Cancel a PixChargeback

Cancel a specific Pix Chargeback using its id.

Query PixChargeback logs

You can query Pix Chargeback Logs to better understand reversal request life cycles.

Get a PixChargeback log

You can also get a specific log by its id.

Query PixDomains

Here you can list all Pix Domains registered at the Brazilian Central Bank. The Pix Domain object displays the domain name and the QR Code domain certificates of registered Pix participants able to issue dynamic QR Codes.

Create StaticBrcodes

StaticBrcodes store account information via a QR code or an image that represents a PixKey and a few extra fixed parameters, such as an amount and a reconciliation ID. They can easily be used to receive Pix transactions.

Query StaticBrcodes

You can query multiple StaticBrcodes according to filters.

Get a StaticBrcodes

After its creation, information on a StaticBrcode may be retrieved by its UUID.

Create DynamicBrcodes

BR codes store information represented by Pix QR Codes, which are used to send or receive Pix transactions in a convenient way. DynamicBrcodes represent charges with information that can change at any time, since all data needed for the payment is requested dynamically to an URL stored in the BR Code. Stark Infra will receive the GET request and forward it to your registered endpoint with a GET request containing the UUID of the BR code for identification.

Query DynamicBrcodes

You can query multiple DynamicBrcodes according to filters.

Get a DynamicBrcode

After its creation, information on a DynamicBrcode may be retrieved by its UUID.

Verify a DynamicBrcode Read

When a DynamicBrcode is read by your user, a GET request will be made to the URL stored in the DynamicBrcode to retrieve additional information needed to complete the transaction. Use this method to verify the authenticity of a GET request received at your registered endpoint. If the provided digital signature does not check out with the Stark public key, a StarkInfra\Exception\InvalidSignatureException will be raised.

Answer to a Due DynamicBrcode Read

When a Due DynamicBrcode is read by your user, a GET request containing the BR code UUID will be made to your registered URL to retrieve additional information needed to complete the transaction.

The GET request must be answered within 5 seconds, with a HTTP status code 200, and in the following format.

Answer to an Instant DynamicBrcode read

When an instant DynamicBrcode is read by your user, a GET request containing the BR code's UUID will be made to your registered URL to retrieve additional information needed to complete the transaction.

The GET request must be answered within 5 seconds, with a HTTP status code 200, and in the following format.

Create BrcodePreviews

You can create BrcodePreviews to preview BR Codes before paying them.

Lending

If you want to establish a lending operation, you can use Stark Infra to create a CCB contract. This will enable your business to lend money without requiring a banking license, as long as you use a Credit Fund or Securitization company.

The required steps to initiate the operation are:

  1. Have funds in your Credit Fund or Securitization account
  2. Request the creation of an Identity Check for the credit receiver (make sure you have their documents and express authorization)
  3. (Optional) Create a Credit Simulation with the desired installment plan to display information for the credit receiver
  4. Create a Credit Note with the desired installment plan

Create CreditNotes

For lending operations, you can create a CreditNote to generate a CCB contract.

Note that you must have recently created an identity check for that same Tax ID before being able to create a credit operation for them.

Note: Instead of using CreditNote objects, you can also pass each element in dictionary format

Query CreditNotes

You can query multiple Credit Notes according to filters.

Get a CreditNote

After its creation, information on a Credit Note may be retrieved by its id.

Cancel a CreditNote

You can cancel a Credit Note if it has not been signed yet.

Query CreditNote logs

You can query Credit Note logs to better understand credit note life cycles.

Get a CreditNote log

You can also get a specific log by its id.

Create CreditPreviews

You can preview a credit operation before creating them (Currently we only have CreditNote / CCB previews):

Note: Instead of using CreditPreview objects, you can also pass each element in dictionary format

Create CreditHolmes

Before you request a credit operation, you may want to check previous credit operations the credit receiver has taken.

For that, open up a CreditHolmes investigation to receive information on all debts and credit operations registered for that individual or company inside the Central Bank's SCR.

Query CreditHolmes

You can query multiple CreditHolmes according to filters.

Get a CreditHolmes

After its creation, information on a CreditHolmes may be retrieved by its id.

Query CreditHolmes logs

You can query CreditHolmes logs to better understand their life cycles.

Get a CreditHolmes log

You can also get a specific log by its id.

Identity

Several operations, especially credit ones, require that the identity of a person or business is validated beforehand.

Identities are validated according to the following sequence:

  1. The Identity resource is created for a specific Tax ID
  2. Documents are attached to the Identity resource
  3. The Identity resource is updated to indicate that all documents have been attached
  4. The Identity is sent for validation and returns a webhook notification to reflect the success or failure of the operation

Create IndividualIdentities

You can create an IndividualIdentity to validate a document of a natural person

Note: Instead of using IndividualIdentity objects, you can also pass each element in dictionary format

Query IndividualIdentity

You can query multiple individual identities according to filters.

Get an IndividualIdentity

After its creation, information on an individual identity may be retrieved by its id.

Update an IndividualIdentity

You can update a specific identity status to "processing" for send it to validation.

Note: Before sending your individual identity to validation by patching its status, you must send all the required documents using the create method of the CreditDocument resource. Note that you must reference the individual identity in the create method of the CreditDocument resource by its id.

Cancel an IndividualIdentity

You can cancel an individual identity before updating its status to processing.

Query IndividualIdentity logs

You can query individual identity logs to better understand individual identity life cycles.

Get an IndividualIdentity log

You can also get a specific log by its id.

Create IndividualDocuments

You can create an individual document to attach images of documents to a specific individual Identity. You must reference the desired individual identity by its id.

Note: Instead of using IndividualDocument objects, you can also pass each element in dictionary format

Query IndividualDocuments

You can query multiple individual documents according to filters.

Get an IndividualDocument

After its creation, information on an individual document may be retrieved by its id.

Query IndividualDocument logs

You can query individual document logs to better understand individual document life cycles.

Get an IndividualDocument log

You can also get a specific log by its id.

Webhook

Create a webhook

To create a Webhook and be notified whenever an event occurs, run:

Query webhooks

To search for registered Webhooks, run:

Get a webhook

You can get a specific Webhook by its id.

Delete a webhook

You can also delete a specific Webhook by its id.

Process Webhook events

It's easy to process events delivered to your Webhook endpoint. Remember to pass the signature header so the SDK can make sure it was StarkInfra that sent you the event.

Query webhook events

To search for webhooks events, run:

Get a webhook event

You can get a specific webhook event by its id.

Delete a webhook event

You can also delete a specific webhook event by its id.

Set webhook events as delivered

This can be used in case you've lost events. With this function, you can manually set events retrieved from the API as "delivered" to help future event queries with "isDelivered" => false.

Query failed webhook event delivery attempts information

You can also get information on failed webhook event delivery attempts.

Get a failed webhook event delivery attempt information

To retrieve information on a single attempt, use the following function:

request

This resource allows you to send HTTP requests to StarkInfra routes.

GET

You can perform a GET request to any StarkInfra route.

It's possible to get a single resource using its id in the path.

You can also get the specific resource log,

This same method will be used to list all created items for the requested resource.

To list logs, you will use the same logic as for getting a single log.

POST

You can perform a POST request to any StarkInfra route.

This will create an object for each item sent in your request

Note: It's not possible to create multiple resources simultaneously. You need to send separate requests if you want to create multiple resources, such as invoices and boletos.

PATCH

You can perform a PATCH request to any StarkInfra route.

It's possible to update a single item of a StarkInfra resource.

DELETE

You can perform a DELETE request to any StarkInfra route.

It's possible to delete a single item of a StarkInfra resource.

Handling errors

The SDK may raise one of four types of errors: InputErrors, InternalServerError, UnknownError, InvalidSignatureError

InputErrors will be raised whenever the API detects an error in your request (status code 400). If you catch such an error, you can get its elements to verify each of the individual errors that were detected in your request by the API. For example:

InternalServerError will be raised if the API runs into an internal error. If you ever stumble upon this one, rest assured that the development team is already rushing in to fix the mistake and get you back up to speed.

UnknownError will be raised if a request encounters an error that is neither InputErrors nor an InternalServerError, such as connectivity problems.

InvalidSignatureError will be raised specifically by StarkInfra\Event::parse() when the provided content and signature do not check out with the Stark Infra public key.

Help and Feedback

If you have any questions about our SDK, just send us an email. We will respond you quickly, pinky promise. We are here to help you integrate with us ASAP. We also love feedback, so don't be shy about sharing your thoughts with us.

Email: [email protected]


All versions of sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
starkinfra/core Version ^0.4.1
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package starkinfra/sdk contains the following files

Loading the files please wait ....