1.0.0-beta.1 • Published 3 years ago
next-stripe v1.0.0-beta.1
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'
})
Acknowledgements
- A lot of the patterns in this library were inspred by NextAuth.
- Thanks to Jamie Barton for the initial idea.
1.0.0-beta.9
3 years ago
1.0.0-beta.8
3 years ago
1.0.0-beta.6
3 years ago
1.0.0-beta.7
3 years ago
1.0.0-beta.3
3 years ago
1.0.0-beta.4
3 years ago
1.0.0-beta.5
3 years ago
1.0.0-beta.2
3 years ago
1.0.0-beta.1
3 years ago
1.0.0
3 years ago