Python SDK for integration with the Payler payment system
Project description
Payler SDK
Python SDK for integration with the Payler payment system.
Installation
pip install payler-sdk
Features
- Card saving and management
- Customer registration
- Processing payments with saved cards
- Transaction status handling
- Get payment status
- Recurrent template management
- Saved card status verification
Quick Start
from payler_sdk import PaylerClient
# Initialize the client
client = PaylerClient(
base_url="sandbox.payler.com",
auth_key="your_auth_key",
)
# Save card and process payment
response = client.initialize_save_card_session(
customer_id="customer123",
currency="RUB",
return_url_success="https://your-website.com/payment/sync-cards"
)
# Get the redirect URL for card saving
redirect_url = response.save_card_url
# After card saving, process payment with saved card
payment = client.charge_saved_card(
amount=100.50,
order_id="order_12345",
currency="RUB",
recurrent_template_id="template_id_from_saved_card"
)
# Get payment status
status = client.get_payment_status(order_id="order_12345")
Usage Examples
Register a New Customer
from payler_sdk.models import PaylerCustomerUpdateOrCreateRequest
customer = PaylerCustomerUpdateOrCreateRequest(
name="Erlich Bachman",
email="erlich.bachman@gmail.com",
phone="+79001234567"
)
response = client.register_new_customer(customer)
customer_id = response.customer_id
Get Card Status After Saving
from payler_sdk.models import PaylerGetStatusSaveCardRequest
request = PaylerGetStatusSaveCardRequest(session_id="your_session_id")
response = client.get_status_save_card(request)
print(f"Card status: {response.card_status}")
print(f"Template ID: {response.recurrent_template_id}")
Get Template Information
from payler_sdk.models import PaylerTemplateRequest
request = PaylerTemplateRequest(recurrent_template_id="your_template_id")
template = client.get_template(request)
print(f"Card holder: {template.card_holder}")
print(f"Card number: {template.card_number}")
print(f"Is active: {template.active}")
Error Handling
from payler_sdk.exceptions import PaylerApiError
try:
payment = client.charge_saved_card(...)
except PaylerApiError as e:
# Handle any API error from Payler
print(f"API error: {e}, status code: {e.status_code}")
# You can check the specific type if needed:
# if isinstance(e, PaylerSpecificError):
# handle_specific_error(e)
Requirements
- Python 3.8+
- requests library
Contributing
Contributions are welcome! Feel free to submit issues or pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
payler_sdk-1.0.1.tar.gz
(11.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file payler_sdk-1.0.1.tar.gz.
File metadata
- Download URL: payler_sdk-1.0.1.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1742bb5f48d330a4f778fe2d683da4312028e954ff9bca49e07ff46f194aef6d
|
|
| MD5 |
3a9636662fec528c86672ff1f91e91f7
|
|
| BLAKE2b-256 |
01a43e22552f5baebf96c94a1d3c9f87078b73366c68e5f0544fb2aed337c3ff
|
File details
Details for the file payler_sdk-1.0.1-py3-none-any.whl.
File metadata
- Download URL: payler_sdk-1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc4724b0f0016205e371ed2aae8c9a646fd882d8acf2d9fb7274f79bf693f06d
|
|
| MD5 |
fc92f2de2a71e57f008c50b463d23dad
|
|
| BLAKE2b-256 |
4444b5a2b5f6234892020aca00a969182e575cd560e25c088f23b848b5b1bfa3
|