next stripe
1.0.0
เวิร์กโฟลว์แถบฝั่งเซิร์ฟเวอร์ที่ง่ายขึ้นใน next.js
โปรดทราบ: ห้องสมุดนี้อยู่ในช่วงเบต้าและควรใช้ในการผลิตด้วยความระมัดระวัง!
yarn add next-stripe@beta
สร้าง [...nextstripe].js เส้นทางการจับทั้งหมดใน pages/api/stripe Directory
โปรดทราบ: ขอแนะนำให้คุณใช้คีย์ที่ จำกัด พร้อมการเข้าถึง API ที่ จำกัด ด้วยไลบรารีนี้ ปุ่มเหล่านี้สามารถสร้างและกำหนดค่าด้วยการเข้าถึงที่จำเป็นในแผงควบคุม Stripe
import NextStripe from 'next-stripe'
export default NextStripe ( {
stripe_key : process . env . STRIPE_RESTRICTED_KEY
} ) ฟังก์ชั่นการส่งออกแบบ next-stripe/client เพื่อเรียกเส้นทาง Next.js API
Docs Stripe 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'
} )Docs Stripe API
import { createPaymentIntent } from 'next-stripe/client'
const paymentIntent = await createPaymentIntent ( {
amount : 1000 ,
currency : 'usd'
} ) Docs Stripe API
import { confirmPaymentIntent } from 'next-stripe/client'
const paymentIntent = await confirmPaymentIntent ( 'pi_id' , {
payment_method : 'pm_id'
} ) Docs Stripe API
import { retrievePaymentIntent } from 'next-stripe/client'
const paymentIntent = await retrievePaymentIntent ( 'pi_id' ) Docs Stripe API
import { updatePaymentIntent } from 'next-stripe/client'
const paymentIntent = await updatePaymentIntent ( 'pi_id' , {
amount : 1000 ,
currency : 'usd'
} )Docs Stripe API
import { createBillingPortalSession } from 'next-stripe/client'
const session = await createBillingPortalSession ( {
customer : 'cus_id' ,
return_url : window . location . href
} )