mirror of
https://github.com/MAGICGrants/campaign-site.git
synced 2026-01-09 12:27:59 -05:00
fix(btcpay webhook handler): respond with 200 immediately if there is no metadata
This commit is contained in:
@@ -27,7 +27,7 @@ type BtcpayBody = Record<string, any> & {
|
||||
timestamp: number
|
||||
storeId: string
|
||||
invoiceId: string
|
||||
metadata: DonationMetadata
|
||||
metadata?: DonationMetadata
|
||||
paymentMethod: string
|
||||
}
|
||||
|
||||
@@ -59,6 +59,10 @@ async function handleBtcpayWebhook(req: NextApiRequest, res: NextApiResponse) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!body.metadata) {
|
||||
return res.status(200).json({ success: true })
|
||||
}
|
||||
|
||||
if (body.type === 'InvoicePaymentSettled') {
|
||||
// Handle payments to funding required API invoices ONLY
|
||||
if (body.metadata.staticGeneratedForApi === 'false') {
|
||||
@@ -105,6 +109,8 @@ async function handleBtcpayWebhook(req: NextApiRequest, res: NextApiResponse) {
|
||||
|
||||
await Promise.all(
|
||||
paymentMethods.map(async (paymentMethod) => {
|
||||
if (!body.metadata) return
|
||||
|
||||
const cryptoAmount = Number(paymentMethod.paymentMethodPaid)
|
||||
|
||||
if (!cryptoAmount) return
|
||||
|
||||
Reference in New Issue
Block a user