Merge pull request #21 from lnbits/final_fixes

Final fixes
This commit is contained in:
Vlad Stan 2023-03-17 11:23:09 +02:00 committed by GitHub
commit f91c0ec38c

View file

@ -193,11 +193,6 @@ async function customerStall(path) {
}, },
async placeOrder() { async placeOrder() {
this.loading = true this.loading = true
LNbits.utils
.confirmDialog(
`Send the order to the merchant? You should receive a message with the payment details.`
)
.onOk(async () => {
let orderData = this.checkoutDialog.data let orderData = this.checkoutDialog.data
let orderObj = { let orderObj = {
name: orderData?.username, name: orderData?.username,
@ -214,9 +209,7 @@ async function customerStall(path) {
} }
let created_at = Math.floor(Date.now() / 1000) let created_at = Math.floor(Date.now() / 1000)
orderObj.id = await hash( orderObj.id = await hash(
[this.customerPubkey, created_at, JSON.stringify(orderObj)].join( [this.customerPubkey, created_at, JSON.stringify(orderObj)].join(':')
':'
)
) )
this.activeOrder = orderObj.id this.activeOrder = orderObj.id
let event = { let event = {
@ -246,16 +239,12 @@ async function customerStall(path) {
} }
event.id = NostrTools.getEventHash(event) event.id = NostrTools.getEventHash(event)
if (this.customerPrivkey) { if (this.customerPrivkey) {
event.sig = await NostrTools.signEvent( event.sig = await NostrTools.signEvent(event, this.customerPrivkey)
event,
this.customerPrivkey
)
} else if (this.customerUseExtension && this.hasNip07) { } else if (this.customerUseExtension && this.hasNip07) {
event = await window.nostr.signEvent(event) event = await window.nostr.signEvent(event)
} }
this.resetCheckout() this.resetCheckout()
await this.sendOrder(event) await this.sendOrder(event)
})
}, },
async sendOrder(order) { async sendOrder(order) {
this.$q.notify({ this.$q.notify({
@ -276,7 +265,7 @@ async function customerStall(path) {
await relay.connect() await relay.connect()
let pub = relay.publish(order) let pub = relay.publish(order)
pub.on('ok', () => { pub.on('ok', () => {
console.debug(`${relay.url} has accepted our event`) console.debug(`${relay.url} has accepted our event: ${order.id}`)
relay.close() relay.close()
}) })
pub.on('failed', reason => { pub.on('failed', reason => {