Skip to main content

Python client library for the Paylio API

Project description

Paylio Python SDK

Python client library for the Paylio API.

Installation

pip install paylio

Usage

import paylio

client = paylio.PaylioClient("sk_live_xxx")

# Get current subscription
sub = client.subscription.retrieve("user_123")
print(sub.status)       # "active"
print(sub.plan.name)    # "Pro Plan"
print(sub.plan.amount)  # 999

# List subscription history
history = client.subscription.list("user_123", page=1, page_size=10)
for item in history.items:
    print(item.plan_name, item.status)

if history.has_more:
    next_page = client.subscription.list("user_123", page=2)

# Cancel subscription (safe default: cancels at end of billing period)
result = client.subscription.cancel("subscription-uuid")
print(result.success)  # True

# Cancel immediately
result = client.subscription.cancel("subscription-uuid", cancel_now=True)

Context Manager

with paylio.PaylioClient("sk_live_xxx") as client:
    sub = client.subscription.retrieve("user_123")

Custom Base URL

client = paylio.PaylioClient("sk_test_xxx", base_url="https://api.paylio.dev/flying/v1")

Error Handling

import paylio

client = paylio.PaylioClient("sk_live_xxx")

try:
    sub = client.subscription.retrieve("user_123")
except paylio.AuthenticationError:
    print("Invalid API key")
except paylio.NotFoundError:
    print("Subscription not found")
except paylio.InvalidRequestError as e:
    print(f"Bad request: {e.message}")
except paylio.APIError as e:
    print(f"API error: {e.message} (status {e.http_status})")
except paylio.APIConnectionError:
    print("Network error")

Requirements

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

paylio-0.1.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paylio-0.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file paylio-0.1.0.tar.gz.

File metadata

  • Download URL: paylio-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for paylio-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7a35da7c5c5081894206a37b0a3e256dbbc7c77b0eff4f043c895fb1f2dfa266
MD5 add38f7af870ae551c1147a20f3bd657
BLAKE2b-256 425ea3c5cff4a3ea32997c2bbd0f1cb85672a9f7b04f2acf2ab2b3071565dc90

See more details on using hashes here.

File details

Details for the file paylio-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: paylio-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for paylio-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8d4eb034dc96c3b56826b9baa7fc35a98eb87156bc785bca989337711567036
MD5 643ade0c2b290013e33f20ab8144a57d
BLAKE2b-256 d5055f832e682057354f392dbebd38e90c4d2b4d8b3f8d10277d24a3c122db9b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page