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:

lib/stripe.ts

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.

tools/list-products.ts

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.

tools/buy-products.ts

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.

app/products/page.tsx

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:

  1. Deploy your application to Vercel and get the URL with the MCP endpoint (https://your-app.vercel.app/mcp).
  2. In ChatGPT go to Apps & ConnectorsAdvanced Settings and enable developer mode.
  3. Create Connector:
    • Go back to Apps & Connectors and click Create
    • Enter a name for your connector and your MCP server URL
    • Select No Authentication
    • Accept the terms and conditions
    • Click Create
  4. Create a new chat and use the / command to access the connector.

One framework to rule them all

    Monetize your GPT apps with Stripe