@payware/mcp-server 1.1.1 β†’ 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 (127) hide show
  1. package/.env.example +0 -0
  2. package/README.md +22 -16
  3. package/check-keys.js +0 -0
  4. package/keys/README.md +0 -0
  5. package/mcp-config.json +0 -0
  6. package/package.json +69 -66
  7. package/payware-mcp-config.json +0 -0
  8. package/src/auth/rsa-keys.js +0 -0
  9. package/src/auth/sandbox-setup.js +186 -186
  10. package/src/config/env.js +0 -0
  11. package/src/config/partner-types.js +0 -0
  12. package/src/core/auth/jwt-factory.js +4 -4
  13. package/src/core/auth/jwt-token.js +107 -66
  14. package/src/core/utils/json-serializer.js +5 -5
  15. package/src/core/utils/key-utils.js +0 -0
  16. package/src/index.js +0 -0
  17. package/src/isv/data/index.js +0 -0
  18. package/src/isv/deep-links/delete-product-link.js +0 -0
  19. package/src/isv/deep-links/delete-transaction-link.js +0 -0
  20. package/src/isv/deep-links/get-product-link.js +0 -0
  21. package/src/isv/deep-links/get-transaction-link.js +0 -0
  22. package/src/isv/deep-links/index.js +0 -0
  23. package/src/isv/index.js +29 -1
  24. package/src/isv/invitations/index.js +471 -0
  25. package/src/isv/oauth2/create-token-simple.js +0 -0
  26. package/src/isv/oauth2/get-token-info.js +0 -0
  27. package/src/isv/oauth2/obtain-token.js +19 -8
  28. package/src/isv/oauth2/token-helper.js +5 -2
  29. package/src/isv/poi/cancel-price.js +2 -10
  30. package/src/isv/poi/create.js +19 -0
  31. package/src/isv/poi/get-poi.js +2 -10
  32. package/src/isv/poi/get-qrcode.js +2 -10
  33. package/src/isv/poi/get-status.js +2 -10
  34. package/src/isv/poi/index.js +5 -0
  35. package/src/isv/poi/list-pois.js +2 -10
  36. package/src/isv/poi/set-price.js +217 -225
  37. package/src/isv/products/audios.js +0 -0
  38. package/src/isv/products/create-product.js +313 -313
  39. package/src/isv/products/delete-product.js +0 -0
  40. package/src/isv/products/get-product-image.js +0 -0
  41. package/src/isv/products/get-product.js +0 -0
  42. package/src/isv/products/index.js +0 -0
  43. package/src/isv/products/list-products.js +0 -0
  44. package/src/isv/products/schedules.js +0 -0
  45. package/src/isv/products/update-product.js +264 -264
  46. package/src/isv/reference/index.js +249 -0
  47. package/src/isv/shops/index.js +22 -0
  48. package/src/isv/transactions/cancel-transaction.js +43 -12
  49. package/src/isv/transactions/create-transaction.js +22 -6
  50. package/src/isv/transactions/get-status.js +18 -11
  51. package/src/isv/transactions/process-transaction.js +160 -42
  52. package/src/isv/transactions/simulate-callback.js +128 -109
  53. package/src/isv/transactions/transaction-history.js +86 -90
  54. package/src/isv/utils/auth.js +2 -2
  55. package/src/mcp-proxy.js +0 -0
  56. package/src/merchant/data/export-report.js +0 -0
  57. package/src/merchant/data/generate-report.js +19 -1
  58. package/src/merchant/data/get-export-list.js +0 -0
  59. package/src/merchant/data/get-report-requests.js +0 -0
  60. package/src/merchant/data/get-report-status.js +0 -0
  61. package/src/merchant/data/index.js +0 -0
  62. package/src/merchant/data/list-reports.js +0 -0
  63. package/src/merchant/deep-links/delete-product-link.js +0 -0
  64. package/src/merchant/deep-links/delete-transaction-link.js +0 -0
  65. package/src/merchant/deep-links/get-product-link.js +0 -0
  66. package/src/merchant/deep-links/get-transaction-link.js +0 -0
  67. package/src/merchant/deep-links/index.js +0 -0
  68. package/src/merchant/index.js +21 -1
  69. package/src/merchant/logs/index.js +366 -0
  70. package/src/merchant/products/audios.js +0 -0
  71. package/src/merchant/products/create-product.js +287 -287
  72. package/src/merchant/products/delete-product.js +0 -0
  73. package/src/merchant/products/get-product-image.js +0 -0
  74. package/src/merchant/products/get-product.js +0 -0
  75. package/src/merchant/products/index.js +0 -0
  76. package/src/merchant/products/list-products.js +0 -0
  77. package/src/merchant/products/schedules.js +0 -0
  78. package/src/merchant/products/update-product.js +281 -281
  79. package/src/merchant/shops/index.js +18 -0
  80. package/src/merchant/transactions/cancel-transaction.js +16 -19
  81. package/src/merchant/transactions/create-transaction.js +99 -19
  82. package/src/merchant/transactions/get-status.js +41 -12
  83. package/src/merchant/transactions/process-transaction.js +8 -16
  84. package/src/merchant/transactions/simulate-callback.js +68 -9
  85. package/src/merchant/transactions/transaction-history.js +275 -257
  86. package/src/payment-institution/data/index.js +0 -0
  87. package/src/payment-institution/deep-links/delete-transaction-link.js +0 -0
  88. package/src/payment-institution/deep-links/get-transaction-link.js +0 -0
  89. package/src/payment-institution/deep-links/index.js +0 -0
  90. package/src/payment-institution/index.js +0 -0
  91. package/src/payment-institution/transactions/create-pi-transaction.js +6 -14
  92. package/src/payment-institution/transactions/finalize-transaction.js +333 -340
  93. package/src/payment-institution/transactions/get-transaction-history.js +3 -11
  94. package/src/payment-institution/transactions/get-transaction-status.js +39 -12
  95. package/src/payment-institution/transactions/process-pi-transaction.js +5 -13
  96. package/src/payment-institution/transactions/simulate-pi-callback.js +49 -9
  97. package/src/payment-institution/transactions/soundbite-transaction.js +5 -13
  98. package/src/proxy-server.js +0 -0
  99. package/src/shared/api-errors.js +188 -0
  100. package/src/shared/auth-headers.js +62 -0
  101. package/src/shared/data/data-api.js +11 -10
  102. package/src/shared/deep-links/api.js +5 -4
  103. package/src/shared/index.js +0 -0
  104. package/src/shared/logs/logs-api.js +242 -0
  105. package/src/shared/poi/poi-create-api.js +419 -0
  106. package/src/shared/products/products-api.js +17 -16
  107. package/src/shared/shops/shops-api.js +155 -0
  108. package/src/tools/advanced-code-generator.js +2255 -2246
  109. package/src/utils/code-examples/common/auth-examples.js +1484 -1481
  110. package/src/utils/code-examples/common/helpers.js +7 -4
  111. package/src/utils/code-examples/common/utils-examples.js +0 -0
  112. package/src/utils/code-examples/frameworks/examples.js +4 -4
  113. package/src/utils/code-examples/index.js +0 -0
  114. package/src/utils/code-examples/isv/oauth2.js +458 -600
  115. package/src/utils/code-examples/isv/products.js +8 -8
  116. package/src/utils/code-examples/isv/transactions.js +815 -812
  117. package/src/utils/code-examples/merchant/products.js +0 -0
  118. package/src/utils/code-examples/merchant/transactions.js +9 -9
  119. package/src/utils/code-examples/payment-institution/transactions.js +0 -0
  120. package/src/utils/code-examples/shared/data.js +0 -0
  121. package/src/utils/code-examples/shared/deep-links.js +0 -0
  122. package/src/utils/code-examples/shared/soundbites.js +0 -0
  123. package/src/utils/code-examples.js +24 -24
  124. package/src/utils/format-request.js +3 -3
  125. package/src/utils/json-formatter.js +20 -20
  126. package/src/utils/server-info.js +0 -0
  127. package/MCP-SETUP.md +0 -190
