Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
1 change: 0 additions & 1 deletion code_samples/python/v1.0.0/cancel_payment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from tatrapayplus import TatrapayPlusClient

client = TatrapayPlusClient(
"https://api.tatrabanka.sk/tatrapayplus/sandbox",
"your-client-id",
"your-client-secret"
)
Expand Down
3 changes: 1 addition & 2 deletions code_samples/python/v1.0.0/chargeback.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from tatrapayplus.models import *

client = TatrapayPlusClient(
"https://api.tatrabanka.sk/tatrapayplus/sandbox",
"your-client-id",
"your-client-secret",
"your-client-secret"
)
payment_id = "b54afd37-5bb9-4080-9416-5ec450779087"
chargeback_data = CardPayUpdateInstruction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from tatrapayplus.models import *

client = TatrapayPlusClient(
"https://api.tatrabanka.sk/tatrapayplus/sandbox",
"your-client-id",
"your-client-secret",
"your-client-secret"
)
payment_id = "b54afd37-5bb9-4080-9416-5ec450779087"
cancel_pre_authorization_data = CardPayUpdateInstruction(
Expand Down
34 changes: 31 additions & 3 deletions code_samples/python/v1.0.0/create_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,48 @@
from tatrapayplus.models import *

client = TatrapayPlusClient(
"https://api.tatrabanka.sk/tatrapayplus/sandbox",
"your-client-id",
"your-client-secret",
)

payment_data = InitiatePaymentRequest(
base_payment=BasePayment(
instructed_amount=Amount(
amount_value=120.0,
amount_value=10.0,
currency="EUR",
),
end_to_end="ORDER123456",
),
bank_transfer=BankTransfer(),
pay_later=PayLater(
order=Order(
order_no="ORDER123456",
order_items=[
OrderItem(
quantity=1,
total_item_price=10.0,
item_detail=ItemDetail(
item_detail_sk=ItemDetailLangUnit(
item_name="Testovací produkt",
item_description="Popis produktu",
),
item_detail_en=ItemDetailLangUnit(
item_name="Test Product",
item_description="Product description",
),
),
)
],
),
),
card_detail=CardDetail(
card_holder="Janko Hruška",
),
user_data=UserData(
first_name="Janko",
last_name="Hruska",
email="janko.hruska@example.com",
),
)

response = client.create_payment(payment_data, "https://your-redirect-uri.com")
response = client.create_payment(payment_data, "https://your-redirect-uri.com", "127.0.0.1")
3 changes: 1 addition & 2 deletions code_samples/python/v1.0.0/create_payment_direct.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from tatrapayplus import TatrapayPlusClient
from tatrapayplus.models import *

payment_data = InitiateDirectTransactionRequest(
Expand Down Expand Up @@ -50,4 +49,4 @@
),
)

client.create_payment_direct(payment_data, "https://your-redirect-uri.com")
client.create_payment_direct(payment_data, "https://your-redirect-uri.com", "127.0.0.1")
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from tatrapayplus.models import *

client = TatrapayPlusClient(
"https://api.tatrabanka.sk/tatrapayplus/sandbox",
"your-client-id",
"your-client-secret"
"your-client-secret",
)

payment_data = InitiatePaymentRequest(
Expand All @@ -22,4 +21,4 @@
bank_transfer=BankTransfer(),
)

response = client.create_payment(payment_data, "https://your-redirect-uri.com")
response = client.create_payment(payment_data, "https://your-redirect-uri.com", "127.0.0.1")
1 change: 0 additions & 1 deletion code_samples/python/v1.0.0/get_access_token.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from tatrapayplus import TatrapayPlusClient

client = TatrapayPlusClient(
"https://api.tatrabanka.sk/tatrapayplus/sandbox",
"your-client-id",
"your-client-secret",
)
Expand Down
3 changes: 1 addition & 2 deletions code_samples/python/v1.0.0/get_available_payment_methods.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from tatrapayplus import TatrapayPlusClient, PaymentMethod

client = TatrapayPlusClient(
"https://api.tatrabanka.sk/tatrapayplus/sandbox",
"your-client-id",
"your-client-secret"
"your-client-secret",
)

# Get all available payment methods for this transaction
Expand Down
3 changes: 1 addition & 2 deletions code_samples/python/v1.0.0/get_payment_status.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from tatrapayplus import TatrapayPlusClient

client = TatrapayPlusClient(
"https://api.tatrabanka.sk/tatrapayplus/sandbox",
"your-client-id",
"your-client-secret"
"your-client-secret",
)
payment_id = "b54afd37-5bb9-4080-9416-5ec450779087" # Retrieved from create payment intent
payment_status = client.get_payment_status(payment_id)
1 change: 0 additions & 1 deletion code_samples/python/v1.0.0/set_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from tatrapayplus.models import *

client = TatrapayPlusClient(
"https://api.tatrabanka.sk/tatrapayplus/sandbox",
"your-client-id",
"your-client-secret"
)
Expand Down
1 change: 0 additions & 1 deletion code_samples/python/v1.0.0/set_logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from tatrapayplus.models import *

client = TatrapayPlusClient(
"https://api.tatrabanka.sk/tatrapayplus/sandbox",
"your-client-id",
"your-client-secret"
)
Expand Down
1 change: 0 additions & 1 deletion code_samples/python/v1.0.0/update_payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from tatrapayplus.models import *

client = TatrapayPlusClient(
"https://api.tatrabanka.sk/tatrapayplus/sandbox",
"your-client-id",
"your-client-secret"
)
Expand Down
108 changes: 108 additions & 0 deletions docs/libraries/node/v1.0.0/logging.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Logging

# TBPlusLogger

