create_stripe_payment_intent
Generate a Stripe payment intent to process transactions within PocketBase databases using the MCP server. Facilitates secure and structured payment handling for advanced database operations.
Instructions
Create a Stripe payment intent for processing payments
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/agent-simple.ts:635-691 (registration)Tool registration including schema, handler, and description for 'create_stripe_payment_intent' in the main PocketBaseMCPAgent class.this.server.tool( 'create_stripe_payment_intent', 'Create a Stripe payment intent for processing payments', { type: 'object', properties: { amount: { type: 'number', description: 'Amount in cents (e.g., 2000 for $20.00)' }, currency: { type: 'string', description: 'Three-letter currency code (e.g., USD)' }, description: { type: 'string', description: 'Optional description for the payment' } }, required: ['amount', 'currency'] }, async ({ amount, currency, description }) => { // Lazy load Stripe service await this.ensureStripeService(); if (!this.stripeService) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'Stripe service not available. Please set STRIPE_SECRET_KEY environment variable.' }) }] }; } try { const paymentIntent = await this.stripeService.createPaymentIntent({ amount, currency, description }); return { content: [{ type: 'text', text: JSON.stringify({ success: true, paymentIntent: { paymentIntentId: paymentIntent.paymentIntentId, clientSecret: paymentIntent.clientSecret } }, null, 2) }] }; } catch (error: any) { return { content: [{ type: 'text', text: JSON.stringify({ error: `Failed to create payment intent: ${error.message}` }) }] }; } } );
- src/agent-simple.ts:648-690 (handler)The execution handler for the create_stripe_payment_intent tool, which invokes StripeService.createPaymentIntent.// Lazy load Stripe service await this.ensureStripeService(); if (!this.stripeService) { return { content: [{ type: 'text', text: JSON.stringify({ error: 'Stripe service not available. Please set STRIPE_SECRET_KEY environment variable.' }) }] }; } try { const paymentIntent = await this.stripeService.createPaymentIntent({ amount, currency, description }); return { content: [{ type: 'text', text: JSON.stringify({ success: true, paymentIntent: { paymentIntentId: paymentIntent.paymentIntentId, clientSecret: paymentIntent.clientSecret } }, null, 2) }] }; } catch (error: any) { return { content: [{ type: 'text', text: JSON.stringify({ error: `Failed to create payment intent: ${error.message}` }) }] }; } }
- src/agent-simple.ts:638-646 (schema)JSON Schema defining the input parameters for the create_stripe_payment_intent tool.{ type: 'object', properties: { amount: { type: 'number', description: 'Amount in cents (e.g., 2000 for $20.00)' }, currency: { type: 'string', description: 'Three-letter currency code (e.g., USD)' }, description: { type: 'string', description: 'Optional description for the payment' } }, required: ['amount', 'currency'] },
- src/services/stripe.ts:110-133 (helper)StripeService.createPaymentIntent helper method that creates the actual Stripe PaymentIntent object and returns clientSecret and ID.async createPaymentIntent(data: { amount: number; currency?: string; customerId?: string; description?: string; metadata?: Record<string, any>; }): Promise<{ clientSecret: string; paymentIntentId: string }> { try { const paymentIntent = await this.stripe.paymentIntents.create({ amount: data.amount, currency: data.currency || 'usd', customer: data.customerId, description: data.description, metadata: data.metadata || {}, }); return { clientSecret: paymentIntent.client_secret!, paymentIntentId: paymentIntent.id, }; } catch (error: any) { throw new Error(`Failed to create payment intent: ${error.message}`); } }