Download the PHP package starkbank/sdk without Composer

On this page you can find all versions of the php package starkbank/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 Bank PHP SDK

Welcome to the Stark Bank 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 Bank API v2.

If you have no idea what Stark Bank is, check out our website and discover a world where receiving or making payments is as easy as sending a text message to your client!

Introduction

Index

Supported PHP Versions

This library supports the following PHP versions:

Stark Bank 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 Composer's autoload:

In manual installations, you will also need to get the following dependency:

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 any 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 Starkbank 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 Starkbank 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.

6. 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 Bank, you'll need funds in your account, which can be added to your balance by creating an Invoice or a Boleto.

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

In Production, you (or one of your clients) will need to actually pay this Invoice or Boleto 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].

Create transactions

To send money between Stark Bank accounts, you can create transactions:

Note: Instead of using Transaction objects, you can also pass each transaction element directly in array format, without using the constructor

Query transactions

To understand your balance changes (bank statement), you can query transactions. Note that our system creates transactions for you when you receive boleto payments, pay a bill or make transfers, for example.

Get a transaction

You can get a specific transaction by its id:

Get balance

To know how much money you have in your workspace, run:

Create transfers

You can also create transfers in the SDK (TED/Pix) and configure transfer behavior according to its rules.

Note: Instead of using Transfer objects, you can also pass each transfer element directly in array format, without using the constructor

Query transfers

You can query multiple transfers according to filters.

Get a transfer

To get a single transfer by its id, run:

Cancel a scheduled transfer

To cancel a single scheduled transfer by its id, run:

Get a transfer PDF

A transfer PDF may also be retrieved by passing its id. This operation is only valid if the transfer status is "processing" or "success".

Be careful not to accidentally enforce any encoding on the raw pdf content, as it may yield abnormal results in the final file, such as missing images and strange characters.

Query transfer logs

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

Get a transfer log

You can also get a specific log by its id.

Get DICT key

You can get Pix key's parameters by its id.

Query your DICT keys

To take a look at the Pix keys linked to your workspace, just run the following:

Query Bacen institutions

You can query institutions registered by the Brazilian Central Bank for Pix and TED transactions.

Create invoices

You can create dynamic QR Code invoices to charge customers or to receive money from accounts you have in other banks.

Since the banking system only understands value modifiers (discounts, fines and interest) when dealing with dates (instead of datetimes), these values will only show up in the end user banking interface if you use dates in the "due" and "discounts" fields.

If you use datetimes instead, our system will apply the value modifiers in the same manner, but the end user will only see the final value to be paid on his interface.

Also, other banks will most likely only allow payment scheduling on invoices defined with dates instead of datetimes.

Note: Instead of using Invoice objects, you can also pass each invoice element directly in array format, without using the constructor

Get an invoice

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

Get an invoice QR Code

After its creation, an Invoice QR Code may be retrieved by its id.

Be careful not to accidentally enforce any encoding on the raw png content, as it may corrupt the file.

Get an invoice PDF

After its creation, an invoice PDF may be retrieved by its id.

Be careful not to accidentally enforce any encoding on the raw pdf content, as it may yield abnormal results in the final file, such as missing images and strange characters.

Cancel an invoice

You can also cancel an invoice by its id. Note that this is not possible if it has been paid already.

Update an invoice

You can update an invoice's amount, due date and expiration by its id. If the invoice has already been paid, only the amount can be decreased, which will result in a payment reversal. To fully reverse the invoice, pass "amount" => 0.

Query invoices

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

Get a reversed invoice log PDF

Whenever an Invoice is successfully reversed, a reversed log will be created. To retrieve a specific reversal receipt, you can request the corresponding log PDF:

Be careful not to accidentally enforce any encoding on the raw pdf content, as it may yield abnormal results in the final file, such as missing images and strange characters.

Get an invoice payment information

Once an invoice has been paid, you can get the payment information using the Invoice.Payment sub-resource:

Query invoice logs

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

Get an invoice log

You can get a single log by its id.

Create DynamicBrcodes

You can create simplified dynamic QR Codes to receive money using Pix transactions. When a DynamicBrcode is paid, a Deposit is created with the tags parameter containing the character “dynamic-brcode/” followed by the DynamicBrcode’s uuid "dynamic-brcode/{uuid}" for conciliation.

The differences between an Invoice and the DynamicBrcode are the following:

Invoice DynamicBrcode
Expiration
Due, fine and fee X
Discount X
Description X
Can be updated X

Note: In order to check if a BR code has expired, you must first calculate its expiration date (add the expiration to the creation date). Note: To know if the BR code has been paid, you need to query your Deposits by the tag "dynamic-brcode/{uuid}" to check if it has been paid.

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

Get a DynamicBrcode

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

Query DynamicBrcodes

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

Query deposits

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

Get a deposit

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

Update an deposit

You can update a deposit's amount by its id. To fully reverse the deposit, pass "amount" => 0.

Query deposit logs

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

Get a deposit log

You can get a single log by its id.

