Official Python SDK for Plugipay — HMAC-signed REST client with full resource coverage (customers, plans, checkout sessions, invoices, subscriptions, refunds, adapters, payouts, ledger, reports, webhooks).
Project description
plugipay (Python)
Official Python SDK for Plugipay. HMAC-signed REST client; works with Flask, FastAPI, Django, or anything else that speaks Python 3.9+.
Install
pip install plugipay
Quickstart
from plugipay import PlugipayClient
plug = PlugipayClient(key_id="ak_live_...", secret="...")
# Create a customer
customer = plug.customers.create(email="ada@example.com", name="Ada Lovelace")
# Open a checkout session
session = plug.checkout_sessions.create(
amount=125000,
currency="IDR",
methods=["qris", "va", "ewallet"],
success_url="https://yourapp.com/checkout/success",
cancel_url="https://yourapp.com/checkout/cancel",
customer_id=customer["id"],
)
print(session["hostedUrl"])
# Paginate customers
page = plug.customers.list(limit=20)
for c in page.data:
print(c["id"], c.get("email"))
if page.has_more:
next_page = plug.customers.list(limit=20, cursor=page.cursor)
The client is a context manager — with PlugipayClient(...) as plug:
will close the underlying httpx pool for you.
Resource namespaces
Mirrors @forjio/plugipay-node 1:1:
| Namespace | Methods |
|---|---|
customers |
create, get, list, update |
plans |
create, get, list, update, archive |
checkout_sessions |
create, get, list, cancel, confirm |
invoices |
create, get, list, finalize, pay, void, send_email |
subscriptions |
create, get, list, cancel, pause, resume |
portal_sessions |
create |
receipts |
list, get |
payouts |
create, get, list, cancel, mark_in_transit, mark_paid, mark_failed, balance, get_bank_account, update_bank_account |
ledger |
list, balances |
reports |
pnl, cash_flow |
webhook_endpoints |
list, create, delete |
events |
list, get |
refunds |
create, get, list |
adapters |
list, update_xendit, update_paypal, update_midtrans, update_manual, managed_onboarding_state, start_managed_onboarding, simulate_managed_onboarding |
api_keys |
list, create, revoke |
billing |
list_tiers, list_plans, refresh_tiers |
onboarding |
provision_managed |
checkout_settings |
get, update |
templates |
list, get, create, update, make_default, duplicate, preview, delete |
uploads |
image |
workspaces |
list, create, update, delete |
account |
get, update, list_sessions, revoke_session, revoke_all_sessions, list_linked, unlink, change_email, change_password, list_members |
admin_portal |
me, list_billing_accounts, update_billing_account, list_partners, create_partner, update_partner, delete_partner |
admin |
provision_workspace, get_workspace, partner_usage |
Webhooks
Plugipay signs every webhook with HMAC-SHA256 over ${timestamp}.${rawBody}.
Pass the raw request body (bytes or str), not the parsed JSON.
from flask import Flask, request, abort
from plugipay import verify_webhook, PlugipaySignatureError
import os
app = Flask(__name__)
SECRET = os.environ["PLUGIPAY_WEBHOOK_SECRET"]
@app.post("/webhooks/plugipay")
def plugipay_webhook():
raw = request.get_data()
sig = request.headers.get("X-Plugipay-Signature", "")
try:
event = verify_webhook(raw, sig, SECRET)
except PlugipaySignatureError:
abort(400)
if event.type == "plugipay.invoice.paid.v1":
invoice = event.object
# ...
return "", 204
Platform keys
If you hold a platform-admin key acting across many merchants, scope
each call with X-Plugipay-On-Behalf-Of via for_merchant():
plat = PlugipayClient(key_id="ak_live_platform_...", secret="...")
for_acc = plat.for_merchant("acc_abc123")
for_acc.invoices.list()
Errors
Every failure raises PlugipayError (or a subclass —
PlugipayNetworkError, PlugipayTimeoutError, PlugipaySignatureError).
The exception carries .status, .code, .message, and (when present)
.request_id.
from plugipay import PlugipayClient, PlugipayError
plug = PlugipayClient(key_id="...", secret="...")
try:
plug.customers.get("cus_does_not_exist")
except PlugipayError as e:
print(e.status, e.code, e.message, e.request_id)
Source
https://github.com/hachimi-cat/saas-plugipay/tree/master/sdk/python
License
MIT
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
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 plugipay-0.1.0.tar.gz.
File metadata
- Download URL: plugipay-0.1.0.tar.gz
- Upload date:
- Size: 18.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93575526e5d399774f411bdb74ad90f069c43aa07439120d3f493864ce03c257
|
|
| MD5 |
6d9f740d0e50c8f137d8aae686853cc3
|
|
| BLAKE2b-256 |
cb925a1fa19444cd173f74b05ffbd99ebc8725e4d6384ff26dc37e7c517ac2f3
|
File details
Details for the file plugipay-0.1.0-py3-none-any.whl.
File metadata
- Download URL: plugipay-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
614fa37a6019818182c4ba22cc52d6baedc2bf564aebf7e8a92800733e3a30ae
|
|
| MD5 |
1778484e877507cdf8b01320d85181d0
|
|
| BLAKE2b-256 |
1e46ce2f9d775ab56c517ae1d71b577f4f86fca686b5bb184277319b8374e3ec
|