validate_payment_response
Process and verify payment response statuses to ensure accurate order confirmation when integrating with the SATIM payment gateway system.
Instructions
Validate and interpret payment response status
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| response | Yes | Order confirmation response object |
Implementation Reference
- satim-mcp-server.ts:447-479 (handler)Executes the validation logic by checking if payment is accepted or rejected using helper methods, determines status (ACCEPTED, REJECTED, ERROR, UNKNOWN), and returns a JSON-formatted response including status, display message, contact info flag, and the original response.
case "validate_payment_response": const response = args.response as OrderConfirmationResponse; const isAccepted = SatimPaymentGateway.isPaymentAccepted(response); const isRejected = SatimPaymentGateway.isPaymentRejected(response); let status = "UNKNOWN"; let displayMessage = ""; if (isAccepted) { status = "ACCEPTED"; displayMessage = response.params?.respCode_desc || response.actionCodeDescription || "Payment accepted"; } else if (isRejected) { status = "REJECTED"; displayMessage = "Your transaction was rejected / Votre transaction a été rejetée / تم رفض معاملتك"; } else { status = "ERROR"; displayMessage = response.params?.respCode_desc || response.actionCodeDescription || "Unknown error"; } return { content: [ { type: "text", text: JSON.stringify({ status, displayMessage, shouldShowContactInfo: status === "REJECTED" || status === "ERROR", contactNumber: "3020 3020", response }, null, 2) } ] }; - satim-mcp-server.ts:329-342 (registration)Registers the 'validate_payment_response' tool within the MCP server's listTools response, specifying its name, description, and input schema requiring a 'response' object.
{ name: "validate_payment_response", description: "Validate and interpret payment response status", inputSchema: { type: "object", properties: { response: { type: "object", description: "Order confirmation response object" } }, required: ["response"] } } - satim-mcp-server.ts:48-73 (schema)TypeScript interface defining the expected structure of the OrderConfirmationResponse object passed as input to the validate_payment_response tool.
interface OrderConfirmationResponse { orderNumber?: string; actionCode?: number; actionCodeDescription?: string; amount?: number; errorCode?: string; errorMessage?: string; orderStatus?: number; approvalCode?: string; authCode?: number; cardholderName?: string; depositAmount?: number; currency?: string; pan?: string; ip?: string; params?: { respCode?: string; respCode_desc?: string; udf1?: string; udf2?: string; udf3?: string; udf4?: string; udf5?: string; }; } - satim-mcp-server.ts:177-190 (helper)Static helper methods on the SatimPaymentGateway class that determine if the payment response indicates acceptance (orderStatus === 2) or rejection (orderStatus === 3), used directly in the tool handler.
static isPaymentAccepted(response: OrderConfirmationResponse): boolean { return response.params?.respCode === "00" && response.errorCode === "0" && response.orderStatus === 2; } /** * Validate payment rejection status */ static isPaymentRejected(response: OrderConfirmationResponse): boolean { return response.params?.respCode === "00" && response.errorCode === "0" && response.orderStatus === 3; }