Skip to main content
Glama

create_payment_link

Generate secure payment links for purchases or donations through Visa Acceptance, specifying currency, amount, and line items for customer transactions.

Instructions

This tool will create a payment link in Visa Acceptance.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
linkTypeYesType of payment link (PURCHASE OR DONATION)
purchaseNumberYesUnique alphanumeric id, no special chararacters for the purchase less than 20 characters
currencyYesCurrency code e.g. "USD" (Required)
totalAmountNoTotal payment amount e.g. "100.00"
requestPhoneNoRequest phone number from customer
requestShippingNoRequest shipping address from customer
clientReferenceCodeNoCustom client reference code for the transaction
lineItemsYesLine items in the purchase

Implementation Reference

  • The main handler function that executes the create_payment_link tool logic by constructing a CreatePaymentLinkRequest and calling the Cybersource PaymentLinksApi.
    export const createPaymentLink = async ( visaClient: any, context: VisaContext, params: z.infer<ReturnType<typeof createPaymentLinkParameters>> ) => { try { const paymentLinkApiInstance = new cybersourceRestApi.PaymentLinksApi(visaClient.configuration, visaClient.visaApiClient); const processingInformation = new cybersourceRestApi.Iplv2paymentlinksProcessingInformation( params.linkType, params.requestPhone, params.requestShipping ); const purchaseInformation = new cybersourceRestApi.Iplv2paymentlinksPurchaseInformation(params.purchaseNumber); const amountDetails = new cybersourceRestApi.Iplv2paymentlinksOrderInformationAmountDetails(params.currency); amountDetails.totalAmount = params.totalAmount; const lineItems = params.lineItems.map((item: LineItem) => { const lineItem = new cybersourceRestApi.Iplv2paymentlinksOrderInformationLineItems(item.productName); lineItem.productSku = item.productSKU; lineItem.productDescription = item.productDescription; lineItem.quantity = parseInt(item.quantity, 10); lineItem.unitPrice = item.unitPrice; return lineItem; }); const orderInformation = new cybersourceRestApi.Iplv2paymentlinksOrderInformation(amountDetails, lineItems); const requestObj = new cybersourceRestApi.CreatePaymentLinkRequest( processingInformation, purchaseInformation, orderInformation ); const clientReferenceInformation = new cybersourceRestApi.Invoicingv2invoicesClientReferenceInformation(); if (params.clientReferenceCode) { clientReferenceInformation.code = params.clientReferenceCode; } else if (context.merchantId) { clientReferenceInformation.code = context.merchantId; } requestObj.clientReferenceInformation = clientReferenceInformation; // Initialize partner object if it doesn't exist requestObj.clientReferenceInformation.partner = {}; // Set the developer ID based on the context mode setDeveloperId(requestObj, context); const result = await new Promise((resolve, reject) => { paymentLinkApiInstance.createPaymentLink(requestObj, (error: any, data: any) => { if (error) { reject(error); } else { resolve(data); } }); }); return result; } catch (error) { return 'Failed to create payment link'; } };
  • Zod schema defining the input parameters for the create_payment_link tool.
    export const createPaymentLinkParameters = ( context: VisaContext = {} as VisaContext ) => { return z.object({ linkType: z.string().describe('Type of payment link (PURCHASE OR DONATION)'), purchaseNumber: z.string().describe('Unique alphanumeric id, no special chararacters for the purchase less than 20 characters'), currency: z.string().describe('Currency code e.g. "USD" (Required)'), totalAmount: z.string().optional().describe('Total payment amount e.g. "100.00"'), requestPhone: z.boolean().optional().default(false).describe('Request phone number from customer'), requestShipping: z.boolean().optional().default(false).describe('Request shipping address from customer'), clientReferenceCode: z.string().optional().describe('Custom client reference code for the transaction'), lineItems: z.array( z.object({ productName: z.string().describe('Name of the product'), productSKU: z.string().optional().describe('Product SKU identifier'), productDescription: z.string().optional().describe('Product description'), quantity: z.string().describe('Quantity of the product'), unitPrice: z.string().describe('Unit price of the product') }) ).describe('Line items in the purchase') }); };
  • Tool module definition and export, registering the create_payment_link tool with its handler, schema, and metadata.
    const tool = (context: VisaContext): Tool => ({ method: 'create_payment_link', name: 'Create Payment Link', description: createPaymentLinkPrompt(context), parameters: createPaymentLinkParameters(context), actions: { paymentLinks: { create: true, }, }, execute: createPaymentLink, }); export default tool;
  • Function that collects and returns all tools, including createPaymentLinkToolModule, for overall tool registration.
    export function createTools(context: VisaContext): Tool[] { return [ createInvoiceToolModule(context), updateInvoiceToolModule(context), getInvoiceToolModule(context), listInvoicesToolModule(context), sendInvoiceToolModule(context), cancelInvoiceToolModule(context), createPaymentLinkToolModule(context), updatePaymentLinkToolModule(context), getPaymentLinkToolModule(context), listPaymentLinkToolModule(context) ];

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/visaacceptance/agent-toolkit'

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