feat: per-event payment methods (extra.payment_methods)
Organizers pick which rails an event accepts — Lightning, card (fiat) or both — instead of a bare "allow fiat" toggle. `extra.payment_methods` uses the field name upstream v2 (lnbits/events#64) introduces so the eventual rebase merges cleanly; an empty list keeps the legacy rule (Lightning always, fiat when allow_fiat), and allow_fiat stays the fiat-currency carrier, kept in lockstep on save. The effective list is published as the NIP-52 tag `tickets_payment_methods` so clients render exactly the buttons the purchase endpoint will accept, and the buyer page defaults to the first accepted rail (a card-only event never submits "lightning"). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EYwoAkZZmXMMmaBp4WGUBo
This commit is contained in:
parent
92642a1f24
commit
c2d9a96239
5 changed files with 94 additions and 38 deletions
|
|
@ -156,6 +156,7 @@ window.PageEvents = {
|
|||
allow_fiat: false,
|
||||
fiat_currency: 'GBP',
|
||||
extra: {
|
||||
payment_methods: ['lightning'],
|
||||
promo_codes: [],
|
||||
notification_subject: '',
|
||||
notification_body: ''
|
||||
|
|
@ -271,12 +272,7 @@ window.PageEvents = {
|
|||
},
|
||||
saveSettings() {
|
||||
LNbits.api
|
||||
.request(
|
||||
'PUT',
|
||||
'/events/api/v1/events/settings',
|
||||
null,
|
||||
this.settings
|
||||
)
|
||||
.request('PUT', '/events/api/v1/events/settings', null, this.settings)
|
||||
.then(() => {
|
||||
Quasar.Notify.create({type: 'positive', message: 'Settings saved'})
|
||||
})
|
||||
|
|
@ -326,7 +322,7 @@ window.PageEvents = {
|
|||
LNbits.utils
|
||||
.confirmDialog(
|
||||
'Re-emit every approved event to Nostr relays? This is safe ' +
|
||||
'to run multiple times but generates one event per approved row.'
|
||||
'to run multiple times but generates one event per approved row.'
|
||||
)
|
||||
.onOk(() => {
|
||||
this.republishing = true
|
||||
|
|
@ -351,9 +347,7 @@ window.PageEvents = {
|
|||
},
|
||||
republishMyEvents() {
|
||||
LNbits.utils
|
||||
.confirmDialog(
|
||||
'Re-emit your approved events to Nostr relays?'
|
||||
)
|
||||
.confirmDialog('Re-emit your approved events to Nostr relays?')
|
||||
.onOk(() => {
|
||||
this.republishingMine = true
|
||||
LNbits.api
|
||||
|
|
@ -420,6 +414,17 @@ window.PageEvents = {
|
|||
code: code.code.trim().toUpperCase()
|
||||
}))
|
||||
}
|
||||
const methods = data.extra?.payment_methods || []
|
||||
if (methods.length === 0) {
|
||||
Quasar.Notify.create({
|
||||
type: 'warning',
|
||||
message: 'Select at least one payment method.'
|
||||
})
|
||||
return
|
||||
}
|
||||
// allow_fiat stays the fiat-currency carrier the backend and the
|
||||
// NIP-52 tags read; keep it in lockstep with the checkbox list.
|
||||
data.allow_fiat = methods.includes('fiat')
|
||||
if (!this.isFiatCurrency(data.currency)) {
|
||||
if (!data.allow_fiat) {
|
||||
data.fiat_currency = 'GBP'
|
||||
|
|
@ -439,6 +444,15 @@ window.PageEvents = {
|
|||
const end = this.splitDateTime(data.event_end_date)
|
||||
this.formDialog.data = {
|
||||
...data,
|
||||
extra: {
|
||||
...(data.extra || {}),
|
||||
// Events created before extra.payment_methods existed carry an
|
||||
// empty list; show the rails the backend actually accepts for
|
||||
// them (Lightning always, fiat when allow_fiat).
|
||||
payment_methods: data.extra?.payment_methods?.length
|
||||
? data.extra.payment_methods
|
||||
: ['lightning', ...(data.allow_fiat ? ['fiat'] : [])]
|
||||
},
|
||||
event_start_day: start.day,
|
||||
event_start_time: start.time,
|
||||
event_end_day: end.day,
|
||||
|
|
@ -454,6 +468,7 @@ window.PageEvents = {
|
|||
event_end_day: '',
|
||||
event_end_time: '',
|
||||
extra: {
|
||||
payment_methods: ['lightning'],
|
||||
conditional: false,
|
||||
min_tickets: 1,
|
||||
email_notifications: false,
|
||||
|
|
@ -473,6 +488,7 @@ window.PageEvents = {
|
|||
allow_fiat: false,
|
||||
fiat_currency: 'GBP',
|
||||
extra: {
|
||||
payment_methods: ['lightning'],
|
||||
email_notifications: false,
|
||||
nostr_notifications: false,
|
||||
promo_codes: [],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue