@payware/mcp-server 1.2.0 → 1.3.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 (58) hide show
  1. package/README.md +5 -0
  2. package/package.json +69 -66
  3. package/src/auth/sandbox-setup.js +186 -186
  4. package/src/isv/index.js +29 -1
  5. package/src/isv/invitations/index.js +471 -0
  6. package/src/isv/oauth2/obtain-token.js +19 -8
  7. package/src/isv/oauth2/token-helper.js +5 -2
  8. package/src/isv/poi/cancel-price.js +2 -10
  9. package/src/isv/poi/create.js +19 -0
  10. package/src/isv/poi/get-poi.js +2 -10
  11. package/src/isv/poi/get-qrcode.js +2 -10
  12. package/src/isv/poi/get-status.js +2 -10
  13. package/src/isv/poi/index.js +5 -0
  14. package/src/isv/poi/list-pois.js +2 -10
  15. package/src/isv/poi/set-price.js +217 -225
  16. package/src/isv/products/create-product.js +313 -313
  17. package/src/isv/products/update-product.js +264 -264
  18. package/src/isv/reference/index.js +249 -0
  19. package/src/isv/shops/index.js +22 -0
  20. package/src/isv/transactions/cancel-transaction.js +41 -10
  21. package/src/isv/transactions/create-transaction.js +20 -4
  22. package/src/isv/transactions/get-status.js +18 -11
  23. package/src/isv/transactions/process-transaction.js +160 -42
  24. package/src/isv/transactions/simulate-callback.js +128 -109
  25. package/src/isv/transactions/transaction-history.js +86 -90
  26. package/src/merchant/data/generate-report.js +19 -1
  27. package/src/merchant/index.js +21 -1
  28. package/src/merchant/logs/index.js +366 -0
  29. package/src/merchant/products/create-product.js +287 -287
  30. package/src/merchant/products/update-product.js +281 -281
  31. package/src/merchant/shops/index.js +18 -0
  32. package/src/merchant/transactions/cancel-transaction.js +10 -13
  33. package/src/merchant/transactions/create-transaction.js +88 -8
  34. package/src/merchant/transactions/get-status.js +40 -11
  35. package/src/merchant/transactions/process-transaction.js +2 -10
  36. package/src/merchant/transactions/simulate-callback.js +68 -9
  37. package/src/merchant/transactions/transaction-history.js +275 -257
  38. package/src/payment-institution/transactions/create-pi-transaction.js +2 -10
  39. package/src/payment-institution/transactions/finalize-transaction.js +333 -340
  40. package/src/payment-institution/transactions/get-transaction-history.js +2 -10
  41. package/src/payment-institution/transactions/get-transaction-status.js +38 -11
  42. package/src/payment-institution/transactions/process-pi-transaction.js +2 -10
  43. package/src/payment-institution/transactions/simulate-pi-callback.js +49 -9
  44. package/src/payment-institution/transactions/soundbite-transaction.js +2 -10
  45. package/src/shared/api-errors.js +188 -0
  46. package/src/shared/auth-headers.js +62 -0
  47. package/src/shared/data/data-api.js +11 -10
  48. package/src/shared/deep-links/api.js +5 -4
  49. package/src/shared/logs/logs-api.js +242 -0
  50. package/src/shared/poi/poi-create-api.js +419 -0
  51. package/src/shared/products/products-api.js +17 -16
  52. package/src/shared/shops/shops-api.js +155 -0
  53. package/src/tools/advanced-code-generator.js +2255 -2246
  54. package/src/utils/code-examples/common/auth-examples.js +1484 -1481
  55. package/src/utils/code-examples/common/helpers.js +7 -4
  56. package/src/utils/code-examples/isv/oauth2.js +458 -600
  57. package/src/utils/code-examples/isv/transactions.js +815 -812
  58. package/MCP-SETUP.md +0 -190
