chargeCreditCard
Charges a credit card and applies the payment to a specific customer bill using provided card details and amount, integrating with the Mews hospitality platform API.
Instructions
Charges a credit card and adds the resulting payment to a customer bill
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| Amount | Yes | Charge amount object | |
| BillId | No | Specific bill ID to apply charge to | |
| CreditCardData | Yes | Credit card information | |
| CustomerId | Yes | Customer ID for the charge | |
| Notes | No | Charge notes |
Implementation Reference
- Complete definition of the chargeCreditCardTool including handler logic (execute method), schema, description. The handler spreads input args and calls the Mews API endpoint /api/connector/v1/payments/chargeCreditCard.export const chargeCreditCardTool: Tool = { name: 'chargeCreditCard', description: 'Charges a credit card and adds the resulting payment to a customer bill', inputSchema: { type: 'object', properties: { CustomerId: { type: 'string', description: 'Customer ID for the charge' }, Amount: { type: 'object', properties: { Currency: { type: 'string', description: 'Charge currency code' }, Value: { type: 'number', description: 'Charge amount value' } }, required: ['Currency', 'Value'], description: 'Charge amount object' }, CreditCardData: { type: 'object', properties: { Number: { type: 'string', description: 'Credit card number' }, Expiry: { type: 'string', description: 'Expiry date (MM/YY)' }, Name: { type: 'string', description: 'Cardholder name' }, SecurityCode: { type: 'string', description: 'CVV/CVC code' } }, required: ['Number', 'Expiry', 'Name'], description: 'Credit card information' }, BillId: { type: 'string', description: 'Specific bill ID to apply charge to' }, Notes: { type: 'string', description: 'Charge notes' } }, required: ['CustomerId', 'Amount', 'CreditCardData'], additionalProperties: false }, async execute(config: MewsAuthConfig, args: unknown): Promise<ToolResult> { const inputArgs = args as Record<string, unknown>; const requestData = { ...inputArgs }; const result = await mewsRequest(config, '/api/connector/v1/payments/chargeCreditCard', requestData); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } };
- Input schema for the chargeCreditCard tool defining required CustomerId, Amount (with Currency/Value), CreditCardData (Number, Expiry, Name), optional BillId and Notes.inputSchema: { type: 'object', properties: { CustomerId: { type: 'string', description: 'Customer ID for the charge' }, Amount: { type: 'object', properties: { Currency: { type: 'string', description: 'Charge currency code' }, Value: { type: 'number', description: 'Charge amount value' } }, required: ['Currency', 'Value'], description: 'Charge amount object' }, CreditCardData: { type: 'object', properties: { Number: { type: 'string', description: 'Credit card number' }, Expiry: { type: 'string', description: 'Expiry date (MM/YY)' }, Name: { type: 'string', description: 'Cardholder name' }, SecurityCode: { type: 'string', description: 'CVV/CVC code' } }, required: ['Number', 'Expiry', 'Name'], description: 'Credit card information' }, BillId: { type: 'string', description: 'Specific bill ID to apply charge to' }, Notes: { type: 'string', description: 'Charge notes' } }, required: ['CustomerId', 'Amount', 'CreditCardData'], additionalProperties: false },
- src/tools/index.ts:127-127 (registration)Registers the chargeCreditCardTool in the allTools array, which populates toolMap and is used for MCP tool definitions.chargeCreditCardTool,
- src/tools/index.ts:42-42 (registration)Imports the chargeCreditCardTool for inclusion in the tools registry.import { chargeCreditCardTool } from './payments/chargeCreditCard.js';