mirror of
https://github.com/MAGICGrants/campaign-site.git
synced 2026-01-09 12:27:59 -05:00
fix(btcpay webhook handler): correctly handle payment methods on InvoicePaymentSettled
This commit is contained in:
@@ -28,6 +28,7 @@ type BtcpayBody = Record<string, any> & {
|
||||
storeId: string
|
||||
invoiceId: string
|
||||
metadata: DonationMetadata
|
||||
paymentMethod: string
|
||||
}
|
||||
|
||||
async function handleBtcpayWebhook(req: NextApiRequest, res: NextApiResponse) {
|
||||
@@ -64,7 +65,10 @@ async function handleBtcpayWebhook(req: NextApiRequest, res: NextApiResponse) {
|
||||
return res.status(200).json({ success: true })
|
||||
}
|
||||
|
||||
const cryptoCode = body.paymentMethod === 'BTC-OnChain' ? 'BTC' : 'XMR'
|
||||
// Handle payment methods like "BTC-LightningNetwork" if added in the future
|
||||
const cryptoCode = body.paymentMethod.includes('-')
|
||||
? body.paymentMethod.split('-')[0]
|
||||
: body.paymentMethod
|
||||
|
||||
const { data: rates } = await btcpayApi.get<BtcPayGetRatesRes>(
|
||||
`/rates?currencyPair=${cryptoCode}_USD`
|
||||
|
||||
Reference in New Issue
Block a user