// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { Metadata, asTextContentResult } from 'dodopayments-mcp/tools/types';
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import DodoPayments from 'dodopayments';
export const metadata: Metadata = {
resource: 'checkout_sessions',
operation: 'write',
tags: [],
httpMethod: 'post',
httpPath: '/checkouts',
operationId: 'create_session',
};
export const tool: Tool = {
name: 'create_checkout_sessions',
description: '',
inputSchema: {
type: 'object',
properties: {
product_cart: {
type: 'array',
items: {
type: 'object',
title: 'Product Item Request',
properties: {
product_id: {
type: 'string',
description: 'unique id of the product',
},
quantity: {
type: 'integer',
},
addons: {
type: 'array',
description: 'only valid if product is a subscription',
items: {
$ref: '#/$defs/attach_addon',
},
},
amount: {
type: 'integer',
description:
'Amount the customer pays if pay_what_you_want is enabled. If disabled then amount will be ignored\nRepresented in the lowest denomination of the currency (e.g., cents for USD).\nFor example, to charge $1.00, pass `100`.\nOnly applicable for one time payments\n\nIf amount is not set for pay_what_you_want product,\ncustomer is allowed to select the amount.',
},
},
required: ['product_id', 'quantity'],
},
},
allowed_payment_method_types: {
type: 'array',
description:
"Customers will never see payment methods that are not in this list.\nHowever, adding a method here does not guarantee customers will see it.\nAvailability still depends on other factors (e.g., customer location, merchant settings).\n\nDisclaimar: Always provide 'credit' and 'debit' as a fallback.\nIf all payment methods are unavailable, checkout session will fail.",
items: {
$ref: '#/$defs/payment_method_types',
},
},
billing_address: {
type: 'object',
title: 'Checkout Session Billing Address',
description: 'Billing address information for the session',
properties: {
country: {
$ref: '#/$defs/country_code',
},
city: {
type: 'string',
description: 'City name',
},
state: {
type: 'string',
description: 'State or province name',
},
street: {
type: 'string',
description: 'Street address including house number and unit/apartment if applicable',
},
zipcode: {
type: 'string',
description: 'Postal code or ZIP code',
},
},
required: ['country'],
},
billing_currency: {
$ref: '#/$defs/currency',
},
confirm: {
type: 'boolean',
description:
'If confirm is true, all the details will be finalized. If required data is missing, an API error is thrown.',
},
customer: {
$ref: '#/$defs/customer_request',
},
customization: {
type: 'object',
title: 'Checkout Session Customization',
description: 'Customization for the checkout session page',
properties: {
force_language: {
type: 'string',
description: 'Force the checkout interface to render in a specific language (e.g. `en`, `es`)',
},
show_on_demand_tag: {
type: 'boolean',
description: 'Show on demand tag\n\nDefault is true',
},
show_order_details: {
type: 'boolean',
description: 'Show order details by default\n\nDefault is true',
},
theme: {
type: 'string',
description: 'Theme of the page\n\nDefault is `System`.',
enum: ['dark', 'light', 'system'],
},
},
},
discount_code: {
type: 'string',
},
feature_flags: {
type: 'object',
title: 'Checkout Session Flags',
properties: {
allow_currency_selection: {
type: 'boolean',
description: 'if customer is allowed to change currency, set it to true\n\nDefault is true',
},
allow_discount_code: {
type: 'boolean',
description:
'If the customer is allowed to apply discount code, set it to true.\n\nDefault is true',
},
allow_phone_number_collection: {
type: 'boolean',
description: 'If phone number is collected from customer, set it to rue\n\nDefault is true',
},
allow_tax_id: {
type: 'boolean',
description: 'If the customer is allowed to add tax id, set it to true\n\nDefault is true',
},
always_create_new_customer: {
type: 'boolean',
description:
'Set to true if a new customer object should be created.\nBy default email is used to find an existing customer to attach the session to\n\nDefault is false',
},
},
},
force_3ds: {
type: 'boolean',
description: 'Override merchant default 3DS behaviour for this session',
},
metadata: {
type: 'object',
description: 'Additional metadata associated with the payment. Defaults to empty if not provided.',
additionalProperties: true,
},
return_url: {
type: 'string',
description: 'The url to redirect after payment failure or success.',
},
show_saved_payment_methods: {
type: 'boolean',
description: 'Display saved payment methods of a returning customer False by default',
},
subscription_data: {
type: 'object',
title: 'Subscription Data',
properties: {
on_demand: {
$ref: '#/$defs/on_demand_subscription',
},
trial_period_days: {
type: 'integer',
description:
"Optional trial period in days If specified, this value overrides the trial period set in the product's price Must be between 0 and 10000 days",
},
},
},
},
required: ['product_cart'],
$defs: {
attach_addon: {
type: 'object',
title: 'Attach Addon Request',
properties: {
addon_id: {
type: 'string',
},
quantity: {
type: 'integer',
},
},
required: ['addon_id', 'quantity'],
},
payment_method_types: {
type: 'string',
enum: [
'credit',
'debit',
'upi_collect',
'upi_intent',
'apple_pay',
'cashapp',
'google_pay',
'multibanco',
'bancontact_card',
'eps',
'ideal',
'przelewy24',
'paypal',
'affirm',
'klarna',
'sepa',
'ach',
'amazon_pay',
'afterpay_clearpay',
],
},
country_code: {
type: 'string',
description: 'ISO country code alpha2 variant',
enum: [
'AF',
'AX',
'AL',
'DZ',
'AS',
'AD',
'AO',
'AI',
'AQ',
'AG',
'AR',
'AM',
'AW',
'AU',
'AT',
'AZ',
'BS',
'BH',
'BD',
'BB',
'BY',
'BE',
'BZ',
'BJ',
'BM',
'BT',
'BO',
'BQ',
'BA',
'BW',
'BV',
'BR',
'IO',
'BN',
'BG',
'BF',
'BI',
'KH',
'CM',
'CA',
'CV',
'KY',
'CF',
'TD',
'CL',
'CN',
'CX',
'CC',
'CO',
'KM',
'CG',
'CD',
'CK',
'CR',
'CI',
'HR',
'CU',
'CW',
'CY',
'CZ',
'DK',
'DJ',
'DM',
'DO',
'EC',
'EG',
'SV',
'GQ',
'ER',
'EE',
'ET',
'FK',
'FO',
'FJ',
'FI',
'FR',
'GF',
'PF',
'TF',
'GA',
'GM',
'GE',
'DE',
'GH',
'GI',
'GR',
'GL',
'GD',
'GP',
'GU',
'GT',
'GG',
'GN',
'GW',
'GY',
'HT',
'HM',
'VA',
'HN',
'HK',
'HU',
'IS',
'IN',
'ID',
'IR',
'IQ',
'IE',
'IM',
'IL',
'IT',
'JM',
'JP',
'JE',
'JO',
'KZ',
'KE',
'KI',
'KP',
'KR',
'KW',
'KG',
'LA',
'LV',
'LB',
'LS',
'LR',
'LY',
'LI',
'LT',
'LU',
'MO',
'MK',
'MG',
'MW',
'MY',
'MV',
'ML',
'MT',
'MH',
'MQ',
'MR',
'MU',
'YT',
'MX',
'FM',
'MD',
'MC',
'MN',
'ME',
'MS',
'MA',
'MZ',
'MM',
'NA',
'NR',
'NP',
'NL',
'NC',
'NZ',
'NI',
'NE',
'NG',
'NU',
'NF',
'MP',
'NO',
'OM',
'PK',
'PW',
'PS',
'PA',
'PG',
'PY',
'PE',
'PH',
'PN',
'PL',
'PT',
'PR',
'QA',
'RE',
'RO',
'RU',
'RW',
'BL',
'SH',
'KN',
'LC',
'MF',
'PM',
'VC',
'WS',
'SM',
'ST',
'SA',
'SN',
'RS',
'SC',
'SL',
'SG',
'SX',
'SK',
'SI',
'SB',
'SO',
'ZA',
'GS',
'SS',
'ES',
'LK',
'SD',
'SR',
'SJ',
'SZ',
'SE',
'CH',
'SY',
'TW',
'TJ',
'TZ',
'TH',
'TL',
'TG',
'TK',
'TO',
'TT',
'TN',
'TR',
'TM',
'TC',
'TV',
'UG',
'UA',
'AE',
'GB',
'UM',
'US',
'UY',
'UZ',
'VU',
'VE',
'VN',
'VG',
'VI',
'WF',
'EH',
'YE',
'ZM',
'ZW',
],
},
currency: {
type: 'string',
enum: [
'AED',
'ALL',
'AMD',
'ANG',
'AOA',
'ARS',
'AUD',
'AWG',
'AZN',
'BAM',
'BBD',
'BDT',
'BGN',
'BHD',
'BIF',
'BMD',
'BND',
'BOB',
'BRL',
'BSD',
'BWP',
'BYN',
'BZD',
'CAD',
'CHF',
'CLP',
'CNY',
'COP',
'CRC',
'CUP',
'CVE',
'CZK',
'DJF',
'DKK',
'DOP',
'DZD',
'EGP',
'ETB',
'EUR',
'FJD',
'FKP',
'GBP',
'GEL',
'GHS',
'GIP',
'GMD',
'GNF',
'GTQ',
'GYD',
'HKD',
'HNL',
'HRK',
'HTG',
'HUF',
'IDR',
'ILS',
'INR',
'IQD',
'JMD',
'JOD',
'JPY',
'KES',
'KGS',
'KHR',
'KMF',
'KRW',
'KWD',
'KYD',
'KZT',
'LAK',
'LBP',
'LKR',
'LRD',
'LSL',
'LYD',
'MAD',
'MDL',
'MGA',
'MKD',
'MMK',
'MNT',
'MOP',
'MRU',
'MUR',
'MVR',
'MWK',
'MXN',
'MYR',
'MZN',
'NAD',
'NGN',
'NIO',
'NOK',
'NPR',
'NZD',
'OMR',
'PAB',
'PEN',
'PGK',
'PHP',
'PKR',
'PLN',
'PYG',
'QAR',
'RON',
'RSD',
'RUB',
'RWF',
'SAR',
'SBD',
'SCR',
'SEK',
'SGD',
'SHP',
'SLE',
'SLL',
'SOS',
'SRD',
'SSP',
'STN',
'SVC',
'SZL',
'THB',
'TND',
'TOP',
'TRY',
'TTD',
'TWD',
'TZS',
'UAH',
'UGX',
'USD',
'UYU',
'UZS',
'VES',
'VND',
'VUV',
'WST',
'XAF',
'XCD',
'XOF',
'XPF',
'YER',
'ZAR',
'ZMW',
],
},
customer_request: {
anyOf: [
{
$ref: '#/$defs/attach_existing_customer',
},
{
$ref: '#/$defs/new_customer',
},
],
title: 'Customer Request',
},
attach_existing_customer: {
type: 'object',
title: 'Attach Existing Customer',
properties: {
customer_id: {
type: 'string',
},
},
required: ['customer_id'],
},
new_customer: {
type: 'object',
title: 'New Customer',
properties: {
email: {
type: 'string',
description: 'Email is required for creating a new customer',
},
name: {
type: 'string',
description:
'Optional full name of the customer. If provided during session creation,\nit is persisted and becomes immutable for the session. If omitted here,\nit can be provided later via the confirm API.',
},
phone_number: {
type: 'string',
},
},
required: ['email'],
},
on_demand_subscription: {
type: 'object',
title: 'On Demand Subscription Request',
properties: {
mandate_only: {
type: 'boolean',
description:
'If set as True, does not perform any charge and only authorizes payment method details for future use.',
},
adaptive_currency_fees_inclusive: {
type: 'boolean',
description:
'Whether adaptive currency fees should be included in the product_price (true) or added on top (false).\nThis field is ignored if adaptive pricing is not enabled for the business.',
},
product_currency: {
$ref: '#/$defs/currency',
},
product_description: {
type: 'string',
description:
'Optional product description override for billing and line items.\nIf not specified, the stored description of the product will be used.',
},
product_price: {
type: 'integer',
description:
'Product price for the initial charge to customer\nIf not specified the stored price of the product will be used\nRepresented in the lowest denomination of the currency (e.g., cents for USD).\nFor example, to charge $1.00, pass `100`.',
},
},
required: ['mandate_only'],
},
},
},
annotations: {},
};
export const handler = async (client: DodoPayments, args: Record<string, unknown> | undefined) => {
const body = args as any;
return asTextContentResult(await client.checkoutSessions.create(body));
};
export default { metadata, tool, handler };