next stripe
1.0.0
next.jsのシンプルなサーバー側のストライプワークフロー
ショ和 注:このライブラリは現在ベータ版であり、慎重に生産に使用する必要があります!
yarn add next-stripe@beta
[...nextstripe].jsプロジェクトのpages/api/stripeディレクトリにJSキャッチオールルートを作成します。
ショ和 注意:このライブラリに限られたAPIアクセスを備えた制限キーを使用することをお勧めします。これらのキーは、Stripeダッシュボードに必要なアクセスを使用して作成および構成できます。
import NextStripe from 'next-stripe'
export default NextStripe ( {
stripe_key : process . env . STRIPE_RESTRICTED_KEY
} ) next-stripe/clientヘルパー機能をエクスポートして、next.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
} )