@@ -1,265 +1,265 @@
1
- import { updateProduct } from '../../shared/products/products-api.js';
2
- import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
3
- import { PRODUCT_TYPES, OVERLAP_PRIORITY } from '../../shared/products/products-api.js';
4
-
5
- /**
6
- * Update product tool implementation for ISVs
7
- */
8
- export const updateProductTool = {
9
- name: "payware_products_update_product",
10
- description: `Update an existing product on behalf of a merchant (ISV operation). Only provide the fields you want to change.`,
11
-
12
- inputSchema: {
13
- type: "object",
14
- properties: {
15
- // ISV Authentication
16
- merchantPartnerId: {
17
- type: "string",
18
- description: "Target merchant partner ID (8 alphanumeric characters, e.g., 'PZAYNMVE')"
19
- },
20
- oauth2Token: {
21
- type: "string",
22
- description: "OAuth2 access token obtained from the merchant"
23
- },
24
- productId: {
25
- type: "string",
26
- description: "Product identifier to update (starts with 'pr')",
27
- pattern: "^pr[a-zA-Z0-9]+$"
28
- },
29
- // Product fields - same as merchant version
30
- name: {
31
- type: "string",
32
- description: "Product recognizable name",
33
- maxLength: 50
34
- },
35
- shortDescription: {
36
- type: "string",
37
- description: "Short product description",
38
- maxLength: 150
39
- },
40
- longDescription: {
41
- type: "string",
42
- description: "Long product description",
43
- maxLength: 1500
44
- },
45
- sku: {
46
- type: "string",
47
- description: "Stock Keeping Unit (SKU)",
48
- maxLength: 25
49
- },
50
- upc: {
51
- type: "string",
52
- description: "Universal Product Code (UPC)",
53
- maxLength: 15
54
- },
55
- shippable: {
56
- type: "string",
57
- enum: ["TRUE", "FALSE"],
58
- description: "Indicates if product requires delivery address"
59
- },
60
- active: {
61
- type: "string",
62
- enum: ["TRUE", "FALSE"],
63
- description: "Indicates if product can serve as payment source"
64
- },
65
- shop: {
66
- type: "string",
67
- description: "Shop code",
68
- maxLength: 10
69
- },
70
- productType: {
71
- type: "string",
72
- enum: Object.values(PRODUCT_TYPES),
73
- description: "Type of product"
74
- },
75
- regularPrice: {
76
- type: "string",
77
- description: "Product regular price (positive number with max 2 decimals)"
78
- },
79
- currency: {
80
- type: "string",
81
- pattern: "^[A-Z]{3}$",
82
- description: "Price currency (3-character ISO code)"
83
- },
84
- overlapPriority: {
85
- type: "string",
86
- enum: Object.values(OVERLAP_PRIORITY),
87
- description: "Priority when overlapping price schedules exist"
88
- },
89
- timeToLive: {
90
- type: "number",
91
- description: "Time allowed for product payment in seconds (60-2592000)",
92
- minimum: 60,
93
- maximum: 2592000
94
- },
95
- activeFrom: {
96
- type: "string",
97
- pattern: "^\\d{4}-\\d{2}-\\d{2}$",
98
- description: "Product active state starting date (YYYY-MM-DD format)"
99
- },
100
- activeTo: {
101
- type: "string",
102
- pattern: "^\\d{4}-\\d{2}-\\d{2}$",
103
- description: "Product active state ending date (YYYY-MM-DD format)"
104
- },
105
- timeZone: {
106
- type: "string",
107
- description: "Product state scheduling timezone (IANA format, e.g., 'Europe/Sofia')"
108
- },
109
- imageUrl: {
110
- type: "string",
111
- description: "URL pointing to external product image resource",
112
- maxLength: 150,
113
- format: "uri"
114
- },
115
- termsUrl: {
116
- type: "string",
117
- description: "URL pointing to external terms and conditions resource",
118
- maxLength: 150,
119
- format: "uri"
120
- },
121
- termsText: {
122
- type: "string",
123
- description: "Terms and conditions text",
124
- maxLength: 3000
125
- },
126
- useSandbox: {
127
- type: "boolean",
128
- description: "Use sandbox environment",
129
- default: true
130
- }
131
- },
132
- required: ["merchantPartnerId", "oauth2Token", "productId"]
133
- },
134
-
135
- async handler(args) {
136
- const {
137
- merchantPartnerId,
138
- oauth2Token,
139
- productId,
140
- name,
141
- shortDescription,
142
- longDescription,
143
- sku,
144
- upc,
145
- shippable,
146
- active,
147
- shop,
148
- productType,
149
- regularPrice,
150
- currency,
151
- overlapPriority,
152
- timeToLive,
153
- activeFrom,
154
- activeTo,
155
- timeZone,
156
- imageUrl,
157
- termsUrl,
158
- termsText,
159
- useSandbox = true
160
- } = args;
161
-
162
- // ISV validation
163
- if (!merchantPartnerId) {
164
- throw new Error("Merchant Partner ID is required for ISV operations");
165
- }
166
-
167
- if (!oauth2Token) {
168
- throw new Error("OAuth2 token is required for ISV operations");
169
- }
170
-
171
- if (!productId) {
172
- throw new Error("Product ID is required");
173
- }
174
-
175
- // Get ISV credentials
176
- const isvPartnerId = getPartnerIdSafe();
177
- const privateKey = getPrivateKeySafe();
178
-
179
- if (!isvPartnerId || !privateKey) {
180
- throw new Error("ISV credentials are required");
181
- }
182
-
183
- // Build prData object only with provided fields
184
- const prData = {};
185
- if (productType !== undefined) prData.type = productType;
186
- if (regularPrice !== undefined) prData.regularPrice = regularPrice;
187
- if (currency !== undefined) prData.currency = currency;
188
- if (overlapPriority !== undefined) prData.overlapPriority = overlapPriority;
189
- if (timeToLive !== undefined) prData.timeToLive = timeToLive;
190
- if (activeFrom !== undefined) prData.activeFrom = activeFrom;
191
- if (activeTo !== undefined) prData.activeTo = activeTo;
192
- if (timeZone !== undefined) prData.timeZone = timeZone;
193
-
194
- // Build prOptions object only with provided fields
195
- const prOptions = {};
196
- if (imageUrl !== undefined) prOptions.imageUrl = imageUrl;
197
- if (termsUrl !== undefined) prOptions.termsUrl = termsUrl;
198
- if (termsText !== undefined) prOptions.termsText = termsText;
199
-
200
- try {
201
- const result = await updateProduct({
202
- productId,
203
- name,
204
- shortDescription,
205
- longDescription,
206
- sku,
207
- upc,
208
- shippable,
209
- active,
210
- shop,
211
- prData,
212
- prOptions,
213
- partnerType: 'isv',
214
- isvPartnerId,
215
- privateKey,
216
- merchantPartnerId,
217
- oauth2Token,
218
- useSandbox
219
- });
220
-
221
- const product = result.data;
222
-
223
- return {
224
- content: [{
225
- type: "text",
226
- text: `✅ **Product Updated Successfully (ISV -> Merchant: ${merchantPartnerId})**
227
-
228
- **Updated Product Details:**
229
- - ID: ${product.productId}
230
- - Name: ${product.name}
231
- - Type: ${product.type}
232
- - Price: ${product.regularPrice} ${product.currencyCode}
233
- - Status: ${product.active ? '✅ Active' : '⏸️ Inactive'}
234
- - Shop: ${product.shopCode} (${product.shopName})
235
-
236
- **ISV Integration Details:**
237
- - ISV Partner: ${isvPartnerId}
238
- - Target Merchant: ${merchantPartnerId}
239
- - OAuth2 Token: ${oauth2Token.substring(0, 8)}...
240
-
241
- **API Response:**
242
- \`\`\`json
243
- ${JSON.stringify(product, null, 2)}
244
- \`\`\``
245
- }]
246
- };
247
- } catch (error) {
248
- return {
249
- content: [{
250
- type: "text",
251
- text: `❌ **Product Update Failed**
252
-
253
- **Error Details:**
254
- - Message: ${error.message}
255
- - Product ID: ${productId}
256
-
257
- **ISV Authentication Check:**
258
- - ISV Partner ID: ${isvPartnerId}
259
- - Merchant Partner ID: ${merchantPartnerId || 'Missing'}
260
- - OAuth2 Token: ${oauth2Token ? 'Provided' : 'Missing'}`
261
- }]
262
- };
263
- }
264
- }
1
+ import { updateProduct } from '../../shared/products/products-api.js';
2
+ import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
3
+ import { PRODUCT_TYPES, OVERLAP_PRIORITY } from '../../shared/products/products-api.js';
4
+
5
+ /**
6
+ * Update product tool implementation for ISVs
7
+ */
8
+ export const updateProductTool = {
9
+ name: "payware_products_update_product",
10
+ description: `Update an existing product on behalf of a merchant (ISV operation). Only provide the fields you want to change.`,
11
+
12
+ inputSchema: {
13
+ type: "object",
14
+ properties: {
15
+ // ISV Authentication
16
+ merchantPartnerId: {
17
+ type: "string",
18
+ description: "Target merchant partner ID (8 alphanumeric characters, e.g., 'PZAYNMVE')"
19
+ },
20
+ oauth2Token: {
21
+ type: "string",
22
+ description: "OAuth2 access token obtained from the merchant"
23
+ },
24
+ productId: {
25
+ type: "string",
26
+ description: "Product identifier to update (starts with 'pr')",
27
+ pattern: "^pr[a-zA-Z0-9]+$"
28
+ },
29
+ // Product fields - same as merchant version
30
+ name: {
31
+ type: "string",
32
+ description: "Product recognizable name",
33
+ maxLength: 50
34
+ },
35
+ shortDescription: {
36
+ type: "string",
37
+ description: "Short product description",
38
+ maxLength: 150
39
+ },
40
+ longDescription: {
41
+ type: "string",
42
+ description: "Long product description",
43
+ maxLength: 1500
44
+ },
45
+ sku: {
46
+ type: "string",
47
+ description: "Stock Keeping Unit (SKU)",
48
+ maxLength: 25
49
+ },
50
+ upc: {
51
+ type: "string",
52
+ description: "Universal Product Code (UPC)",
53
+ maxLength: 15
54
+ },
55
+ shippable: {
56
+ type: "string",
57
+ enum: ["TRUE", "FALSE"],
58
+ description: "Indicates if product requires delivery address"
59
+ },
60
+ active: {
61
+ type: "string",
62
+ enum: ["TRUE", "FALSE"],
63
+ description: "Indicates if product can serve as payment source"
64
+ },
65
+ shop: {
66
+ type: "string",
67
+ description: "Shop code",
68
+ maxLength: 10
69
+ },
70
+ productType: {
71
+ type: "string",
72
+ enum: Object.values(PRODUCT_TYPES),
73
+ description: "Type of product"
74
+ },
75
+ regularPrice: {
76
+ type: "string",
77
+ description: "Product regular price as a decimal string. Zero or positive, at most 12 integer digits, and no more decimals than the currency's minor unit (0 for JPY, 2 for EUR, 3 for KWD, 8 for BTC). Returned as a string too."
78
+ },
79
+ currency: {
80
+ type: "string",
81
+ pattern: "^[A-Z]{3}$",
82
+ description: "Price currency (3-character ISO code)"
83
+ },
84
+ overlapPriority: {
85
+ type: "string",
86
+ enum: Object.values(OVERLAP_PRIORITY),
87
+ description: "Priority when overlapping price schedules exist"
88
+ },
89
+ timeToLive: {
90
+ type: "number",
91
+ description: "Time allowed for product payment in seconds (60-2592000)",
92
+ minimum: 60,
93
+ maximum: 2592000
94
+ },
95
+ activeFrom: {
96
+ type: "string",
97
+ pattern: "^\\d{4}-\\d{2}-\\d{2}$",
98
+ description: "Product active state starting date (YYYY-MM-DD format)"
99
+ },
100
+ activeTo: {
101
+ type: "string",
102
+ pattern: "^\\d{4}-\\d{2}-\\d{2}$",
103
+ description: "Product active state ending date (YYYY-MM-DD format)"
104
+ },
105
+ timeZone: {
106
+ type: "string",
107
+ description: "Product state scheduling timezone (IANA format, e.g., 'Europe/Sofia')"
108
+ },
109
+ imageUrl: {
110
+ type: "string",
111
+ description: "URL pointing to external product image resource",
112
+ maxLength: 150,
113
+ format: "uri"
114
+ },
115
+ termsUrl: {
116
+ type: "string",
117
+ description: "URL pointing to external terms and conditions resource",
118
+ maxLength: 150,
119
+ format: "uri"
120
+ },
121
+ termsText: {
122
+ type: "string",
123
+ description: "Terms and conditions text",
124
+ maxLength: 3000
125
+ },
126
+ useSandbox: {
127
+ type: "boolean",
128
+ description: "Use sandbox environment",
129
+ default: true
130
+ }
131
+ },
132
+ required: ["merchantPartnerId", "oauth2Token", "productId"]
133
+ },
134
+
135
+ async handler(args) {
136
+ const {
137
+ merchantPartnerId,
138
+ oauth2Token,
139
+ productId,
140
+ name,
141
+ shortDescription,
142
+ longDescription,
143
+ sku,
144
+ upc,
145
+ shippable,
146
+ active,
147
+ shop,
148
+ productType,
149
+ regularPrice,
150
+ currency,
151
+ overlapPriority,
152
+ timeToLive,
153
+ activeFrom,
154
+ activeTo,
155
+ timeZone,
156
+ imageUrl,
157
+ termsUrl,
158
+ termsText,
159
+ useSandbox = true
160
+ } = args;
161
+
162
+ // ISV validation
163
+ if (!merchantPartnerId) {
164
+ throw new Error("Merchant Partner ID is required for ISV operations");
165
+ }
166
+
167
+ if (!oauth2Token) {
168
+ throw new Error("OAuth2 token is required for ISV operations");
169
+ }
170
+
171
+ if (!productId) {
172
+ throw new Error("Product ID is required");
173
+ }
174
+
175
+ // Get ISV credentials
176
+ const isvPartnerId = getPartnerIdSafe();
177
+ const privateKey = getPrivateKeySafe();
178
+
179
+ if (!isvPartnerId || !privateKey) {
180
+ throw new Error("ISV credentials are required");
181
+ }
182
+
183
+ // Build prData object only with provided fields
184
+ const prData = {};
185
+ if (productType !== undefined) prData.type = productType;
186
+ if (regularPrice !== undefined) prData.regularPrice = regularPrice;
187
+ if (currency !== undefined) prData.currency = currency;
188
+ if (overlapPriority !== undefined) prData.overlapPriority = overlapPriority;
189
+ if (timeToLive !== undefined) prData.timeToLive = timeToLive;
190
+ if (activeFrom !== undefined) prData.activeFrom = activeFrom;
191
+ if (activeTo !== undefined) prData.activeTo = activeTo;
192
+ if (timeZone !== undefined) prData.timeZone = timeZone;
193
+
194
+ // Build prOptions object only with provided fields
195
+ const prOptions = {};
196
+ if (imageUrl !== undefined) prOptions.imageUrl = imageUrl;
197
+ if (termsUrl !== undefined) prOptions.termsUrl = termsUrl;
198
+ if (termsText !== undefined) prOptions.termsText = termsText;
199
+
200
+ try {
201
+ const result = await updateProduct({
202
+ productId,
203
+ name,
204
+ shortDescription,
205
+ longDescription,
206
+ sku,
207
+ upc,
208
+ shippable,
209
+ active,
210
+ shop,
211
+ prData,
212
+ prOptions,
213
+ partnerType: 'isv',
214
+ isvPartnerId,
215
+ privateKey,
216
+ merchantPartnerId,
217
+ oauth2Token,
218
+ useSandbox
219
+ });
220
+
221
+ const product = result.data;
222
+
223
+ return {
224
+ content: [{
225
+ type: "text",
226
+ text: `✅ **Product Updated Successfully (ISV -> Merchant: ${merchantPartnerId})**
227
+
228
+ **Updated Product Details:**
229
+ - ID: ${product.productId}
230
+ - Name: ${product.name}
231
+ - Type: ${product.type}
232
+ - Price: ${product.regularPrice} ${product.currencyCode}
233
+ - Status: ${product.active ? '✅ Active' : '⏸️ Inactive'}
234
+ - Shop: ${product.shopCode} (${product.shopName})
235
+
236
+ **ISV Integration Details:**
237
+ - ISV Partner: ${isvPartnerId}
238
+ - Target Merchant: ${merchantPartnerId}
239
+ - OAuth2 Token: ${oauth2Token.substring(0, 8)}...
240
+
241
+ **API Response:**
242
+ \`\`\`json
243
+ ${JSON.stringify(product, null, 2)}
244
+ \`\`\``
245
+ }]
246
+ };
247
+ } catch (error) {
248
+ return {
249
+ content: [{
250
+ type: "text",
251
+ text: `❌ **Product Update Failed**
252
+
253
+ **Error Details:**
254
+ - Message: ${error.message}
255
+ - Product ID: ${productId}
256
+
257
+ **ISV Authentication Check:**
258
+ - ISV Partner ID: ${isvPartnerId}
259
+ - Merchant Partner ID: ${merchantPartnerId || 'Missing'}
260
+ - OAuth2 Token: ${oauth2Token ? 'Provided' : 'Missing'}`
261
+ }]
262
+ };
263
+ }
264
+ }
265
265
  };