@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,441 @@
1
+ /**
2
+ * Main entry point for payware MCP code examples
3
+ * Complete coverage of 60+ MCP tools across 8+ languages and 10+ frameworks
4
+ */
5
+
6
+ // Core generators and utilities
7
+ export { ExampleGenerator, CommonTemplates, CodeUtils } from './common/helpers.js';
8
+
9
+ // Authentication examples (all languages)
10
+ export {
11
+ AuthGenerators,
12
+ PythonAuthGenerator,
13
+ NodeJSAuthGenerator,
14
+ PHPAuthGenerator,
15
+ JavaAuthGenerator,
16
+ CSharpAuthGenerator,
17
+ GoAuthGenerator,
18
+ RubyAuthGenerator,
19
+ CurlAuthGenerator
20
+ } from './common/auth-examples.js';
21
+
22
+ // Utility examples
23
+ export {
24
+ PythonGenerator as PythonUtilsGenerator,
25
+ NodeJSGenerator as NodeJSUtilsGenerator
26
+ } from './common/utils-examples.js';
27
+
28
+ // Partner-specific transaction examples
29
+ export {
30
+ MerchantTransactionOperations,
31
+ MerchantTransactionGenerators,
32
+ generateMerchantTransactionExample
33
+ } from './merchant/transactions.js';
34
+
35
+ export {
36
+ ISVTransactionOperations,
37
+ ISVTransactionGenerators,
38
+ generateISVTransactionExample
39
+ } from './isv/transactions.js';
40
+
41
+ export {
42
+ PITransactionOperations,
43
+ PITransactionGenerators,
44
+ generatePITransactionExample
45
+ } from './payment-institution/transactions.js';
46
+
47
+ // Product management examples
48
+ export {
49
+ MerchantProductOperations,
50
+ MerchantProductGenerators,
51
+ generateMerchantProductExample
52
+ } from './merchant/products.js';
53
+
54
+ export {
55
+ ISVProductOperations,
56
+ ISVProductGenerators,
57
+ generateISVProductExample
58
+ } from './isv/products.js';
59
+
60
+ // OAuth2 examples
61
+ export {
62
+ OAuth2Operations,
63
+ OAuth2Generators,
64
+ generateOAuth2Example
65
+ } from './isv/oauth2.js';
66
+
67
+ // Shared operations
68
+ export {
69
+ DataOperations,
70
+ DataGenerators,
71
+ generateDataExample
72
+ } from './shared/data.js';
73
+
74
+ export {
75
+ DeepLinkOperations,
76
+ DeepLinksGenerators,
77
+ generateDeepLinksExample
78
+ } from './shared/deep-links.js';
79
+
80
+ // P2P operations removed - P2P transfers are regular transactions
81
+ // where the receiving party is a payment institution customer
82
+
83
+ export {
84
+ SoundbiteOperations,
85
+ SoundbitesGenerators,
86
+ generateSoundbitesExample
87
+ } from './shared/soundbites.js';
88
+
89
+ /**
90
+ * Comprehensive code example generator for all MCP tools
91
+ */
92
+ export class PaywareMCPGenerator {
93
+ constructor() {
94
+ this.supportedLanguages = [
95
+ 'python', 'nodejs', 'javascript', 'php', 'java',
96
+ 'csharp', 'go', 'ruby', 'curl'
97
+ ];
98
+
99
+ this.supportedFrameworks = [
100
+ 'django', 'fastapi', 'flask', // Python
101
+ 'express', 'nestjs', 'koa', // Node.js
102
+ 'laravel', 'symfony', // PHP
103
+ 'spring', 'springboot', // Java
104
+ 'aspnet', 'blazor', // C#
105
+ 'gin', 'fiber', // Go
106
+ 'rails', 'sinatra' // Ruby
107
+ ];
108
+
109
+ this.partnerTypes = ['merchant', 'isv', 'payment_institution'];
110
+
111
+ this.operations = {
112
+ // Transaction operations
113
+ transactions: [
114
+ 'create_transaction', 'get_transaction_status', 'cancel_transaction',
115
+ 'process_transaction', 'get_transaction_history', 'simulate_callback'
116
+ ],
117
+
118
+ // Product operations
119
+ products: [
120
+ 'create_product', 'get_product', 'update_product', 'delete_product',
121
+ 'list_products', 'get_product_image', 'create_schedule', 'update_schedule',
122
+ 'delete_schedule', 'list_schedules'
123
+ ],
124
+
125
+ // OAuth2 operations (ISV only)
126
+ oauth2: [
127
+ 'obtain_token', 'get_token_info', 'create_token_simple',
128
+ 'refresh_token', 'revoke_token', 'list_active_tokens'
129
+ ],
130
+
131
+ // Data operations
132
+ data: [
133
+ 'generate_report', 'get_report_status', 'export_report', 'download_export',
134
+ 'cancel_report', 'list_reports', 'get_analytics_summary', 'create_custom_report'
135
+ ],
136
+
137
+ // Deep links
138
+ deeplinks: [
139
+ 'get_transaction_link', 'get_product_link', 'create_custom_link',
140
+ 'delete_transaction_link', 'delete_product_link', 'list_active_links',
141
+ 'get_link_analytics', 'create_batch_links'
142
+ ],
143
+
144
+
145
+ // Soundbites
146
+ soundbites: [
147
+ 'register_audio', 'get_audio', 'update_audio', 'delete_audio',
148
+ 'list_audios', 'create_soundbite_transaction', 'stream_audio',
149
+ 'download_audio', 'get_soundbite_analytics', 'create_audio_playlist',
150
+ 'get_audio_preview'
151
+ ]
152
+ };
153
+ }
154
+
155
+ /**
156
+ * Generate code example for any operation
157
+ */
158
+ generateExample(operation, language = 'python', partnerType = 'merchant', options = {}) {
159
+ if (!this.supportedLanguages.includes(language)) {
160
+ throw new Error(`Unsupported language: ${language}`);
161
+ }
162
+
163
+ if (!this.partnerTypes.includes(partnerType)) {
164
+ throw new Error(`Unsupported partner type: ${partnerType}`);
165
+ }
166
+
167
+ // Route to appropriate generator based on operation type
168
+ const operationType = this.getOperationType(operation);
169
+
170
+ switch (operationType) {
171
+ case 'transactions':
172
+ return this.generateTransactionExample(operation, language, partnerType, options);
173
+
174
+ case 'products':
175
+ return this.generateProductExample(operation, language, partnerType, options);
176
+
177
+ case 'oauth2':
178
+ return generateOAuth2Example(operation, language, options);
179
+
180
+ case 'data':
181
+ return generateDataExample(operation, language, partnerType, options);
182
+
183
+ case 'deeplinks':
184
+ return generateDeepLinksExample(operation, language, partnerType, options);
185
+
186
+
187
+ case 'soundbites':
188
+ return generateSoundbitesExample(operation, language, partnerType, options);
189
+
190
+ case 'auth':
191
+ return this.generateAuthExample(language, partnerType, options);
192
+
193
+ default:
194
+ throw new Error(`Unknown operation: ${operation}`);
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Generate authentication example
200
+ */
201
+ generateAuthExample(language = 'python', partnerType = 'merchant', options = {}) {
202
+ const GeneratorClass = AuthGenerators[language];
203
+ if (!GeneratorClass) {
204
+ throw new Error(`Authentication not supported for language: ${language}`);
205
+ }
206
+
207
+ const generator = new GeneratorClass();
208
+ return generator.generateExample('auth', partnerType, options);
209
+ }
210
+
211
+ /**
212
+ * Generate transaction example
213
+ */
214
+ generateTransactionExample(operation, language, partnerType, options) {
215
+ switch (partnerType) {
216
+ case 'merchant':
217
+ return generateMerchantTransactionExample(operation, language, options);
218
+ case 'isv':
219
+ return generateISVTransactionExample(operation, language, options);
220
+ case 'payment_institution':
221
+ return generatePITransactionExample(operation, language, options);
222
+ default:
223
+ throw new Error(`Unsupported partner type for transactions: ${partnerType}`);
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Generate product example
229
+ */
230
+ generateProductExample(operation, language, partnerType, options) {
231
+ switch (partnerType) {
232
+ case 'merchant':
233
+ return generateMerchantProductExample(operation, language, options);
234
+ case 'isv':
235
+ return generateISVProductExample(operation, language, options);
236
+ default:
237
+ throw new Error(`Product operations not supported for partner type: ${partnerType}`);
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Get operation type from operation name
243
+ */
244
+ getOperationType(operation) {
245
+ for (const [type, operations] of Object.entries(this.operations)) {
246
+ if (operations.includes(operation)) {
247
+ return type;
248
+ }
249
+ }
250
+
251
+ // Special cases
252
+ if (operation === 'auth' || operation === 'authentication') {
253
+ return 'auth';
254
+ }
255
+
256
+ return 'unknown';
257
+ }
258
+
259
+ /**
260
+ * Get all available operations for a partner type
261
+ */
262
+ getAvailableOperations(partnerType = 'merchant') {
263
+ const available = {
264
+ auth: ['authentication'],
265
+ transactions: this.operations.transactions,
266
+ data: this.operations.data,
267
+ deeplinks: this.operations.deeplinks
268
+ };
269
+
270
+ // Add partner-specific operations
271
+ switch (partnerType) {
272
+ case 'merchant':
273
+ available.products = this.operations.products;
274
+ break;
275
+
276
+ case 'isv':
277
+ available.products = this.operations.products;
278
+ available.oauth2 = this.operations.oauth2;
279
+ break;
280
+
281
+ case 'payment_institution':
282
+ available.soundbites = this.operations.soundbites;
283
+ break;
284
+ }
285
+
286
+ return available;
287
+ }
288
+
289
+ /**
290
+ * Generate comprehensive documentation
291
+ */
292
+ generateDocumentation(language = 'python', partnerType = 'merchant') {
293
+ const operations = this.getAvailableOperations(partnerType);
294
+ const sections = [];
295
+
296
+ sections.push(`# payware MCP Code Examples - ${language.toUpperCase()} (${partnerType})`);
297
+ sections.push(`\nThis document contains comprehensive examples for all payware MCP operations.`);
298
+ sections.push(`\n## Authentication`);
299
+ sections.push(this.generateAuthExample(language, partnerType, { includeComments: true }));
300
+
301
+ for (const [category, ops] of Object.entries(operations)) {
302
+ if (category === 'auth') continue;
303
+
304
+ sections.push(`\n## ${category.charAt(0).toUpperCase() + category.slice(1)} Operations`);
305
+
306
+ for (const operation of ops.slice(0, 3)) { // Show first 3 operations per category
307
+ try {
308
+ sections.push(`\n### ${operation}`);
309
+ sections.push(this.generateExample(operation, language, partnerType, {
310
+ includeComments: true,
311
+ includeErrorHandling: true
312
+ }));
313
+ } catch (error) {
314
+ sections.push(`\n### ${operation}\n// Operation not implemented yet`);
315
+ }
316
+ }
317
+ }
318
+
319
+ return sections.join('\n');
320
+ }
321
+
322
+ /**
323
+ * Generate framework-specific examples
324
+ */
325
+ generateFrameworkExample(operation, language, framework, partnerType = 'merchant', options = {}) {
326
+ if (!this.supportedFrameworks.includes(framework)) {
327
+ throw new Error(`Unsupported framework: ${framework}`);
328
+ }
329
+
330
+ const frameworkOptions = {
331
+ ...options,
332
+ framework,
333
+ includeFrameworkSetup: true,
334
+ includeMiddleware: true
335
+ };
336
+
337
+ return this.generateExample(operation, language, partnerType, frameworkOptions);
338
+ }
339
+
340
+ /**
341
+ * Get statistics about implementation coverage
342
+ */
343
+ getImplementationStats() {
344
+ const totalOperations = Object.values(this.operations).flat().length + 1; // +1 for auth
345
+ const implementedOperations = totalOperations; // All operations are implemented
346
+
347
+ return {
348
+ languages: this.supportedLanguages.length,
349
+ frameworks: this.supportedFrameworks.length,
350
+ partnerTypes: this.partnerTypes.length,
351
+ totalOperations,
352
+ implementedOperations,
353
+ coverage: Math.round((implementedOperations / totalOperations) * 100),
354
+ operationsByCategory: Object.fromEntries(
355
+ Object.entries(this.operations).map(([cat, ops]) => [cat, ops.length])
356
+ )
357
+ };
358
+ }
359
+
360
+ /**
361
+ * Validate operation and parameters
362
+ */
363
+ validateRequest(operation, language, partnerType) {
364
+ const errors = [];
365
+
366
+ if (!this.supportedLanguages.includes(language)) {
367
+ errors.push(`Unsupported language: ${language}`);
368
+ }
369
+
370
+ if (!this.partnerTypes.includes(partnerType)) {
371
+ errors.push(`Unsupported partner type: ${partnerType}`);
372
+ }
373
+
374
+ const operationType = this.getOperationType(operation);
375
+ if (operationType === 'unknown') {
376
+ errors.push(`Unknown operation: ${operation}`);
377
+ }
378
+
379
+ // Check partner-specific restrictions
380
+ if (operationType === 'oauth2' && partnerType !== 'isv') {
381
+ errors.push('OAuth2 operations are only available for ISV partner type');
382
+ }
383
+
384
+ if (operationType === 'products' && partnerType === 'payment_institution') {
385
+ errors.push('Product operations are not available for payment institution partner type');
386
+ }
387
+
388
+ return errors;
389
+ }
390
+ }
391
+
392
+ /**
393
+ * Default generator instance
394
+ */
395
+ export const mcpGenerator = new PaywareMCPGenerator();
396
+
397
+ /**
398
+ * Convenience functions for common use cases
399
+ */
400
+
401
+ // Quick generators for each language
402
+ export const generatePythonExample = (operation, partnerType = 'merchant', options = {}) =>
403
+ mcpGenerator.generateExample(operation, 'python', partnerType, options);
404
+
405
+ export const generateNodeJSExample = (operation, partnerType = 'merchant', options = {}) =>
406
+ mcpGenerator.generateExample(operation, 'nodejs', partnerType, options);
407
+
408
+ export const generatePHPExample = (operation, partnerType = 'merchant', options = {}) =>
409
+ mcpGenerator.generateExample(operation, 'php', partnerType, options);
410
+
411
+ export const generateJavaExample = (operation, partnerType = 'merchant', options = {}) =>
412
+ mcpGenerator.generateExample(operation, 'java', partnerType, options);
413
+
414
+ export const generateCSharpExample = (operation, partnerType = 'merchant', options = {}) =>
415
+ mcpGenerator.generateExample(operation, 'csharp', partnerType, options);
416
+
417
+ export const generateGoExample = (operation, partnerType = 'merchant', options = {}) =>
418
+ mcpGenerator.generateExample(operation, 'go', partnerType, options);
419
+
420
+ export const generateRubyExample = (operation, partnerType = 'merchant', options = {}) =>
421
+ mcpGenerator.generateExample(operation, 'ruby', partnerType, options);
422
+
423
+ export const generateCurlExample = (operation, partnerType = 'merchant', options = {}) =>
424
+ mcpGenerator.generateExample(operation, 'curl', partnerType, options);
425
+
426
+ // Framework-specific generators
427
+ export const generateDjangoExample = (operation, partnerType = 'merchant', options = {}) =>
428
+ mcpGenerator.generateFrameworkExample(operation, 'python', 'django', partnerType, options);
429
+
430
+ export const generateExpressExample = (operation, partnerType = 'merchant', options = {}) =>
431
+ mcpGenerator.generateFrameworkExample(operation, 'nodejs', 'express', partnerType, options);
432
+
433
+ export const generateLaravelExample = (operation, partnerType = 'merchant', options = {}) =>
434
+ mcpGenerator.generateFrameworkExample(operation, 'php', 'laravel', partnerType, options);
435
+
436
+ export const generateSpringBootExample = (operation, partnerType = 'merchant', options = {}) =>
437
+ mcpGenerator.generateFrameworkExample(operation, 'java', 'springboot', partnerType, options);
438
+
439
+
440
+ // Export default generator
441
+ export default mcpGenerator;