Skip to main content
フレームワークアダプターを使用すると、各フレームワークのrequestとresponseの型を使って、アプリにDodo Paymentsのcheckout、Customer Portal、webhook handlerを追加できます。各アダプターは@dodopaymentsスコープのnpmパッケージです。パッケージは、checkoutの検証、Dodo Payments APIリクエスト、webhookペイロードの検証、型付きイベントコールバックに@dodopayments/coreを使用します。
各アダプターは、handlerの設定でAPI keyとenvironmentを受け取ります。これらの値はenvironment variablesに保存し、handlerの作成時に渡してください。
coding agentにアダプターを追加させるには、Agent Pluginをインストールしてください。

利用可能なフレームワークアダプター

使用するフレームワークに対応するアダプターを選択してください。

Next.js

App Routerでcheckout、customer portal、webhook用のroute handlerを提供します。

Nuxt

フルスタックVueフレームワークであるNuxt 3用のserver route handlerです。

Express

Node.jsアプリのExpress 5 route用のrequest handlerです。

Fastify

pluginアーキテクチャを備えたNode.jsフレームワーク、Fastify 5用のroute handlerです。

Hono

Cloudflare Workers、その他のedge runtime、Node.js向けのweb frameworkであるHono 4用のroute handlerです。

Astro

コンテンツに重点を置いたweb framework、Astro 4および5用のserver endpoint handlerです。

SvelteKit

フルスタックSvelteフレームワークであるSvelteKit 2用のserver route handlerです。

Remix

フルスタックReactフレームワークであるRemix 2用のloaderおよびaction handlerです。

TanStack Start

型安全なフルスタックReactフレームワークであるTanStack Start用のserver route handlerです。

Better Auth

Better Auth authentication framework用のpluginです。checkout、portal、usage、webhook endpointを追加し、sign-up時にcustomerを作成できます。

Convex

checkoutおよびcustomer portal actionとwebhook HTTP actionを備えたConvex backend用のcomponentです。

Bun

checkout、customer portal、webhook用のネイティブBun.serve() handlerです。

主な機能

route handlerアダプターには、次の機能が共通して備わっています。 Better Auth pluginとConvex componentは、それぞれ独自のAPIを通じて同じ機能を提供します。違いについては各ページを参照してください。

クイックスタート

route handlerアダプターを3つの手順で設定します。
1

Install the Adaptor

使用するフレームワークのパッケージをインストールします。
2

Configure Environment Variables

Dodo Paymentsのcredentialをenvironmentに追加します。dashboardのDeveloper → API KeysでAPI keyを、Developer → Webhooksでwebhook secretを作成します。test modeのAPI keyはtest_modeでのみ機能します。
environmentを渡さない場合、アダプターはlive_modeを使用します。
.envファイルやsecretをversion controlにcommitしないでください。
3

Create Route Handlers

checkout routeを作成します。customer portalとwebhook routeも同じパターンに従います。
checkout routeはcheckout URLを返すようになります。各アダプターのページでは、customer portalとwebhook handlerについて説明し、すべてのoptionを一覧表示しています。

Checkout Flowの種類

route handlerアダプターは3種類のcheckout flowをサポートします。Better Auth pluginはcheckout sessionとdeprecated dynamic checkoutをサポートします。Convex componentはcheckout sessionのみをサポートします。
Static checkoutは1つの商品用のpayment linkを返すため、共有またはredirectできます。query parameterとしてproduct IDを渡します。
handlerはproductが存在することを確認し、linkをcheckout_urlとして返します。オプションのquery parameterを使用して顧客情報を事前入力し、checkout formを制御できます。
Dynamic checkoutは、カスタム情報を含むJSON bodyからpayment linkを作成します。billingとcustomerは必須です。
one-time paymentとsubscriptionの両方をサポートします。product typeに応じてdeprecatedなPOST /paymentsまたはPOST /subscriptions endpointを呼び出すため、新しい統合にはcheckout sessionを使用してください。
Checkout sessionが推奨されるflowです。最も多くのoptionを提供し、複数の商品を含むcartを受け付けます。
サポートされているすべてのfieldについては、Checkout Sessions Guideを参照してください。

Webhook Eventの処理

すべてのroute handlerアダプターはWebhooks handlerをexportします。これはwebhook secretと、個別のevent type用のオプションの型付きcallbackを受け取ります。onPayloadはすべてのeventで実行されます。
callbackは、payment、refund、dispute、subscription、license key、abandoned checkout、dunning、credit、entitlement grant、payout eventを対象とします。Better Auth pluginはwebhooks()で同じcallbackを受け付け、Convex componentはcreateDodoWebhookHandlerで受け付けます。
各webhook handlerはStandard Webhooks libraryを使用してwebhook-id、webhook-signature、webhook-timestamp headerを検証し、その後Zod schemaでpayloadを検証します。無効なrequestは、callbackが実行される前にerror statusで拒否されます。

適切なアダプターの選択

ヘルプを受ける

framework adaptor に関するヘルプ:
最終更新日 2026年9月26日