Skip to content

Commit 919678d

Browse files
Fix indentation
1 parent f5a99a7 commit 919678d

File tree

12 files changed

+158
-93
lines changed

12 files changed

+158
-93
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Given a version number MAJOR.MINOR.PATCH, increment:
1414

1515
## [Unreleased]
1616
### Added
17-
- merchantSession and merchantSessionPurchase resources
17+
- MerchantSession and MerchantSessionPurchase resources
1818

1919
## [2.26.1] - 2025-02-18
2020
### Fixed

README.md

+117-65
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ is as easy as sending a text message to your client!
4949
- [CorporateBalance](#get-your-corporatebalance): View your corporate balance
5050
- [CorporateTransactions](#query-corporatetransactions): View the transactions that have affected your corporate balance
5151
- [CorporateEnums](#corporate-enums): Query enums related to the corporate purchases, such as merchant categories, countries and card purchase methods
52-
- [MerchantSession](#merchant-session): The Merchant Session allows you to create a session prior to a purchase. Sessions are essential for defining the parameters of a purchase, including funding type, expiration, 3DS, and more.
53-
- [MerchantPurchase](#merchant-purchase): The Merchant Purchase resource can be used to charge customers with credit or debit cards. If a card hasn't been used before, a Merchant Session Purchase must be created and approved with that specific card before it can be used directly in a Merchant Purchase.
52+
- [MerchantCard](#query-merchantcard): The Merchant Card resource stores information about cards used in approved purchases. These cards can be used in new purchases without the need to create a new session.
53+
- [MerchantSession](#create-a-merchantsession): The Merchant Session allows you to create a session prior to a purchase. Sessions are essential for defining the parameters of a purchase, including funding type, expiration, 3DS, and more.
54+
- [MerchantPurchase](#create-a-merchantpurchase): The Merchant Purchase resource can be used to charge customers with credit or debit cards. If a card hasn't been used before, a Merchant Session Purchase must be created and approved with that specific card before it can be used directly in a Merchant Purchase.
55+
- [MerchantInstallment](#query-merchantinstallment): Merchant Installments are created for every installment in a purchase. These resources will track its own due payment date and settlement lifecycle.
5456
- [Split](#query-splits): Split received Invoice payments between different receivers
5557
- [SplitReceiver](#create-splitreceivers): Receiver of an Invoice split
5658
- [Webhooks](#create-a-webhook-subscription): Configure your webhook endpoints and subscriptions
@@ -2334,13 +2336,36 @@ log = starkbank.splitreceiver.log.get("5155165527080960")
23342336

23352337
print(log)
23362338
```
2337-
## Merchant Session
23382339

2339-
The Merchant Session allows you to create a session prior to a purchase.
2340-
Sessions are essential for defining the parameters of a purchase, including funding type, expiration, 3DS, and more.
2340+
## Merchant Card
2341+
2342+
The Merchant Card resource stores information about cards used in approved purchases.
2343+
These cards can be used in new purchases without the need to create a new session.
2344+
2345+
## Query MerchantCard
2346+
2347+
```python
2348+
import starkbank
2349+
2350+
merchant_cards = starkbank.merchantcard.query(limit=3)
2351+
for merchant_card in merchant_cards:
2352+
print(merchant_card)
2353+
```
2354+
2355+
## Get a MerchantCard
2356+
2357+
```python
2358+
import starkbank
2359+
2360+
merchantcard = starkbank.merchantcard.get('5950134772826112')
2361+
print(merchantcard)
2362+
```
23412363

23422364
## Create a MerchantSession
23432365

2366+
The Merchant Session allows you to create a session prior to a purchase.
2367+
Sessions are essential for defining the parameters of a purchase, including funding type, expiration, 3DS, and more.
2368+
23442369
```python
23452370
import starkbank
23462371

@@ -2355,18 +2380,18 @@ merchant_session = starkbank.merchantsession.create({
23552380
"count": 1
23562381
},
23572382
{
2358-
"totalAmount": 120,
2383+
"totalAmount": 12000,
23592384
"count": 2
23602385
},
23612386
{
2362-
"totalAmount": 180,
2387+
"totalAmount": 18000,
23632388
"count": 12
23642389
}
23652390
],
23662391
"expiration": 3600,
23672392
"challengeMode": "disabled",
23682393
"tags": [
2369-
"yourTags"
2394+
"your-tags"
23702395
]
23712396
})
23722397

@@ -2376,105 +2401,132 @@ print(merchant_session)
23762401
You can create a MerchantPurchase through a MerchantSession by passing its UUID.
23772402
**Note**: This method must be implemented in your front-end to ensure that sensitive card data does not pass through the back-end of the integration.
23782403

2379-
### Create a MerchantSession Purchase
2404+
## Create a MerchantSession Purchase
23802405

23812406
```python
23822407
import starkbank
23832408

23842409
merchant_session_purchase = starkbank.merchantsession.purchase(
2385-
uuid="0bb894a2697d41d99fe02cad2c00c9bc",
2386-
amount=180,
2387-
installment_count=12,
2388-
card_expiration="2035-01",
2389-
card_number="5448280000000007",
2390-
card_security_code="123",
2391-
holder_name="Margaery Tyrell",
2392-
holder_email="[email protected]",
2393-
holder_phone="11998663456",
2394-
funding_type="credit",
2395-
billing_country_code="BRA",
2396-
billing_city="São Paulo",
2397-
billing_state_code="SP",
2398-
billing_street_line1="Rua do Jardim de cima, 123",
2399-
billing_street_line2="1 andar",
2400-
billing_zip_code="11111-111",
2401-
metadata={
2402-
"extraData": "extraData",
2403-
"language": "pt-BR",
2404-
"timezoneOffset": 3,
2405-
"userAgent": "Mozilla",
2406-
"userIp": "255.255.255.255"
2407-
}
2408-
)
2410+
uuid="0bb894a2697d41d99fe02cad2c00c9bc",
2411+
amount=18000,
2412+
installment_count=12,
2413+
card_expiration="2035-01",
2414+
card_number="5448280000000007",
2415+
card_security_code="123",
2416+
holder_name="Margaery Tyrell",
2417+
holder_email="[email protected]",
2418+
holder_phone="11998663456",
2419+
funding_type="credit",
2420+
billing_country_code="BRA",
2421+
billing_city="São Paulo",
2422+
billing_state_code="SP",
2423+
billing_street_line1="Rua do Jardim de cima, 123",
2424+
billing_street_line2="1 andar",
2425+
billing_zip_code="11111-111",
2426+
metadata={
2427+
"extraData": "extraData",
2428+
"language": "pt-BR",
2429+
"timezoneOffset": 3,
2430+
"userAgent": "Mozilla",
2431+
"userIp": "255.255.255.255"
2432+
}
2433+
)
24092434

24102435
print(merchant_session_purchase)
24112436
```
2412-
### Query MerchantSessions
2437+
2438+
## Query MerchantSessions
2439+
24132440
```python
24142441
import starkbank
24152442

24162443
merchant_sessions = starkbank.merchantsession.query(limit=3)
24172444
for merchant_session in merchant_sessions:
24182445
print(merchant_session)
24192446
```
2420-
### Get a MerchantSession
2447+
2448+
## Get a MerchantSession
2449+
24212450
```python
24222451
import starkbank
24232452

24242453
merchant_session = starkbank.merchantsession.get('5950134772826112')
24252454
print(merchant_session)
24262455
```
2427-
## Merchant Purchase
2456+
2457+
## Create a MerchantPurchase
2458+
24282459
The Merchant Purchase resource can be used to charge customers with credit or debit cards.
24292460
If a card hasn't been used before, a Merchant Session Purchase must be created and approved with that specific card before it can be used directly in a Merchant Purchase.
24302461

2431-
### Create a MerchantPurchases
24322462
```python
24332463
import starkbank
24342464

24352465
merchant_purchase = starkbank.merchantpurchase.create(
2436-
starkbank.MerchantPurchase(
2437-
amount=10000,
2438-
installment_count=5,
2439-
card_id="6295415968235520",
2440-
funding_type="credit",
2441-
challenge_mode="disabled",
2442-
billing_city="Sao Paulo",
2443-
billing_country_code="BRA",
2444-
billing_state_code="SP",
2445-
billing_street_line_1="Rua Casterly Rock, 2000",
2446-
billing_street_line_2="1 andar",
2447-
billing_zip_code="11111-111",
2448-
holder_email="[email protected]",
2449-
holder_phone="11985923451",
2450-
metadata={
2451-
"userAgent": "userAgent",
2452-
"userIp": "255.255.255.255",
2453-
"language": "pt-BR",
2454-
"timezoneOffset": 3,
2455-
"extraData": "extraData"
2456-
},
2457-
tags=["teste"]
2458-
)
2459-
)
2460-
```
2461-
2462-
### Query MerchantPurchases
2466+
starkbank.MerchantPurchase(
2467+
amount=10000,
2468+
installment_count=5,
2469+
card_id="6295415968235520",
2470+
funding_type="credit",
2471+
challenge_mode="disabled",
2472+
billing_city="Sao Paulo",
2473+
billing_country_code="BRA",
2474+
billing_state_code="SP",
2475+
billing_street_line_1="Rua Casterly Rock, 2000",
2476+
billing_street_line_2="1 andar",
2477+
billing_zip_code="11111-111",
2478+
holder_email="[email protected]",
2479+
holder_phone="11985923451",
2480+
metadata={
2481+
"userAgent": "userAgent",
2482+
"userIp": "255.255.255.255",
2483+
"language": "pt-BR",
2484+
"timezoneOffset": 3,
2485+
"extraData": "extraData"
2486+
},
2487+
tags=["teste"]
2488+
)
2489+
)
2490+
```
2491+
2492+
## Query MerchantPurchases
2493+
24632494
```python
24642495
import starkbank
24652496

24662497
merchant_purchases = starkbank.merchantpurchase.query(limit=3)
24672498
for merchant_purchase in merchant_purchases:
24682499
print(merchant_purchase)
24692500
```
2470-
### Get a MerchantPurchase
2501+
2502+
## Get a MerchantPurchase
2503+
24712504
```python
24722505
import starkbank
24732506

24742507
merchant_purchase = starkbank.merchantpurchase.get('5950134772826112')
24752508
print(merchant_purchase)
24762509
```
24772510

2511+
## Query MerchantInstallment
2512+
2513+
```python
2514+
import starkbank
2515+
2516+
merchant_installments = starkbank.merchantinstallment.query(limit=3)
2517+
for merchant_installment in merchant_installments:
2518+
print(merchant_installment)
2519+
```
2520+
2521+
## Get a MerchantInstallment
2522+
2523+
```python
2524+
import starkbank
2525+
2526+
merchant_installment = starkbank.merchantinstallment.get('5950134772826112')
2527+
print(merchant_installment)
2528+
```
2529+
24782530
## Create a webhook subscription
24792531

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

starkbank/merchantcard/__merchantcard.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
from starkcore.utils.resource import Resource
21
from ..utils import rest
2+
from starkcore.utils.resource import Resource
33
from starkcore.utils.checks import check_date, check_datetime, check_datetime_or_date
44

55
class MerchantCard(Resource):
66
"""# MerchantCard object
77
Check out our API Documentation at https://starkbank.com/docs/api#merchant-card
88
"""
99

10-
def __init__(self, id=None, ending=None , funding_type=None, holder_name=None, network=None, status=None, tags=None, expiration=None, created=None, updated=None):
10+
def __init__(self, id=None, ending=None , funding_type=None, holder_name=None, network=None, status=None, tags=None,
11+
expiration=None, created=None, updated=None):
1112
Resource.__init__(self, id=id)
1213
self.ending = ending
1314
self.funding_type = funding_type
@@ -19,8 +20,10 @@ def __init__(self, id=None, ending=None , funding_type=None, holder_name=None, n
1920
self.created = check_datetime(created)
2021
self.updated = check_datetime(updated)
2122

23+
2224
_resource = {"class": MerchantCard, "name": "MerchantCard"}
2325

26+
2427
def get(id, user=None):
2528
return rest.get_id(resource=_resource, id=id, user=user)
2629

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .__log import query, page, get
1+
from .__log import query, page, get

starkbank/merchantcard/log/__log.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
from starkcore.utils.resource import Resource
21
from ...utils import rest
2+
from starkcore.utils.resource import Resource
33
from starkcore.utils.api import from_api_json
4-
from starkcore.utils.checks import check_date
4+
from starkcore.utils.checks import check_date, check_datetime
55
from ..__merchantcard import _resource as _merchant_card_resource
66

77

88
class Log(Resource):
9-
"""# MerchantCard object
9+
"""# MerchantCard.Log object
1010
Check out our API Documentation at https://starkbank.com/docs/api#merchant-card
1111
"""
1212

1313
def __init__(self, id, created, updated, type, errors, card):
1414
Resource.__init__(self, id=id)
15-
self.created = check_date(created)
16-
self.updated = check_date(updated)
15+
self.created = check_datetime(created)
16+
self.updated = check_datetime(updated)
1717
self.type = type
1818
self.errors = errors
1919
self.card = from_api_json(_merchant_card_resource, card)
2020

21+
2122
_resource = {"class": Log, "name": "MerchantCardLog"}
2223

2324

starkbank/merchantinstallment/__merchantinstallment.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from starkcore.utils.resource import Resource
21
from ..utils import rest
2+
from starkcore.utils.resource import Resource
33
from starkcore.utils.checks import check_date, check_datetime, check_datetime_or_date
44

55

@@ -8,7 +8,8 @@ class MerchantInstallment(Resource):
88
Check out our API Documentation at https://starkbank.com/docs/api#merchant-installment
99
"""
1010

11-
def __init__(self, id=None, amount=None, created=None, due=None, fee=None, funding_type=None, network=None, purchase_id=None, status=None, tags=None, transaction_ids=None, updated=None):
11+
def __init__(self, id=None, amount=None, created=None, due=None, fee=None, funding_type=None, network=None,
12+
purchase_id=None, status=None, tags=None, transaction_ids=None, updated=None):
1213
Resource.__init__(self, id=id)
1314

1415
self.amount = amount
@@ -23,8 +24,10 @@ def __init__(self, id=None, amount=None, created=None, due=None, fee=None, fundi
2324
self.created = check_datetime(created)
2425
self.updated = check_datetime(updated)
2526

27+
2628
_resource = {"class": MerchantInstallment, "name": "MerchantInstallment"}
2729

30+
2831
def get(id, user=None):
2932
return rest.get_id(resource=_resource, id=id, user=user)
3033

starkbank/merchantinstallment/log/__log.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
from starkcore.utils.resource import Resource
21
from ...utils import rest
2+
from starkcore.utils.resource import Resource
33
from starkcore.utils.api import from_api_json
4-
from starkcore.utils.checks import check_date
4+
from starkcore.utils.checks import check_date, check_datetime
55
from ..__merchantinstallment import _resource as _merchant_installment_resource
66

77

88
class Log(Resource):
9-
"""# MerchantInstallment object
9+
"""# MerchantInstallment.Log object
1010
Check out our API Documentation at https://starkbank.com/docs/api#merchant-installment
1111
"""
1212

1313
def __init__(self, id, created, updated, type, errors, installment):
1414
Resource.__init__(self, id=id)
15-
self.created = check_date(created)
16-
self.updated = check_date(updated)
15+
self.created = check_datetime(created)
16+
self.updated = check_datetime(updated)
1717
self.type = type
1818
self.errors = errors
1919
self.installment = from_api_json(_merchant_installment_resource, installment)
2020

21+
2122
_resource = {"class": Log, "name": "MerchantInstallmentLog"}
2223

2324

0 commit comments

Comments
 (0)