next stripe
1.0.0
Les flux de travail à rayures côté serveur simplifié dans Next.js
️ Veuillez noter: cette bibliothèque est actuellement en version bêta et doit être utilisée en production avec prudence!
yarn add next-stripe@beta
Créez un [...nextstripe].js Catch-All Route dans le répertoire pages/api/stripe de votre projet.
️ Veuillez noter: il est recommandé d'utiliser une clé restreinte avec un accès à l'API limité avec cette bibliothèque. Ces touches peuvent être créées et configurées avec l'accès requis dans le tableau de bord Stripe.
import NextStripe from 'next-stripe'
export default NextStripe ( {
stripe_key : process . env . STRIPE_RESTRICTED_KEY
} ) Fonctions d'assistance next-stripe/client pour appeler les routes API suivantes.
Docs API Stripe
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'
} )Docs API Stripe
import { createPaymentIntent } from 'next-stripe/client'
const paymentIntent = await createPaymentIntent ( {
amount : 1000 ,
currency : 'usd'
} ) Docs API Stripe
import { confirmPaymentIntent } from 'next-stripe/client'
const paymentIntent = await confirmPaymentIntent ( 'pi_id' , {
payment_method : 'pm_id'
} ) Docs API Stripe
import { retrievePaymentIntent } from 'next-stripe/client'
const paymentIntent = await retrievePaymentIntent ( 'pi_id' ) Docs API Stripe
import { updatePaymentIntent } from 'next-stripe/client'
const paymentIntent = await updatePaymentIntent ( 'pi_id' , {
amount : 1000 ,
currency : 'usd'
} )Docs API Stripe
import { createBillingPortalSession } from 'next-stripe/client'
const session = await createBillingPortalSession ( {
customer : 'cus_id' ,
return_url : window . location . href
} )