// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { maybeFilter } from 'dodopayments-mcp/filtering';
import { Metadata, asTextContentResult } from 'dodopayments-mcp/tools/types';
import { Tool } from '@modelcontextprotocol/sdk/types.js';
import DodoPayments from 'dodopayments';
export const metadata: Metadata = {
resource: 'subscriptions',
operation: 'write',
tags: [],
httpMethod: 'post',
httpPath: '/subscriptions/{subscription_id}/charge',
operationId: 'create_subscription_charge',
};
export const tool: Tool = {
name: 'charge_subscriptions',
description:
"When using this tool, always use the `jq_filter` parameter to reduce the response size and improve performance.\n\nOnly omit if you're sure you don't need the data.\n\n\n\n# Response Schema\n```json\n{\n $ref: '#/$defs/subscription_charge_response',\n $defs: {\n subscription_charge_response: {\n type: 'object',\n properties: {\n payment_id: {\n type: 'string'\n }\n },\n required: [ 'payment_id'\n ]\n }\n }\n}\n```",
inputSchema: {
type: 'object',
properties: {
subscription_id: {
type: 'string',
},
product_price: {
type: 'integer',
description:
'The product price. Represented in the lowest denomination of the currency (e.g., cents for USD).\nFor example, to charge $1.00, pass `100`.',
},
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.',
},
customer_balance_config: {
type: 'object',
description: 'Specify how customer balance is used for the payment',
properties: {
allow_customer_credits_purchase: {
type: 'boolean',
description: 'Allows Customer Credit to be purchased to settle payments',
},
allow_customer_credits_usage: {
type: 'boolean',
description: 'Allows Customer Credit Balance to be used to settle payments',
},
},
},
metadata: {
type: 'object',
description:
'Metadata for the payment. If not passed, the metadata of the subscription will be taken',
additionalProperties: true,
},
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.',
},
jq_filter: {
type: 'string',
title: 'jq Filter',
description:
'A jq filter to apply to the response to include certain fields. Consult the output schema in the tool description to see the fields that are available.\n\nFor example: to include only the `name` field in every object of a results array, you can provide ".results[].name".\n\nFor more information, see the [jq documentation](https://jqlang.org/manual/).',
},
},
required: ['subscription_id', 'product_price'],
$defs: {
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',
],
},
},
},
annotations: {},
};
export const handler = async (client: DodoPayments, args: Record<string, unknown> | undefined) => {
const { subscription_id, jq_filter, ...body } = args as any;
return asTextContentResult(
await maybeFilter(jq_filter, await client.subscriptions.charge(subscription_id, body)),
);
};
export default { metadata, tool, handler };