Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create_charge is broken on latest satspay #13

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions templates/tipjar/display.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ <h5 class="q-my-none">Tip {{ donatee }} some sats!</h5>
}
},
methods: {
invoice: function () {
invoice() {
axios
.post('/tipjar/api/v1/tips', {
tipjar: '{{ tipjar_id }}',
name: self.tipDialog.data.name,
sats: self.tipDialog.data.sats,
message: self.tipDialog.data.message
name: this.tipDialog.data.name,
sats: this.tipDialog.data.sats,
message: this.tipDialog.data.message
})
.then(response => {
this.redirect_url = response.data.redirect_url
Expand Down
44 changes: 28 additions & 16 deletions views_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,27 @@ async def api_create_tip(data: CreateTips):
)

name = data.name or "Anonymous"
charge_id = await create_charge(
data={
"amount": sats,
"webhook": tipjar.webhook or "",
"name": name,
"description": message,
"onchainwallet": tipjar.onchain or "",
"lnbitswallet": tipjar.wallet,
"completelink": "/tipjar/" + str(tipjar_id),
"completelinktext": "Thanks for the tip!",
"time": 1440,
"custom_css": "",
},
api_key=wallet.inkey,
)
try:
charge_id = await create_charge(
data={
"amount": sats,
"webhook": tipjar.webhook or None,
"name": name,
"description": message,
"onchainwallet": tipjar.onchain or None,
"lnbitswallet": tipjar.wallet,
"completelink": f"/tipjar/{tipjar_id}",
"completelinktext": "Thanks for the tip!",
"time": 1440,
"custom_css": "",
},
api_key=wallet.inkey,
)
except Exception as exc:
msg = f"Failed to create charge: {exc!s}"
raise HTTPException(
status_code=HTTPStatus.INTERNAL_SERVER_ERROR, detail=msg
) from exc

await create_tip(
tip_id=charge_id,
Expand Down Expand Up @@ -184,7 +190,13 @@ async def api_delete_tip(
detail="Not authorized to delete this tip!",
)
await delete_tip(tip_id)
await delete_charge(tip_id, key_type.wallet.inkey)
try:
await delete_charge(tip_id, key_type.wallet.inkey)
except Exception as exc:
raise HTTPException(
status_code=HTTPStatus.INTERNAL_SERVER_ERROR,
detail=f"Failed to delete charge: {exc!s}",
) from exc

return "", HTTPStatus.NO_CONTENT

Expand Down