--- title: "In-Chat App Integration" description: "Accept payments in your ChatGPT app using Adyen." url: "https://docs.adyen.com/online-payments/agentic-commerce/in-chat-app-integration" source_url: "https://docs.adyen.com/online-payments/agentic-commerce/in-chat-app-integration.md" canonical: "https://docs.adyen.com/online-payments/agentic-commerce/in-chat-app-integration" last_modified: "2026-05-08T17:09:17+02:00" language: "en" --- # In-Chat App Integration Accept payments in your ChatGPT app using Adyen. Build an ecommerce experience that is native to ChatGPT, where your shoppers can make transactions directly inside of the chat interface. Using the [OpenAI Apps SDK](https://developers.openai.com/apps-sdk/), you can create custom, interactive ecommerce interfaces where users can browse, select, and pay without leaving the AI chat. Adyen securely processes payments initiated by these interactions with AI agents, ensuring a seamless flow from chat to checkout. ## Requirements | Requirement | Description | | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | **Integration type** | An [online payments](/online-payments/build-your-integration) integration. | | **Setup steps** | Before you begin:- Build your ChatGPT app, following the [OpenAI Apps SDK](https://developers.openai.com/apps-sdk) documentation. - Set up your [MCP server](https://developers.openai.com/apps-sdk/build/mcp-server) to connect ChatGPT with your backend. | | **Limitations** | [Instant Checkout](https://developers.openai.com/apps-sdk/build/monetization) availability is limited. If it is not available to you, you can instead redirect shoppers to your own checkout page. By redirecting shoppers to your own checkout page, you have full control over the checkout experience and can use any [online payments integration](/online-payments/build-your-integration), like Drop-in/Components or Hosted Checkout. | ## How it works To accept payments in your ChatGPT app with Adyen, you need to implement the following components: | Component | Description | | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------- | | **Checkout session creation tool** | An MCP tool that creates a checkout session with line items, totals, and Adyen as the payment provider. | | **Widget** | Your ChatGPT app UI component that displays the cart and calls `window.openai.requestCheckout` to initiate payment. | | **complete\_checkout tool** | An MCP tool that receives the ACP token from OpenAI and calls Adyen to authorize the payment. | Create MCP tools that correspond to the [Agentic Checkout Spec (ACS)](https://developers.openai.com/commerce/specs/checkout) REST endpoints: | MCP tool | ACS endpoint | | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | | **Checkout session tool** | [`POST /checkout_sessions`](https://developers.openai.com/commerce/specs/checkout#post-checkout_sessions) | | **complete\_checkout** | [`POST /checkout_sessions/{id}/complete`](https://developers.openai.com/commerce/specs/checkout#post-checkout_sessionscheckout_session_idcomplete) | ### Transaction flow When a shopper initiates a transaction in the chat interface, the following flow occurs: 1. **Shopper initiates transaction**: The shopper prompts the AI agent to buy something from you, and the checkout session tool from your MCP server is invoked. 2. **Server prepares session**: Your MCP tool returns checkout session data (session ID, line items, totals, Adyen as the payment provider) in `structuredContent`. 3. **Widget previews cart**: Your widget renders the line items and totals so that the shopper can review and confirm. 4. **Widget calls requestCheckout**: When the shopper selects the button to continue with checkout, your widget calls `window.openai.requestCheckout(session_data)`. ChatGPT opens the Instant Checkout UI and shows available payment methods. 5. **Shopper selects payment method and pays**: The shopper selects their payment method and clicks **Pay**. ChatGPT communicates with Adyen to register the Agentic Commerce Protocol (ACP) token, then calls the `complete_checkout` tool from your MCP server with the ACP token in `payment_data.token`. 6. **Server authorizes payment**: Your `complete_checkout` tool uses the ACP token to make a payment request to Adyen. Adyen authorizes the payment and returns the result. 7. **Order confirmation**: Your MCP tool returns payment result to ChatGPT, which passes it to your widget. Your widget displays the payment result to the shopper. The following diagram shows the interaction between the shopper in the chat interface, your app widget, the Apps SDK, your MCP server, and Adyen's server. ```mermaid sequenceDiagram participant Shopper as Shopper participant Widget as Widget participant SDK as Apps SDK participant MCP as Your MCP Server participant Adyen as Adyen Shopper->>Widget: Prompt to start transaction Widget->>SDK: Invoke checkout tool SDK->>MCP: Call checkout tool MCP-->>SDK: Return checkout session data (provider: adyen) SDK-->>Widget: Return structured content Widget-->>Shopper: Show product page Shopper->>Widget: Select button to continue with checkout Widget->>SDK: Call window.openai.requestCheckout SDK-->>Shopper: Show payment page Shopper->>SDK: Select payment method SDK->>MCP: Call complete_checkout MCP->>Adyen: Make POST /payments request Adyen-->>MCP: Return payment result MCP-->>SDK: Return order information SDK-->>Widget: Return order confirmation Widget-->>Shopper: Show payment result ``` ## Build your checkout session tool Create an MCP tool that returns the checkout session data in the `payment_provider` object in `structuredContent`. Include in the `merchant_id` field: It must include the following: | Field | Description | | --------------------------- | ---------------------------------------------------------------------------- | | `provider` | **adyen** | | `merchant_id` | Your Adyen [merchant account](/account/account-structure#merchant-accounts). | | `supported_payment_methods` | An array of supported payment methods. Example: **\[scheme]** | **Example payment\_provider in checkout session response** ```json { "payment_provider": { "provider": "adyen", "merchant_id": "ADYEN_MERCHANT_ACCOUNT", "supported_payment_methods": ["scheme"] } } ``` For the full checkout session payload structure, go to the [Agentic Checkout Spec](https://developers.openai.com/commerce/specs/checkout#response). ## Build your widget Create a widget that handles the checkout UI and initiates the payment flow. Your widget must: 1. Receive the checkout session data from your MCP tool via `structuredContent`. 2. Render the cart (line items, totals, terms) so the shopper can review before paying. 3. Call `window.openai.requestCheckout(session_data)` when the shopper clicks to proceed. ### Call `requestCheckout` When the shopper indicates that they are ready to pay, call `window.openai.requestCheckout` with your checkout session data. This opens the Instant Checkout UI where the shopper selects their payment method. **Example requestCheckout call with Adyen** ```javascript const order = await window.openai.requestCheckout({ ...checkoutSession, id: checkoutSessionId }); ``` The function returns a promise that resolves with the order result or rejects on error or cancellation. For further details on building widgets, go to the [OpenAI Apps SDK monetization guide](https://developers.openai.com/apps-sdk/build/monetization). ## Build your `complete_checkout` tool When the shopper selects a payment method and selects the pay button, OpenAI calls the `complete_checkout` tool from your MCP server with the ACP token in `payment_data.token`. Use this token to authorize the payment with Adyen. For the Adyen API request details, go to [Authorize a payment with the ACP token](/online-payments/agentic-commerce/product-feed-integration#authorize-a-payment-with-the-acp-token). ### Handle errors Your `complete_checkout` tool can return error messages to handle payment failures. The following error codes are displayed on the Instant Checkout UI: | Error code | Description | | ------------------ | ---------------------------------------------- | | `payment_declined` | The payment was declined by Adyen. | | `requires_3ds` | The payment requires 3D Secure authentication. | All other error messages are returned to your widget as a response to `requestCheckout`, where you can show them. For the full list of error codes, go to the [ACP error messages specification](https://developers.openai.com/commerce/specs/checkout#message-type--error). ## Testing Use ChatGPT's test payment mode with the Adyen test environment to test your integration without processing real payments. 1. Use your test Adyen merchant account and your test [API credentials](/development-resources/api-credentials). 2. Set `payment_mode: test` in your `requestCheckout` call. **Set payment\_mode to test** ```javascript window.openai.requestCheckout({ id: checkout_session_id, payment_mode: "test", payment_provider: { provider: "adyen" }, merchant_id: "ADYEN_MERCHANT_ACCOUNT", supported_payment_methods: ["scheme"] }) ``` 3. Use Adyen [test card numbers](/development-resources/test-cards-and-credentials/test-card-numbers), for example: **4111 1111 1111 1111**. 4. Verify that you receive test payments: * In your [test Customer Area](https://ca-test.adyen.com/), test payments show up in the payment list. Go to **Transactions** > **Payments**. * For each test payment, we send you a [webhook message](/development-resources/webhooks/). ## Go live After you submit your ChatGPT app, do not use test payment mode, because it is exposed to users in the live environment. When you are ready to accept live payments: 1. Switch to your live Adyen merchant account. 2. Update your MCP server to use your live [API credentials](/development-resources/api-credentials) and an idempotency key for each request to Adyen. 3. Set `payment_mode: "live"` in your `requestCheckout` call. 4. Submit your ChatGPT app for review.