next-stripe

    1.0.0-beta.1 • Public • Published

    next-stripe

    A convenience library for server side Stripe workflows with Next.js

    Getting Started

    yarn add next-stripe@beta
    

    Add the API route

    Create a [...nextstripe.js] catch-all route in your project's pages/api/stripe directory.

    import NextStripe from 'next-stripe'
    
    const options = {
      secret_key: process.env.STRIPE_SECRET_KEY
    }
    
    export default (req, res) => NextStripe(req, res, options)

    Usage

    next-stripe/client exports a selection helper functions to call the Next.js API routes.

    Checkout Sessions

    Create

    import { createCheckoutSession } from 'next-stripe/client'
    
    const session = await createCheckoutSession({
      success_url: window.location.href,
      cancel_url: window.location.href,
      line_items: [{ price: 'price_id', quantity: 1 }],
      payment_method_types: ['card'],
      mode: 'payment'
    })

    PaymentIntents

    Create

    import { createPaymentIntent } from 'next-stripe/client'
    
    const session = await createPaymentIntent({
      amount: 1000,
      currency: 'usd'
    })

    Keywords

    none

    Install

    npm i next-stripe

    DownloadsWeekly Downloads

    524

    Version

    1.0.0-beta.1

    License

    MIT

    Unpacked Size

    6.19 kB

    Total Files

    15

    Last publish

    Collaborators

    • ynnoj