next stripe
1.0.0
Next.js에서 단순화 된 서버 측 스트라이프 워크 플로우
켈 참고 :이 라이브러리는 현재 베타 버전에 있으며주의해서 생산에 사용해야합니다!
yarn add next-stripe@beta
프로젝트 pages/api/stripe 디렉토리에서 [...nextstripe].js 캐치-모든 경로를 만듭니다.
켈 참고 :이 라이브러리에서 제한된 API 액세스가 제한된 제한된 키를 사용하는 것이 좋습니다. 이 키는 Stripe 대시 보드에서 필요한 액세스로 작성 및 구성 할 수 있습니다.
import NextStripe from 'next-stripe'
export default NextStripe ( {
stripe_key : process . env . STRIPE_RESTRICTED_KEY
} ) next-stripe/client Secports 도우미 기능은 다음으로 호출하여 JS API 경로를 호출합니다.
스트라이프 API 문서
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'
} )스트라이프 API 문서
import { createPaymentIntent } from 'next-stripe/client'
const paymentIntent = await createPaymentIntent ( {
amount : 1000 ,
currency : 'usd'
} ) 스트라이프 API 문서
import { confirmPaymentIntent } from 'next-stripe/client'
const paymentIntent = await confirmPaymentIntent ( 'pi_id' , {
payment_method : 'pm_id'
} ) 스트라이프 API 문서
import { retrievePaymentIntent } from 'next-stripe/client'
const paymentIntent = await retrievePaymentIntent ( 'pi_id' ) 스트라이프 API 문서
import { updatePaymentIntent } from 'next-stripe/client'
const paymentIntent = await updatePaymentIntent ( 'pi_id' , {
amount : 1000 ,
currency : 'usd'
} )스트라이프 API 문서
import { createBillingPortalSession } from 'next-stripe/client'
const session = await createBillingPortalSession ( {
customer : 'cus_id' ,
return_url : window . location . href
} )