Skip to main content
Glama

create_payment_intent

Initiates payment processing through Bayarcash by generating a payment intent with required details like order number, amount, and payer information, then returns an ID for status tracking.

Instructions

Create a new payment intent for processing payments through Bayarcash. Returns payment intent ID in response. WORKFLOW: 1) If user did not provide payer_email, call list_transactions (per_page=1) to get latest email and ask: "Use email from last payment: {email}?" 2) If user did not provide portal_key, call get_portals and ask user to select. 3) If user did not specify payment channel, call get_payment_channels and ask user to select. 4) Ask if they want to provide phone number (optional). IMPORTANT: Store the returned "id" field (e.g., pi_pGwAaq) to check payment status later.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
order_numberYesUnique order number for this payment
amountYesPayment amount in MYR (e.g., 100.50)
payer_emailYesEmail address of the payer. If not provided, get latest transaction email and ask user if they want to use it.
payer_nameYesName of the payer
descriptionYesDescription of the payment
portal_keyYesPortal key selected by user from get_portals list
payment_channelNoPayment channel ID selected by user from get_payment_channels list. Examples: 1=FPX, 2=DuitNow, 3=Boost, 4=GrabPay.
payer_telephone_numberNoPayer phone number (integer, Malaysia numbers only). Ask user: "Would you like to provide a phone number?" Format: 60123456789

