FetcherPay Python SDK
Official Python SDK for the FetcherPay API — One API. Every Rail.
Installation
pip install fetcherpay
Quick Start
from fetcherpay import FetcherPay
client = FetcherPay(
api_key='fp_test_your_key',
environment='sandbox' # or 'production'
)
# Create a payment
payment = client.payments.create(
amount=10000, # $100.00 in cents
currency='USD',
source={'payment_method_id': 'pm_123'},
destination={'payment_method_id': 'pm_456'},
rail='auto' # Auto-select optimal rail
)
print(payment['id'], payment['status'])
Configuration
| Option | Type | Default | Description |
|---|---|---|---|
api_key |
str | required | Your FetcherPay API key |
environment |
str | 'sandbox' | 'sandbox' or 'production' |
base_url |
str | auto | Override base URL |
timeout |
int | 30 | Request timeout (seconds) |
API Reference
Payments
# Create payment
payment = client.payments.create(
amount=10000,
source={'payment_method_id': 'pm_123'},
destination={'payment_method_id': 'pm_456'},
idempotency_key='unique-key'
)
# Retrieve payment
payment = client.payments.retrieve('pay_xxx')
# List payments
payments = client.payments.list(limit=10)
# Cancel payment
client.payments.cancel('pay_xxx', reason='Customer request')
# Refund payment
client.payments.refund('pay_xxx', amount=5000, reason='Partial refund')
Ledger
# List accounts
accounts = client.ledger.list_accounts()
# Get account balance
account = client.ledger.retrieve_account('la_xxx')
print(account['balance']['available'])
# List entries
entries = client.ledger.list_entries(account_id='la_xxx')
Payment Methods
# Create bank account
pm = client.payment_methods.create(
type='bank_account',
bank_account={
'account_number': '000123456789',
'routing_number': '011000015',
'account_type': 'checking'
}
)
# List payment methods
methods = client.payment_methods.list()
Webhooks
# Create webhook endpoint
webhook = client.webhooks.create(
url='https://your-app.com/webhooks',
events=['payment.settled', 'payment.failed']
)
# Verify webhook signature
is_valid = client.verify_webhook_signature(
payload,
signature, # from X-FetcherPay-Signature header
webhook['secret']
)
Error Handling
from fetcherpay import (
FetcherPayError,
AuthenticationError,
ValidationError,
NotFoundError
)
try:
client.payments.create(...)
except AuthenticationError:
print('Invalid API key')
except ValidationError as e:
print(f'Validation failed: {e.param}')
except FetcherPayError as e:
print(f'API error: {e.type} ({e.status_code})')
Webhook Verification
import json
# In your webhook handler
def handle_webhook(request):
payload = request.body
signature = request.headers.get('X-FetcherPay-Signature')
secret = 'whsec_your_webhook_secret'
if client.verify_webhook_signature(payload, signature, secret):
event = json.loads(payload)
if event['type'] == 'payment.settled':
handle_payment_settled(event['data'])
return 'OK', 200
else:
return 'Invalid signature', 401
License
MIT
Metadata
Release files for fetcherpay 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fetcherpay-1.0.0.tar.gz | 8.3 kB | Without provenance | Details for fetcherpay-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fetcherpay-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for fetcherpay-1.0.0-py3-none-any.whl |
Total release size: 18.0 kB
Release files / fetcherpay-1.0.0.tar.gz
| Download URL | fetcherpay-1.0.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b075be4e8db2ecaab57a77c0d8197fd2d9ce1a7ea974c33d9baa7b63f8417d08
|
|
BLAKE2b-256 checksum How to use checksums |
a249be98a4eb0859b743eb0334db8f36d6ba7cf836f42b361ae658d132d21ac1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / fetcherpay-1.0.0-py3-none-any.whl
| Download URL | fetcherpay-1.0.0-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1877cf833b323e3e1458cceeef2f635c786142b6a620ae621681fe482d0a6919
|
|
BLAKE2b-256 checksum How to use checksums |
81244906cd8d788817da251c1dfaa663099777efbaabdbaa2794f1d54fb0d863
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for fetcherpay 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.