Create boletos

You can create boletos to charge customers or to receive money from accounts you have in other banks.

Note: Instead of using Boleto objects, you can also pass each boleto element directly in array format, without using the constructor

Get a boleto

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

Get a boleto PDF

After its creation, a boleto PDF may be retrieved by passing its id.

Be careful not to accidentally enforce any encoding on the raw pdf content, as it may yield abnormal results in the final file, such as missing images and strange characters.

Delete a boleto

You can also cancel a boleto by its id. Note that this is not possible if it has been processed already.

Query boletos

You can get an array of created boletos given some filters.

Query boleto logs

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

Get a boleto log

You can get a single log by its id.

Investigate a boleto

You can discover if a StarkBank boleto has been recently paid before we receive the response on the next day. This can be done by creating a BoletoHolmes object, which fetches the updated status of the corresponding Boleto object according to CIP to check, for example, whether it is still payable or not. The investigation happens asynchronously and the most common way to retrieve the results is to register a "boleto-holmes" webhook subscription, although polling is also possible.

Note: Instead of using BoletoHolmes objects, you can also pass each payment element directly in array format, without using the constructor

Get a boleto holmes

To get a single Holmes by its id, run:

Query boleto holmes

You can search for boleto Holmes using filters.

Query boleto holmes logs

Searches are also possible with boleto holmes logs:

Get a boleto holmes log

You can also get a boleto holmes log by specifying its id.

Pay a BR Code

Paying a BR Code is also simple.

Note: You can also configure payment behavior according to its rules Note: Instead of using BrcodePayment objects, you can also pass each payment element directly in array format, without using the constructor

Get a BR Code payment

To get a single BR Code payment by its id, run:

Get a BR Code payment PDF

After its creation, a BR Code payment PDF may be retrieved by its id.

Be careful not to accidentally enforce any encoding on the raw pdf content, as it may yield abnormal results in the final file, such as missing images and strange characters.

Query BR Code payments

You can search for BR Code payments using filters.

Query BR Code payment logs

Searches are also possible with BR Code payment logs:

Get a BR Code payment log

You can also get a BR Code payment log by specifying its id.

Pay a boleto

Paying a boleto is also simple.

Note: Instead of using BoletoPayment objects, you can also pass each payment element directly in array format, without using the constructor

Get a boleto payment

To get a single boleto payment by its id, run:

Get a boleto payment PDF

After its creation, a boleto payment PDF may be retrieved by passing its id.

Be careful not to accidentally enforce any encoding on the raw pdf content, as it may yield abnormal results in the final file, such as missing images and strange characters.

Delete a boleto payment

You can also cancel a boleto payment by its id. Note that this is not possible if it has been processed already.

Query boleto payments

You can search for boleto payments using filters.

Query boleto payment logs

Searches are also possible with boleto payment logs:

Get a boleto payment log

You can also get a boleto payment log by specifying its id.

Create utility payments

It's also simple to pay utility bills (such as electricity and water bills) in the SDK.

Note: Instead of using UtilityPayment objects, you can also pass each payment element directly in array format, without using the constructor

Query utility payments

To search for utility payments using filters, run:

Get a utility payment

You can get a specific bill by its id:

Get a utility payment PDF

After its creation, a utility payment PDF may also be retrieved by passing its id.

Be careful not to accidentally enforce any encoding on the raw pdf content, as it may yield abnormal results in the final file, such as missing images and strange characters.

Delete a utility payment

You can also cancel a utility payment by its id. Note that this is not possible if it has been processed already.

Query utility payment logs

You can search for payments by specifying filters. Use this to understand the bills life cycles.

Get a utility payment log

If you want to get a specific payment log by its id, just run:

Create tax payment

It is also simple to pay taxes (such as ISS and DAS) using this SDK.

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

Query tax payments

To search for tax payments using filters, run:

Get tax payment

You can get a specific tax payment by its id:

Get tax payment PDF

After its creation, a tax payment PDF may also be retrieved by its id.

Be careful not to accidentally enforce any encoding on the raw pdf content, as it may yield abnormal results in the final file, such as missing images and strange characters.

Delete tax payment

You can also cancel a tax payment by its id. Note that this is not possible if it has been processed already.

Query tax payment logs

You can search for payment logs by specifying filters. Use this to understand each payment life cycle.

Get tax payment log

If you want to get a specific payment log by its id, just run:

Create DARF payment

If you want to manually pay DARFs without barcodes, you may create DarfPayments:

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

Query DARF payments

To search for DARF payments using filters, run:

Get DARF payment

You can get a specific DARF payment by its id:

Get DARF payment PDF

After its creation, a DARF payment PDF may also be retrieved by its id.

Be careful not to accidentally enforce any encoding on the raw pdf content, as it may yield abnormal results in the final file, such as missing images and strange characters.

Delete DARF payment

You can also cancel a DARF payment by its id. Note that this is not possible if it has been processed already.

Query DARF payment logs

You can search for payment logs by specifying filters. Use this to understand each payment life cycle.

