Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Given a version number MAJOR.MINOR.PATCH, increment:


## [Unreleased]
### Added
- installmentCount attribute to IssuingPurchase resource
- IssuingBillingInvoice resource
- IssuingBillingTransaction resource
- activationCode and url attributes to IssuingToken resource

## [0.18.0] - 2026-05-04
### Added
Expand Down
96 changes: 96 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ This SDK version is compatible with the Stark Infra API v2.
- [Withdrawals](#create-issuingwithdrawals): Send money back to your Workspace from your issuing balance
- [Balance](#get-your-issuingbalance): View your issuing balance
- [Transactions](#query-issuingtransactions): View the transactions that have affected your issuing balance
- [BillingInvoices](#query-issuingbillinginvoices): View the invoices charged for your issuing usage
- [BillingTransactions](#query-issuingbillingtransactions): View the transactions of your issuing billing invoices
- [Pix](#pix)
- [PixRequests](#create-pixrequests): Create Pix transactions
- [PixReversals](#create-pixreversals): Reverse Pix transactions
Expand Down Expand Up @@ -1004,6 +1006,19 @@ await (async() => {
})();
```

You may supply an `activationCode` received through the bank app or SMS when building one.

```javascript
await (async() => {
let token = new starkinfra.IssuingToken({
cardId: '5189831499972623',
activationCode: '481632'
});

console.log(token.activationCode);
})();
```

### Update an IssuingToken

You can update a specific token by its id.
Expand Down Expand Up @@ -1147,6 +1162,21 @@ await (async() => {
})();
```

### Update an IssuingPurchase

You can update a purchase's tags and description by its id.

```javascript
await (async() => {
let purchase = await starkinfra.issuingPurchase.update('5155165527080960', {
'tags': ['tony', 'stark'],
'description': 'Office Supplies'
});

console.log(purchase);
})();
```

### Query IssuingPurchase logs

Logs are pretty important to understand the life cycle of a purchase.
Expand Down Expand Up @@ -1342,6 +1372,72 @@ await (async() => {
})();
```

### Query IssuingBillingInvoices

To view the invoices charged for your issuing usage, you can query them
according to filters.

```javascript
await (async() => {
let invoices = await starkinfra.issuingBillingInvoice.query({
after: '2020-01-01',
before: '2020-03-01'
});

for await (let invoice of invoices) {
console.log(invoice);
}
})();
```

### Get an IssuingBillingInvoice

You can get a specific billing invoice by its id:

```javascript
await (async() => {
let invoice = await starkinfra.issuingBillingInvoice.get('5155165527080960');

console.log(invoice);
})();
```

### Query IssuingBillingTransactions

To view the transactions of your issuing billing invoices, you can query them
according to filters.

```javascript
await (async() => {
let transactions = await starkinfra.issuingBillingTransaction.query({
after: '2020-01-01',
before: '2020-03-01'
});

for await (let transaction of transactions) {
console.log(transaction);
}
})();
```

### Query paginated IssuingBillingTransactions

If your initial number of transactions is too large for a single query, you can page through
the results manually using the cursor returned on each call.

```javascript
await (async() => {
let cursor = null;
let page = null;
do {
[page, cursor] = await starkinfra.issuingBillingTransaction.page({limit: 5, cursor: cursor});
for (let transaction of page) {
console.log(transaction);
}
} while (cursor != null);
})();
```

## Pix

### Create PixRequests
Expand Down
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ exports.issuingTokenDesign = require('./sdk/issuingTokenDesign');
exports.issuingTokenRequest = require('./sdk/issuingTokenRequest');
exports.issuingWithdrawal = require('./sdk/issuingWithdrawal');
exports.issuingTransaction = require('./sdk/issuingTransaction');
exports.issuingBillingInvoice = require('./sdk/issuingBillingInvoice');
exports.issuingBillingTransaction = require('./sdk/issuingBillingTransaction');
exports.event = require('./sdk/event');
exports.webhook = require('./sdk/webhook');
exports.bacenId = require('./sdk/utils/bacenId.js');
Expand Down Expand Up @@ -110,5 +112,7 @@ exports.IssuingTokenDesign = exports.issuingTokenDesign.IssuingTokenDesign;
exports.IssuingTokenRequest = exports.issuingTokenRequest.IssuingTokenRequest;
exports.IssuingWithdrawal = exports.issuingWithdrawal.IssuingWithdrawal;
exports.IssuingTransaction = exports.issuingTransaction.IssuingTransaction;
exports.IssuingBillingInvoice = exports.issuingBillingInvoice.IssuingBillingInvoice;
exports.IssuingBillingTransaction = exports.issuingBillingTransaction.IssuingBillingTransaction;
exports.Event = exports.event.Event;
exports.Webhook = exports.webhook.Webhook;
8 changes: 6 additions & 2 deletions sdk/issuingBalance/issuingBalance.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@ class IssuingBalance extends Resource {
* @param id [string]: unique id returned when IssuingBalance is created. ex: '5656565656565656'
* @param amount [integer]: current balance amount of the workspace in cents. ex: 200 (= R$ 2.00)
* @param currency [string]: currency of the current workspace. Expect others to be added eventually. ex: 'BRL', 'USD'
* @param limit [integer]: Spending limit of the balance
* @param maxLimit [integer]: Maximum spending limit. This field is currently always equal to limit
* @param updated [string]: datetime for the IssuingBalance. ex: '2020-03-10 10:30:00.000'u
*
*/
constructor(id, amount, currency, updated) {
constructor(id, amount, currency, limit, maxLimit, updated) {
super(id);

this.amount = amount;
this.currency = currency;
this.limit = limit;
this.maxLimit = maxLimit;
this.updated = check.datetime(updated);
}
}
Expand Down
6 changes: 6 additions & 0 deletions sdk/issuingBillingInvoice/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const issuingBillingInvoice = require('./issuingBillingInvoice.js');

exports.get = issuingBillingInvoice.get;
exports.query = issuingBillingInvoice.query;
exports.page = issuingBillingInvoice.page;
exports.IssuingBillingInvoice = issuingBillingInvoice.IssuingBillingInvoice;
141 changes: 141 additions & 0 deletions sdk/issuingBillingInvoice/issuingBillingInvoice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
const rest = require('../utils/rest.js');
const check = require('starkcore').check;
const Resource = require('starkcore').Resource;


class IssuingBillingInvoice extends Resource {
/**
*
* IssuingBillingInvoice object
*
* @description Displays the IssuingBillingInvoice objects created in your Workspace.
*
* Attributes (return-only):
* @param id [string]: unique id returned when IssuingBillingInvoice is created. ex: '5656565656565656'
* @param taxId [string]: payer tax ID. ex: '012.345.678-90'
* @param name [string]: payer name. ex: 'Tony Stark'
* @param fine [float]: Fine percentage applied when paid after the due date. ex: 2.0
* @param interest [float]: Monthly interest percentage applied when paid after the due date. ex: 1.0
* @param amount [integer]: invoice value in cents. ex: 1234 (= R$ 12.34)
* @param nominalAmount [integer]: nominal amount in cents. ex: 1234 (= R$ 12.34)
* @param status [string]: current IssuingBillingInvoice status. ex: 'paid'
* @param brcode [string]: BR Code for the invoice payment. ex: '00020101021226930014br.gov.bcb.pix'
* @param link [string]: public invoice webpage URL. ex: 'https://starkbank-card-issuer.sandbox.starkbank.com/billinginvoicelink/97de4d51e8984c459639a645ce920abb'
* @param due [string]: invoice due datetime. ex: '2020-03-10 10:30:00.000'
* @param start [string]: billing cycle start datetime. ex: '2020-03-10 10:30:00.000'
* @param end [string]: billing cycle end datetime. ex: '2020-03-10 10:30:00.000'
* @param created [string]: creation datetime for the IssuingBillingInvoice. ex: '2020-03-10 10:30:00.000'
* @param updated [string]: latest update datetime for the IssuingBillingInvoice. ex: '2020-03-10 10:30:00.000'
*
*/
constructor({
id = null, taxId = null, name = null, fine = null, interest = null, amount = null,
nominalAmount = null, status = null, brcode = null, link = null, due = null,
start = null, end = null, created = null, updated = null
}) {
super(id);

this.taxId = taxId;
this.name = name;
this.fine = fine;
this.interest = interest;
this.amount = amount;
this.nominalAmount = nominalAmount;
this.status = status;
this.brcode = brcode;
this.link = link;
this.due = check.datetime(due);
this.start = check.datetime(start);
this.end = check.datetime(end);
this.created = check.datetime(created);
this.updated = check.datetime(updated);
}
}

exports.IssuingBillingInvoice = IssuingBillingInvoice;
let resource = {'class': exports.IssuingBillingInvoice, 'name': 'IssuingBillingInvoice'};

exports.get = async function (id, {user} = {}) {
/**
*
* Retrieve a specific IssuingBillingInvoice
*
* @description Receive a single IssuingBillingInvoice object previously created in the Stark Infra API by its id
*
* Parameters (required):
* @param id [string]: object unique id. ex: '5656565656565656'
*
* Parameters (optional):
* @param user [Organization/Project object, default null]: Organization or Project object. Not necessary if starkinfra.user was set before function call
*
* Return:
* @returns IssuingBillingInvoice object with updated attributes
*
*/
return rest.getId(resource, id, user);
};

exports.query = async function ({limit, after, before, status, tags, ids, user} = {}) {
/**
*
* Retrieve IssuingBillingInvoices
*
* @description Receive a generator of IssuingBillingInvoice objects previously created in the Stark Infra API
*
* Parameters (optional):
* @param limit [integer, default null]: maximum number of objects to be retrieved. Unlimited if null. ex: 35
* @param after [string, default null]: date filter for objects created only after specified date. ex: '2020-04-03'
* @param before [string, default null]: date filter for objects created only before specified date. ex: '2020-04-03'
* @param status [list of strings, default null]: filter for status of retrieved objects. ex: ['paid']
* @param tags [list of strings, default null]: tags to filter retrieved objects. ex: ['tony', 'stark']
* @param ids [list of strings, default null]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
* @param user [Organization/Project object, default null]: Project object. Not necessary if starkinfra.user was set before function call
*
* Return:
* @returns generator of IssuingBillingInvoice objects with updated attributes
*
*/
let query = {
limit: limit,
after: after,
before: before,
status: status,
tags: tags,
ids: ids,
};
return rest.getList(resource, query, user);
};

exports.page = async function ({cursor, limit, after, before, status, tags, ids, user} = {}) {
/**
*
* Retrieve paged IssuingBillingInvoices
*
* @description Receive a list of up to 100 IssuingBillingInvoice objects previously created in the Stark Infra API and the cursor to the next page.
* Use this function instead of query if you want to manually page your requests.
*
* Parameters (optional):
* @param cursor [string, default null]: cursor returned on the previous page function call
* @param limit [integer, default 100]: maximum number of objects to be retrieved. It must be an integer between 1 and 100. ex: 35
* @param after [string, default null]: date filter for objects created only after specified date. ex: '2020-04-03'
* @param before [string, default null]: date filter for objects created only before specified date. ex: '2020-04-03'
* @param status [list of strings, default null]: filter for status of retrieved objects. ex: ['paid']
* @param tags [list of strings, default null]: tags to filter retrieved objects. ex: ['tony', 'stark']
* @param ids [list of strings, default null]: list of ids to filter retrieved objects. ex: ['5656565656565656', '4545454545454545']
* @param user [Organization/Project object, default null]: Project object. Not necessary if starkinfra.user was set before function call
*
* Return:
* @returns list of IssuingBillingInvoice objects with updated attributes and cursor to retrieve the next page of IssuingBillingInvoice objects
*
*/
let query = {
cursor: cursor,
limit: limit,
after: after,
before: before,
status: status,
tags: tags,
ids: ids,
};
return rest.getPage(resource, query, user);
};
5 changes: 5 additions & 0 deletions sdk/issuingBillingTransaction/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const issuingBillingTransaction = require('./issuingBillingTransaction.js');

exports.query = issuingBillingTransaction.query;
exports.page = issuingBillingTransaction.page;
exports.IssuingBillingTransaction = issuingBillingTransaction.IssuingBillingTransaction;
Loading