Merge pull request #135 from MAGICGrants/btcpay-payment-methods-fix

fix: correctly use btcpay payment methods endpoint generally
This commit is contained in:
Artur
2025-01-15 11:09:57 -03:00
committed by GitHub
3 changed files with 7 additions and 8 deletions

View File

@@ -142,7 +142,7 @@ async function handleBtcpayWebhook(req: NextApiRequest, res: NextApiResponse) {
projectName: body.metadata.projectName,
projectSlug: body.metadata.projectSlug,
fundSlug: body.metadata.fundSlug,
cryptoCode: paymentMethod.cryptoCode,
cryptoCode: paymentMethod.currency,
grossCryptoAmount: Number(grossCryptoAmount.toFixed(2)),
grossFiatAmount: Number(grossFiatAmount.toFixed(2)),
netCryptoAmount: Number(netCryptoAmount.toFixed(2)),
@@ -186,7 +186,7 @@ async function handleBtcpayWebhook(req: NextApiRequest, res: NextApiResponse) {
donorName: body.metadata.donorName,
donorEmail: body.metadata.donorEmail,
amount: Number(grossFiatAmount.toFixed(2)),
method: paymentMethod.cryptoCode as 'BTC' | 'XMR',
method: paymentMethod.currency,
fundName: funds[body.metadata.fundSlug].title,
fundSlug: body.metadata.fundSlug,
periodStart: new Date(),
@@ -202,7 +202,7 @@ async function handleBtcpayWebhook(req: NextApiRequest, res: NextApiResponse) {
donorName: body.metadata.donorName,
donorEmail: body.metadata.donorEmail,
amount: Number(grossFiatAmount.toFixed(2)),
method: paymentMethod.cryptoCode as 'BTC' | 'XMR',
method: paymentMethod.currency,
fundName: funds[body.metadata.fundSlug].title,
fundSlug: body.metadata.fundSlug,
projectName: body.metadata.projectName,
@@ -222,7 +222,7 @@ async function handleBtcpayWebhook(req: NextApiRequest, res: NextApiResponse) {
isMembership: body.metadata.isMembership === 'true',
isSubscription: false,
pointsReceived: pointsAdded,
btcpayAsset: paymentMethod.cryptoCode as 'BTC' | 'XMR',
btcpayAsset: paymentMethod.currency,
btcpayCryptoAmount: grossCryptoAmount,
attestationMessage,
attestationSignature,

View File

@@ -143,11 +143,11 @@ async function handle(
)
paymentMethods.forEach((paymentMethod) => {
if (paymentMethod.paymentMethod === 'BTC-CHAIN') {
if (paymentMethod.currency === 'BTC') {
bitcoinAddress = paymentMethod.destination
}
if (paymentMethod.paymentMethod === 'XMR-CHAIN') {
if (paymentMethod.currency === 'XMR') {
moneroAddress = paymentMethod.destination
}
})

View File

@@ -39,8 +39,7 @@ export type BtcPayGetRatesRes = [
export type BtcPayGetPaymentMethodsRes = {
rate: string
amount: string
cryptoCode: string
paymentMethod: string
currency: 'BTC' | 'XMR'
paymentMethodPaid: string
destination: string
}[]