• Blog
  • Documentation
  • Courses
  • Changelog
  • AI Starters
  • UI Kit
  • FAQ
  • Supamode
    New
  • Pricing

Launch your next SaaS in record time with Makerkit, a React SaaS Boilerplate for Next.js and Supabase.

Makerkit is a product of Makerkit Pte Ltd (registered in the Republic of Singapore)Company Registration No: 202407149CFor support or inquiries, please contact us

About
  • FAQ
  • Contact
  • Verify your Discord
  • Consultation
  • Open Source
  • Become an Affiliate
Product
  • Documentation
  • Blog
  • Changelog
  • UI Blocks
  • Figma UI Kit
  • AI SaaS Starters
License
  • Activate License
  • Upgrade License
  • Invite Member
Legal
  • Terms of License
  • Auth Overview
  • Global Configuration
    • Setting up your Firebase Project
    • Setting up Firebase Functions
  • Writing data to Firestore
  • Commands
  • Introduction
  • Production Checklist
  • Introduction
  • Overview
  • Stripe Configuration
  • Running Tests
  • Introduction
  • Setting up Firebase Auth
  • Fetching data from Firestore
  • Technical Details
  • Extending Organizations
  • Stripe Webhooks
  • CI Tests
  • Initial Setup
  • React Hooks
  • Auth Flow
  • API requests
  • Code Style
  • Clone the repository
  • Security Rules
  • User Permissions
  • Limitations
  • Project Structure
  • Third-Party Providers
  • Reading data from Storage
  • Running the application
  • Subscription Permissions
  • One-Time Payments
  • Running the App
  • Email Link Authentication
  • Uploading data to Storage
  • Security Rules
  • Migrate to Lemon Squeezy
  • Project Configuration
  • Multi-Factor Authentication
  • Writing your own Fetch
  • Translations and Locales
  • Coding Conventions
  • Environment Variables
  • Architecture and Folder Structure
    • Structure your Application
    • Data Model
  • Requiring Email verification
  • Sending Emails
  • Tailwind CSS and Styling
  • Validating API payload with Zod
  • Authentication
  • Onboarding Flow
  • Logging
  • Development: adding custom features
  • Prevent abuse with AppCheck
  • Enable CORS
  • Encrypting Secrets
  • User Roles
  • Firestore: Data Fetching
  • Custom React Hooks
  • Custom React Hooks
  • Firestore: Data Writing
  • Troubleshooting
  • Forms
  • Application Pages
  • API Routes
  • API Routes Validation
  • Translations
  • Adding pages to the Marketing Site
  • Deploying to Production
  • Updating to the latest version
This kit is no longer maintained.

Enabling One-Time Payments with Stripe | Remix Firebase

Learn how to switch from Stripe Subscriptions to One-Time Payments in your Makerkit application

While Makerkit uses subscriptions by default, you can offer your customers one-time payments.

Fortunately, Stripe Checkout makes it insanely easy. Let's see how to update Makerkit's codebase to enable Stripe one-off payments for your product.

  1. First, when choosing your Stripe Price's billing type, select One Time. Learn more about creating Prices with Stripe.

  2. Secondly, we need to change the payment mode in Makerkit's codebase. To do so, we will update the createStripeCheckout function defined at ~/lib/stripe/create-checkout.ts.

If you open the file, you'll find the line below:

tsx
const mode: Stripe.Checkout.SessionCreateParams.Mode = 'subscription';
// some code here...
return stripe.checkout.sessions.create({
mode,
// more code here...
});

To enable one-time payments, we will replace the mode constant from subscription to payment:

tsx
const mode: Stripe.Checkout.SessionCreateParams.Mode = 'payment';
// some code here...
return stripe.checkout.sessions.create({
mode,
// more code here...
});

Now, make sure to remove the subscription_data parameter from the stripe.checkout.sessions.create function call. Otherwise, it will throw an error.

tsx
return stripe.checkout.sessions.create({
mode,
ui_mode: uiMode,
customer,
line_items: [lineItem],
client_reference_id: clientReferenceId.toString(),
subscription_data: subscriptionData,
customer_email: params.customerEmail,
...urls,
});

And that's it! Stripe will not charge our users recurringly but will simply charge them once.

As the UI is set up for recurring subscriptions, you may want to tweak the Subscription Page UI to reflect that charges are not recurring and that the product has been successfully purchased.

Handling the Payment Method dynamically

The above works great if you only offer one plan. However, let's assume you have multiple prices and want to dynamically update the payment mode based on the selected price.

In this case, let's do the following:

  1. Extend the plan information in the application configuration
  2. Select the appropriate method when creating the checkout by retrieving the plan's model

If you open your application's configuration, you will notice that plans have the following interface:

src/configuration.ts
{
name: 'Basic',
description: 'Unlimited applications and 2-hour onboarding session',
price: '$249/year',
stripePriceId: 'price_***********',
}

Now, we can extend it with the payment mode, which would be subscription or payment:

tsx
{
name: 'Basic',
description: 'Unlimited applications and 2-hour onboarding session',
price: '$249 one off!',
stripePriceId: 'price_***********',
mode: 'payment'
}

Now, let's reopen the file create-checkout.ts file and find the payment mode of the selected price ID:

tsx
const price = configuration.plans.find(item => {
return item.stripePriceId === params.priceId;
});
if (!price) {
throw new Error(`Price with ID ${params.priceId} not found in config`);
}
const mode: Stripe.Checkout.SessionCreateParams.Mode = price.mode;
// some code here...
return stripe.checkout.sessions.create({
mode,
// more code here...
});

🎉 Now it looks better and works for multiple plans based on their payment mode!

On this page
  1. Handling the Payment Method dynamically