aipp-sdk 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- aipp/__init__.py +4 -0
- aipp/client.py +51 -0
- aipp/models.py +20 -0
- aipp_sdk-1.0.0.dist-info/METADATA +47 -0
- aipp_sdk-1.0.0.dist-info/RECORD +7 -0
- aipp_sdk-1.0.0.dist-info/WHEEL +5 -0
- aipp_sdk-1.0.0.dist-info/top_level.txt +1 -0
aipp/__init__.py
ADDED
aipp/client.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from typing import Optional, Dict, Any
|
|
3
|
+
from .models import ChargeParams, ChargeResponse, ChargeStatus
|
|
4
|
+
|
|
5
|
+
class AippAPIError(Exception):
|
|
6
|
+
pass
|
|
7
|
+
|
|
8
|
+
class Aipp:
|
|
9
|
+
def __init__(self, api_key: str, base_url: str = "https://aipp.dev"):
|
|
10
|
+
if not api_key:
|
|
11
|
+
raise ValueError("AIPP: api_key is required")
|
|
12
|
+
self.api_key = api_key
|
|
13
|
+
self.base_url = base_url.rstrip('/')
|
|
14
|
+
self.session = requests.Session()
|
|
15
|
+
self.session.headers.update({
|
|
16
|
+
"Content-Type": "application/json",
|
|
17
|
+
"X-Api-Key": self.api_key
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
def _request(self, method: str, endpoint: str, **kwargs) -> Dict[str, Any]:
|
|
21
|
+
url = f"{self.base_url}{endpoint}"
|
|
22
|
+
response = self.session.request(method, url, **kwargs)
|
|
23
|
+
|
|
24
|
+
if not response.ok:
|
|
25
|
+
try:
|
|
26
|
+
error_data = response.json()
|
|
27
|
+
error_msg = error_data.get("error", response.reason)
|
|
28
|
+
except Exception:
|
|
29
|
+
error_msg = response.reason
|
|
30
|
+
raise AippAPIError(f"AIPP API Error: {error_msg}")
|
|
31
|
+
|
|
32
|
+
return response.json()
|
|
33
|
+
|
|
34
|
+
def create_charge(self, amount_sats: int, memo: Optional[str] = None) -> ChargeResponse:
|
|
35
|
+
"""Creates a new Lightning Invoice"""
|
|
36
|
+
if amount_sats <= 0:
|
|
37
|
+
raise ValueError("AIPP: amount_sats must be greater than 0")
|
|
38
|
+
|
|
39
|
+
data = self._request("POST", "/invoice/create", json={
|
|
40
|
+
"amount_sats": amount_sats,
|
|
41
|
+
"memo": memo
|
|
42
|
+
})
|
|
43
|
+
return ChargeResponse(**data)
|
|
44
|
+
|
|
45
|
+
def get_charge(self, payment_hash: str) -> ChargeStatus:
|
|
46
|
+
"""Checks the status of an existing charge"""
|
|
47
|
+
if not payment_hash:
|
|
48
|
+
raise ValueError("AIPP: payment_hash is required")
|
|
49
|
+
|
|
50
|
+
data = self._request("GET", f"/invoice/status/{payment_hash}")
|
|
51
|
+
return ChargeStatus(**data)
|
aipp/models.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
class ChargeParams(BaseModel):
|
|
5
|
+
amount_sats: int
|
|
6
|
+
memo: Optional[str] = None
|
|
7
|
+
|
|
8
|
+
class ChargeResponse(BaseModel):
|
|
9
|
+
payment_request: str
|
|
10
|
+
payment_hash: str
|
|
11
|
+
amount_sats: int
|
|
12
|
+
|
|
13
|
+
class ChargeStatus(BaseModel):
|
|
14
|
+
status: str
|
|
15
|
+
payment_hash: str
|
|
16
|
+
amount_sats: int
|
|
17
|
+
|
|
18
|
+
class AippErrorResponse(BaseModel):
|
|
19
|
+
error: str
|
|
20
|
+
code: Optional[str] = None
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aipp-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Official Python SDK for AIPP - The Lightning Network Split-Payment Gateway
|
|
5
|
+
Home-page: https://github.com/aippde/aipp-key
|
|
6
|
+
Author: AIPP
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.7
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: requests>=2.25.1
|
|
13
|
+
Requires-Dist: pydantic>=2.0.0
|
|
14
|
+
Dynamic: author
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: home-page
|
|
19
|
+
Dynamic: requires-dist
|
|
20
|
+
Dynamic: requires-python
|
|
21
|
+
Dynamic: summary
|
|
22
|
+
|
|
23
|
+
# AIPP Python SDK
|
|
24
|
+
|
|
25
|
+
Official Python client for the AIPP API (The Lightning Network Split-Payment Gateway).
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install aipp-sdk
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from aipp import Aipp
|
|
37
|
+
|
|
38
|
+
client = Aipp(api_key="your_api_key_here")
|
|
39
|
+
|
|
40
|
+
# Create a charge
|
|
41
|
+
charge = client.create_charge(amount_sats=500, memo="Test payment")
|
|
42
|
+
print(f"Pay this invoice: {charge.payment_request}")
|
|
43
|
+
|
|
44
|
+
# Check status
|
|
45
|
+
status = client.get_charge(charge.payment_hash)
|
|
46
|
+
print(f"Status: {status.status}")
|
|
47
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
aipp/__init__.py,sha256=GX5lYAtboQhYTteIcmR3HWV_zKKi0syDY402hl6Cef0,188
|
|
2
|
+
aipp/client.py,sha256=Fx7JPpuFLZOBUHgSTmRtKrSc9gxyBTpcD0UL3h4LC0U,1877
|
|
3
|
+
aipp/models.py,sha256=BeJwX-nkOVzdOp9AAZZ3zyl67vw__3AxJs1zNJrqaBQ,419
|
|
4
|
+
aipp_sdk-1.0.0.dist-info/METADATA,sha256=wo0-eoKTHaw4fJj7IPCKLDN_I5BvP-abBMIlRJe7Dug,1129
|
|
5
|
+
aipp_sdk-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
6
|
+
aipp_sdk-1.0.0.dist-info/top_level.txt,sha256=Tc3IJEkZfOr6xj2EI6MzxEqIo7Jie_HgEaOrePmdIJM,5
|
|
7
|
+
aipp_sdk-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
aipp
|