Get DARF payment log

If you want to get a specific payment log by its id, just run:

Note: Some taxes can't be payed with bar codes. Since they have specific parameters, each one of them has its own resource and routes, which are all analogous to the TaxPayment resource. The ones we currently support are:

Preview payment information before executing the payment

You can preview multiple types of payment to confirm any information before actually paying. If the "scheduled" parameter is not informed, today will be assumed as the intended payment date. Right now, the "scheduled" parameter only has effect on BrcodePreviews. This resource is able to preview the following types of payment: "brcode-payment", "boleto-payment", "utility-payment" and "tax-payment"

Note: Instead of using PaymentPreview objects, you can also pass each element directly in array format, without using the constructor

Create payment requests to be approved by authorized people in a cost center

You can also request payments that must pass through a specific cost center approval flow to be executed. In certain structures, this allows double checks for cash-outs and also gives time to load your account with the required amount before the payments take place. The approvals can be granted at our website and must be performed according to the rules specified in the cost center.

Note: The value of the centerId parameter can be consulted by logging into our website and going to the desired cost center page.

Note: Instead of using PaymentRequest objects, you can also pass each request element directly in array format, without using the constructor

Query payment requests

To search for payment requests, run:

Create CorporateHolders

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 CorporateHolder objects, you can also pass each element in dictionary format

Query CorporateHolders

You can query multiple holders according to filters.

Cancel a CorporateHolder

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

Get a CorporateHolder

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

Query CorporateHolder logs

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

Get a CorporateHolder log

You can also get a specific log by its id.

Create CorporateCard

You can issue cards with specific spending rules.

Query CorporateCards

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

Get a CorporateCard

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

Update a CorporateCard

You can update a specific card by its id.

Cancel a CorporateCard

You can also cancel a card by its id.

Query CorporateCard logs

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

Get a CorporateCard log

You can get a single log by its id.

Query CorporatePurchases

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

Get a CorporatePurchase

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

Query CorporatePurchase logs

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

Get a CorporatePurchase log

You can get a single log by its id.

Create CorporateInvoices

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

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

Query CorporateInvoices

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

Create CorporateWithdrawals

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

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

Get a CorporateWithdrawal

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

Query CorporateWithdrawals

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

Get your CorporateBalance

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

Query CorporateTransactions

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

Get a CorporateTransaction

You can get a specific transaction by its id:

Corporate Enums

Query MerchantCategories

You can query any merchant categories using this resource. You may also use MerchantCategories to define specific category filters in CorporateRules. 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 CorporateRules.

Query CardMethods

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

Split

Query Splits

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

Get a Split

To get a single Split by its id, run:

Query Split Logs

You can query Split logs to check additional information.

Get a Split Log

You can also get a Split log by specifying its id.

Create SplitReceivers

You can create receivers to an Invoice Split by using the SplitReceiver resource.

Query SplitReceivers

To take a look at the SplitReceivers created to your workspace, just run the following:

Get a Split Receiver

To get a single SplitReceiver by its id, run:

Query SplitReceiver Logs

You can query SplitReceiver logs to check additional information

Get a SplitReceiver Log

You can also get a SplitReceiver Log by specifying its id.

Put SplitProfile

You can create a profile or update if it is alredy created.

Query SplitProfile

To take a look at the SplitProfile created to your workspace, just run the following:

Get a Split Profile

To get a single SplitProfile by its id, run:

Query SplitProfile Logs

You can query SplitProfile logs to check additional information

Get a SplitProfile Log

You can also get a SplitProfile Log by specifying its id.

Create a webhook subscription

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

Query webhook subscriptions

To search for registered webhooks, run:

Get a webhook subscription

You can get a specific webhook by its id.

Delete a webhook subscription

You can also delete a specific webhook by its id.

Process webhook events

It's easy to process events that arrived in your webhook. Remember to pass the signature header so the SDK can make sure it's really StarkBank 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:

Create a new Workspace

The Organization user allows you to create new Workspaces (bank accounts) under your organization. Workspaces have independent balances, statements, operations and users. The only link between your Workspaces is the Organization that controls them.

Note: This route will only work if the Organization user is used with workspaceId=null.

List your Workspaces

This route lists Workspaces. If no parameter is passed, all the workspaces the user has access to will be listed, but you can also find other Workspaces by searching for their usernames or IDs directly.

Get a Workspace

You can get a specific Workspace by its id.

Update a Workspace

You can update a specific Workspace by its id.

Request

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

GET

You can perform a GET request to any StarkBank 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.

You can get a resource file using this method.

POST

You can perform a POST request to any StarkBank 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 StarkBank route.

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

PUT

You can perform a PUT request to any StarkBank route.

It's possible to put a single item of a StarkBank resource.

DELETE

You can perform a DELETE request to any StarkBank route.

It's possible to delete a single item of a StarkBank 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 StarkBank\Event::parse() when the provided content and signature do not check out with the Stark Bank 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
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 starkbank/sdk contains the following files

Loading the files please wait ....