mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-03 18:04:36 +02:00
satspay done
This commit is contained in:
@@ -17,15 +17,6 @@ from ..watchonly.crud import get_watch_wallet, get_fresh_address, get_mempool
|
|||||||
async def create_charge(
|
async def create_charge(
|
||||||
user: str,
|
user: str,
|
||||||
data: CreateCharge
|
data: CreateCharge
|
||||||
# user: str,
|
|
||||||
# description: str = None,
|
|
||||||
# onchainwallet: Optional[str] = None,
|
|
||||||
# lnbitswallet: Optional[str] = None,
|
|
||||||
# webhook: Optional[str] = None,
|
|
||||||
# completelink: Optional[str] = None,
|
|
||||||
# completelinktext: Optional[str] = "Back to Merchant",
|
|
||||||
# time: Optional[int] = None,
|
|
||||||
# amount: Optional[int] = None,
|
|
||||||
) -> Charges:
|
) -> Charges:
|
||||||
charge_id = urlsafe_short_hash()
|
charge_id = urlsafe_short_hash()
|
||||||
if data.onchainwallet:
|
if data.onchainwallet:
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
from sqlite3 import Row
|
from sqlite3 import Row
|
||||||
|
from typing import Optional
|
||||||
from fastapi.param_functions import Query
|
from fastapi.param_functions import Query
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
import time
|
import time
|
||||||
@@ -16,15 +17,15 @@ class CreateCharge(BaseModel):
|
|||||||
class Charges(BaseModel):
|
class Charges(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
user: str
|
user: str
|
||||||
description: str
|
description: Optional[str]
|
||||||
onchainwallet: str
|
onchainwallet: Optional[str]
|
||||||
onchainaddress: str
|
onchainaddress: Optional[str]
|
||||||
lnbitswallet: str
|
lnbitswallet: Optional[str]
|
||||||
payment_request: str
|
payment_request: str
|
||||||
payment_hash: str
|
payment_hash: str
|
||||||
webhook: str
|
webhook: Optional[str]
|
||||||
completelink: str
|
completelink: Optional[str]
|
||||||
completelinktext: str
|
completelinktext: Optional[str] = "Back to Merchant"
|
||||||
time: int
|
time: int
|
||||||
amount: int
|
amount: int
|
||||||
balance: int
|
balance: int
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
"description": <string>, "webhook":<string>, "time":
|
"description": <string>, "webhook":<string>, "time":
|
||||||
<integer>, "amount": <integer>, "lnbitswallet":
|
<integer>, "amount": <integer>, "lnbitswallet":
|
||||||
<string, lnbits_wallet_id>}' -H "Content-type:
|
<string, lnbits_wallet_id>}' -H "Content-type:
|
||||||
application/json" -H "X-Api-Key: {{g.user.wallets[0].adminkey }}"
|
application/json" -H "X-Api-Key: {{user.wallets[0].adminkey }}"
|
||||||
</code>
|
</code>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
"description": <string>, "webhook":<string>, "time":
|
"description": <string>, "webhook":<string>, "time":
|
||||||
<integer>, "amount": <integer>, "lnbitswallet":
|
<integer>, "amount": <integer>, "lnbitswallet":
|
||||||
<string, lnbits_wallet_id>}' -H "Content-type:
|
<string, lnbits_wallet_id>}' -H "Content-type:
|
||||||
application/json" -H "X-Api-Key: {{g.user.wallets[0].adminkey }}"
|
application/json" -H "X-Api-Key: {{user.wallets[0].adminkey }}"
|
||||||
</code>
|
</code>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
@@ -207,7 +207,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %} {% block scripts %}
|
{% endblock %} {% block scripts %}
|
||||||
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
|
|
||||||
<style>
|
<style>
|
||||||
.theCard {
|
.theCard {
|
||||||
width: 360px;
|
width: 360px;
|
||||||
@@ -302,6 +302,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
|
console.log('{{ charge.onchainaddress }}' == 'None')
|
||||||
if ('{{ charge.lnbitswallet }}' == 'None') {
|
if ('{{ charge.lnbitswallet }}' == 'None') {
|
||||||
this.lnbtc = false
|
this.lnbtc = false
|
||||||
this.onbtc = true
|
this.onbtc = true
|
||||||
|
@@ -280,7 +280,8 @@
|
|||||||
</q-dialog>
|
</q-dialog>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %} {% block scripts %} {{ window_vars(user) }}
|
{% endblock %} {% block scripts %} {{ window_vars(user) }}
|
||||||
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
|
<!-- lnbits/static/vendor
|
||||||
|
<script src="/vendor/vue-qrcode@1.0.2/vue-qrcode.min.js"></script> -->
|
||||||
<style></style>
|
<style></style>
|
||||||
<script>
|
<script>
|
||||||
Vue.component(VueQrcode.name, VueQrcode)
|
Vue.component(VueQrcode.name, VueQrcode)
|
||||||
@@ -542,6 +543,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
|
console.log(this.g.user)
|
||||||
var self = this
|
var self = this
|
||||||
var getCharges = this.getCharges
|
var getCharges = this.getCharges
|
||||||
getCharges()
|
getCharges()
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
from fastapi.param_functions import Depends
|
from fastapi.param_functions import Depends
|
||||||
from starlette.exceptions import HTTPException
|
from starlette.exceptions import HTTPException
|
||||||
from starlette.responses import HTMLResponse
|
from starlette.responses import HTMLResponse
|
||||||
|
from starlette.requests import Request
|
||||||
from lnbits.core.models import User
|
from lnbits.core.models import User
|
||||||
from lnbits.core.crud import get_wallet
|
from lnbits.core.crud import get_wallet
|
||||||
from lnbits.decorators import check_user_exists
|
from lnbits.decorators import check_user_exists
|
||||||
|
@@ -33,10 +33,10 @@ from .crud import (
|
|||||||
|
|
||||||
async def api_charge_create_or_update(data: CreateCharge, wallet: WalletTypeInfo = Depends(get_key_type), charge_id=None):
|
async def api_charge_create_or_update(data: CreateCharge, wallet: WalletTypeInfo = Depends(get_key_type), charge_id=None):
|
||||||
if not charge_id:
|
if not charge_id:
|
||||||
charge = await create_charge(user=wallet.wallet.user, **data)
|
charge = await create_charge(user=wallet.wallet.user, data=data)
|
||||||
return charge.dict()
|
return charge.dict()
|
||||||
else:
|
else:
|
||||||
charge = await update_charge(charge_id=charge_id, **data)
|
charge = await update_charge(charge_id=charge_id, data=data)
|
||||||
return charge.dict()
|
return charge.dict()
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user