From 18b1271326578fbea2fb09e10f3801b6871822f4 Mon Sep 17 00:00:00 2001 From: austinkelsay Date: Thu, 14 Nov 2024 13:23:05 -0600 Subject: [PATCH] Set real subscription price and recurring cron job --- .../bitcoinConnect/SubscriptionPaymentButton.js | 8 ++++---- src/db/models/userModels.js | 4 ++-- src/pages/api/users/subscription/cron.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/bitcoinConnect/SubscriptionPaymentButton.js b/src/components/bitcoinConnect/SubscriptionPaymentButton.js index 7348feb..e890906 100644 --- a/src/components/bitcoinConnect/SubscriptionPaymentButton.js +++ b/src/components/bitcoinConnect/SubscriptionPaymentButton.js @@ -27,7 +27,7 @@ const SubscriptionPaymentButtons = ({ onSuccess, onError, onRecurringSubscriptio const router = useRouter(); const lnAddress = process.env.NEXT_PUBLIC_LIGHTNING_ADDRESS; - const amount = 25; + const amount = 70000; useEffect(() => { initializeBitcoinConnect(); @@ -94,9 +94,9 @@ const SubscriptionPaymentButtons = ({ onSuccess, onError, onRecurringSubscriptio const initNwcOptions = { name: "plebdevs.com", requestMethods: ['pay_invoice'], - maxAmount: 25, + maxAmount: 70000, editable: false, - budgetRenewal: 'daily', + budgetRenewal: 'monthly', expiresAt: yearFromNow, }; await newNwc.initNWC(initNwcOptions); @@ -259,7 +259,7 @@ const SubscriptionPaymentButtons = ({ onSuccess, onError, onRecurringSubscriptio or

Manually enter NWC URL

- *make sure you set a budget of at least 25000 sats and set budget renewal to monthly + *make sure you set a budget of at least 70000 sats and set budget renewal to monthly { export const findExpiredSubscriptions = async () => { try { const now = new Date(); - const oneDayAndOneHourAgo = new Date(now.getTime() - 1 * 24 * 60 * 60 * 1000 - 1 * 60 * 60 * 1000); + const oneMonthAndOneHourAgo = new Date(now.getTime() - 1 * 30 * 24 * 60 * 60 * 1000 - 1 * 60 * 60 * 1000); const result = await prisma.role.findMany({ where: { subscribed: true, lastPaymentAt: { - lt: oneDayAndOneHourAgo + lt: oneMonthAndOneHourAgo } }, select: { diff --git a/src/pages/api/users/subscription/cron.js b/src/pages/api/users/subscription/cron.js index 4095693..5b36e4d 100644 --- a/src/pages/api/users/subscription/cron.js +++ b/src/pages/api/users/subscription/cron.js @@ -3,7 +3,7 @@ import { webln } from "@getalby/sdk"; import { LightningAddress } from '@getalby/lightning-tools'; const lnAddress = process.env.LIGHTNING_ADDRESS; -const amount = 25; // Set the subscription amount in satoshis +const amount = 70000; // Set the subscription amount in satoshis export default async function handler(req, res) { // if (req.headers.authorization !== process.env.CRON_SECRET) {