@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,134 @@
1
+ import { getProductDeepLink } from '../../shared/deep-links/api.js';
2
+ import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
3
+
4
+ /**
5
+ * Get deep link for a merchant product
6
+ */
7
+ export const getProductLinkTool = {
8
+ name: "payware_deep_links_get_product_link",
9
+ description: `Get an active deep link for a product. Returns a clickable URL that redirects to the payware mobile app.
10
+
11
+ **Deep Link Format:**
12
+ - Web URL: https://url.payware.eu/{productId}
13
+ - Mobile Redirect: payware://{productId}
14
+
15
+ **Use Cases:**
16
+ - Mobile-only e-commerce product references
17
+ - Advertisement links to products
18
+ - Product sharing via messaging
19
+
20
+ **Important Notes:**
21
+ - Deep links are only supported in production environment
22
+ - Link expiration is synchronized with the referenced product
23
+ - Traditional deep links that route to app content when app is installed`,
24
+
25
+ inputSchema: {
26
+ type: "object",
27
+ properties: {
28
+ productId: {
29
+ type: "string",
30
+ description: "The product identifier (e.g., 'pr7e4rCToG')",
31
+ pattern: "^[a-zA-Z0-9]+$"
32
+ },
33
+ partnerId: {
34
+ type: "string",
35
+ description: "Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default.",
36
+ default: getPartnerIdSafe()
37
+ },
38
+ privateKey: {
39
+ type: "string",
40
+ description: "RSA private key for JWT token creation. Uses environment-specific private key as default.",
41
+ default: getPrivateKeySafe()
42
+ }
43
+ },
44
+ required: ["productId"]
45
+ },
46
+
47
+ async handler(args) {
48
+ const {
49
+ productId,
50
+ partnerId = getPartnerIdSafe(),
51
+ privateKey = getPrivateKeySafe()
52
+ } = args;
53
+
54
+ if (!productId) {
55
+ throw new Error("productId is required");
56
+ }
57
+
58
+ if (!partnerId) {
59
+ throw new Error("Partner ID is required. Provide via 'partnerId' parameter or set PAYWARE_PARTNER_ID environment variable.");
60
+ }
61
+
62
+ if (!privateKey) {
63
+ throw new Error("Private key is required. Provide via 'privateKey' parameter or set PAYWARE_PRIVATE_KEY environment variable.");
64
+ }
65
+
66
+ try {
67
+ const result = await getProductDeepLink({
68
+ productId,
69
+ partnerType: 'merchant',
70
+ partnerId,
71
+ privateKey
72
+ });
73
+
74
+ // Extract the URL - API returns either string directly or object with link property
75
+ const linkUrl = typeof result.data === 'string' ? result.data : (result.data.link || result.data)
76
+
77
+ return {
78
+ content: [{
79
+ type: "text",
80
+ text: `🔗 **Product Deep Link Retrieved**
81
+
82
+ **Deep Link Details:**
83
+ - Product ID: ${productId}
84
+ - Web URL: ${linkUrl}
85
+ - Mobile Redirect: payware://${productId}
86
+
87
+ **Link Information:**
88
+ - Status: Active
89
+ - Expiration: Synchronized with product
90
+ - Platform: Production only
91
+
92
+ **API Response:**
93
+ \`\`\`json
94
+ ${JSON.stringify(result.data, null, 2)}
95
+ \`\`\`
96
+
97
+ **API Call Details:**
98
+ - Endpoint: GET ${result.requestInfo.url}
99
+ - Status: ${result.requestInfo.statusCode}
100
+ - Method: ${result.requestInfo.method}
101
+
102
+ **Usage:**
103
+ 1. Share the web URL: \`${linkUrl}\`
104
+ 2. On mobile devices, it will redirect to: \`payware://${productId}\`
105
+ 3. Link expires when the product expires
106
+ 4. Recreate if product is updated`
107
+ }]
108
+ };
109
+ } catch (error) {
110
+ return {
111
+ content: [{
112
+ type: "text",
113
+ text: `❌ **Failed to Get Product Deep Link**
114
+
115
+ **Error Details:**
116
+ - Product ID: ${productId}
117
+ - Message: ${error.message}
118
+
119
+ **Common Issues:**
120
+ 1. **Product not found**: Check if product exists and is not expired
121
+ 2. **Authentication failed**: Verify partner ID and private key
122
+ 3. **Sandbox environment**: Deep links are production-only
123
+ 4. **Invalid product ID**: Ensure product ID format is correct
124
+
125
+ **Troubleshooting:**
126
+ 1. Verify product exists in your payware dashboard
127
+ 2. Check if running in production environment
128
+ 3. Ensure JWT authentication is working
129
+ 4. Confirm product is active and not expired`
130
+ }]
131
+ };
132
+ }
133
+ }
134
+ };
@@ -0,0 +1,134 @@
1
+ import { getTransactionDeepLink } from '../../shared/deep-links/api.js';
2
+ import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
3
+
4
+ /**
5
+ * Get deep link for a merchant transaction
6
+ */
7
+ export const getTransactionLinkTool = {
8
+ name: "payware_deep_links_get_transaction_link",
9
+ description: `Get an active deep link for a transaction. Returns a clickable URL that redirects to the payware mobile app.
10
+
11
+ **Deep Link Format:**
12
+ - Web URL: https://url.payware.eu/{transactionId}
13
+ - Mobile Redirect: payware://{transactionId}
14
+
15
+ **Use Cases:**
16
+ - P2P payments via messaging services
17
+ - Mobile-only e-commerce payments
18
+ - Advertisement references
19
+
20
+ **Important Notes:**
21
+ - Deep links are only supported in production environment
22
+ - Link expiration is synchronized with the referenced transaction
23
+ - Traditional deep links that route to app content when app is installed`,
24
+
25
+ inputSchema: {
26
+ type: "object",
27
+ properties: {
28
+ transactionId: {
29
+ type: "string",
30
+ description: "The transaction identifier (e.g., 'pw7e4rCToG')",
31
+ pattern: "^[a-zA-Z0-9]+$"
32
+ },
33
+ partnerId: {
34
+ type: "string",
35
+ description: "Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default.",
36
+ default: getPartnerIdSafe()
37
+ },
38
+ privateKey: {
39
+ type: "string",
40
+ description: "RSA private key for JWT token creation. Uses environment-specific private key as default.",
41
+ default: getPrivateKeySafe()
42
+ }
43
+ },
44
+ required: ["transactionId"]
45
+ },
46
+
47
+ async handler(args) {
48
+ const {
49
+ transactionId,
50
+ partnerId = getPartnerIdSafe(),
51
+ privateKey = getPrivateKeySafe()
52
+ } = args;
53
+
54
+ if (!transactionId) {
55
+ throw new Error("transactionId is required");
56
+ }
57
+
58
+ if (!partnerId) {
59
+ throw new Error("Partner ID is required. Provide via 'partnerId' parameter or set PAYWARE_PARTNER_ID environment variable.");
60
+ }
61
+
62
+ if (!privateKey) {
63
+ throw new Error("Private key is required. Provide via 'privateKey' parameter or set PAYWARE_PRIVATE_KEY environment variable.");
64
+ }
65
+
66
+ try {
67
+ const result = await getTransactionDeepLink({
68
+ transactionId,
69
+ partnerType: 'merchant',
70
+ partnerId,
71
+ privateKey
72
+ });
73
+
74
+ // Extract the URL - API returns either string directly or object with link property
75
+ const linkUrl = typeof result.data === 'string' ? result.data : (result.data.link || result.data)
76
+
77
+ return {
78
+ content: [{
79
+ type: "text",
80
+ text: `🔗 **Transaction Deep Link Retrieved**
81
+
82
+ **Deep Link Details:**
83
+ - Transaction ID: ${transactionId}
84
+ - Web URL: ${linkUrl}
85
+ - Mobile Redirect: payware://${transactionId}
86
+
87
+ **Link Information:**
88
+ - Status: Active
89
+ - Expiration: Synchronized with transaction
90
+ - Platform: Production only
91
+
92
+ **API Response:**
93
+ \`\`\`json
94
+ ${JSON.stringify(result.data, null, 2)}
95
+ \`\`\`
96
+
97
+ **API Call Details:**
98
+ - Endpoint: GET ${result.requestInfo.url}
99
+ - Status: ${result.requestInfo.statusCode}
100
+ - Method: ${result.requestInfo.method}
101
+
102
+ **Usage:**
103
+ 1. Share the web URL: \`${linkUrl}\`
104
+ 2. On mobile devices, it will redirect to: \`payware://${transactionId}\`
105
+ 3. Link expires when the transaction expires
106
+ 4. Recreate if transaction is extended`
107
+ }]
108
+ };
109
+ } catch (error) {
110
+ return {
111
+ content: [{
112
+ type: "text",
113
+ text: `❌ **Failed to Get Transaction Deep Link**
114
+
115
+ **Error Details:**
116
+ - Transaction ID: ${transactionId}
117
+ - Message: ${error.message}
118
+
119
+ **Common Issues:**
120
+ 1. **Transaction not found**: Check if transaction exists and is not expired
121
+ 2. **Authentication failed**: Verify partner ID and private key
122
+ 3. **Sandbox environment**: Deep links are production-only
123
+ 4. **Invalid transaction ID**: Ensure transaction ID format is correct
124
+
125
+ **Troubleshooting:**
126
+ 1. Verify transaction exists using \`payware_transactions_get_transaction_status\`
127
+ 2. Check if running in production environment
128
+ 3. Ensure JWT authentication is working
129
+ 4. Confirm transaction is not expired`
130
+ }]
131
+ };
132
+ }
133
+ }
134
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Merchant Deep Links Tools
3
+ * Deep link management for merchants
4
+ */
5
+
6
+ import { getTransactionLinkTool } from './get-transaction-link.js';
7
+ import { getProductLinkTool } from './get-product-link.js';
8
+ import { deleteTransactionLinkTool } from './delete-transaction-link.js';
9
+ import { deleteProductLinkTool } from './delete-product-link.js';
10
+
11
+ export const merchantDeepLinksTools = [
12
+ getTransactionLinkTool,
13
+ getProductLinkTool,
14
+ deleteTransactionLinkTool,
15
+ deleteProductLinkTool
16
+ ];
17
+
18
+ export {
19
+ getTransactionLinkTool,
20
+ getProductLinkTool,
21
+ deleteTransactionLinkTool,
22
+ deleteProductLinkTool
23
+ };
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Merchant partner tools registry
3
+ * Tools available for merchants accepting payments directly
4
+ */
5
+
6
+ // Transaction tools
7
+ import { createTransactionTool } from './transactions/create-transaction.js';
8
+ import { getTransactionStatusTool } from './transactions/get-status.js';
9
+ import { cancelTransactionTool } from './transactions/cancel-transaction.js';
10
+ import { getTransactionHistoryTool } from './transactions/transaction-history.js';
11
+ import { processTransactionTool } from './transactions/process-transaction.js';
12
+ import { simulateCallbackTool } from './transactions/simulate-callback.js';
13
+
14
+ // Data tools
15
+ import { merchantDataTools } from './data/index.js';
16
+
17
+ // Product tools
18
+ import { merchantProductTools } from './products/index.js';
19
+
20
+ // Deep links tools
21
+ import { merchantDeepLinksTools } from './deep-links/index.js';
22
+
23
+ // Shared utility tools
24
+ import { getServerInfoTool } from '../utils/server-info.js';
25
+
26
+ // Import shared tools
27
+ import { sharedTools } from '../shared/index.js';
28
+
29
+ /**
30
+ * All merchant-specific tools
31
+ */
32
+ export const merchantTools = [
33
+ // Shared tools (authentication, utilities, etc.)
34
+ ...sharedTools,
35
+
36
+ // Transaction management
37
+ createTransactionTool,
38
+ getTransactionStatusTool,
39
+ cancelTransactionTool,
40
+ getTransactionHistoryTool,
41
+ processTransactionTool,
42
+ simulateCallbackTool,
43
+
44
+ // Data management
45
+ ...merchantDataTools,
46
+
47
+ // Product management
48
+ ...merchantProductTools,
49
+
50
+ // Deep links management
51
+ ...merchantDeepLinksTools
52
+ ];
53
+
54
+ /**
55
+ * Get tools for merchant partner type
56
+ * @returns {Array} Array of merchant tools with proper grouping names
57
+ */
58
+ export function getMerchantTools() {
59
+ return merchantTools.map(tool => {
60
+ let newName = tool.name;
61
+
62
+ // Authentication tools use authentication grouping
63
+ if (tool.name.startsWith('payware_authentication_')) {
64
+ newName = tool.name; // Keep authentication grouping
65
+ }
66
+ // Utility tools keep their utils grouping
67
+ else if (tool.name.startsWith('payware_utils_')) {
68
+ newName = tool.name; // Keep utils grouping
69
+ }
70
+ // Operations tools (previously transactions) keep operations grouping
71
+ else if (tool.name.startsWith('payware_operations_')) {
72
+ newName = tool.name; // Keep operations grouping
73
+ }
74
+ // Data tools keep their data grouping
75
+ else if (tool.name.startsWith('payware_data_')) {
76
+ newName = tool.name; // Keep data grouping
77
+ }
78
+ // Product tools keep their products grouping
79
+ else if (tool.name.startsWith('payware_products_')) {
80
+ newName = tool.name; // Keep products grouping
81
+ }
82
+ // Deep links tools keep their deep_links grouping
83
+ else if (tool.name.startsWith('payware_deep_links_')) {
84
+ newName = tool.name; // Keep deep_links grouping
85
+ }
86
+
87
+ return {
88
+ ...tool,
89
+ name: newName
90
+ };
91
+ });
92
+ }