🚀
eziSaas
Github Repository
  • Welcome
  • đź“•GUIDES
    • Getting Started
    • Environment Variables Setup
  • 🖥️SERVER
    • Overview
    • /config/mail.js
    • /controllers/authController.js
    • /routes/payment.js
    • /routes/webhook.js
  • 📦Components & PAGES
    • Landing
      • Navbar
      • CheckoutButton
      • Hero
      • SellingPoints
        • SellingPoint
        • Filter
      • Title
        • OfferPill
      • Video
      • Pricing
        • PricingCard
      • Faq
        • Accordion
      • FinalMessage
      • Footer
        • FooterSection
    • Login
    • Success
    • Failure
    • Dashboard
      • ChangePassword
  • OTHER
    • Github Repository
Powered by GitBook
On this page
  1. SERVER

/routes/payment.js

Purpose

Defines the route for initiating a Stripe checkout session, allowing clients to make payments using a Stripe-hosted checkout page.

Prerequisites

This route requires the following environment variables:

  • TEST_PRODUCT_PRICE_ID: The Price ID for the product in Stripe (available in the Stripe Dashboard).

  • TEST_COUPON_ID: The Coupon ID for discounts in Stripe.

Route: /create-checkout-session

  • Method: POST

  • Description: Creates a Stripe checkout session for processing payments.

  • Request Body: No specific body fields are required.

  • Response:

    • On success, returns the id of the created session.

    • On failure, returns a 500 status with an error message.

Stripe Checkout Session Configuration

  • payment_method_types: Accepts card payments.

  • line_items: Contains the product’s price ID and quantity.

  • mode: Set to "payment" for a one-time payment.

  • discounts: Applies a coupon based on the provided TEST_COUPON_ID.

  • success_url: Redirects to the success page upon payment completion.

  • cancel_url: Redirects to the cancellation page if payment is canceled.

Notes

  • Dependencies: Uses stripeTest (a Stripe instance) from the /config/stripe file.

  • Environment Setup: Ensure .env has the correct Stripe credentials and product IDs.

This route enables streamlined payment handling using Stripe’s checkout, making it a plug-and-play payment solution.


This documentation provides a focused overview of the payment route’s purpose, configuration, and usage.

Previous/controllers/authController.jsNext/routes/webhook.js

Last updated 6 months ago

🖥️