SDK for integrating YouCan Pay API with Python
Project description
YouCanPay SDK
A Python SDK for integrating with the YouCan Pay payment gateway.
Installation
pip install youcanpay-sdk
Usage
from youcanpay import YouCanPay
# Initialize the client
client = YouCanPay(
private_key="pri_your_private_key",
public_key="pub_your_public_key",
sandbox=True # Set to False for production
)
# Create a payment token
try:
token = client.create_payment_token(
order_id="order_123",
amount=1000, # 10.00 MAD (in cents)
currency="MAD",
customer_ip="123.123.123.123",
success_url="https://yourdomain.com/success",
error_url="https://yourdomain.com/error",
customer_info={
"name": "John Doe",
"email": "john@example.com",
"phone": "+212600000000"
},
metadata={
"description": "Test payment"
}
)
print(f"Payment token: {token['id']}")
print(f"Redirect URL: {token['redirect_url']}")
except YouCanPayError as e:
print(f"Error: {e}")
# Get transaction details
try:
transaction = client.get_transaction("transaction_id")
print(f"Transaction status: {transaction['status']}")
except YouCanPayError as e:
print(f"Error: {e}")
# Refund a transaction
try:
refund = client.refund_transaction("transaction_id", amount=500) # Partial refund of 5.00 MAD
print(f"Refund status: {refund['status']}")
except YouCanPayError as e:
print(f"Error: {e}")
Features
- Create payment tokens
- Get transaction details
- Process refunds
- Support for sandbox and production environments
- Type hints for better IDE support
Requirements
- Python 3.6+
- requests>=2.25.1
License
MIT License
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
youcanpay_sdk-0.1.0.tar.gz
(4.2 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 youcanpay_sdk-0.1.0.tar.gz.
File metadata
- Download URL: youcanpay_sdk-0.1.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b891fba9a6fea2f83c4880a80c1b97dbc4928452ff2987ad6fb89daedd764e7f
|
|
| MD5 |
8f5ff7e67c45a481fd8f92dae3eacf5c
|
|
| BLAKE2b-256 |
28dd08729468a5bc7b21a018c17d0138d14799cf46dd280a45bf6d49501d30f2
|
File details
Details for the file youcanpay_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: youcanpay_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
779b2a54d2b34b51a4d488ecdb106224d052c4009f1f5f3b6692f04ab2b0aa70
|
|
| MD5 |
2050acdb30e82b10fb34b7f2a648c1aa
|
|
| BLAKE2b-256 |
6231d5d94621a1ae8a0b66f974144d5c4fcce748e5b382c4f61f30c1c22ea940
|