Implementation Reference

  • MCP server tool handler for 'create_payment_intent': validates input using createPaymentIntentSchema and delegates to bayarcash client.
    case 'create_payment_intent': {
      // Validate input
      const validation = validateInput(createPaymentIntentSchema, args);
      if (!validation.success) {
        throw new McpError(ErrorCode.InvalidParams, `Validation error: ${validation.error}`);
      }
    
      const result = await bayarcash.createPaymentIntent(validation.data);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2)
          }
        ]
      };
    }
  • src/index.ts:60-101 (registration)
    Tool registration in ListToolsResponse: defines name, description, and inputSchema for create_payment_intent
    {
      name: 'create_payment_intent',
      description: 'Create a new payment intent for processing payments through Bayarcash. Returns payment intent ID in response. WORKFLOW: 1) If user did not provide payer_email, call list_transactions (per_page=1) to get latest email and ask: "Use email from last payment: {email}?" 2) If user did not provide portal_key, call get_portals and ask user to select. 3) If user did not specify payment channel, call get_payment_channels and ask user to select. 4) Ask if they want to provide phone number (optional). IMPORTANT: Store the returned "id" field (e.g., pi_pGwAaq) to check payment status later.',
      inputSchema: {
        type: 'object',
        properties: {
          order_number: {
            type: 'string',
            description: 'Unique order number for this payment'
          },
          amount: {
            type: 'number',
            description: 'Payment amount in MYR (e.g., 100.50)'
          },
          payer_email: {
            type: 'string',
            description: 'Email address of the payer. If not provided, get latest transaction email and ask user if they want to use it.'
          },
          payer_name: {
            type: 'string',
            description: 'Name of the payer'
          },
          description: {
            type: 'string',
            description: 'Description of the payment'
          },
          portal_key: {
            type: 'string',
            description: 'Portal key selected by user from get_portals list'
          },
          payment_channel: {
            type: 'number',
            description: 'Payment channel ID selected by user from get_payment_channels list. Examples: 1=FPX, 2=DuitNow, 3=Boost, 4=GrabPay.'
          },
          payer_telephone_number: {
            type: 'number',
            description: 'Payer phone number (integer, Malaysia numbers only). Ask user: "Would you like to provide a phone number?" Format: 60123456789'
          }
        },
        required: ['order_number', 'amount', 'payer_email', 'payer_name', 'description', 'portal_key']
      }
    },
  • Zod input validation schema for create_payment_intent tool, used in handler for validation
    export const createPaymentIntentSchema = z.object({
      order_number: z.string().min(1, 'Order number is required'),
      amount: amountSchema,
      payer_email: emailSchema,
      payer_name: z.string().min(1, 'Payer name is required'),
      description: z.string().min(1, 'Description is required'),
      portal_key: z.string().min(1, 'Portal key is required'),
      payment_channel: paymentChannelSchema.optional(),
      payer_telephone_number: phoneSchema.optional()
    });
  • BayarcashClient helper method: makes POST request to /payment-intents API endpoint to create the payment intent
    async createPaymentIntent(intent: PaymentIntentRequest): Promise<PaymentIntentResponse> {
      try {
        const response = await this.axiosInstance.post('/payment-intents', intent);
        return response.data;
      } catch (error) {
        this.handleError(error);
      }
    }
  • Alternative Smithery MCP tool handler/registration for create_payment_intent (combined), delegates to same bayarcash client.
    server.tool(
      'create_payment_intent',
      'Create a new payment intent for processing payments through Bayarcash. Returns payment URL and order details with payment intent ID. WORKFLOW: 1) If user has NOT provided payer_email, call list_transactions (limit 1, sorted by latest) to get the most recent payer_email and ask user: "Would you like to use the email from your last payment: {email}?" If yes, use it. If no or no previous transactions, ask for email. 2) If user has NOT provided portal_key, call get_portals first to show list and ask user to select. 3) If user has NOT specified payment_channel, call get_payment_channels to show list and ask user to select. 4) Ask user if they want to provide payer telephone number (optional, Malaysia numbers only). 5) If user already provided these values in their message, use them directly. IMPORTANT: After creating payment, store the returned "id" field (e.g., pi_pGwAaq) - this can be used later to check payment status with get_payment_intent tool.',
      {
        order_number: z.string().describe('Unique order number for this payment. Must be unique across all transactions. Example: ORD-001'),
        amount: z.number().positive().describe('Payment amount in Malaysian Ringgit (MYR). Must be positive. Example: 100.50 for RM100.50'),
        payer_email: z.string().email().describe('Valid email address of the payer. If user did not provide email: 1) Call list_transactions with per_page=1 to get latest transaction, 2) Extract payer_email from response, 3) Ask user: "Would you like to use the email from your last payment: {email}?" If yes use it, if no ask for new email.'),
        payer_name: z.string().min(1).describe('Full name of the payer. Required for transaction records.'),
        description: z.string().min(1).describe('Description of what the payment is for. Shown to customer during payment.'),
        portal_key: z.string().describe('Portal key from the portal selected by user. Get this from get_portals API call.'),
        payment_channel: z.number().int().positive().default(1).optional().describe('Payment channel ID (integer). Get this from user selection after showing get_payment_channels list. Examples: 1=FPX, 2=DuitNow, 3=Boost, 4=GrabPay, 5=TNG, 6=ShopeePay.'),
        payer_telephone_number: z.number().int().positive().optional().describe('Payer phone number (integer, Malaysia numbers only). Ask user: "Would you like to provide a phone number?" If yes, collect the number in format 60123456789 (without spaces or dashes). If no, skip this field.')
      },
      async ({ order_number, amount, payer_email, payer_name, description, portal_key, payment_channel, payer_telephone_number }) => {
        const result = await bayarcash.createPaymentIntent({
          order_number,
          amount,
          payer_email,
          payer_name,
          description,
          portal_key,
          payment_channel,
          payer_telephone_number
        });
        return {
          content: [{ type: 'text', text: JSON.stringify(result, null, 2) }]
        };
      }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it's a creation/mutation tool (implied by 'Create'), requires storing the returned ID for future status checks, and outlines a multi-step interactive workflow. However, it doesn't mention error handling, rate limits, or authentication requirements.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose but becomes verbose with detailed workflow steps. While all sentences are relevant, the structure could be more streamlined by separating core functionality from implementation details. It's appropriately sized but not optimally organized for quick scanning.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (8 parameters, mutation tool, no annotations, no output schema), the description is mostly complete. It covers the purpose, workflow, and critical post-call action (storing the ID). However, it lacks details on error responses, return format beyond the ID, and any system constraints like rate limits or permissions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 8 parameters thoroughly. The description adds minimal parameter semantics beyond the schema—it only references parameters in the workflow context without providing additional meaning. This meets the baseline of 3 when schema coverage is high.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Create a new payment intent for processing payments through Bayarcash') and distinguishes it from siblings by focusing on creation rather than retrieval (e.g., get_payment_intent, list_transactions). It explicitly mentions the resource (payment intent) and the platform (Bayarcash).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit workflow steps for when to use alternative tools (list_transactions, get_portals, get_payment_channels) when parameters are missing. It specifies conditions for invoking siblings and includes user interaction prompts, making it clear when to use this tool versus others.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/khairulimran-97/bayarcash-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server