@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,168 @@
1
+ import { getProduct } from '../../shared/products/products-api.js';
2
+ import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
3
+
4
+ /**
5
+ * Get product tool implementation for ISVs
6
+ */
7
+ export const getProductTool = {
8
+ name: "payware_products_get_product",
9
+ description: "Get detailed information about a specific product by ID (ISV operation)",
10
+
11
+ inputSchema: {
12
+ type: "object",
13
+ properties: {
14
+ // ISV Authentication
15
+ merchantPartnerId: {
16
+ type: "string",
17
+ description: "Target merchant partner ID (8 alphanumeric characters, e.g., 'PZAYNMVE')"
18
+ },
19
+ oauth2Token: {
20
+ type: "string",
21
+ description: "OAuth2 access token obtained from the merchant"
22
+ },
23
+ productId: {
24
+ type: "string",
25
+ description: "Product identifier (starts with 'pr')",
26
+ pattern: "^pr[a-zA-Z0-9]+$"
27
+ },
28
+ useSandbox: {
29
+ type: "boolean",
30
+ description: "Use sandbox environment",
31
+ default: true
32
+ }
33
+ },
34
+ required: ["merchantPartnerId", "oauth2Token", "productId"]
35
+ },
36
+
37
+ async handler(args) {
38
+ const {
39
+ merchantPartnerId,
40
+ oauth2Token,
41
+ productId,
42
+ useSandbox = true
43
+ } = args;
44
+
45
+ // ISV validation
46
+ if (!merchantPartnerId) {
47
+ throw new Error("Merchant Partner ID is required for ISV operations");
48
+ }
49
+
50
+ if (!oauth2Token) {
51
+ throw new Error("OAuth2 token is required for ISV operations");
52
+ }
53
+
54
+ if (!productId) {
55
+ throw new Error("Product ID is required");
56
+ }
57
+
58
+ // Get ISV credentials
59
+ const isvPartnerId = getPartnerIdSafe();
60
+ const privateKey = getPrivateKeySafe();
61
+
62
+ if (!isvPartnerId) {
63
+ throw new Error("ISV Partner ID is required. Set PAYWARE_PARTNER_ID environment variable.");
64
+ }
65
+
66
+ if (!privateKey) {
67
+ throw new Error("Private key is required. Set environment-specific private key variable.");
68
+ }
69
+
70
+ try {
71
+ const result = await getProduct({
72
+ productId,
73
+ partnerType: 'isv',
74
+ isvPartnerId,
75
+ privateKey,
76
+ merchantPartnerId,
77
+ oauth2Token,
78
+ useSandbox
79
+ });
80
+
81
+ const product = result.data;
82
+
83
+ return {
84
+ content: [{
85
+ type: "text",
86
+ text: `📦 **Product Details (ISV -> Merchant: ${merchantPartnerId})**
87
+
88
+ **Basic Information:**
89
+ - ID: ${product.productId}
90
+ - Name: ${product.name}
91
+ - Type: ${product.type}
92
+ - Status: ${product.active ? '✅ Active' : '⏸️ Inactive'}
93
+ - Shop: ${product.shopCode} (${product.shopName})
94
+
95
+ **Description:**
96
+ ${product.shortDescription ? `- Short: ${product.shortDescription}` : ''}
97
+ ${product.longDescription ? `- Long: ${product.longDescription}` : ''}
98
+
99
+ **Identifiers:**
100
+ ${product.sku ? `- SKU: ${product.sku}` : ''}
101
+ ${product.upc ? `- UPC: ${product.upc}` : ''}
102
+
103
+ **Pricing:**
104
+ - Regular Price: ${product.regularPrice} ${product.currencyCode}
105
+ - Current Sale Price: ${product.salePrice} ${product.currencyCode}
106
+ - Time to Live: ${product.timeToLive} seconds
107
+
108
+ **Settings:**
109
+ - Shippable: ${product.shippable ? 'Yes (requires delivery address)' : 'No (digital product)'}
110
+
111
+ **Active Period:**
112
+ - From: ${product.activeFromZoned || product.activeFrom}
113
+ - To: ${product.activeToZoned || product.activeTo}
114
+ - Timezone: ${product.timeZone}
115
+
116
+ **Resources:**
117
+ ${product.imageUrl ? `- Image: ${product.imageUrl}` : ''}
118
+ ${product.termsUrl ? `- Terms URL: ${product.termsUrl}` : ''}
119
+ ${product.termsText ? `- Terms Text: ${product.termsText.substring(0, 100)}${product.termsText.length > 100 ? '...' : ''}` : ''}
120
+ ${product.deepLink && product.deepLink !== '-' ? `- Deep Link: ${product.deepLink}` : ''}
121
+
122
+ **ISV Integration Details:**
123
+ - ISV Partner: ${isvPartnerId}
124
+ - Target Merchant: ${merchantPartnerId}
125
+ - OAuth2 Token: ${oauth2Token.substring(0, 8)}...
126
+
127
+ **API Response:**
128
+ \`\`\`json
129
+ ${JSON.stringify(product, null, 2)}
130
+ \`\`\`
131
+
132
+ **API Call Details:**
133
+ - Endpoint: ${result.requestInfo.method} ${result.requestInfo.url}
134
+ - Status: ${result.requestInfo.statusCode}
135
+
136
+ **Available Actions:**
137
+ - \`payware_products_update_product\` - Update this product
138
+ - \`payware_products_delete_product\` - Delete this product
139
+ - \`payware_products_get_product_image\` - Generate QR/barcode image
140
+ - \`payware_products_get_schedules\` - View price schedules
141
+ - \`payware_products_get_audios\` - View registered audios`
142
+ }]
143
+ };
144
+ } catch (error) {
145
+ return {
146
+ content: [{
147
+ type: "text",
148
+ text: `❌ **Failed to Get Product**
149
+
150
+ **Error Details:**
151
+ - Message: ${error.message}
152
+ - Product ID: ${productId}
153
+
154
+ **ISV Authentication Check:**
155
+ - ISV Partner ID: ${isvPartnerId}
156
+ - Merchant Partner ID: ${merchantPartnerId || 'Missing'}
157
+ - OAuth2 Token: ${oauth2Token ? 'Provided' : 'Missing'}
158
+
159
+ **Troubleshooting:**
160
+ 1. Verify the product ID is correct and starts with 'pr'
161
+ 2. Ensure the product exists and belongs to the target merchant
162
+ 3. Check OAuth2 token validity and permissions
163
+ 4. Confirm ISV has authorization to access merchant's products`
164
+ }]
165
+ };
166
+ }
167
+ }
168
+ };
@@ -0,0 +1,65 @@
1
+ /**
2
+ * ISV Products Tools
3
+ * Complete implementation of the Products API for ISVs
4
+ */
5
+
6
+ // Product Management
7
+ import { createProductTool } from './create-product.js';
8
+ import { listProductsTool } from './list-products.js';
9
+ import { getProductTool } from './get-product.js';
10
+ import { updateProductTool } from './update-product.js';
11
+ import { deleteProductTool } from './delete-product.js';
12
+ import { getProductImageTool } from './get-product-image.js';
13
+
14
+ // Price Schedules
15
+ import {
16
+ createScheduleTool,
17
+ getSchedulesTool,
18
+ getScheduleTool,
19
+ updateScheduleTool,
20
+ deleteScheduleTool
21
+ } from './schedules.js';
22
+
23
+ // Audio/Soundbite Management
24
+ import {
25
+ registerAudioTool,
26
+ getAudiosTool,
27
+ getAudioTool,
28
+ updateAudioTool,
29
+ deleteAudioTool
30
+ } from './audios.js';
31
+
32
+ /**
33
+ * All ISV product tools
34
+ */
35
+ export const isvProductTools = [
36
+ // Product Management
37
+ createProductTool,
38
+ listProductsTool,
39
+ getProductTool,
40
+ updateProductTool,
41
+ deleteProductTool,
42
+ getProductImageTool,
43
+
44
+ // Price Schedules
45
+ createScheduleTool,
46
+ getSchedulesTool,
47
+ getScheduleTool,
48
+ updateScheduleTool,
49
+ deleteScheduleTool,
50
+
51
+ // Audio/Soundbite Management
52
+ registerAudioTool,
53
+ getAudiosTool,
54
+ getAudioTool,
55
+ updateAudioTool,
56
+ deleteAudioTool
57
+ ];
58
+
59
+ /**
60
+ * Get ISV product tools with proper naming
61
+ * @returns {Array} Array of ISV product tools
62
+ */
63
+ export function getISVProductTools() {
64
+ return isvProductTools;
65
+ }
@@ -0,0 +1,136 @@
1
+ import { getProducts } from '../../shared/products/products-api.js';
2
+ import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
3
+
4
+ /**
5
+ * List products tool implementation for ISVs
6
+ */
7
+ export const listProductsTool = {
8
+ name: "payware_products_list_products",
9
+ description: "Get a list of all products for a merchant account (ISV operation)",
10
+
11
+ inputSchema: {
12
+ type: "object",
13
+ properties: {
14
+ // ISV Authentication
15
+ merchantPartnerId: {
16
+ type: "string",
17
+ description: "Target merchant partner ID (8 alphanumeric characters, e.g., 'PZAYNMVE')"
18
+ },
19
+ oauth2Token: {
20
+ type: "string",
21
+ description: "OAuth2 access token obtained from the merchant"
22
+ },
23
+ useSandbox: {
24
+ type: "boolean",
25
+ description: "Use sandbox environment",
26
+ default: true
27
+ }
28
+ },
29
+ required: ["merchantPartnerId", "oauth2Token"]
30
+ },
31
+
32
+ async handler(args) {
33
+ const {
34
+ merchantPartnerId,
35
+ oauth2Token,
36
+ useSandbox = true
37
+ } = args;
38
+
39
+ // ISV validation
40
+ if (!merchantPartnerId) {
41
+ throw new Error("Merchant Partner ID is required for ISV operations");
42
+ }
43
+
44
+ if (!oauth2Token) {
45
+ throw new Error("OAuth2 token is required for ISV operations");
46
+ }
47
+
48
+ // Get ISV credentials
49
+ const isvPartnerId = getPartnerIdSafe();
50
+ const privateKey = getPrivateKeySafe();
51
+
52
+ if (!isvPartnerId) {
53
+ throw new Error("ISV Partner ID is required. Set PAYWARE_PARTNER_ID environment variable.");
54
+ }
55
+
56
+ if (!privateKey) {
57
+ throw new Error("Private key is required. Set environment-specific private key variable.");
58
+ }
59
+
60
+ try {
61
+ const result = await getProducts({
62
+ partnerType: 'isv',
63
+ isvPartnerId,
64
+ privateKey,
65
+ merchantPartnerId,
66
+ oauth2Token,
67
+ useSandbox
68
+ });
69
+
70
+ const products = result.data;
71
+ const productCount = Array.isArray(products) ? products.length : 0;
72
+
73
+ let productsList = '';
74
+ if (Array.isArray(products) && products.length > 0) {
75
+ productsList = products.map(product =>
76
+ `- **${product.name}** (${product.productId})
77
+ - Type: ${product.type} | Price: ${product.salePrice} ${product.currencyCode}
78
+ - Status: ${product.active ? '✅ Active' : '⏸️ Inactive'} | Shop: ${product.shopCode}
79
+ - TTL: ${product.timeToLive}s | ${product.shippable ? 'Shippable' : 'Digital'}`
80
+ ).join('\n\n');
81
+ } else {
82
+ productsList = 'No products found.';
83
+ }
84
+
85
+ return {
86
+ content: [{
87
+ type: "text",
88
+ text: `📦 **Products List (ISV -> Merchant: ${merchantPartnerId})**
89
+
90
+ **Summary:**
91
+ - Total Products: ${productCount}
92
+ - Environment: ${useSandbox ? 'Sandbox' : 'Production'}
93
+
94
+ **ISV Integration Details:**
95
+ - ISV Partner: ${isvPartnerId}
96
+ - Target Merchant: ${merchantPartnerId}
97
+ - OAuth2 Token: ${oauth2Token.substring(0, 8)}...
98
+
99
+ **Products:**
100
+ ${productsList}
101
+
102
+ **API Call Details:**
103
+ - Endpoint: ${result.requestInfo.method} ${result.requestInfo.url}
104
+ - Status: ${result.requestInfo.statusCode}
105
+
106
+ **Available Actions:**
107
+ - \`payware_products_get_product\` - Get detailed product information
108
+ - \`payware_products_create_product\` - Create a new product
109
+ - \`payware_products_update_product\` - Update existing product
110
+ - \`payware_products_delete_product\` - Delete a product`
111
+ }]
112
+ };
113
+ } catch (error) {
114
+ return {
115
+ content: [{
116
+ type: "text",
117
+ text: `❌ **Failed to List Products**
118
+
119
+ **Error Details:**
120
+ - Message: ${error.message}
121
+
122
+ **ISV Authentication Check:**
123
+ - ISV Partner ID: ${isvPartnerId}
124
+ - Merchant Partner ID: ${merchantPartnerId || 'Missing'}
125
+ - OAuth2 Token: ${oauth2Token ? 'Provided' : 'Missing'}
126
+
127
+ **Troubleshooting:**
128
+ 1. Verify OAuth2 token is valid and not expired
129
+ 2. Ensure merchant partner ID is correct (8 characters)
130
+ 3. Confirm ISV has authorization to act on behalf of merchant
131
+ 4. Check private key matches public key registered with payware`
132
+ }]
133
+ };
134
+ }
135
+ }
136
+ };