Agent Enablement Toolkit

Build AI-powered payment agents with LangChain, Vercel AI SDK, and the OpenAI Agents SDK using Pine Labs Online APIs.

Overview

The Pine Labs Online Agent Toolkit lets you build AI-powered payment agents with LangChain, Vercel AI SDK, and the OpenAI Agents SDK. It exposes Pine Labs Online payment APIs as agent tools via function calling, so your agents can create orders, process payments, and manage transactions programmatically.

Prerequisites

Complete the following prerequisites before building PineLabs payment agents.

  1. Create Pine Labs Online Merchant Account. You can register to Pine Labs Online Merchant Account here.
  2. After Creating Successfully, Login to our Dashboard and generate the client_id and client_secret.
  3. Ensure Node.js version 18 or later is installed.

Framework support

The toolkit supports the following frameworks, each accessible through a dedicated sub-path.

FrameworkImport PathDescription
OpenAI@plural_pinelabs/agent-toolkit/openaiFor Open AI Agents SDK
LangChain@plural_pinelabs/agent-toolkit/langchainFor LangChain agents
Vercel AI SDK@plural_pinelabs/agent-toolkit/ai-sdkFor Vercel's AI SDK

Installation

Use the below code to Install the toolkit using your preferred package manager:

Text
npm install @plural_pinelabs/agent-toolkit

Available Tools

The table below shows the list of PineLabs Tools available.

ToolDescription
createOrderUse this tool to create an Order.
getOrderUse this tool to retrieve the order by order ID.
cancelOrderUse this tool to cancel the Payment against an order.
createRefundUse this tool to initiate a refund against an order.

Sample Codes

Use the below code samples to test and integrate quickly.

import { Agent, run } from '@openai/agents';
import {
  PinelabsAgentToolkit,
  pinelabsEnvironment,
} from '@plural_pinelabs/agent-toolkit/openai';

const pinelabs = new PinelabsAgentToolkit(
  pinelabsEnvironment.UAT,               // or pinelabsEnvironment.PRODUCTION
  process.env.PINE_CLIENT_ID!,
  process.env.PINE_CLIENT_SECRET!
);

const agent = new Agent({
  name: 'Payment Agent',
  instructions: 'You are a helpful payment assistant.',
  model: 'gpt-4o',
  tools: pinelabs.getAgentTools(),
});

const result = await run(agent, 'Create an order for Rs. 500 for customer john@example.com');
console.log(result.finalOutput);

Expected Result

{
  "token": "<<Redirect Token>>",
  "order_id": "v1-5757575757-aa-hU1rUd",
  "redirect_url": "https://api.pluralonline.com/api/v3/checkout-bff/redirect/checkout?token=<<Redirect Token>>",
  "response_code": 200,
  "response_message": "Order Creation Successful."
}
import OpenAI from 'openai';
import {
  PinelabsAgentToolkit,
  pinelabsEnvironment,
} from '@plural_pinelabs/agent-toolkit/openai';

const openai = new OpenAI();

const pinelabs = new PinelabsAgentToolkit(
  pinelabsEnvironment.UAT,
  process.env.PINE_CLIENT_ID!,
  process.env.PINE_CLIENT_SECRET!
);

const response = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Create an order for Rs. 500' }],
  tools: pinelabs.getTools(),
});

for (const toolCall of response.choices[0].message.tool_calls ?? []) {
  const result = await pinelabs.handleToolCall(
    toolCall.function.name,
    JSON.parse(toolCall.function.arguments)
  );
  console.log(result);
}

Expected Result

{
  "token": "<<Redirect Token>>",
  "order_id": "v1-5757575757-aa-hU1rUd",
  "redirect_url": "https://api.pluralonline.com/api/v3/checkout-bff/redirect/checkout?token=<<Redirect Token>>",
  "response_code": 200,
  "response_message": "Order Creation Successful."
}
import { ChatOpenAI } from '@langchain/openai';
import { AgentExecutor, createOpenAIFunctionsAgent } from 'langchain/agents';
import { ChatPromptTemplate } from '@langchain/core/prompts';
import {
  PinelabsAgentToolkit,
  pinelabsEnvironment,
} from '@plural_pinelabs/agent-toolkit/langchain';

const pinelabs = new PinelabsAgentToolkit(
  pinelabsEnvironment.UAT,
  process.env.PINE_CLIENT_ID!,
  process.env.PINE_CLIENT_SECRET!
);

const tools = pinelabs.getTools(); // DynamicStructuredTool[]

const llm = new ChatOpenAI({ model: 'gpt-4o' });
const prompt = ChatPromptTemplate.fromMessages([
  ['system', 'You are a helpful payment assistant.'],
  ['human', '{input}'],
  ['placeholder', '{agent_scratchpad}'],
]);

const agent = await createOpenAIFunctionsAgent({ llm, tools, prompt });
const executor = new AgentExecutor({ agent, tools });

const result = await executor.invoke({ input: 'Create an order for Rs. 500' });
console.log(result.output);

Expected Result

{
  "token": "<<Redirect Token>>",
  "order_id": "v1-5757575757-aa-hU1rUd",
  "redirect_url": "https://api.pluralonline.com/api/v3/checkout-bff/redirect/checkout?token=<<Redirect Token>>",
  "response_code": 200,
  "response_message": "Order Creation Successful."
}
import { generateText } from 'ai';
import { openai } from '@ai-sdk/openai';
import {
  PinelabsAgentToolkit,
  pinelabsEnvironment,
} from '@plural_pinelabs/agent-toolkit/ai-sdk';

const pinelabs = new PinelabsAgentToolkit(
  pinelabsEnvironment.UAT,
  process.env.PINE_CLIENT_ID!,
  process.env.PINE_CLIENT_SECRET!
);

const result = await generateText({
  model: openai('gpt-4o'),
  tools: pinelabs.getTools(),
  prompt: 'Create an order for Rs. 500',
  maxSteps: 5,
});

console.log(result.text);

Expected Result

{
  "token": "<<Redirect Token>>",
  "order_id": "v1-5757575757-aa-hU1rUd",
  "redirect_url": "https://api.pluralonline.com/api/v3/checkout-bff/redirect/checkout?token=<<Redirect Token>>",
  "response_code": 200,
  "response_message": "Order Creation Successful."
}

Environment Variables

VariableDescription
PINE_CLIENT_IDClient ID from the Pine Labs Online Developer Dashboard
PINE_CLIENT_SECRETClient Secret from the Pine Labs Online Developer Dashboard

Environments

EnvironmentConstantBase URL
UATpinelabsEnvironment.UAThttps://pluraluat.v2.pinepg.in
ProductionpinelabsEnvironment.PRODUCTIONhttps://api.pluralpay.in

Authentication

Authentication is handled automatically. The toolkit uses your PINE_CLIENT_ID and PINE_CLIENT_SECRET to obtain a Bearer token via the Pine Labs Online OAuth2 token API. Tokens are cached and refreshed automatically before expiry — no manual token management required.

Resources

New chat
Responses are generated using AI and may contain mistakes.
Hi! I'm Pine, your AI developer assistant. Ask me anything about Pine Labs APIs, integrations, or troubleshooting.

Tip: you can create a new chat with + E