-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: remove dependency to `create_charge` from `satspay` * refactor: remove dependency to `satspay.crud.delete_charge`
- Loading branch information
Showing
3 changed files
with
58 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import httpx | ||
|
||
from lnbits.app import settings | ||
|
||
|
||
async def create_charge(data: dict, api_key: str) -> str: | ||
async with httpx.AsyncClient() as client: | ||
headers = {"X-API-KEY": api_key} | ||
r = await client.post( | ||
url=f"http://{settings.host}:{settings.port}/satspay/api/v1/charge", | ||
headers=headers, | ||
json=data, | ||
) | ||
r.raise_for_status() | ||
return r.json()["id"] | ||
|
||
|
||
async def delete_charge(charge_id: str, api_key: str): | ||
async with httpx.AsyncClient() as client: | ||
headers = {"X-API-KEY": api_key} | ||
r = await client.delete( | ||
url=f"http://{settings.host}:{settings.port}/satspay/api/v1/charge/{charge_id}", | ||
headers=headers, | ||
) | ||
r.raise_for_status() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters