mirror of
https://github.com/MAGICGrants/campaign-site.git
synced 2026-01-09 12:27:59 -05:00
Merge pull request #135 from MAGICGrants/btcpay-payment-methods-fix
fix: correctly use btcpay payment methods endpoint generally
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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
|
||||
}[]
|
||||
|
||||
Reference in New Issue
Block a user