@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,646 @@
1
+ import {
2
+ createPriceSchedule,
3
+ getProductSchedules,
4
+ getSchedule,
5
+ updatePriceSchedule,
6
+ deletePriceSchedule
7
+ } from '../../shared/products/products-api.js';
8
+ import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
9
+ import { PRICE_CORRECTION_TYPES, CORRECTION_TYPES } from '../../shared/products/products-api.js';
10
+
11
+ /**
12
+ * Create price schedule tool implementation for merchants
13
+ */
14
+ export const createScheduleTool = {
15
+ name: "payware_products_create_schedule",
16
+ description: "Create a price schedule for a product to manage time-based pricing",
17
+
18
+ inputSchema: {
19
+ type: "object",
20
+ properties: {
21
+ productId: {
22
+ type: "string",
23
+ description: "Product identifier (starts with 'pr')",
24
+ pattern: "^pr[a-zA-Z0-9]+$"
25
+ },
26
+ description: {
27
+ type: "string",
28
+ description: "Schedule description",
29
+ maxLength: 300
30
+ },
31
+ priceCorrection: {
32
+ type: "string",
33
+ enum: Object.values(PRICE_CORRECTION_TYPES),
34
+ description: "Price correction direction",
35
+ default: PRICE_CORRECTION_TYPES.DISCOUNT
36
+ },
37
+ correctionType: {
38
+ type: "string",
39
+ enum: Object.values(CORRECTION_TYPES),
40
+ description: "Price correction method",
41
+ default: CORRECTION_TYPES.PERCENTAGE
42
+ },
43
+ correctionValue: {
44
+ type: "string",
45
+ description: "Correction value (positive number with max 2 decimals)",
46
+ default: "0.00"
47
+ },
48
+ dateFrom: {
49
+ type: "string",
50
+ pattern: "^\\d{4}-\\d{2}-\\d{2}$",
51
+ description: "Schedule start date (YYYY-MM-DD format)"
52
+ },
53
+ dateTo: {
54
+ type: "string",
55
+ pattern: "^\\d{4}-\\d{2}-\\d{2}$",
56
+ description: "Schedule end date (YYYY-MM-DD format)"
57
+ },
58
+ partnerId: {
59
+ type: "string",
60
+ description: "Merchant partner ID (uses PAYWARE_PARTNER_ID env var as default)",
61
+ default: getPartnerIdSafe()
62
+ },
63
+ privateKey: {
64
+ type: "string",
65
+ description: "RSA private key for authentication (uses environment-specific private key as default)",
66
+ default: getPrivateKeySafe()
67
+ },
68
+ useSandbox: {
69
+ type: "boolean",
70
+ description: "Use sandbox environment",
71
+ default: true
72
+ }
73
+ },
74
+ required: ["productId"]
75
+ },
76
+
77
+ async handler(args) {
78
+ const {
79
+ productId,
80
+ description,
81
+ priceCorrection = PRICE_CORRECTION_TYPES.DISCOUNT,
82
+ correctionType = CORRECTION_TYPES.PERCENTAGE,
83
+ correctionValue = "0.00",
84
+ dateFrom,
85
+ dateTo,
86
+ partnerId = getPartnerIdSafe(),
87
+ privateKey = getPrivateKeySafe(),
88
+ useSandbox = true
89
+ } = args;
90
+
91
+ if (!productId) {
92
+ throw new Error("Product ID is required");
93
+ }
94
+
95
+ if (!partnerId || !privateKey) {
96
+ throw new Error("Partner ID and private key are required");
97
+ }
98
+
99
+ try {
100
+ const result = await createPriceSchedule({
101
+ productId,
102
+ description,
103
+ priceCorrection,
104
+ correctionType,
105
+ correctionValue,
106
+ dateFrom,
107
+ dateTo,
108
+ partnerType: 'merchant',
109
+ partnerId,
110
+ privateKey,
111
+ useSandbox
112
+ });
113
+
114
+ const schedule = result.data;
115
+
116
+ return {
117
+ content: [{
118
+ type: "text",
119
+ text: `📅 **Price Schedule Created Successfully**
120
+
121
+ **Schedule Details:**
122
+ - ID: ${schedule.id}
123
+ - Product ID: ${schedule.productId}
124
+ - Description: ${schedule.description || 'No description'}
125
+ - Type: ${schedule.priceCorrection} (${schedule.correctionType})
126
+ - Value: ${schedule.correctionValue}${schedule.correctionType === 'PERCENTAGE' ? '%' : ''}
127
+
128
+ **Pricing:**
129
+ - Regular Price: ${schedule.regularPrice}
130
+ - Sale Price: ${schedule.salePrice}
131
+
132
+ **Active Period:**
133
+ - From: ${schedule.dateFrom}
134
+ - To: ${schedule.dateTo}
135
+
136
+ **API Response:**
137
+ \`\`\`json
138
+ ${JSON.stringify(schedule, null, 2)}
139
+ \`\`\`
140
+
141
+ **API Call Details:**
142
+ - Endpoint: ${result.requestInfo.method} ${result.requestInfo.url}
143
+ - Status: ${result.requestInfo.statusCode}
144
+
145
+ **Next Steps:**
146
+ - Use \`payware_products_get_schedules\` to view all schedules
147
+ - Use \`payware_products_update_schedule\` to modify this schedule
148
+ - Monitor product sale price changes during active period`
149
+ }]
150
+ };
151
+ } catch (error) {
152
+ return {
153
+ content: [{
154
+ type: "text",
155
+ text: `❌ **Schedule Creation Failed**
156
+
157
+ **Error Details:**
158
+ - Message: ${error.message}
159
+ - Product ID: ${productId}
160
+
161
+ **Troubleshooting:**
162
+ 1. Verify the product ID exists and belongs to your account
163
+ 2. Check date format (YYYY-MM-DD) and ensure dateTo > dateFrom
164
+ 3. Verify correction value is a positive number
165
+ 4. Ensure JWT token is valid and not expired`
166
+ }]
167
+ };
168
+ }
169
+ }
170
+ };
171
+
172
+ /**
173
+ * Get product schedules tool implementation for merchants
174
+ */
175
+ export const getSchedulesTool = {
176
+ name: "payware_products_get_schedules",
177
+ description: "Get all price schedules for a product",
178
+
179
+ inputSchema: {
180
+ type: "object",
181
+ properties: {
182
+ productId: {
183
+ type: "string",
184
+ description: "Product identifier (starts with 'pr')",
185
+ pattern: "^pr[a-zA-Z0-9]+$"
186
+ },
187
+ partnerId: {
188
+ type: "string",
189
+ description: "Merchant partner ID (uses PAYWARE_PARTNER_ID env var as default)",
190
+ default: getPartnerIdSafe()
191
+ },
192
+ privateKey: {
193
+ type: "string",
194
+ description: "RSA private key for authentication (uses environment-specific private key as default)",
195
+ default: getPrivateKeySafe()
196
+ },
197
+ useSandbox: {
198
+ type: "boolean",
199
+ description: "Use sandbox environment",
200
+ default: true
201
+ }
202
+ },
203
+ required: ["productId"]
204
+ },
205
+
206
+ async handler(args) {
207
+ const {
208
+ productId,
209
+ partnerId = getPartnerIdSafe(),
210
+ privateKey = getPrivateKeySafe(),
211
+ useSandbox = true
212
+ } = args;
213
+
214
+ if (!productId) {
215
+ throw new Error("Product ID is required");
216
+ }
217
+
218
+ if (!partnerId || !privateKey) {
219
+ throw new Error("Partner ID and private key are required");
220
+ }
221
+
222
+ try {
223
+ const result = await getProductSchedules({
224
+ productId,
225
+ partnerType: 'merchant',
226
+ partnerId,
227
+ privateKey,
228
+ useSandbox
229
+ });
230
+
231
+ const schedules = result.data;
232
+ const scheduleCount = Array.isArray(schedules) ? schedules.length : 0;
233
+
234
+ let schedulesList = '';
235
+ if (Array.isArray(schedules) && schedules.length > 0) {
236
+ schedulesList = schedules.map(schedule =>
237
+ `**Schedule ${schedule.id}:**
238
+ - Description: ${schedule.description || 'No description'}
239
+ - Type: ${schedule.priceCorrection} ${schedule.correctionValue}${schedule.correctionType === 'PERCENTAGE' ? '%' : ''}
240
+ - Period: ${schedule.dateFrom} to ${schedule.dateTo}
241
+ - Sale Price: ${schedule.salePrice}`
242
+ ).join('\n\n');
243
+ } else {
244
+ schedulesList = 'No price schedules found for this product.';
245
+ }
246
+
247
+ return {
248
+ content: [{
249
+ type: "text",
250
+ text: `📅 **Product Price Schedules**
251
+
252
+ **Product ID:** ${productId}
253
+ **Total Schedules:** ${scheduleCount}
254
+
255
+ **Schedules:**
256
+ ${schedulesList}
257
+
258
+ **API Call Details:**
259
+ - Endpoint: ${result.requestInfo.method} ${result.requestInfo.url}
260
+ - Status: ${result.requestInfo.statusCode}
261
+
262
+ **Available Actions:**
263
+ - \`payware_products_create_schedule\` - Create new schedule
264
+ - \`payware_products_get_schedule\` - Get specific schedule details
265
+ - \`payware_products_update_schedule\` - Update existing schedule
266
+ - \`payware_products_delete_schedule\` - Delete schedule`
267
+ }]
268
+ };
269
+ } catch (error) {
270
+ return {
271
+ content: [{
272
+ type: "text",
273
+ text: `❌ **Failed to Get Schedules**
274
+
275
+ **Error Details:**
276
+ - Message: ${error.message}
277
+ - Product ID: ${productId}`
278
+ }]
279
+ };
280
+ }
281
+ }
282
+ };
283
+
284
+ /**
285
+ * Get specific schedule tool implementation for merchants
286
+ */
287
+ export const getScheduleTool = {
288
+ name: "payware_products_get_schedule",
289
+ description: "Get detailed information about a specific price schedule",
290
+
291
+ inputSchema: {
292
+ type: "object",
293
+ properties: {
294
+ productId: {
295
+ type: "string",
296
+ description: "Product identifier (starts with 'pr')",
297
+ pattern: "^pr[a-zA-Z0-9]+$"
298
+ },
299
+ scheduleId: {
300
+ type: "number",
301
+ description: "Schedule identifier"
302
+ },
303
+ partnerId: {
304
+ type: "string",
305
+ description: "Merchant partner ID (uses PAYWARE_PARTNER_ID env var as default)",
306
+ default: getPartnerIdSafe()
307
+ },
308
+ privateKey: {
309
+ type: "string",
310
+ description: "RSA private key for authentication (uses environment-specific private key as default)",
311
+ default: getPrivateKeySafe()
312
+ },
313
+ useSandbox: {
314
+ type: "boolean",
315
+ description: "Use sandbox environment",
316
+ default: true
317
+ }
318
+ },
319
+ required: ["productId", "scheduleId"]
320
+ },
321
+
322
+ async handler(args) {
323
+ const {
324
+ productId,
325
+ scheduleId,
326
+ partnerId = getPartnerIdSafe(),
327
+ privateKey = getPrivateKeySafe(),
328
+ useSandbox = true
329
+ } = args;
330
+
331
+ if (!productId || !scheduleId) {
332
+ throw new Error("Product ID and schedule ID are required");
333
+ }
334
+
335
+ if (!partnerId || !privateKey) {
336
+ throw new Error("Partner ID and private key are required");
337
+ }
338
+
339
+ try {
340
+ const result = await getSchedule({
341
+ productId,
342
+ scheduleId,
343
+ partnerType: 'merchant',
344
+ partnerId,
345
+ privateKey,
346
+ useSandbox
347
+ });
348
+
349
+ const schedule = result.data;
350
+
351
+ return {
352
+ content: [{
353
+ type: "text",
354
+ text: `📅 **Schedule Details**
355
+
356
+ **Schedule Information:**
357
+ - ID: ${schedule.id}
358
+ - Product ID: ${schedule.productId}
359
+ - Description: ${schedule.description || 'No description'}
360
+
361
+ **Price Configuration:**
362
+ - Type: ${schedule.priceCorrection} (${schedule.correctionType})
363
+ - Value: ${schedule.correctionValue}${schedule.correctionType === 'PERCENTAGE' ? '%' : ''}
364
+ - Regular Price: ${schedule.regularPrice}
365
+ - Sale Price: ${schedule.salePrice}
366
+
367
+ **Active Period:**
368
+ - From: ${schedule.dateFrom}
369
+ - To: ${schedule.dateTo}
370
+
371
+ **API Response:**
372
+ \`\`\`json
373
+ ${JSON.stringify(schedule, null, 2)}
374
+ \`\`\`
375
+
376
+ **Available Actions:**
377
+ - \`payware_products_update_schedule\` - Update this schedule
378
+ - \`payware_products_delete_schedule\` - Delete this schedule`
379
+ }]
380
+ };
381
+ } catch (error) {
382
+ return {
383
+ content: [{
384
+ type: "text",
385
+ text: `❌ **Failed to Get Schedule**
386
+
387
+ **Error Details:**
388
+ - Message: ${error.message}
389
+ - Product ID: ${productId}
390
+ - Schedule ID: ${scheduleId}`
391
+ }]
392
+ };
393
+ }
394
+ }
395
+ };
396
+
397
+ /**
398
+ * Update schedule tool implementation for merchants
399
+ */
400
+ export const updateScheduleTool = {
401
+ name: "payware_products_update_schedule",
402
+ description: "Update an existing price schedule. Only provide fields you want to change.",
403
+
404
+ inputSchema: {
405
+ type: "object",
406
+ properties: {
407
+ productId: {
408
+ type: "string",
409
+ description: "Product identifier (starts with 'pr')",
410
+ pattern: "^pr[a-zA-Z0-9]+$"
411
+ },
412
+ scheduleId: {
413
+ type: "number",
414
+ description: "Schedule identifier"
415
+ },
416
+ description: {
417
+ type: "string",
418
+ description: "Schedule description",
419
+ maxLength: 300
420
+ },
421
+ priceCorrection: {
422
+ type: "string",
423
+ enum: Object.values(PRICE_CORRECTION_TYPES),
424
+ description: "Price correction direction"
425
+ },
426
+ correctionType: {
427
+ type: "string",
428
+ enum: Object.values(CORRECTION_TYPES),
429
+ description: "Price correction method"
430
+ },
431
+ correctionValue: {
432
+ type: "string",
433
+ description: "Correction value (positive number with max 2 decimals)"
434
+ },
435
+ dateFrom: {
436
+ type: "string",
437
+ pattern: "^\\d{4}-\\d{2}-\\d{2}$",
438
+ description: "Schedule start date (YYYY-MM-DD format)"
439
+ },
440
+ dateTo: {
441
+ type: "string",
442
+ pattern: "^\\d{4}-\\d{2}-\\d{2}$",
443
+ description: "Schedule end date (YYYY-MM-DD format)"
444
+ },
445
+ partnerId: {
446
+ type: "string",
447
+ description: "Merchant partner ID (uses PAYWARE_PARTNER_ID env var as default)",
448
+ default: getPartnerIdSafe()
449
+ },
450
+ privateKey: {
451
+ type: "string",
452
+ description: "RSA private key for authentication (uses environment-specific private key as default)",
453
+ default: getPrivateKeySafe()
454
+ },
455
+ useSandbox: {
456
+ type: "boolean",
457
+ description: "Use sandbox environment",
458
+ default: true
459
+ }
460
+ },
461
+ required: ["productId", "scheduleId"]
462
+ },
463
+
464
+ async handler(args) {
465
+ const {
466
+ productId,
467
+ scheduleId,
468
+ description,
469
+ priceCorrection,
470
+ correctionType,
471
+ correctionValue,
472
+ dateFrom,
473
+ dateTo,
474
+ partnerId = getPartnerIdSafe(),
475
+ privateKey = getPrivateKeySafe(),
476
+ useSandbox = true
477
+ } = args;
478
+
479
+ if (!productId || !scheduleId) {
480
+ throw new Error("Product ID and schedule ID are required");
481
+ }
482
+
483
+ if (!partnerId || !privateKey) {
484
+ throw new Error("Partner ID and private key are required");
485
+ }
486
+
487
+ try {
488
+ const result = await updatePriceSchedule({
489
+ productId,
490
+ scheduleId,
491
+ description,
492
+ priceCorrection,
493
+ correctionType,
494
+ correctionValue,
495
+ dateFrom,
496
+ dateTo,
497
+ partnerType: 'merchant',
498
+ partnerId,
499
+ privateKey,
500
+ useSandbox
501
+ });
502
+
503
+ const schedule = result.data;
504
+
505
+ return {
506
+ content: [{
507
+ type: "text",
508
+ text: `✅ **Schedule Updated Successfully**
509
+
510
+ **Updated Schedule:**
511
+ - ID: ${schedule.id}
512
+ - Product ID: ${schedule.productId}
513
+ - Description: ${schedule.description || 'No description'}
514
+ - Type: ${schedule.priceCorrection} (${schedule.correctionType})
515
+ - Value: ${schedule.correctionValue}${schedule.correctionType === 'PERCENTAGE' ? '%' : ''}
516
+ - Regular Price: ${schedule.regularPrice}
517
+ - Sale Price: ${schedule.salePrice}
518
+
519
+ **Active Period:**
520
+ - From: ${schedule.dateFrom}
521
+ - To: ${schedule.dateTo}
522
+
523
+ **API Response:**
524
+ \`\`\`json
525
+ ${JSON.stringify(schedule, null, 2)}
526
+ \`\`\``
527
+ }]
528
+ };
529
+ } catch (error) {
530
+ return {
531
+ content: [{
532
+ type: "text",
533
+ text: `❌ **Schedule Update Failed**
534
+
535
+ **Error Details:**
536
+ - Message: ${error.message}
537
+ - Product ID: ${productId}
538
+ - Schedule ID: ${scheduleId}`
539
+ }]
540
+ };
541
+ }
542
+ }
543
+ };
544
+
545
+ /**
546
+ * Delete schedule tool implementation for merchants
547
+ */
548
+ export const deleteScheduleTool = {
549
+ name: "payware_products_delete_schedule",
550
+ description: "Delete a price schedule. This action cannot be undone.",
551
+
552
+ inputSchema: {
553
+ type: "object",
554
+ properties: {
555
+ productId: {
556
+ type: "string",
557
+ description: "Product identifier (starts with 'pr')",
558
+ pattern: "^pr[a-zA-Z0-9]+$"
559
+ },
560
+ scheduleId: {
561
+ type: "number",
562
+ description: "Schedule identifier"
563
+ },
564
+ partnerId: {
565
+ type: "string",
566
+ description: "Merchant partner ID (uses PAYWARE_PARTNER_ID env var as default)",
567
+ default: getPartnerIdSafe()
568
+ },
569
+ privateKey: {
570
+ type: "string",
571
+ description: "RSA private key for authentication (uses environment-specific private key as default)",
572
+ default: getPrivateKeySafe()
573
+ },
574
+ useSandbox: {
575
+ type: "boolean",
576
+ description: "Use sandbox environment",
577
+ default: true
578
+ }
579
+ },
580
+ required: ["productId", "scheduleId"]
581
+ },
582
+
583
+ async handler(args) {
584
+ const {
585
+ productId,
586
+ scheduleId,
587
+ partnerId = getPartnerIdSafe(),
588
+ privateKey = getPrivateKeySafe(),
589
+ useSandbox = true
590
+ } = args;
591
+
592
+ if (!productId || !scheduleId) {
593
+ throw new Error("Product ID and schedule ID are required");
594
+ }
595
+
596
+ if (!partnerId || !privateKey) {
597
+ throw new Error("Partner ID and private key are required");
598
+ }
599
+
600
+ try {
601
+ const result = await deletePriceSchedule({
602
+ productId,
603
+ scheduleId,
604
+ partnerType: 'merchant',
605
+ partnerId,
606
+ privateKey,
607
+ useSandbox
608
+ });
609
+
610
+ return {
611
+ content: [{
612
+ type: "text",
613
+ text: `🗑️ **Schedule Deleted Successfully**
614
+
615
+ **Deleted Schedule:**
616
+ - Product ID: ${productId}
617
+ - Schedule ID: ${scheduleId}
618
+
619
+ **API Call Details:**
620
+ - Endpoint: ${result.requestInfo.method} ${result.requestInfo.url}
621
+ - Status: ${result.requestInfo.statusCode}
622
+
623
+ **Important Notes:**
624
+ ⚠️ This action cannot be undone
625
+ ⚠️ Product pricing may change if this was an active schedule
626
+
627
+ **Next Steps:**
628
+ - Use \`payware_products_get_schedules\` to view remaining schedules
629
+ - Check current product sale price with \`payware_products_get_product\``
630
+ }]
631
+ };
632
+ } catch (error) {
633
+ return {
634
+ content: [{
635
+ type: "text",
636
+ text: `❌ **Schedule Deletion Failed**
637
+
638
+ **Error Details:**
639
+ - Message: ${error.message}
640
+ - Product ID: ${productId}
641
+ - Schedule ID: ${scheduleId}`
642
+ }]
643
+ };
644
+ }
645
+ }
646
+ };