mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-06 18:31:00 +00:00
Set real subscription price and recurring cron job
This commit is contained in:
parent
6040cdf879
commit
18b1271326
@ -27,7 +27,7 @@ const SubscriptionPaymentButtons = ({ onSuccess, onError, onRecurringSubscriptio
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const lnAddress = process.env.NEXT_PUBLIC_LIGHTNING_ADDRESS;
|
const lnAddress = process.env.NEXT_PUBLIC_LIGHTNING_ADDRESS;
|
||||||
const amount = 25;
|
const amount = 70000;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initializeBitcoinConnect();
|
initializeBitcoinConnect();
|
||||||
@ -94,9 +94,9 @@ const SubscriptionPaymentButtons = ({ onSuccess, onError, onRecurringSubscriptio
|
|||||||
const initNwcOptions = {
|
const initNwcOptions = {
|
||||||
name: "plebdevs.com",
|
name: "plebdevs.com",
|
||||||
requestMethods: ['pay_invoice'],
|
requestMethods: ['pay_invoice'],
|
||||||
maxAmount: 25,
|
maxAmount: 70000,
|
||||||
editable: false,
|
editable: false,
|
||||||
budgetRenewal: 'daily',
|
budgetRenewal: 'monthly',
|
||||||
expiresAt: yearFromNow,
|
expiresAt: yearFromNow,
|
||||||
};
|
};
|
||||||
await newNwc.initNWC(initNwcOptions);
|
await newNwc.initNWC(initNwcOptions);
|
||||||
@ -259,7 +259,7 @@ const SubscriptionPaymentButtons = ({ onSuccess, onError, onRecurringSubscriptio
|
|||||||
<AlbyButton handleSubmit={handleRecurringSubscription} />
|
<AlbyButton handleSubmit={handleRecurringSubscription} />
|
||||||
<span className='my-4 text-lg font-bold'>or</span>
|
<span className='my-4 text-lg font-bold'>or</span>
|
||||||
<p className='text-lg font-bold'>Manually enter NWC URL</p>
|
<p className='text-lg font-bold'>Manually enter NWC URL</p>
|
||||||
<span className='text-sm text-gray-500'>*make sure you set a budget of at least 25000 sats and set budget renewal to monthly</span>
|
<span className='text-sm text-gray-500'>*make sure you set a budget of at least 70000 sats and set budget renewal to monthly</span>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={nwcInput}
|
value={nwcInput}
|
||||||
|
@ -187,13 +187,13 @@ export const updateUserSubscription = async (userId, isSubscribed, nwc) => {
|
|||||||
export const findExpiredSubscriptions = async () => {
|
export const findExpiredSubscriptions = async () => {
|
||||||
try {
|
try {
|
||||||
const now = new Date();
|
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({
|
const result = await prisma.role.findMany({
|
||||||
where: {
|
where: {
|
||||||
subscribed: true,
|
subscribed: true,
|
||||||
lastPaymentAt: {
|
lastPaymentAt: {
|
||||||
lt: oneDayAndOneHourAgo
|
lt: oneMonthAndOneHourAgo
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
|
@ -3,7 +3,7 @@ import { webln } from "@getalby/sdk";
|
|||||||
import { LightningAddress } from '@getalby/lightning-tools';
|
import { LightningAddress } from '@getalby/lightning-tools';
|
||||||
|
|
||||||
const lnAddress = process.env.LIGHTNING_ADDRESS;
|
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) {
|
export default async function handler(req, res) {
|
||||||
// if (req.headers.authorization !== process.env.CRON_SECRET) {
|
// if (req.headers.authorization !== process.env.CRON_SECRET) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user