프로젝트
GitHub에서 보기
ynnoj/next-stripe
소개
Next.js에서 Stripe의 서버 측 워크플로를 간소화
웹 및 앱 개발측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalNextStripe
Simplified server-side Stripe workflows in Next.js
⚠️ PLEASE NOTE: This library is currently in beta and should be used in production with caution!
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.
⚠️ PLEASE NOTE: It is recommended you use a restricted key with limited API access with this library. These keys can be created and configured with the required access in the Stripe Dashboard.
import NextStripe from 'next-stripe'
export default NextStripe({
stripe_key: process.env.STRIPE_RESTRICTED_KEY
})
Usage
next-stripe/client exports 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 paymentIntent = await createPaymentIntent({
amount: 1000,
currency: 'usd'
})
Confirm
import { confirmPaymentIntent } from 'next-stripe/client'
const paymentIntent = await confirmPaymentIntent('pi_id', {
payment_method: 'pm_id'
})
Retrieve
import { retrievePaymentIntent } from 'next-stripe/client'
const paymentIntent = await retrievePaymentIntent('pi_id')
Update
import { updatePaymentIntent } from 'next-stripe/client'
const paymentIntent = await updatePaymentIntent('pi_id', {
amount: 1000,
currency: 'usd'
})
Billing Portal Sessions
Create
import { createBillingPortalSession } from 'next-stripe/client'
const session = await createBillingPortalSession({
customer: 'cus_id',
return_url: window.location.href
})
Acknowledgements
- A lot of the patterns in this library were inspired by NextAuth.
- Thanks to Jamie Barton for the initial idea.
관련 프로젝트 살펴보기
불러오는 중…