@airwallex/developer-mcp
Version:
MCP server for AI agents that assist developers integrating with the Airwallex platform
71 lines (70 loc) • 2.7 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createPaymentLinkToolConfig = exports.createPaymentLinkSchema = void 0;
exports.executeCreatePaymentLink = executeCreatePaymentLink;
const zod_1 = require("zod");
const descriptions_1 = require("../constants/descriptions");
exports.createPaymentLinkSchema = zod_1.z.object({
amount: zod_1.z
.number()
.positive()
.describe("The payment amount. For Fixed pricing only."),
currency: zod_1.z
.string()
.length(3)
.describe("The payment currency. For Fixed pricing only."),
description: zod_1.z
.string()
.optional()
.describe("The additional description text that appears under the title in the payment checkout page."),
reusable: zod_1.z.boolean().optional().default(false),
shopper_email: zod_1.z
.string()
.email()
.optional()
.describe("The email address to send the payment link to. Since this parameter is optional, OMIT it when it is not explicitly supplied by the user. NEVER mock or use a placeholder email address."),
title: zod_1.z
.string()
.min(1)
.describe("The title of the payment link that is displayed in the payment checkout page."),
});
async function executeCreatePaymentLink(airwallex, args) {
try {
const createPayload = {
amount: args.amount,
currency: args.currency,
reusable: args.reusable,
title: args.title,
};
if (args.description) {
createPayload.description = args.description;
}
const response = (await airwallex.post("/api/v1/pa/payment_links/create", createPayload));
if (args.shopper_email) {
await airwallex.post(`/api/v1/pa/payment_links/${response.id}/notify_shopper`, { shopper_email: args.shopper_email });
}
return {
content: [
{
text: JSON.stringify(response, null, 2),
type: "text",
},
],
};
}
catch (error) {
const statusCode = error?.status || error?.statusCode || 500;
const errorMessage = error?.message || "Unknown error occurred";
throw new Error(`Failed to create payment link (${statusCode}): ${errorMessage}`);
}
}
exports.createPaymentLinkToolConfig = {
annotations: {
openWorldHint: true,
readOnlyHint: false,
title: "Create payment link",
},
description: descriptions_1.TOOL_DESCRIPTIONS.CREATE_PAYMENT_LINK,
inputSchema: exports.createPaymentLinkSchema,
name: "create_payment_link",
};