The `TBPlusLogger` is a simple and customizable HTTP logger for the `TBPlusSDK`.
It helps you debug API calls by logging outgoing requests and incoming responses, while safely masking sensitive data.

---

## Features

- Logs **request and response** metadata
- Built-in **field masking**
- Extendable via `writeLine()` to customize output (console, file, etc.)

## Masked Fields

The logger masks sensitive values before outputting them:

- **Headers**: `Authorization`
- **Body fields (reqest and response)**: `client_id`, `client_secret`, `access_token`

Example masked output: `client_secret=abcde*************uvxyz`

You can disable masking by passing false to the constructor:
```javascript
const logger = new TBPlusLogger(false);
```

## Usage Example

### Step 1: Create a Logger Subclass


```javascript
import { TBPlusLogger } from "./logger";

class ConsoleLogger extends TBPlusLogger {
protected writeLine(line: string): void {
console.log("[ConsoleLogger]", line);
}
}
}

```

### Step 2: Use Logger with the SDK

```javascript
import { TBPlusSDK } from "tbplus-sdk";

const logger = new ConsoleLogger();

const sdk = new TBPlusSDK(
API_KEY,
API_SECRET,
"192.0.2.123",
{},
logger
);
```

## Customization
You can configure which fields are masked:

```javascript
logger.maskSensitiveData = true;
logger.maskBodyFields = ["client_id", "client_secret", "access_token"];
logger.maskHeaderFields = ["authorization"];
```

## Example output
```
[ConsoleLogger] Request: POST https://api.tatrabanka.sk/tatrapayplus/sandbox/v1/payments
[ConsoleLogger] Headers:
{
"authorization": "Beare*********************************70d69",
"content-type": "application/json",
"x-request-id": "df7f30e8-6cde-4c76-b377-a2e83fd937dd"
}
[ConsoleLogger] Body:
{
"basePayment": {
"instructedAmount": {
"amountValue": 120,
"currency": "EUR"
},
"endToEnd": "ORDER123456"
},
"bankTransfer": {}
}
[ConsoleLogger] Response Status: 201
[ConsoleLogger] Response:
{
"paymentId": "baf651a5-1582-4b92-9a59-dacd61f65a51",
"tatraPayPlusUrl": "https://api.tatrabanka.sk/...&client_id=l7ba7f*****4955f54&hmac=bf17*****3479a2",
"availablePaymentMethods": [
{
"paymentMethod": "BANK_TRANSFER",
"isAvailable": true
},
...
]
}
```
2 changes: 1 addition & 1 deletion docs/libraries/node/v1.0.0/process_payment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import getPaymentStatus from '!!raw-loader!@site/code_samples/node/v1.0.0/getPay

<CodeBlock language="jsx">{getPaymentStatus}</CodeBlock>

Result includes a `simpleStatus` attribute that can have one of three values: `ACCEPTED`, `PENDING`, or `REJECTED`.
Result includes a `simpleStatus` attribute that can have one of three values: `AUTHORIZED`,`CAPTURE`,`PENDING` or `REJECTED`.
Your implementation should take the appropriate action based on the value of `simpleStatus`.

`data` attribute contains all the information based on structure described in [API reference](/docs/api/get-payment-intent-status).
Expand Down
2 changes: 2 additions & 0 deletions docs/libraries/python/v1.0.0/create_payment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ If `preferred_method` is available user will be directly navigated to this metho
```python
client.create_payment(
payment_data,
redirect_uri,
ip_address,
'en',
'BANK_TRANSFER'
)
Expand Down
1 change: 1 addition & 0 deletions docs/libraries/python/v1.0.0/errors_handling.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ try:
payment_response = client.create_payment(
request=payment_data,
redirect_uri="https://tatrabanka.sk/",
ip_address="127.0.0.1"
)
except TatrapayPlusApiException as e:
print("Payment failed:", e)
Expand Down
14 changes: 10 additions & 4 deletions docs/libraries/python/v1.0.0/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@
To be able to use and test payment gateway you need to have **Client ID** and **Client secret** from [TB developer portal](https://developer.tatrabanka.sk/).

# Installation

🚧 WIP 🚧

```python
pip install tatrapayplus-python
```
# Client Initialization

To start working with the API, you need to initialize the `TatrapayPlusClient` with the following parameters:

```python
from tatrapayplus import TatrapayPlusClient
from tatrapayplus.enums import Mode

client = TatrapayPlusClient(
"https://api.tatrabanka.sk/tatrapayplus/sandbox", # API base URL
"your-client-id", # Client ID
"your-client-secret", # Client secret
mode=Mode.SANDBOX, # Mode you are working with: SANDBOX or PRODUCTION
)
```

There are 2 supported modes:
- `SANDBOX (default)`: requests will be sent to SANDBOX (test) environment of gateway
- `PRODUCTION`: requests will be sent to PRODUCTION (live) environment of gateway
1 change: 0 additions & 1 deletion docs/libraries/python/v1.0.0/logging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ from tatrapayplus.client import TatrapayPlusClient
logger = ConsoleLogger()

client = TatrapayPlusClient(
base_url="https://api.tatrabanka.sk/tatrapayplus/sandbox",
client_id="your-client-id",
client_secret="your-client-secret",
redirect_uri="https://yourapp.com/redirect",
Expand Down
1 change: 1 addition & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const sidebars = {
"libraries/node/v1.0.0/google_apple_pay",
"libraries/node/v1.0.0/cancel_payment",
"libraries/node/v1.0.0/appearances",
"libraries/node/v1.0.0/logging",
],
pythonSidebar: [
"libraries/python/v1.0.0/index",
Expand Down