diff --git a/code_samples/python/v1.0.0/cancel_payment.py b/code_samples/python/v1.0.0/cancel_payment.py index 4afbffa..665598f 100644 --- a/code_samples/python/v1.0.0/cancel_payment.py +++ b/code_samples/python/v1.0.0/cancel_payment.py @@ -1,7 +1,6 @@ from tatrapayplus import TatrapayPlusClient client = TatrapayPlusClient( - "https://api.tatrabanka.sk/tatrapayplus/sandbox", "your-client-id", "your-client-secret" ) diff --git a/code_samples/python/v1.0.0/chargeback.py b/code_samples/python/v1.0.0/chargeback.py index 6d6fd7e..fdc362f 100644 --- a/code_samples/python/v1.0.0/chargeback.py +++ b/code_samples/python/v1.0.0/chargeback.py @@ -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( diff --git a/code_samples/python/v1.0.0/confirm_cancel_pre_authorization.py b/code_samples/python/v1.0.0/confirm_cancel_pre_authorization.py index 6eddba3..4456613 100644 --- a/code_samples/python/v1.0.0/confirm_cancel_pre_authorization.py +++ b/code_samples/python/v1.0.0/confirm_cancel_pre_authorization.py @@ -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( diff --git a/code_samples/python/v1.0.0/create_payment.py b/code_samples/python/v1.0.0/create_payment.py index 153b009..19cdde6 100644 --- a/code_samples/python/v1.0.0/create_payment.py +++ b/code_samples/python/v1.0.0/create_payment.py @@ -2,7 +2,6 @@ from tatrapayplus.models import * client = TatrapayPlusClient( - "https://api.tatrabanka.sk/tatrapayplus/sandbox", "your-client-id", "your-client-secret", ) @@ -10,12 +9,41 @@ 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") diff --git a/code_samples/python/v1.0.0/create_payment_direct.py b/code_samples/python/v1.0.0/create_payment_direct.py index 078944c..a731fb5 100644 --- a/code_samples/python/v1.0.0/create_payment_direct.py +++ b/code_samples/python/v1.0.0/create_payment_direct.py @@ -1,4 +1,3 @@ -from tatrapayplus import TatrapayPlusClient from tatrapayplus.models import * payment_data = InitiateDirectTransactionRequest( @@ -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") diff --git a/code_samples/python/v1.0.0/create_payment_pre_authorization.py b/code_samples/python/v1.0.0/create_payment_pre_authorization.py index 47e696a..cadc9a0 100644 --- a/code_samples/python/v1.0.0/create_payment_pre_authorization.py +++ b/code_samples/python/v1.0.0/create_payment_pre_authorization.py @@ -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( @@ -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") diff --git a/code_samples/python/v1.0.0/get_access_token.py b/code_samples/python/v1.0.0/get_access_token.py index 2edeaf2..7d170d2 100644 --- a/code_samples/python/v1.0.0/get_access_token.py +++ b/code_samples/python/v1.0.0/get_access_token.py @@ -1,7 +1,6 @@ from tatrapayplus import TatrapayPlusClient client = TatrapayPlusClient( - "https://api.tatrabanka.sk/tatrapayplus/sandbox", "your-client-id", "your-client-secret", ) diff --git a/code_samples/python/v1.0.0/get_available_payment_methods.py b/code_samples/python/v1.0.0/get_available_payment_methods.py index 096668b..871bc15 100644 --- a/code_samples/python/v1.0.0/get_available_payment_methods.py +++ b/code_samples/python/v1.0.0/get_available_payment_methods.py @@ -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 diff --git a/code_samples/python/v1.0.0/get_payment_status.py b/code_samples/python/v1.0.0/get_payment_status.py index bc6f7d5..c2a3e1a 100644 --- a/code_samples/python/v1.0.0/get_payment_status.py +++ b/code_samples/python/v1.0.0/get_payment_status.py @@ -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) diff --git a/code_samples/python/v1.0.0/set_colors.py b/code_samples/python/v1.0.0/set_colors.py index 8557da6..4d4a651 100644 --- a/code_samples/python/v1.0.0/set_colors.py +++ b/code_samples/python/v1.0.0/set_colors.py @@ -2,7 +2,6 @@ from tatrapayplus.models import * client = TatrapayPlusClient( - "https://api.tatrabanka.sk/tatrapayplus/sandbox", "your-client-id", "your-client-secret" ) diff --git a/code_samples/python/v1.0.0/set_logo.py b/code_samples/python/v1.0.0/set_logo.py index 9e4ff7f..4150b94 100644 --- a/code_samples/python/v1.0.0/set_logo.py +++ b/code_samples/python/v1.0.0/set_logo.py @@ -2,7 +2,6 @@ from tatrapayplus.models import * client = TatrapayPlusClient( - "https://api.tatrabanka.sk/tatrapayplus/sandbox", "your-client-id", "your-client-secret" ) diff --git a/code_samples/python/v1.0.0/update_payment.py b/code_samples/python/v1.0.0/update_payment.py index ef18148..8f45cc7 100644 --- a/code_samples/python/v1.0.0/update_payment.py +++ b/code_samples/python/v1.0.0/update_payment.py @@ -2,7 +2,6 @@ from tatrapayplus.models import * client = TatrapayPlusClient( - "https://api.tatrabanka.sk/tatrapayplus/sandbox", "your-client-id", "your-client-secret" ) diff --git a/docs/libraries/node/v1.0.0/logging.mdx b/docs/libraries/node/v1.0.0/logging.mdx new file mode 100644 index 0000000..ccedacb --- /dev/null +++ b/docs/libraries/node/v1.0.0/logging.mdx @@ -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 + }, + ... + ] +} +``` \ No newline at end of file diff --git a/docs/libraries/node/v1.0.0/process_payment.mdx b/docs/libraries/node/v1.0.0/process_payment.mdx index b975c5e..6289769 100644 --- a/docs/libraries/node/v1.0.0/process_payment.mdx +++ b/docs/libraries/node/v1.0.0/process_payment.mdx @@ -41,7 +41,7 @@ import getPaymentStatus from '!!raw-loader!@site/code_samples/node/v1.0.0/getPay {getPaymentStatus} -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). diff --git a/docs/libraries/python/v1.0.0/create_payment.mdx b/docs/libraries/python/v1.0.0/create_payment.mdx index 500e115..d4fd3e0 100644 --- a/docs/libraries/python/v1.0.0/create_payment.mdx +++ b/docs/libraries/python/v1.0.0/create_payment.mdx @@ -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' ) diff --git a/docs/libraries/python/v1.0.0/errors_handling.mdx b/docs/libraries/python/v1.0.0/errors_handling.mdx index 540b7ac..8a2fc74 100644 --- a/docs/libraries/python/v1.0.0/errors_handling.mdx +++ b/docs/libraries/python/v1.0.0/errors_handling.mdx @@ -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) diff --git a/docs/libraries/python/v1.0.0/index.mdx b/docs/libraries/python/v1.0.0/index.mdx index ebacfd7..29fc527 100644 --- a/docs/libraries/python/v1.0.0/index.mdx +++ b/docs/libraries/python/v1.0.0/index.mdx @@ -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 \ No newline at end of file diff --git a/docs/libraries/python/v1.0.0/logging.mdx b/docs/libraries/python/v1.0.0/logging.mdx index 2f49063..5a5d909 100644 --- a/docs/libraries/python/v1.0.0/logging.mdx +++ b/docs/libraries/python/v1.0.0/logging.mdx @@ -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", diff --git a/sidebars.js b/sidebars.js index 9322d65..5e089c5 100644 --- a/sidebars.js +++ b/sidebars.js @@ -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",