@@ -1,314 +1,314 @@
1
- import { createProduct } 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
- * Create product tool implementation for ISVs
7
- */
8
- export const createProductTool = {
9
- name: "payware_products_create_product",
10
- description: `Create a new product for inventory management and payment processing on behalf of a merchant (ISV operation).
11
-
12
- **ISV Authentication**: Requires ISV credentials and OAuth2 token from target merchant.
13
-
14
- **Product Structure:**
15
- πŸ“¦ **PRODUCT METADATA**: name, shortDescription, longDescription, sku, upc, shippable, active, shop
16
- πŸ’° **PRODUCT DATA** (prData object): type, regularPrice, currency, overlapPriority, timeToLive, activeFrom, activeTo, timeZone
17
- βš™οΈ **PRODUCT OPTIONS** (prOptions object): imageUrl, termsUrl, termsText
18
-
19
- **Required:** merchantPartnerId, oauth2Token, name`,
20
-
21
- inputSchema: {
22
- type: "object",
23
- properties: {
24
- // ISV Authentication
25
- merchantPartnerId: {
26
- type: "string",
27
- description: "Target merchant partner ID (8 alphanumeric characters, e.g., 'PZAYNMVE')"
28
- },
29
- oauth2Token: {
30
- type: "string",
31
- description: "OAuth2 access token obtained from the merchant"
32
- },
33
- // Product fields
34
- name: {
35
- type: "string",
36
- description: "Product recognizable name (required)",
37
- maxLength: 50
38
- },
39
- shortDescription: {
40
- type: "string",
41
- description: "Short product description",
42
- maxLength: 150
43
- },
44
- longDescription: {
45
- type: "string",
46
- description: "Long product description",
47
- maxLength: 1500
48
- },
49
- sku: {
50
- type: "string",
51
- description: "Stock Keeping Unit (SKU)",
52
- maxLength: 25
53
- },
54
- upc: {
55
- type: "string",
56
- description: "Universal Product Code (UPC)",
57
- maxLength: 15
58
- },
59
- shippable: {
60
- type: "string",
61
- enum: ["TRUE", "FALSE"],
62
- description: "Indicates if product requires delivery address",
63
- default: "FALSE"
64
- },
65
- active: {
66
- type: "string",
67
- enum: ["TRUE", "FALSE"],
68
- description: "Indicates if product can serve as payment source",
69
- default: "FALSE"
70
- },
71
- shop: {
72
- type: "string",
73
- description: "Shop code (if not supplied, default shop is used)",
74
- maxLength: 10
75
- },
76
- // Product Data Properties
77
- productType: {
78
- type: "string",
79
- enum: Object.values(PRODUCT_TYPES),
80
- description: "Type of product",
81
- default: PRODUCT_TYPES.ITEM
82
- },
83
- regularPrice: {
84
- type: "string",
85
- description: "Product regular price (positive number with max 2 decimals)",
86
- default: "0.00"
87
- },
88
- currency: {
89
- type: "string",
90
- pattern: "^[A-Z]{3}$",
91
- description: "Price currency (3-character ISO code)",
92
- default: "EUR"
93
- },
94
- overlapPriority: {
95
- type: "string",
96
- enum: Object.values(OVERLAP_PRIORITY),
97
- description: "Priority when overlapping price schedules exist",
98
- default: OVERLAP_PRIORITY.LOWEST
99
- },
100
- timeToLive: {
101
- type: "number",
102
- description: "Time allowed for product payment in seconds (60-2592000)",
103
- minimum: 60,
104
- maximum: 2592000,
105
- default: 86400
106
- },
107
- activeFrom: {
108
- type: "string",
109
- pattern: "^\\d{4}-\\d{2}-\\d{2}$",
110
- description: "Product active state starting date (YYYY-MM-DD format)"
111
- },
112
- activeTo: {
113
- type: "string",
114
- pattern: "^\\d{4}-\\d{2}-\\d{2}$",
115
- description: "Product active state ending date (YYYY-MM-DD format)"
116
- },
117
- timeZone: {
118
- type: "string",
119
- description: "Product state scheduling timezone (IANA format, e.g., 'Europe/Sofia')",
120
- default: "GMT"
121
- },
122
- // Product Options Properties
123
- imageUrl: {
124
- type: "string",
125
- description: "URL pointing to external product image resource",
126
- maxLength: 150,
127
- format: "uri"
128
- },
129
- termsUrl: {
130
- type: "string",
131
- description: "URL pointing to external terms and conditions resource",
132
- maxLength: 150,
133
- format: "uri"
134
- },
135
- termsText: {
136
- type: "string",
137
- description: "Terms and conditions text",
138
- maxLength: 3000
139
- },
140
- // ISV Environment
141
- useSandbox: {
142
- type: "boolean",
143
- description: "Use sandbox environment",
144
- default: true
145
- }
146
- },
147
- required: ["merchantPartnerId", "oauth2Token", "name"]
148
- },
149
-
150
- async handler(args) {
151
- const {
152
- merchantPartnerId,
153
- oauth2Token,
154
- name,
155
- shortDescription,
156
- longDescription,
157
- sku,
158
- upc,
159
- shippable = "FALSE",
160
- active = "FALSE",
161
- shop,
162
- productType = PRODUCT_TYPES.ITEM,
163
- regularPrice = "0.00",
164
- currency = "EUR",
165
- overlapPriority = OVERLAP_PRIORITY.LOWEST,
166
- timeToLive = 86400,
167
- activeFrom,
168
- activeTo,
169
- timeZone = "GMT",
170
- imageUrl,
171
- termsUrl,
172
- termsText,
173
- useSandbox = true
174
- } = args;
175
-
176
- // ISV validation
177
- if (!merchantPartnerId) {
178
- throw new Error("Merchant Partner ID is required for ISV operations");
179
- }
180
-
181
- if (!oauth2Token) {
182
- throw new Error("OAuth2 token is required for ISV operations");
183
- }
184
-
185
- if (!name) {
186
- throw new Error("Product name is required");
187
- }
188
-
189
- // Get ISV credentials
190
- const isvPartnerId = getPartnerIdSafe();
191
- const privateKey = getPrivateKeySafe(useSandbox);
192
-
193
- if (!isvPartnerId) {
194
- throw new Error("ISV Partner ID is required. Set PAYWARE_PARTNER_ID environment variable.");
195
- }
196
-
197
- if (!privateKey) {
198
- throw new Error("Private key is required. Set environment-specific private key variable.");
199
- }
200
-
201
- // Build prData object
202
- const prData = {
203
- type: productType,
204
- regularPrice,
205
- currency,
206
- overlapPriority,
207
- timeToLive,
208
- timeZone
209
- };
210
-
211
- if (activeFrom) prData.activeFrom = activeFrom;
212
- if (activeTo) prData.activeTo = activeTo;
213
-
214
- // Build prOptions object
215
- const prOptions = {};
216
- if (imageUrl) prOptions.imageUrl = imageUrl;
217
- if (termsUrl) prOptions.termsUrl = termsUrl;
218
- if (termsText) prOptions.termsText = termsText;
219
-
220
- try {
221
- const result = await createProduct({
222
- name,
223
- shortDescription,
224
- longDescription,
225
- sku,
226
- upc,
227
- shippable,
228
- active,
229
- shop,
230
- prData,
231
- prOptions,
232
- partnerType: 'isv',
233
- isvPartnerId,
234
- privateKey,
235
- merchantPartnerId,
236
- oauth2Token,
237
- useSandbox
238
- });
239
-
240
- const product = result.data;
241
-
242
- return {
243
- content: [{
244
- type: "text",
245
- text: `πŸ“¦ **Product Created Successfully (ISV -> Merchant: ${merchantPartnerId})**
246
-
247
- **Product Details:**
248
- - ID: ${product.productId}
249
- - Name: ${product.name}
250
- - Type: ${product.type}
251
- - Price: ${product.regularPrice} ${product.currencyCode}
252
- - Status: ${product.active ? 'βœ… Active' : '⏸️ Inactive'}
253
- - Shop: ${product.shopCode} (${product.shopName})
254
- ${product.shortDescription ? `- Description: ${product.shortDescription}` : ''}
255
- ${product.sku ? `- SKU: ${product.sku}` : ''}
256
- ${product.upc ? `- UPC: ${product.upc}` : ''}
257
-
258
- **Product Settings:**
259
- - Shippable: ${product.shippable ? 'Yes' : 'No'}
260
- - Time to Live: ${product.timeToLive} seconds
261
- - Sale Price: ${product.salePrice} ${product.currencyCode}
262
- - Overlap Priority: ${product.overlapPriority}
263
-
264
- **Active Period:**
265
- - From: ${product.activeFromZoned || product.activeFrom}
266
- - To: ${product.activeToZoned || product.activeTo}
267
- - Timezone: ${product.timeZone}
268
-
269
- **ISV Integration Details:**
270
- - ISV Partner: ${isvPartnerId}
271
- - Target Merchant: ${merchantPartnerId}
272
- - OAuth2 Token: ${oauth2Token.substring(0, 8)}...
273
-
274
- **API Response:**
275
- \`\`\`json
276
- ${JSON.stringify(product, null, 2)}
277
- \`\`\`
278
-
279
- **API Call Details:**
280
- - Endpoint: ${result.requestInfo.method} ${result.requestInfo.url}
281
- - Status: ${result.requestInfo.statusCode}
282
-
283
- **Next Steps:**
284
- 1. Save the product ID: \`${product.productId}\`
285
- 2. Use \`payware_products_get_product\` to view product details
286
- 3. Use \`payware_products_create_schedule\` to add price schedules
287
- 4. Use \`payware_products_register_audio\` to add soundbites`
288
- }]
289
- };
290
- } catch (error) {
291
- return {
292
- content: [{
293
- type: "text",
294
- text: `❌ **Product Creation Failed**
295
-
296
- **Error Details:**
297
- - Message: ${error.message}
298
-
299
- **ISV Authentication Check:**
300
- - ISV Partner ID: ${isvPartnerId}
301
- - Merchant Partner ID: ${merchantPartnerId || 'Missing'}
302
- - OAuth2 Token: ${oauth2Token ? 'Provided' : 'Missing'}
303
-
304
- **Troubleshooting:**
305
- 1. Verify OAuth2 token is valid and not expired
306
- 2. Ensure merchant partner ID is correct (8 characters)
307
- 3. Check product parameters (name, price format, dates)
308
- 4. Confirm ISV has authorization to act on behalf of merchant
309
- 5. Verify private key matches public key registered with payware`
310
- }]
311
- };
312
- }
313
- }
1
+ import { createProduct } 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
+ * Create product tool implementation for ISVs
7
+ */
8
+ export const createProductTool = {
9
+ name: "payware_products_create_product",
10
+ description: `Create a new product for inventory management and payment processing on behalf of a merchant (ISV operation).
11
+
12
+ **ISV Authentication**: Requires ISV credentials and OAuth2 token from target merchant.
13
+
14
+ **Product Structure:**
15
+ πŸ“¦ **PRODUCT METADATA**: name, shortDescription, longDescription, sku, upc, shippable, active, shop
16
+ πŸ’° **PRODUCT DATA** (prData object): type, regularPrice, currency, overlapPriority, timeToLive, activeFrom, activeTo, timeZone
17
+ βš™οΈ **PRODUCT OPTIONS** (prOptions object): imageUrl, termsUrl, termsText
18
+
19
+ **Required:** merchantPartnerId, oauth2Token, name`,
20
+
21
+ inputSchema: {
22
+ type: "object",
23
+ properties: {
24
+ // ISV Authentication
25
+ merchantPartnerId: {
26
+ type: "string",
27
+ description: "Target merchant partner ID (8 alphanumeric characters, e.g., 'PZAYNMVE')"
28
+ },
29
+ oauth2Token: {
30
+ type: "string",
31
+ description: "OAuth2 access token obtained from the merchant"
32
+ },
33
+ // Product fields
34
+ name: {
35
+ type: "string",
36
+ description: "Product recognizable name (required)",
37
+ maxLength: 50
38
+ },
39
+ shortDescription: {
40
+ type: "string",
41
+ description: "Short product description",
42
+ maxLength: 150
43
+ },
44
+ longDescription: {
45
+ type: "string",
46
+ description: "Long product description",
47
+ maxLength: 1500
48
+ },
49
+ sku: {
50
+ type: "string",
51
+ description: "Stock Keeping Unit (SKU)",
52
+ maxLength: 25
53
+ },
54
+ upc: {
55
+ type: "string",
56
+ description: "Universal Product Code (UPC)",
57
+ maxLength: 15
58
+ },
59
+ shippable: {
60
+ type: "string",
61
+ enum: ["TRUE", "FALSE"],
62
+ description: "Indicates if product requires delivery address",
63
+ default: "FALSE"
64
+ },
65
+ active: {
66
+ type: "string",
67
+ enum: ["TRUE", "FALSE"],
68
+ description: "Indicates if product can serve as payment source",
69
+ default: "FALSE"
70
+ },
71
+ shop: {
72
+ type: "string",
73
+ description: "Shop code (if not supplied, default shop is used)",
74
+ maxLength: 10
75
+ },
76
+ // Product Data Properties
77
+ productType: {
78
+ type: "string",
79
+ enum: Object.values(PRODUCT_TYPES),
80
+ description: "Type of product",
81
+ default: PRODUCT_TYPES.ITEM
82
+ },
83
+ regularPrice: {
84
+ type: "string",
85
+ 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.",
86
+ default: "0.00"
87
+ },
88
+ currency: {
89
+ type: "string",
90
+ pattern: "^[A-Z]{3}$",
91
+ description: "Price currency (3-character ISO code)",
92
+ default: "EUR"
93
+ },
94
+ overlapPriority: {
95
+ type: "string",
96
+ enum: Object.values(OVERLAP_PRIORITY),
97
+ description: "Priority when overlapping price schedules exist",
98
+ default: OVERLAP_PRIORITY.LOWEST
99
+ },
100
+ timeToLive: {
101
+ type: "number",
102
+ description: "Time allowed for product payment in seconds (60-2592000)",
103
+ minimum: 60,
104
+ maximum: 2592000,
105
+ default: 86400
106
+ },
107
+ activeFrom: {
108
+ type: "string",
109
+ pattern: "^\\d{4}-\\d{2}-\\d{2}$",
110
+ description: "Product active state starting date (YYYY-MM-DD format)"
111
+ },
112
+ activeTo: {
113
+ type: "string",
114
+ pattern: "^\\d{4}-\\d{2}-\\d{2}$",
115
+ description: "Product active state ending date (YYYY-MM-DD format)"
116
+ },
117
+ timeZone: {
118
+ type: "string",
119
+ description: "Product state scheduling timezone (IANA format, e.g., 'Europe/Sofia')",
120
+ default: "GMT"
121
+ },
122
+ // Product Options Properties
123
+ imageUrl: {
124
+ type: "string",
125
+ description: "URL pointing to external product image resource",
126
+ maxLength: 150,
127
+ format: "uri"
128
+ },
129
+ termsUrl: {
130
+ type: "string",
131
+ description: "URL pointing to external terms and conditions resource",
132
+ maxLength: 150,
133
+ format: "uri"
134
+ },
135
+ termsText: {
136
+ type: "string",
137
+ description: "Terms and conditions text",
138
+ maxLength: 3000
139
+ },
140
+ // ISV Environment
141
+ useSandbox: {
142
+ type: "boolean",
143
+ description: "Use sandbox environment",
144
+ default: true
145
+ }
146
+ },
147
+ required: ["merchantPartnerId", "oauth2Token", "name"]
148
+ },
149
+
150
+ async handler(args) {
151
+ const {
152
+ merchantPartnerId,
153
+ oauth2Token,
154
+ name,
155
+ shortDescription,
156
+ longDescription,
157
+ sku,
158
+ upc,
159
+ shippable = "FALSE",
160
+ active = "FALSE",
161
+ shop,
162
+ productType = PRODUCT_TYPES.ITEM,
163
+ regularPrice = "0.00",
164
+ currency = "EUR",
165
+ overlapPriority = OVERLAP_PRIORITY.LOWEST,
166
+ timeToLive = 86400,
167
+ activeFrom,
168
+ activeTo,
169
+ timeZone = "GMT",
170
+ imageUrl,
171
+ termsUrl,
172
+ termsText,
173
+ useSandbox = true
174
+ } = args;
175
+
176
+ // ISV validation
177
+ if (!merchantPartnerId) {
178
+ throw new Error("Merchant Partner ID is required for ISV operations");
179
+ }
180
+
181
+ if (!oauth2Token) {
182
+ throw new Error("OAuth2 token is required for ISV operations");
183
+ }
184
+
185
+ if (!name) {
186
+ throw new Error("Product name is required");
187
+ }
188
+
189
+ // Get ISV credentials
190
+ const isvPartnerId = getPartnerIdSafe();
191
+ const privateKey = getPrivateKeySafe(useSandbox);
192
+
193
+ if (!isvPartnerId) {
194
+ throw new Error("ISV Partner ID is required. Set PAYWARE_PARTNER_ID environment variable.");
195
+ }
196
+
197
+ if (!privateKey) {
198
+ throw new Error("Private key is required. Set environment-specific private key variable.");
199
+ }
200
+
201
+ // Build prData object
202
+ const prData = {
203
+ type: productType,
204
+ regularPrice,
205
+ currency,
206
+ overlapPriority,
207
+ timeToLive,
208
+ timeZone
209
+ };
210
+
211
+ if (activeFrom) prData.activeFrom = activeFrom;
212
+ if (activeTo) prData.activeTo = activeTo;
213
+
214
+ // Build prOptions object
215
+ const prOptions = {};
216
+ if (imageUrl) prOptions.imageUrl = imageUrl;
217
+ if (termsUrl) prOptions.termsUrl = termsUrl;
218
+ if (termsText) prOptions.termsText = termsText;
219
+
220
+ try {
221
+ const result = await createProduct({
222
+ name,
223
+ shortDescription,
224
+ longDescription,
225
+ sku,
226
+ upc,
227
+ shippable,
228
+ active,
229
+ shop,
230
+ prData,
231
+ prOptions,
232
+ partnerType: 'isv',
233
+ isvPartnerId,
234
+ privateKey,
235
+ merchantPartnerId,
236
+ oauth2Token,
237
+ useSandbox
238
+ });
239
+
240
+ const product = result.data;
241
+
242
+ return {
243
+ content: [{
244
+ type: "text",
245
+ text: `πŸ“¦ **Product Created Successfully (ISV -> Merchant: ${merchantPartnerId})**
246
+
247
+ **Product Details:**
248
+ - ID: ${product.productId}
249
+ - Name: ${product.name}
250
+ - Type: ${product.type}
251
+ - Price: ${product.regularPrice} ${product.currencyCode}
252
+ - Status: ${product.active ? 'βœ… Active' : '⏸️ Inactive'}
253
+ - Shop: ${product.shopCode} (${product.shopName})
254
+ ${product.shortDescription ? `- Description: ${product.shortDescription}` : ''}
255
+ ${product.sku ? `- SKU: ${product.sku}` : ''}
256
+ ${product.upc ? `- UPC: ${product.upc}` : ''}
257
+
258
+ **Product Settings:**
259
+ - Shippable: ${product.shippable ? 'Yes' : 'No'}
260
+ - Time to Live: ${product.timeToLive} seconds
261
+ - Sale Price: ${product.salePrice} ${product.currencyCode}
262
+ - Overlap Priority: ${product.overlapPriority}
263
+
264
+ **Active Period:**
265
+ - From: ${product.activeFromZoned || product.activeFrom}
266
+ - To: ${product.activeToZoned || product.activeTo}
267
+ - Timezone: ${product.timeZone}
268
+
269
+ **ISV Integration Details:**
270
+ - ISV Partner: ${isvPartnerId}
271
+ - Target Merchant: ${merchantPartnerId}
272
+ - OAuth2 Token: ${oauth2Token.substring(0, 8)}...
273
+
274
+ **API Response:**
275
+ \`\`\`json
276
+ ${JSON.stringify(product, null, 2)}
277
+ \`\`\`
278
+
279
+ **API Call Details:**
280
+ - Endpoint: ${result.requestInfo.method} ${result.requestInfo.url}
281
+ - Status: ${result.requestInfo.statusCode}
282
+
283
+ **Next Steps:**
284
+ 1. Save the product ID: \`${product.productId}\`
285
+ 2. Use \`payware_products_get_product\` to view product details
286
+ 3. Use \`payware_products_create_schedule\` to add price schedules
287
+ 4. Use \`payware_products_register_audio\` to add soundbites`
288
+ }]
289
+ };
290
+ } catch (error) {
291
+ return {
292
+ content: [{
293
+ type: "text",
294
+ text: `❌ **Product Creation Failed**
295
+
296
+ **Error Details:**
297
+ - Message: ${error.message}
298
+
299
+ **ISV Authentication Check:**
300
+ - ISV Partner ID: ${isvPartnerId}
301
+ - Merchant Partner ID: ${merchantPartnerId || 'Missing'}
302
+ - OAuth2 Token: ${oauth2Token ? 'Provided' : 'Missing'}
303
+
304
+ **Troubleshooting:**
305
+ 1. Verify OAuth2 token is valid and not expired
306
+ 2. Ensure merchant partner ID is correct (8 characters)
307
+ 3. Check product parameters (name, price format, dates)
308
+ 4. Confirm ISV has authorization to act on behalf of merchant
309
+ 5. Verify private key matches public key registered with payware`
310
+ }]
311
+ };
312
+ }
313
+ }
314
314
  };
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes