commit
f91c0ec38c
1 changed files with 52 additions and 63 deletions
|
|
@ -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 => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue