Monetize your GPT apps with Stripe
Learn how to monetize your GPT apps using Stripe external checkout integration.
Allow users to buy products directly from ChatGPT through Stripe's external checkout integration.
Find the complete project on GitHub.
Project Setup
Create a new Next.js project and initialize it with xmcp:
The final structure of the project would look like this:
Stripe
Start by creating a Stripe account, enable the sandbox environment, copy the secret key (sk_test_…), and define several one-off products.
Then install the Stripe package:
Create lib/stripe.ts file that will initilize the Stripe client and create a checkout session for the selected products:
Setting up our server
Once your project setup is complete, let's create the tools for our MCP server that will handle the listing and the checkout of the products.
Listing your products
This tool will be used to get the products available for purchase and display them in a widget.
Buying a product
This tool will be used to create a checkout session for the selected products and quantities, then return the URL to the checkout page.
Completing the checkout
On the application side, you will find the products/page.tsx file, which displays the products and handles the checkout process.
This components calls our MCP server tools using the OpenAI SDK hooks: useCallTool to invoke the buy-products tool and useToolOutput to access the products. Finally, it uses the useOpenExternal hook to open the checkout page in a new tab.
Handling successful orders
Once a customer completes a payment, your application must reliably fulfill the order. Even if you configure a success_url, Stripe strongly recommends subscribing to webhooks to handle order fulfillment.
Refer to Stripe’s guide to handling successful payments for implementation details and best practices.
Deployment and testing
Here's the complete user flow for testing your application:
- Deploy your application to Vercel and get the URL with the MCP endpoint (
https://your-app.vercel.app/mcp). - In ChatGPT go to
Apps & Connectors→Advanced Settingsand enable developer mode. - Create Connector:
- Go back to
Apps & Connectorsand clickCreate - Enter a name for your connector and your MCP server URL
- Select
No Authentication - Accept the terms and conditions
- Click
Create
- Go back to
- Create a new chat and use the
/command to access the connector.