The official LuniPay Python SDK.
Project description
lunipay
The official LuniPay Python SDK.
pip install lunipay
Quick start
import lunipay
lunipay.api_key = "sk_test_YOUR_KEY"
session = lunipay.CheckoutSession.create(
amount=5000,
currency="usd",
success_url="https://example.com/thanks?session_id={CHECKOUT_SESSION_ID}",
)
print(session["url"])
Resources
Every LuniPay resource is a top-level class on the module:
lunipay.Customer.create(email="ada@example.com", first_name="Ada", last_name="Lovelace")
lunipay.Customer.retrieve("cus_01JRZK...")
lunipay.Customer.modify("cus_01JRZK...", phone="+18765559999")
lunipay.Customer.delete("cus_01JRZK...")
for customer in lunipay.Customer.list().auto_paging_iter():
print(customer["email"])
Supported resources: CheckoutSession, Customer, Invoice, Payment, PaymentLink, WebhookEndpoint, Event.
Webhooks
import lunipay
@app.post("/webhook")
def webhook():
payload = request.get_data()
sig = request.headers.get("LuniPay-Signature")
try:
event = lunipay.Webhook.construct_event(
payload=payload,
sig_header=sig,
secret="whsec_your_secret",
)
except lunipay.error.SignatureVerificationError:
return "bad signature", 400
if event["type"] == "checkout.session.completed":
# fulfill the order
pass
return "", 200
Errors
All LuniPay API errors raise subclasses of lunipay.error.LuniPayError:
try:
lunipay.Customer.create(email="bad", first_name="x", last_name="y")
except lunipay.error.InvalidRequestError as e:
print(e.code, e.param, str(e))
Subclasses: AuthenticationError, PermissionError, InvalidRequestError, IdempotencyError, RateLimitError, APIError, APIConnectionError.
Idempotency
Pass idempotency_key to any mutating request:
import uuid
key = str(uuid.uuid4())
session = lunipay.CheckoutSession.create(
amount=5000,
currency="usd",
success_url="https://example.com/thanks",
idempotency_key=key,
)
Full documentation
See lunipay.io/docs/sdks/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 lunipay-0.1.0.tar.gz.
File metadata
- Download URL: lunipay-0.1.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68504a067285556710e722c275339907ab060bc861cf35e4dbb54d2527806e9e
|
|
| MD5 |
10c19b62f32bd54b2429df9ab1612a6f
|
|
| BLAKE2b-256 |
1d9e1575ede2b8b9b59f2d3792b091f7bb03f9356bfbd5f3764118a50769ec71
|
Provenance
The following attestation bundles were made for lunipay-0.1.0.tar.gz:
Publisher:
publish-python.yml on SammarieoBrown/lunipay-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lunipay-0.1.0.tar.gz -
Subject digest:
68504a067285556710e722c275339907ab060bc861cf35e4dbb54d2527806e9e - Sigstore transparency entry: 1303033440
- Sigstore integration time:
-
Permalink:
SammarieoBrown/lunipay-sdk@fd84b271c498238cf173f4817a1595ac2dc45103 -
Branch / Tag:
refs/tags/lunipay-python-v0.1.0 - Owner: https://github.com/SammarieoBrown
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@fd84b271c498238cf173f4817a1595ac2dc45103 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lunipay-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lunipay-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53d7d6cffe80a0d5eb7bf0348fd42a9450cb8458cc40f08e2f0fb63f04036cab
|
|
| MD5 |
63f41369fe52537033efe0af8238a357
|
|
| BLAKE2b-256 |
af06ba77eb19ff060a434bbd3dbc0a4a8ef32ac3c129d3fae0484794e4ac7fbe
|
Provenance
The following attestation bundles were made for lunipay-0.1.0-py3-none-any.whl:
Publisher:
publish-python.yml on SammarieoBrown/lunipay-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lunipay-0.1.0-py3-none-any.whl -
Subject digest:
53d7d6cffe80a0d5eb7bf0348fd42a9450cb8458cc40f08e2f0fb63f04036cab - Sigstore transparency entry: 1303033629
- Sigstore integration time:
-
Permalink:
SammarieoBrown/lunipay-sdk@fd84b271c498238cf173f4817a1595ac2dc45103 -
Branch / Tag:
refs/tags/lunipay-python-v0.1.0 - Owner: https://github.com/SammarieoBrown
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@fd84b271c498238cf173f4817a1595ac2dc45103 -
Trigger Event:
push
-
Statement type: