@payware/mcp-server 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/.env.example +92 -0
  2. package/MCP-SETUP.md +190 -0
  3. package/README.md +483 -0
  4. package/check-keys.js +52 -0
  5. package/keys/README.md +112 -0
  6. package/mcp-config.json +9 -0
  7. package/package.json +66 -0
  8. package/payware-mcp-config.json +12 -0
  9. package/src/auth/rsa-keys.js +82 -0
  10. package/src/auth/sandbox-setup.js +187 -0
  11. package/src/config/env.js +229 -0
  12. package/src/config/partner-types.js +143 -0
  13. package/src/core/auth/jwt-factory.js +182 -0
  14. package/src/core/auth/jwt-token.js +735 -0
  15. package/src/core/utils/json-serializer.js +100 -0
  16. package/src/core/utils/key-utils.js +133 -0
  17. package/src/index.js +237 -0
  18. package/src/isv/data/index.js +291 -0
  19. package/src/isv/deep-links/delete-product-link.js +154 -0
  20. package/src/isv/deep-links/delete-transaction-link.js +154 -0
  21. package/src/isv/deep-links/get-product-link.js +167 -0
  22. package/src/isv/deep-links/get-transaction-link.js +167 -0
  23. package/src/isv/deep-links/index.js +23 -0
  24. package/src/isv/index.js +103 -0
  25. package/src/isv/oauth2/create-token-simple.js +46 -0
  26. package/src/isv/oauth2/get-token-info.js +157 -0
  27. package/src/isv/oauth2/obtain-token.js +189 -0
  28. package/src/isv/oauth2/token-helper.js +151 -0
  29. package/src/isv/products/audios.js +470 -0
  30. package/src/isv/products/create-product.js +314 -0
  31. package/src/isv/products/delete-product.js +119 -0
  32. package/src/isv/products/get-product-image.js +247 -0
  33. package/src/isv/products/get-product.js +168 -0
  34. package/src/isv/products/index.js +65 -0
  35. package/src/isv/products/list-products.js +136 -0
  36. package/src/isv/products/schedules.js +522 -0
  37. package/src/isv/products/update-product.js +265 -0
  38. package/src/isv/transactions/cancel-transaction.js +129 -0
  39. package/src/isv/transactions/create-transaction.js +361 -0
  40. package/src/isv/transactions/get-status.js +217 -0
  41. package/src/isv/transactions/process-transaction.js +145 -0
  42. package/src/isv/transactions/simulate-callback.js +146 -0
  43. package/src/isv/transactions/transaction-history.js +186 -0
  44. package/src/isv/utils/auth.js +159 -0
  45. package/src/mcp-proxy.js +150 -0
  46. package/src/merchant/data/export-report.js +108 -0
  47. package/src/merchant/data/generate-report.js +151 -0
  48. package/src/merchant/data/get-report-status.js +120 -0
  49. package/src/merchant/data/index.js +351 -0
  50. package/src/merchant/deep-links/delete-product-link.js +121 -0
  51. package/src/merchant/deep-links/delete-transaction-link.js +121 -0
  52. package/src/merchant/deep-links/get-product-link.js +134 -0
  53. package/src/merchant/deep-links/get-transaction-link.js +134 -0
  54. package/src/merchant/deep-links/index.js +23 -0
  55. package/src/merchant/index.js +92 -0
  56. package/src/merchant/products/audios.js +606 -0
  57. package/src/merchant/products/create-product.js +288 -0
  58. package/src/merchant/products/delete-product.js +111 -0
  59. package/src/merchant/products/get-product-image.js +252 -0
  60. package/src/merchant/products/get-product.js +144 -0
  61. package/src/merchant/products/index.js +65 -0
  62. package/src/merchant/products/list-products.js +112 -0
  63. package/src/merchant/products/schedules.js +646 -0
  64. package/src/merchant/products/update-product.js +282 -0
  65. package/src/merchant/transactions/cancel-transaction.js +241 -0
  66. package/src/merchant/transactions/create-transaction.js +482 -0
  67. package/src/merchant/transactions/get-status.js +196 -0
  68. package/src/merchant/transactions/process-transaction.js +349 -0
  69. package/src/merchant/transactions/simulate-callback.js +246 -0
  70. package/src/merchant/transactions/transaction-history.js +258 -0
  71. package/src/payment-institution/data/index.js +280 -0
  72. package/src/payment-institution/deep-links/delete-transaction-link.js +128 -0
  73. package/src/payment-institution/deep-links/get-transaction-link.js +141 -0
  74. package/src/payment-institution/deep-links/index.js +17 -0
  75. package/src/payment-institution/index.js +92 -0
  76. package/src/payment-institution/transactions/create-pi-transaction.js +484 -0
  77. package/src/payment-institution/transactions/finalize-transaction.js +340 -0
  78. package/src/payment-institution/transactions/get-transaction-history.js +269 -0
  79. package/src/payment-institution/transactions/get-transaction-status.js +234 -0
  80. package/src/payment-institution/transactions/process-pi-transaction.js +421 -0
  81. package/src/payment-institution/transactions/simulate-pi-callback.js +326 -0
  82. package/src/payment-institution/transactions/soundbite-transaction.js +269 -0
  83. package/src/proxy-server.js +205 -0
  84. package/src/shared/data/data-api.js +372 -0
  85. package/src/shared/deep-links/api.js +214 -0
  86. package/src/shared/index.js +44 -0
  87. package/src/shared/products/products-api.js +872 -0
  88. package/src/tools/advanced-code-generator.js +2247 -0
  89. package/src/utils/code-examples/common/auth-examples.js +1482 -0
  90. package/src/utils/code-examples/common/helpers.js +416 -0
  91. package/src/utils/code-examples/common/utils-examples.js +591 -0
  92. package/src/utils/code-examples/frameworks/examples.js +859 -0
  93. package/src/utils/code-examples/index.js +441 -0
  94. package/src/utils/code-examples/isv/oauth2.js +600 -0
  95. package/src/utils/code-examples/isv/products.js +666 -0
  96. package/src/utils/code-examples/isv/transactions.js +813 -0
  97. package/src/utils/code-examples/merchant/products.js +497 -0
  98. package/src/utils/code-examples/merchant/transactions.js +623 -0
  99. package/src/utils/code-examples/payment-institution/transactions.js +388 -0
  100. package/src/utils/code-examples/shared/data.js +607 -0
  101. package/src/utils/code-examples/shared/deep-links.js +662 -0
  102. package/src/utils/code-examples/shared/soundbites.js +808 -0
  103. package/src/utils/code-examples.js +646 -0
  104. package/src/utils/format-request.js +363 -0
  105. package/src/utils/json-formatter.js +249 -0
  106. package/src/utils/server-info.js +132 -0
@@ -0,0 +1,351 @@
1
+ /**
2
+ * Merchant Data Tools - Complete Data API Implementation
3
+ * Production-only tools for data retrieval, reporting, and export functionality
4
+ */
5
+
6
+ import {
7
+ getReportStatus,
8
+ getExportStatus,
9
+ downloadExport,
10
+ cancelReport,
11
+ cancelExport,
12
+ EXPORT_FORMATS
13
+ } from '../../shared/data/data-api.js';
14
+ import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
15
+
16
+ // Import individual tools
17
+ import { generateReportTool } from './generate-report.js';
18
+ import { getReportStatusTool } from './get-report-status.js';
19
+ import { exportReportTool } from './export-report.js';
20
+
21
+ /**
22
+ * Get export status tool for merchants
23
+ */
24
+ export const getExportStatusTool = {
25
+ name: "payware_data_get_export_status",
26
+ description: "Get the status of a report export request. Use this to monitor export progress.",
27
+ inputSchema: {
28
+ type: "object",
29
+ properties: {
30
+ exportId: {
31
+ type: "string",
32
+ description: "The export ID returned from the export request (UUID format)"
33
+ },
34
+ partnerId: {
35
+ type: "string",
36
+ description: "Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default.",
37
+ default: getPartnerIdSafe()
38
+ },
39
+ privateKey: {
40
+ type: "string",
41
+ description: "RSA private key for authentication. Uses environment-specific private key as default.",
42
+ default: getPrivateKeySafe()
43
+ }
44
+ },
45
+ required: ["exportId"]
46
+ },
47
+
48
+ async handler(args) {
49
+ const {
50
+ exportId,
51
+ partnerId = getPartnerIdSafe(),
52
+ privateKey = getPrivateKeySafe()
53
+ } = args;
54
+
55
+ if (!partnerId || !privateKey) {
56
+ throw new Error("Partner ID and private key are required. Set PAYWARE_PARTNER_ID and environment-specific private key variables or provide them as parameters.");
57
+ }
58
+
59
+ try {
60
+ const result = await getExportStatus({
61
+ exportId,
62
+ partnerType: 'merchant',
63
+ partnerId,
64
+ privateKey
65
+ });
66
+
67
+ const data = result.data;
68
+ const exportResource = data.outputResource;
69
+
70
+ // The export status API returns export information in outputResource
71
+ let downloadInfo = '';
72
+ if (exportResource?.status === 'READY') {
73
+ downloadInfo = `
74
+ **🎉 Export is Ready for Download!**
75
+ Use the "Download Export" tool with export ID: \`${exportId}\`
76
+ Format: ${exportResource.contentType?.toUpperCase()}
77
+ Pages: ${exportResource.pages || 'N/A'}`;
78
+ }
79
+
80
+ return {
81
+ content: [{
82
+ type: "text",
83
+ text: `📊 **Export Status Check**
84
+
85
+ **Export Information:**
86
+ - Export ID: ${exportId}
87
+ - Status: ${exportResource?.status || 'Unknown'}
88
+ - Format: ${exportResource?.contentType?.toUpperCase() || 'Unknown'}
89
+ - Pages: ${exportResource?.pages || 'N/A'}
90
+ - Completed: ${exportResource?.outputFinal ? 'Yes' : 'No'}
91
+ - Exported: ${exportResource?.exportedAt || 'N/A'}
92
+
93
+ **Related Report:**
94
+ - Request ID: ${data.requestId}
95
+ - Report Type: ${data.reportUnitId}
96
+ - Date Range: ${data.dateFrom || 'Default'} to ${data.dateTo || 'Default'}
97
+ ${downloadInfo}
98
+
99
+ **Status Meanings:**
100
+ - 🟡 **QUEUED**: Export is being processed
101
+ - ✅ **READY**: Export completed and ready for download
102
+ - ❌ **CANCELLED**: Export was cancelled
103
+ - 💥 **FAILED**: Error occurred during export`
104
+ }]
105
+ };
106
+ } catch (error) {
107
+ throw new Error(`Failed to get export status: ${error.message}`);
108
+ }
109
+ }
110
+ };
111
+
112
+ /**
113
+ * Download export tool for merchants
114
+ */
115
+ export const downloadExportTool = {
116
+ name: "payware_data_download_export",
117
+ description: "Download a READY export file. The export must be in READY status. Returns binary data for the file.",
118
+ inputSchema: {
119
+ type: "object",
120
+ properties: {
121
+ exportId: {
122
+ type: "string",
123
+ description: "The export ID from the export request (UUID format)"
124
+ },
125
+ partnerId: {
126
+ type: "string",
127
+ description: "Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default.",
128
+ default: getPartnerIdSafe()
129
+ },
130
+ privateKey: {
131
+ type: "string",
132
+ description: "RSA private key for authentication. Uses environment-specific private key as default.",
133
+ default: getPrivateKeySafe()
134
+ }
135
+ },
136
+ required: ["exportId"]
137
+ },
138
+
139
+ async handler(args) {
140
+ const {
141
+ exportId,
142
+ partnerId = getPartnerIdSafe(),
143
+ privateKey = getPrivateKeySafe()
144
+ } = args;
145
+
146
+ if (!partnerId || !privateKey) {
147
+ throw new Error("Partner ID and private key are required. Set PAYWARE_PARTNER_ID and environment-specific private key variables or provide them as parameters.");
148
+ }
149
+
150
+ try {
151
+ const result = await downloadExport({
152
+ exportId,
153
+ partnerType: 'merchant',
154
+ partnerId,
155
+ privateKey
156
+ });
157
+
158
+ // Convert binary data to base64 for display
159
+ const base64Data = Buffer.from(result.data).toString('base64');
160
+ const sizeInKB = Math.round(result.data.length / 1024);
161
+
162
+ return {
163
+ content: [{
164
+ type: "text",
165
+ text: `📊 **Export Download Completed**
166
+
167
+ **File Information:**
168
+ - Export ID: ${exportId}
169
+ - Content Type: ${result.contentType}
170
+ - File Size: ${sizeInKB} KB (${result.contentLength} bytes)
171
+ - Status: Successfully downloaded
172
+
173
+ **File Data (Base64 encoded):**
174
+ \`\`\`
175
+ ${base64Data.substring(0, 200)}${base64Data.length > 200 ? '...[truncated]' : ''}
176
+ \`\`\`
177
+
178
+ **Usage Notes:**
179
+ - The file data is provided in Base64 encoding above
180
+ - For CSV/JSON files, you can decode and view the content
181
+ - For binary files (PDF, Excel), save the Base64 data and decode to get the original file
182
+ - Full file size: ${sizeInKB} KB
183
+
184
+ **Next Steps:**
185
+ 1. Copy the Base64 data if you need to save the file
186
+ 2. For text formats (CSV, JSON), decode Base64 to view content
187
+ 3. For binary formats (PDF, Excel), decode and save as appropriate file type
188
+
189
+ **Successfully downloaded ${result.contentType} file (${sizeInKB} KB)**`
190
+ }]
191
+ };
192
+ } catch (error) {
193
+ throw new Error(`Failed to download export: ${error.message}`);
194
+ }
195
+ }
196
+ };
197
+
198
+ /**
199
+ * Cancel report tool for merchants
200
+ */
201
+ export const cancelReportTool = {
202
+ name: "payware_data_cancel_report",
203
+ description: "Cancel a running report generation. Only reports in QUEUED status can be cancelled.",
204
+ inputSchema: {
205
+ type: "object",
206
+ properties: {
207
+ requestId: {
208
+ type: "string",
209
+ description: "The request ID of the report to cancel (UUID format)"
210
+ },
211
+ partnerId: {
212
+ type: "string",
213
+ description: "Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default.",
214
+ default: getPartnerIdSafe()
215
+ },
216
+ privateKey: {
217
+ type: "string",
218
+ description: "RSA private key for authentication. Uses environment-specific private key as default.",
219
+ default: getPrivateKeySafe()
220
+ }
221
+ },
222
+ required: ["requestId"]
223
+ },
224
+
225
+ async handler(args) {
226
+ const {
227
+ requestId,
228
+ partnerId = getPartnerIdSafe(),
229
+ privateKey = getPrivateKeySafe()
230
+ } = args;
231
+
232
+ if (!partnerId || !privateKey) {
233
+ throw new Error("Partner ID and private key are required. Set PAYWARE_PARTNER_ID and environment-specific private key variables or provide them as parameters.");
234
+ }
235
+
236
+ try {
237
+ const result = await cancelReport({
238
+ requestId,
239
+ partnerType: 'merchant',
240
+ partnerId,
241
+ privateKey
242
+ });
243
+
244
+ return {
245
+ content: [{
246
+ type: "text",
247
+ text: `📊 **Report Cancellation**
248
+
249
+ **Cancellation Result:**
250
+ - Request ID: ${requestId}
251
+ - Status: Successfully cancelled
252
+ - Response: ${typeof result.data === 'string' ? result.data : 'CANCELLED'}
253
+
254
+ **What This Means:**
255
+ - The report generation has been stopped
256
+ - No further processing will occur for this request
257
+ - You can generate a new report with the same or different parameters if needed
258
+
259
+ **Note:**
260
+ Only reports in QUEUED status can be cancelled. Reports that are already READY, FAILED, or previously CANCELLED cannot be cancelled.`
261
+ }]
262
+ };
263
+ } catch (error) {
264
+ throw new Error(`Failed to cancel report: ${error.message}`);
265
+ }
266
+ }
267
+ };
268
+
269
+ /**
270
+ * Cancel export tool for merchants
271
+ */
272
+ export const cancelExportTool = {
273
+ name: "payware_data_cancel_export",
274
+ description: "Cancel a running export process. Only exports in QUEUED status can be cancelled.",
275
+ inputSchema: {
276
+ type: "object",
277
+ properties: {
278
+ exportId: {
279
+ type: "string",
280
+ description: "The export ID of the export to cancel (UUID format)"
281
+ },
282
+ partnerId: {
283
+ type: "string",
284
+ description: "Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default.",
285
+ default: getPartnerIdSafe()
286
+ },
287
+ privateKey: {
288
+ type: "string",
289
+ description: "RSA private key for authentication. Uses environment-specific private key as default.",
290
+ default: getPrivateKeySafe()
291
+ }
292
+ },
293
+ required: ["exportId"]
294
+ },
295
+
296
+ async handler(args) {
297
+ const {
298
+ exportId,
299
+ partnerId = getPartnerIdSafe(),
300
+ privateKey = getPrivateKeySafe()
301
+ } = args;
302
+
303
+ if (!partnerId || !privateKey) {
304
+ throw new Error("Partner ID and private key are required. Set PAYWARE_PARTNER_ID and environment-specific private key variables or provide them as parameters.");
305
+ }
306
+
307
+ try {
308
+ const result = await cancelExport({
309
+ exportId,
310
+ partnerType: 'merchant',
311
+ partnerId,
312
+ privateKey
313
+ });
314
+
315
+ return {
316
+ content: [{
317
+ type: "text",
318
+ text: `📊 **Export Cancellation**
319
+
320
+ **Cancellation Result:**
321
+ - Export ID: ${exportId}
322
+ - Status: Successfully cancelled
323
+ - Response: ${typeof result.data === 'string' ? result.data : 'CANCELLED'}
324
+
325
+ **What This Means:**
326
+ - The export process has been stopped
327
+ - No file will be generated for this export request
328
+ - You can start a new export with the same report request if the report is still READY
329
+
330
+ **Note:**
331
+ Only exports in QUEUED status can be cancelled. Exports that are already READY, FAILED, or previously CANCELLED cannot be cancelled.`
332
+ }]
333
+ };
334
+ } catch (error) {
335
+ throw new Error(`Failed to cancel export: ${error.message}`);
336
+ }
337
+ }
338
+ };
339
+
340
+ /**
341
+ * All merchant data tools
342
+ */
343
+ export const merchantDataTools = [
344
+ generateReportTool,
345
+ getReportStatusTool,
346
+ exportReportTool,
347
+ getExportStatusTool,
348
+ downloadExportTool,
349
+ cancelReportTool,
350
+ cancelExportTool
351
+ ];
@@ -0,0 +1,121 @@
1
+ import { deleteProductDeepLink } from '../../shared/deep-links/api.js';
2
+ import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
3
+
4
+ /**
5
+ * Delete deep link for a merchant product
6
+ */
7
+ export const deleteProductLinkTool = {
8
+ name: "payware_deep_links_delete_product_link",
9
+ description: `Delete an active deep link for a product. Once deleted, the deep link URL will no longer redirect to the payware mobile app.
10
+
11
+ **Use Cases:**
12
+ - Remove expired product links
13
+ - Clean up after product removal
14
+ - Security cleanup for discontinued products
15
+
16
+ **Important Notes:**
17
+ - Deep links are only supported in production environment
18
+ - Once deleted, the link cannot be recovered - you'll need to create a new one
19
+ - This operation is irreversible`,
20
+
21
+ inputSchema: {
22
+ type: "object",
23
+ properties: {
24
+ productId: {
25
+ type: "string",
26
+ description: "The product identifier (e.g., 'pr7e4rCToG')",
27
+ pattern: "^[a-zA-Z0-9]+$"
28
+ },
29
+ partnerId: {
30
+ type: "string",
31
+ description: "Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default.",
32
+ default: getPartnerIdSafe()
33
+ },
34
+ privateKey: {
35
+ type: "string",
36
+ description: "RSA private key for JWT token creation. Uses environment-specific private key as default.",
37
+ default: getPrivateKeySafe()
38
+ }
39
+ },
40
+ required: ["productId"]
41
+ },
42
+
43
+ async handler(args) {
44
+ const {
45
+ productId,
46
+ partnerId = getPartnerIdSafe(),
47
+ privateKey = getPrivateKeySafe()
48
+ } = args;
49
+
50
+ if (!productId) {
51
+ throw new Error("productId is required");
52
+ }
53
+
54
+ if (!partnerId) {
55
+ throw new Error("Partner ID is required. Provide via 'partnerId' parameter or set PAYWARE_PARTNER_ID environment variable.");
56
+ }
57
+
58
+ if (!privateKey) {
59
+ throw new Error("Private key is required. Provide via 'privateKey' parameter or set PAYWARE_PRIVATE_KEY environment variable.");
60
+ }
61
+
62
+ try {
63
+ const result = await deleteProductDeepLink({
64
+ productId,
65
+ partnerType: 'merchant',
66
+ partnerId,
67
+ privateKey
68
+ });
69
+
70
+ return {
71
+ content: [{
72
+ type: "text",
73
+ text: `✅ **Product Deep Link Deleted**
74
+
75
+ **Deletion Details:**
76
+ - Product ID: ${productId}
77
+ - Status: Successfully deleted
78
+ - Link URL: https://url.payware.eu/${productId} (now inactive)
79
+
80
+ **API Call Details:**
81
+ - Endpoint: DELETE ${result.requestInfo.url}
82
+ - Status: ${result.requestInfo.statusCode}
83
+ - Method: ${result.requestInfo.method}
84
+
85
+ **Result:**
86
+ - The deep link is no longer active
87
+ - Mobile redirects will no longer work
88
+ - URL will return an error if accessed
89
+
90
+ **Important Notes:**
91
+ ⚠️ This operation is irreversible
92
+ ⚠️ Create a new link if needed using \`payware_deep_links_get_product_link\`
93
+ ⚠️ Any existing shared links will stop working immediately`
94
+ }]
95
+ };
96
+ } catch (error) {
97
+ return {
98
+ content: [{
99
+ type: "text",
100
+ text: `❌ **Failed to Delete Product Deep Link**
101
+
102
+ **Error Details:**
103
+ - Product ID: ${productId}
104
+ - Message: ${error.message}
105
+
106
+ **Common Issues:**
107
+ 1. **Link not found**: Deep link may already be deleted or never existed
108
+ 2. **Authentication failed**: Verify partner ID and private key
109
+ 3. **Sandbox environment**: Deep links are production-only
110
+ 4. **Invalid product ID**: Ensure product ID format is correct
111
+
112
+ **Troubleshooting:**
113
+ 1. Check if deep link exists using \`payware_deep_links_get_product_link\`
114
+ 2. Verify running in production environment
115
+ 3. Ensure JWT authentication is working
116
+ 4. Confirm product ID is correct`
117
+ }]
118
+ };
119
+ }
120
+ }
121
+ };
@@ -0,0 +1,121 @@
1
+ import { deleteTransactionDeepLink } from '../../shared/deep-links/api.js';
2
+ import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
3
+
4
+ /**
5
+ * Delete deep link for a merchant transaction
6
+ */
7
+ export const deleteTransactionLinkTool = {
8
+ name: "payware_deep_links_delete_transaction_link",
9
+ description: `Delete an active deep link for a transaction. Once deleted, the deep link URL will no longer redirect to the payware mobile app.
10
+
11
+ **Use Cases:**
12
+ - Remove expired transaction links
13
+ - Clean up after transaction completion
14
+ - Security cleanup for sensitive transactions
15
+
16
+ **Important Notes:**
17
+ - Deep links are only supported in production environment
18
+ - Once deleted, the link cannot be recovered - you'll need to create a new one
19
+ - This operation is irreversible`,
20
+
21
+ inputSchema: {
22
+ type: "object",
23
+ properties: {
24
+ transactionId: {
25
+ type: "string",
26
+ description: "The transaction identifier (e.g., 'pw7e4rCToG')",
27
+ pattern: "^[a-zA-Z0-9]+$"
28
+ },
29
+ partnerId: {
30
+ type: "string",
31
+ description: "Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default.",
32
+ default: getPartnerIdSafe()
33
+ },
34
+ privateKey: {
35
+ type: "string",
36
+ description: "RSA private key for JWT token creation. Uses environment-specific private key as default.",
37
+ default: getPrivateKeySafe()
38
+ }
39
+ },
40
+ required: ["transactionId"]
41
+ },
42
+
43
+ async handler(args) {
44
+ const {
45
+ transactionId,
46
+ partnerId = getPartnerIdSafe(),
47
+ privateKey = getPrivateKeySafe()
48
+ } = args;
49
+
50
+ if (!transactionId) {
51
+ throw new Error("transactionId is required");
52
+ }
53
+
54
+ if (!partnerId) {
55
+ throw new Error("Partner ID is required. Provide via 'partnerId' parameter or set PAYWARE_PARTNER_ID environment variable.");
56
+ }
57
+
58
+ if (!privateKey) {
59
+ throw new Error("Private key is required. Provide via 'privateKey' parameter or set PAYWARE_PRIVATE_KEY environment variable.");
60
+ }
61
+
62
+ try {
63
+ const result = await deleteTransactionDeepLink({
64
+ transactionId,
65
+ partnerType: 'merchant',
66
+ partnerId,
67
+ privateKey
68
+ });
69
+
70
+ return {
71
+ content: [{
72
+ type: "text",
73
+ text: `✅ **Transaction Deep Link Deleted**
74
+
75
+ **Deletion Details:**
76
+ - Transaction ID: ${transactionId}
77
+ - Status: Successfully deleted
78
+ - Link URL: https://url.payware.eu/${transactionId} (now inactive)
79
+
80
+ **API Call Details:**
81
+ - Endpoint: DELETE ${result.requestInfo.url}
82
+ - Status: ${result.requestInfo.statusCode}
83
+ - Method: ${result.requestInfo.method}
84
+
85
+ **Result:**
86
+ - The deep link is no longer active
87
+ - Mobile redirects will no longer work
88
+ - URL will return an error if accessed
89
+
90
+ **Important Notes:**
91
+ ⚠️ This operation is irreversible
92
+ ⚠️ Create a new link if needed using \`payware_deep_links_get_transaction_link\`
93
+ ⚠️ Any existing shared links will stop working immediately`
94
+ }]
95
+ };
96
+ } catch (error) {
97
+ return {
98
+ content: [{
99
+ type: "text",
100
+ text: `❌ **Failed to Delete Transaction Deep Link**
101
+
102
+ **Error Details:**
103
+ - Transaction ID: ${transactionId}
104
+ - Message: ${error.message}
105
+
106
+ **Common Issues:**
107
+ 1. **Link not found**: Deep link may already be deleted or never existed
108
+ 2. **Authentication failed**: Verify partner ID and private key
109
+ 3. **Sandbox environment**: Deep links are production-only
110
+ 4. **Invalid transaction ID**: Ensure transaction ID format is correct
111
+
112
+ **Troubleshooting:**
113
+ 1. Check if deep link exists using \`payware_deep_links_get_transaction_link\`
114
+ 2. Verify running in production environment
115
+ 3. Ensure JWT authentication is working
116
+ 4. Confirm transaction ID is correct`
117
+ }]
118
+ };
119
+ }
120
+ }
121
+ };