update_payment_link
Modify an existing payment link in Visa Acceptance to update transaction details, line items, customer information requests, or expiration settings.
Instructions
This tool will update a payment link in Visa Acceptance.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| clientReferenceCode | No | Custom client reference code for the transaction | |
| currency | No | Currency code e.g. "USD" | |
| expirationDays | No | Number of days the link remains valid | |
| id | Yes | Payment link ID (required) | |
| lineItems | No | Line items in the purchase | |
| linkType | No | Type of payment link (PURCHASE OR DONATION) | |
| purchaseNumber | No | Unique identifier for the purchase | |
| requestPhone | No | Request phone number from customer | |
| requestShipping | No | Request shipping address from customer | |
| totalAmount | No | Total payment amount e.g. "100.00" |
Implementation Reference
- The main handler function that executes the 'update_payment_link' tool logic. It constructs a CyberSource UpdatePaymentLinkRequest and calls the PaymentLinksApi.updatePaymentLink method.export const updatePaymentLink = async ( visaClient: any, context: VisaContext, params: z.infer<ReturnType<typeof updatePaymentLinkParameters>> ) => { try { const paymentLinkApiInstance = new cybersourceRestApi.PaymentLinksApi(visaClient.configuration, visaClient.visaApiClient); const { id, ...updateParams } = params; let expirationDate; if (params.expirationDays) { expirationDate = new Date(Date.now() + params.expirationDays * 24 * 60 * 60 * 1000).toISOString().split('T')[0]; } /** * Create the SDK model objects for the payment link update */ let processingInformation; if (params.linkType) { processingInformation = new cybersourceRestApi.Iplv2paymentlinksProcessingInformation( params.linkType, params.requestPhone, params.requestShipping ); } let purchaseInformation; if (params.purchaseNumber) { purchaseInformation = new cybersourceRestApi.Iplv2paymentlinksPurchaseInformation(params.purchaseNumber); } let amountDetails; let orderInformation; if (params.currency) { amountDetails = new cybersourceRestApi.Iplv2paymentlinksOrderInformationAmountDetails(params.currency); if (params.totalAmount) { amountDetails.totalAmount = params.totalAmount; } let lineItems; if (params.lineItems && params.lineItems.length > 0) { 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; }); orderInformation = new cybersourceRestApi.Iplv2paymentlinksOrderInformation(amountDetails, lineItems); } else if (amountDetails) { orderInformation = new cybersourceRestApi.Iplv2paymentlinksOrderInformation(amountDetails); } } const requestObj = new cybersourceRestApi.UpdatePaymentLinkRequest(); if (processingInformation) { requestObj.processingInformation = processingInformation; } if (purchaseInformation) { requestObj.purchaseInformation = purchaseInformation; } if (orderInformation) { requestObj.orderInformation = orderInformation; } const clientReferenceInformation = new cybersourceRestApi.Invoicingv2invoicesClientReferenceInformation(); if (params.clientReferenceCode) { clientReferenceInformation.code = params.clientReferenceCode; } else if (context.merchantId) { clientReferenceInformation.code = context.merchantId; } requestObj.clientReferenceInformation = clientReferenceInformation; const result = await new Promise((resolve, reject) => { paymentLinkApiInstance.updatePaymentLink(id, requestObj, (error: any, data: any) => { if (error) { reject(error); } else { resolve(data); } }); }); return result; } catch (error) { return 'Failed to update payment link'; } };
- Zod schema defining the input parameters for the update_payment_link tool.export const updatePaymentLinkParameters = ( context: VisaContext = {} as VisaContext ) => { return z.object({ id: z.string().describe('Payment link ID (required)'), linkType: z.string().optional().describe('Type of payment link (PURCHASE OR DONATION)'), purchaseNumber: z.string().optional().describe('Unique identifier for the purchase'), currency: z.string().optional().describe('Currency code e.g. "USD"'), totalAmount: z.string().optional().describe('Total payment amount e.g. "100.00"'), requestPhone: z.boolean().optional().describe('Request phone number from customer'), requestShipping: z.boolean().optional().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') }) ).optional().describe('Line items in the purchase'), expirationDays: z.number().optional().describe('Number of days the link remains valid') }); };
- Tool module definition exporting the tool object with method 'update_payment_link', including description, parameters, and execute handler.const tool = (context: VisaContext): Tool => ({ method: 'update_payment_link', name: 'Update Payment Link', description: updatePaymentLinkPrompt(context), parameters: updatePaymentLinkParameters(context), actions: { paymentLinks: { update: true, }, }, execute: updatePaymentLink, }); export default tool;
- typescript/src/shared/tools.ts:40-53 (registration)Central registration function that includes the updatePaymentLinkToolModule in the list of all tools returned.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) ]; }