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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Given a version number MAJOR.MINOR.PATCH, increment:


## [Unreleased]
### Added
- PixPullSubscription resource
- PixPullRequest resource

## [0.25.0] - 2026-04-08
### Added
Expand Down
250 changes: 250 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ This SDK version is compatible with the Stark Infra API v2.
- [DynamicBrcode](#create-dynamicbrcodes): Create dynamic Pix BR codes
- [BrcodePreview](#create-brcodepreviews): Read data from BR Codes before paying them
- [PixDispute](#create-pixdisputes): Create Pix Disputes
- [PixPullSubscription](#create-pixpullsubscriptions): Set up recurring Pix debit authorizations
- [PixPullRequest](#create-pixpullrequests): Trigger automatic Pix debits against a subscription
- [Lending](#lending)
- [CreditNote](#create-creditnotes): Create credit notes
- [CreditPreview](#create-creditpreviews): Create credit previews
Expand Down Expand Up @@ -2649,6 +2651,254 @@ log = starkinfra.pixdispute.log.get("5155165527080960")
print(log)
```

### Create PixPullSubscriptions

You can create recurring Pix debit authorizations to allow a receiver to pull a series of Pix payments from a sender.

```python
import starkinfra
from datetime import datetime

subscriptions = starkinfra.pixpullsubscription.create([
starkinfra.PixPullSubscription(
bacen_id="RR2017032900000000000000003",
external_id="my-subscription-001",
installment_start=datetime(2026, 4, 1, 12, 0, 0),
interval="month",
receiver_name="Edward Stark",
receiver_tax_id="20.018.183/0001-80",
sender_account_number="876543-2",
sender_bank_code="20018183",
sender_branch_code="1357-9",
sender_tax_id="01234567890",
type="push",
amount=11234,
description="Monthly subscription",
tags=["employees", "monthly"],
)
])

for subscription in subscriptions:
print(subscription)
```

### Query PixPullSubscriptions

You can query multiple PixPullSubscriptions according to filters.

```python
import starkinfra
from datetime import date

subscriptions = starkinfra.pixpullsubscription.query(
limit=10,
after=date(2026, 1, 1),
before=date(2026, 4, 30),
status=["active"],
tags=["monthly"],
)

for subscription in subscriptions:
print(subscription)
```

### Get a PixPullSubscription

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

```python
import starkinfra

subscription = starkinfra.pixpullsubscription.get("5656565656565656")

print(subscription)
```

### Update a PixPullSubscription

You can update a PixPullSubscription by passing its id.

When patching `status` to `"confirmed"`, `sender_city_code` MUST be present in the patch.

```python
import starkinfra

subscription = starkinfra.pixpullsubscription.update(
id="5656565656565656",
status="confirmed",
sender_city_code="3550308",
)

print(subscription)
```

### Cancel a PixPullSubscription

You can cancel a PixPullSubscription by passing its id and a reason. The reason is sent as a query parameter on the DELETE request.

```python
import starkinfra

subscription = starkinfra.pixpullsubscription.cancel(
id="5656565656565656",
reason="accountClosed",
)

print(subscription)
```

### Query PixPullSubscription logs

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

```python
import starkinfra
from datetime import date

logs = starkinfra.pixpullsubscription.log.query(
limit=50,
after=date(2026, 1, 1),
before=date(2026, 4, 30),
subscription_ids=["5656565656565656"],
)

for log in logs:
print(log)
```

### Get a PixPullSubscription log

You can also get a specific log by its id.

```python
import starkinfra

log = starkinfra.pixpullsubscription.log.get("5155165527080960")

print(log)
```

### Process inbound PixPullSubscription events

Inbound PixPullSubscription events will be POSTed at your registered endpoint. You can use the `parse` function to verify the digital signature and reconstruct the PixPullSubscription object.

```python
import starkinfra

subscription = starkinfra.pixpullsubscription.parse(
content='{"bacenId": "RR2017032900000000000000003", ...}',
signature="MEUCIQC7FVhXdripx/aXg5yNLxmNoZlehpyvX3QYDXJ8o3PAZQIgVe1omKFh7Vd54ML4U1z7L+kpx+GHl+G2XLeFTLZeBJk=",
)

print(subscription)
```

### Create PixPullRequests

You can create PixPullRequests to trigger automatic debits against an active PixPullSubscription.

```python
import starkinfra
from datetime import datetime

requests = starkinfra.pixpullrequest.create([
starkinfra.PixPullRequest(
amount=11234,
due=datetime(2026, 4, 15, 12, 0, 0),
end_to_end_id="E00002649202201172211u34srod19le",
receiver_account_number="876543-2",
receiver_account_type="checking",
receiver_bank_code="20018183",
reconciliation_id="cycle-202604",
subscription_id="5656565656565656",
tags=["monthly"],
)
])

for request in requests:
print(request)
```

### Query PixPullRequests

```python
import starkinfra
from datetime import date

requests = starkinfra.pixpullrequest.query(
limit=10,
after=date(2026, 1, 1),
before=date(2026, 4, 30),
status=["created", "active"],
subscription_ids=["5656565656565656"],
)

for request in requests:
print(request)
```

### Get a PixPullRequest

```python
import starkinfra

request = starkinfra.pixpullrequest.get("5656565656565656")
print(request)
```

### Update a PixPullRequest

Change the status to `"scheduled"` or `"denied"`. When denying, `reason` is required.

```python
import starkinfra

request = starkinfra.pixpullrequest.update(
id="5656565656565656",
status="denied",
reason="senderAccountClosed",
)
print(request)
```

### Cancel a PixPullRequest

```python
import starkinfra

request = starkinfra.pixpullrequest.cancel(
id="5656565656565656",
reason="senderUserRequested",
)
print(request)
```

### Query PixPullRequest logs

```python
import starkinfra
from datetime import date

logs = starkinfra.pixpullrequest.log.query(
limit=50,
after=date(2026, 1, 1),
before=date(2026, 4, 30),
request_ids=["5656565656565656"],
)

for log in logs:
print(log)
```

### Get a PixPullRequest log

```python
import starkinfra

log = starkinfra.pixpullrequest.log.get("5155165527080960")
print(log)
```

## 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
Expand Down
6 changes: 6 additions & 0 deletions starkinfra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
from . import pixuser
from .pixuser.__pixuser import PixUser

from . import pixpullsubscription
from .pixpullsubscription.__pixpullsubscription import PixPullSubscription

from . import pixpullrequest
from .pixpullrequest.__pixpullrequest import PixPullRequest

from . import issuingbalance
from .issuingbalance.__issuingbalance import IssuingBalance

Expand Down
6 changes: 5 additions & 1 deletion starkinfra/event/__event.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from ..pixchargeback.log.__log import _resource as _pixchargeback_log_resource
from ..pixdispute.log.__log import _resource as _pixdispute_log_resource
from ..pixinfraction.log.__log import _resource as _pixinfraction_log_resource
from ..pixpullsubscription.log.__log import _resource as _pixpullsubscription_log_resource
from ..pixpullrequest.log.__log import _resource as _pixpullrequest_log_resource
from ..issuingcard.log.__log import _resource as _issuingcard_log_resource
from ..issuinginvoice.log.__log import _resource as _issuinginvoice_log_resource
from ..issuingpurchase.log.__log import _resource as _issuingpurchase_log_resource
Expand All @@ -26,6 +28,8 @@
"pix-request.out": _pixrequest_log_resource,
"pix-reversal.in": _pixreversal_log_resource,
"pix-reversal.out": _pixreversal_log_resource,
"pix-pull-subscription": _pixpullsubscription_log_resource,
"pix-pull-request": _pixpullrequest_log_resource,
"issuing-card": _issuingcard_log_resource,
"issuing-invoice": _issuinginvoice_log_resource,
"issuing-purchase": _issuingpurchase_log_resource,
Expand All @@ -43,7 +47,7 @@ class Event(Resource):
- log [Log]: a Log object from one of the subscribed services (PixRequestLog, PixReversalLog)
- created [datetime.datetime]: creation datetime for the notification Event. ex: datetime.datetime(2020, 3, 10, 10, 30, 0, 0)
- is_delivered [bool]: true if the Event has been successfully delivered to the user url. ex: False
- subscription [string]: service that triggered this Event. Options: "pix-request.in", "pix-request.out", "pix-reversal.in", "pix-reversal.out", "pix-key", "pix-claim", "pix-infraction", "pix-chargeback", "issuing-card", "issuing-invoice", "issuing-purchase", "credit-note"
- subscription [string]: service that triggered this Event. Options: "pix-request.in", "pix-request.out", "pix-reversal.in", "pix-reversal.out", "pix-key", "pix-claim", "pix-infraction", "pix-chargeback", "pix-dispute", "pix-pull-subscription", "pix-pull-request", "issuing-card", "issuing-invoice", "issuing-purchase", "credit-note"
- workspace_id [string]: ID of the Workspace that generated this Event. Mostly used when multiple Workspaces have Webhooks registered to the same endpoint. ex: "4545454545454545"
"""

Expand Down
3 changes: 3 additions & 0 deletions starkinfra/pixpullrequest/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import log
from .log.__log import Log
from .__pixpullrequest import create, get, query, page, update, cancel
Loading