saas-starter icon indicating copy to clipboard operation
saas-starter copied to clipboard

Enable multilingual support

Open mhmdAljefri opened this issue 1 year ago β€’ 1 comments

mhmdAljefri avatar Nov 04 '24 10:11 mhmdAljefri

Hi @leerob I'd love to take on enabling multilingual support if it’s still available.

yousri-mahmoud avatar Nov 04 '24 11:11 yousri-mahmoud

import Stripe from 'stripe';

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

export default async function handler(req, res) { if (req.method === 'POST') { const { action, customerId, returnUrl } = req.body;

try {
  if (action === 'configure') {
    // Configure the Billing Portal
    const configuration = await stripe.billingPortal.configurations.create({
      business_profile: {
        name: 'Your Business Name', // Replace with your business name
        privacy_policy_url: 'https://example.com/privacy',
        terms_of_service_url: 'https://example.com/terms',
      },
      features: {
        subscription_update: {
          enabled: true,
          default_allowed_updates: ['plan', 'quantity'], // Adjust as needed
        },
        payment_method_update: {
          enabled: true,
        },
      },
    });

    return res.status(200).json({ message: 'Configuration created', configuration });
  } else if (action === 'create-session') {
    // Create a Billing Portal Session
    if (!customerId || !returnUrl) {
      return res.status(400).json({ error: 'Missing customerId or returnUrl' });
    }

    const session = await stripe.billingPortal.sessions.create({
      customer: customerId,
      return_url: returnUrl,
    });

    return res.status(200).json({ url: session.url });
  } else {
    return res.status(400).json({ error: 'Invalid action' });
  }
} catch (error) {
  console.error('Stripe API Error:', error);
  return res.status(500).json({ error: error.message });
}

} else { return res.status(405).json({ error: 'Method not allowed' }); } }

sanjomathew09 avatar Jan 26 '25 14:01 sanjomathew09

πŸŽ‰ Welcome to my open-source project: https://github.com/liuhuapiaoyuan/nextjs-prisma-stripe-saas-starter

🌍 We are now supporting i18n!

  • πŸ” Simplify your authentication architecture with Auth.js.
  • 🌐 Easily implement internationalization using next-intl.
  • πŸ› οΈ Make database operations more convenient with prisma ORM tool.

Let's build something amazing together! πŸš€βœ¨

Image

liuhuapiaoyuan avatar Feb 01 '25 17:02 liuhuapiaoyuan

Hey there, we don't plan to add this to the base template, but seems like there's already some good forks exploring this!

leerob avatar Feb 11 '25 15:02 leerob