@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.
- package/.env.example +92 -0
- package/MCP-SETUP.md +190 -0
- package/README.md +483 -0
- package/check-keys.js +52 -0
- package/keys/README.md +112 -0
- package/mcp-config.json +9 -0
- package/package.json +66 -0
- package/payware-mcp-config.json +12 -0
- package/src/auth/rsa-keys.js +82 -0
- package/src/auth/sandbox-setup.js +187 -0
- package/src/config/env.js +229 -0
- package/src/config/partner-types.js +143 -0
- package/src/core/auth/jwt-factory.js +182 -0
- package/src/core/auth/jwt-token.js +735 -0
- package/src/core/utils/json-serializer.js +100 -0
- package/src/core/utils/key-utils.js +133 -0
- package/src/index.js +237 -0
- package/src/isv/data/index.js +291 -0
- package/src/isv/deep-links/delete-product-link.js +154 -0
- package/src/isv/deep-links/delete-transaction-link.js +154 -0
- package/src/isv/deep-links/get-product-link.js +167 -0
- package/src/isv/deep-links/get-transaction-link.js +167 -0
- package/src/isv/deep-links/index.js +23 -0
- package/src/isv/index.js +103 -0
- package/src/isv/oauth2/create-token-simple.js +46 -0
- package/src/isv/oauth2/get-token-info.js +157 -0
- package/src/isv/oauth2/obtain-token.js +189 -0
- package/src/isv/oauth2/token-helper.js +151 -0
- package/src/isv/products/audios.js +470 -0
- package/src/isv/products/create-product.js +314 -0
- package/src/isv/products/delete-product.js +119 -0
- package/src/isv/products/get-product-image.js +247 -0
- package/src/isv/products/get-product.js +168 -0
- package/src/isv/products/index.js +65 -0
- package/src/isv/products/list-products.js +136 -0
- package/src/isv/products/schedules.js +522 -0
- package/src/isv/products/update-product.js +265 -0
- package/src/isv/transactions/cancel-transaction.js +129 -0
- package/src/isv/transactions/create-transaction.js +361 -0
- package/src/isv/transactions/get-status.js +217 -0
- package/src/isv/transactions/process-transaction.js +145 -0
- package/src/isv/transactions/simulate-callback.js +146 -0
- package/src/isv/transactions/transaction-history.js +186 -0
- package/src/isv/utils/auth.js +159 -0
- package/src/mcp-proxy.js +150 -0
- package/src/merchant/data/export-report.js +108 -0
- package/src/merchant/data/generate-report.js +151 -0
- package/src/merchant/data/get-report-status.js +120 -0
- package/src/merchant/data/index.js +351 -0
- package/src/merchant/deep-links/delete-product-link.js +121 -0
- package/src/merchant/deep-links/delete-transaction-link.js +121 -0
- package/src/merchant/deep-links/get-product-link.js +134 -0
- package/src/merchant/deep-links/get-transaction-link.js +134 -0
- package/src/merchant/deep-links/index.js +23 -0
- package/src/merchant/index.js +92 -0
- package/src/merchant/products/audios.js +606 -0
- package/src/merchant/products/create-product.js +288 -0
- package/src/merchant/products/delete-product.js +111 -0
- package/src/merchant/products/get-product-image.js +252 -0
- package/src/merchant/products/get-product.js +144 -0
- package/src/merchant/products/index.js +65 -0
- package/src/merchant/products/list-products.js +112 -0
- package/src/merchant/products/schedules.js +646 -0
- package/src/merchant/products/update-product.js +282 -0
- package/src/merchant/transactions/cancel-transaction.js +241 -0
- package/src/merchant/transactions/create-transaction.js +482 -0
- package/src/merchant/transactions/get-status.js +196 -0
- package/src/merchant/transactions/process-transaction.js +349 -0
- package/src/merchant/transactions/simulate-callback.js +246 -0
- package/src/merchant/transactions/transaction-history.js +258 -0
- package/src/payment-institution/data/index.js +280 -0
- package/src/payment-institution/deep-links/delete-transaction-link.js +128 -0
- package/src/payment-institution/deep-links/get-transaction-link.js +141 -0
- package/src/payment-institution/deep-links/index.js +17 -0
- package/src/payment-institution/index.js +92 -0
- package/src/payment-institution/transactions/create-pi-transaction.js +484 -0
- package/src/payment-institution/transactions/finalize-transaction.js +340 -0
- package/src/payment-institution/transactions/get-transaction-history.js +269 -0
- package/src/payment-institution/transactions/get-transaction-status.js +234 -0
- package/src/payment-institution/transactions/process-pi-transaction.js +421 -0
- package/src/payment-institution/transactions/simulate-pi-callback.js +326 -0
- package/src/payment-institution/transactions/soundbite-transaction.js +269 -0
- package/src/proxy-server.js +205 -0
- package/src/shared/data/data-api.js +372 -0
- package/src/shared/deep-links/api.js +214 -0
- package/src/shared/index.js +44 -0
- package/src/shared/products/products-api.js +872 -0
- package/src/tools/advanced-code-generator.js +2247 -0
- package/src/utils/code-examples/common/auth-examples.js +1482 -0
- package/src/utils/code-examples/common/helpers.js +416 -0
- package/src/utils/code-examples/common/utils-examples.js +591 -0
- package/src/utils/code-examples/frameworks/examples.js +859 -0
- package/src/utils/code-examples/index.js +441 -0
- package/src/utils/code-examples/isv/oauth2.js +600 -0
- package/src/utils/code-examples/isv/products.js +666 -0
- package/src/utils/code-examples/isv/transactions.js +813 -0
- package/src/utils/code-examples/merchant/products.js +497 -0
- package/src/utils/code-examples/merchant/transactions.js +623 -0
- package/src/utils/code-examples/payment-institution/transactions.js +388 -0
- package/src/utils/code-examples/shared/data.js +607 -0
- package/src/utils/code-examples/shared/deep-links.js +662 -0
- package/src/utils/code-examples/shared/soundbites.js +808 -0
- package/src/utils/code-examples.js +646 -0
- package/src/utils/format-request.js +363 -0
- package/src/utils/json-formatter.js +249 -0
- package/src/utils/server-info.js +132 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ISV Data Tools - Complete Data API Implementation
|
|
3
|
+
* Production-only tools for data retrieval, reporting, and export functionality for ISVs
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
generateReport,
|
|
8
|
+
getReportStatus,
|
|
9
|
+
exportReport,
|
|
10
|
+
getExportStatus,
|
|
11
|
+
downloadExport,
|
|
12
|
+
cancelReport,
|
|
13
|
+
cancelExport,
|
|
14
|
+
REPORT_TYPES,
|
|
15
|
+
EXPORT_FORMATS,
|
|
16
|
+
LOCALES
|
|
17
|
+
} from '../../shared/data/data-api.js';
|
|
18
|
+
import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
|
|
19
|
+
|
|
20
|
+
// Create ISV data tool factory
|
|
21
|
+
const createISVDataTool = (toolName, apiFunction, description, additionalParams = {}) => ({
|
|
22
|
+
name: `payware_data_${toolName}`,
|
|
23
|
+
description: `${description} (ISV acting on behalf of merchant)`,
|
|
24
|
+
inputSchema: {
|
|
25
|
+
type: "object",
|
|
26
|
+
additionalProperties: false,
|
|
27
|
+
properties: {
|
|
28
|
+
merchantPartnerId: {
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "The merchant's partner ID (required for ISV operations)"
|
|
31
|
+
},
|
|
32
|
+
oauth2Token: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "OAuth2 access token obtained from the merchant"
|
|
35
|
+
},
|
|
36
|
+
isvPartnerId: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "ISV Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default.",
|
|
39
|
+
default: getPartnerIdSafe()
|
|
40
|
+
},
|
|
41
|
+
privateKey: {
|
|
42
|
+
type: "string",
|
|
43
|
+
description: "ISV RSA private key for authentication. Uses environment-specific private key as default.",
|
|
44
|
+
default: getPrivateKeySafe()
|
|
45
|
+
},
|
|
46
|
+
...additionalParams
|
|
47
|
+
},
|
|
48
|
+
required: ["merchantPartnerId", "oauth2Token", ...Object.keys(additionalParams)]
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
async handler(args) {
|
|
52
|
+
const {
|
|
53
|
+
merchantPartnerId,
|
|
54
|
+
oauth2Token,
|
|
55
|
+
isvPartnerId = getPartnerIdSafe(),
|
|
56
|
+
privateKey = getPrivateKeySafe()
|
|
57
|
+
} = args;
|
|
58
|
+
|
|
59
|
+
if (!isvPartnerId || !privateKey) {
|
|
60
|
+
throw new Error("ISV Partner ID and private key are required.");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!merchantPartnerId || !oauth2Token) {
|
|
64
|
+
throw new Error("Merchant Partner ID and OAuth2 token are required for ISV operations.");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
const result = await apiFunction({
|
|
69
|
+
...args,
|
|
70
|
+
partnerType: 'isv',
|
|
71
|
+
isvPartnerId,
|
|
72
|
+
privateKey,
|
|
73
|
+
merchantPartnerId,
|
|
74
|
+
oauth2Token
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
content: [{
|
|
79
|
+
type: "text",
|
|
80
|
+
text: `📊 **ISV ${description} Completed**
|
|
81
|
+
|
|
82
|
+
**Result:**
|
|
83
|
+
${JSON.stringify(result.data, null, 2)}
|
|
84
|
+
|
|
85
|
+
**ISV Context:**
|
|
86
|
+
- ISV Partner ID: ${isvPartnerId}
|
|
87
|
+
- Merchant Partner ID: ${merchantPartnerId}
|
|
88
|
+
- OAuth2 Token: ${oauth2Token.substring(0, 20)}...
|
|
89
|
+
|
|
90
|
+
**Note:** This operation was performed on behalf of the merchant using ISV authentication.`
|
|
91
|
+
}]
|
|
92
|
+
};
|
|
93
|
+
} catch (error) {
|
|
94
|
+
throw new Error(`ISV failed to ${toolName.replace('_', ' ')}: ${error.message}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Generate report tool for ISVs
|
|
101
|
+
*/
|
|
102
|
+
export const generateReportTool = {
|
|
103
|
+
name: "payware_data_generate_report",
|
|
104
|
+
description: "Generate an asynchronous data report for ISV data analysis and reporting on behalf of merchants. Production only - not supported in sandbox.",
|
|
105
|
+
inputSchema: {
|
|
106
|
+
type: "object",
|
|
107
|
+
additionalProperties: false,
|
|
108
|
+
properties: {
|
|
109
|
+
reportUnitId: {
|
|
110
|
+
type: "string",
|
|
111
|
+
description: "The ID of the report to generate",
|
|
112
|
+
enum: Object.values(REPORT_TYPES),
|
|
113
|
+
default: REPORT_TYPES.PROCESSED_TRANSACTIONS
|
|
114
|
+
},
|
|
115
|
+
merchantPartnerId: {
|
|
116
|
+
type: "string",
|
|
117
|
+
description: "The merchant's partner ID (required for ISV operations)"
|
|
118
|
+
},
|
|
119
|
+
oauth2Token: {
|
|
120
|
+
type: "string",
|
|
121
|
+
description: "OAuth2 access token obtained from the merchant"
|
|
122
|
+
},
|
|
123
|
+
dateFrom: {
|
|
124
|
+
type: "string",
|
|
125
|
+
description: "Start date for the reporting period (YYYY-MM-DD format). Required for premium reports.",
|
|
126
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
127
|
+
},
|
|
128
|
+
dateTo: {
|
|
129
|
+
type: "string",
|
|
130
|
+
description: "End date for the reporting period (YYYY-MM-DD format). Required for premium reports.",
|
|
131
|
+
pattern: "^\\d{4}-\\d{2}-\\d{2}$"
|
|
132
|
+
},
|
|
133
|
+
ignorePagination: {
|
|
134
|
+
type: "boolean",
|
|
135
|
+
description: "If true, return report as single continuous document. If false, paginate results.",
|
|
136
|
+
default: false
|
|
137
|
+
},
|
|
138
|
+
locale: {
|
|
139
|
+
type: "string",
|
|
140
|
+
description: "Locale for the report",
|
|
141
|
+
enum: Object.values(LOCALES),
|
|
142
|
+
default: LOCALES.ENGLISH_US
|
|
143
|
+
},
|
|
144
|
+
timeZone: {
|
|
145
|
+
type: "string",
|
|
146
|
+
description: "Timezone for date calculations (e.g., 'Europe/Sofia', 'America/New_York')",
|
|
147
|
+
default: "GMT"
|
|
148
|
+
},
|
|
149
|
+
isvPartnerId: {
|
|
150
|
+
type: "string",
|
|
151
|
+
description: "ISV Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default.",
|
|
152
|
+
default: getPartnerIdSafe()
|
|
153
|
+
},
|
|
154
|
+
privateKey: {
|
|
155
|
+
type: "string",
|
|
156
|
+
description: "ISV RSA private key for authentication. Uses environment-specific private key as default.",
|
|
157
|
+
default: getPrivateKeySafe()
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
required: ["reportUnitId", "merchantPartnerId", "oauth2Token"]
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
async handler(args) {
|
|
164
|
+
const {
|
|
165
|
+
reportUnitId,
|
|
166
|
+
merchantPartnerId,
|
|
167
|
+
oauth2Token,
|
|
168
|
+
dateFrom,
|
|
169
|
+
dateTo,
|
|
170
|
+
ignorePagination = false,
|
|
171
|
+
locale = LOCALES.ENGLISH_US,
|
|
172
|
+
timeZone = 'GMT',
|
|
173
|
+
isvPartnerId = getPartnerIdSafe(),
|
|
174
|
+
privateKey = getPrivateKeySafe()
|
|
175
|
+
} = args;
|
|
176
|
+
|
|
177
|
+
if (!isvPartnerId || !privateKey) {
|
|
178
|
+
throw new Error("ISV Partner ID and private key are required. Set PAYWARE_PARTNER_ID and environment-specific private key variables or provide them as parameters.");
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (!merchantPartnerId || !oauth2Token) {
|
|
182
|
+
throw new Error("Merchant Partner ID and OAuth2 token are required for ISV operations.");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
try {
|
|
186
|
+
const result = await generateReport({
|
|
187
|
+
reportUnitId,
|
|
188
|
+
dateFrom,
|
|
189
|
+
dateTo,
|
|
190
|
+
ignorePagination,
|
|
191
|
+
locale,
|
|
192
|
+
timeZone,
|
|
193
|
+
partnerType: 'isv',
|
|
194
|
+
isvPartnerId,
|
|
195
|
+
privateKey,
|
|
196
|
+
merchantPartnerId,
|
|
197
|
+
oauth2Token
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
content: [{
|
|
202
|
+
type: "text",
|
|
203
|
+
text: `📊 **ISV Data Report Generation Started**
|
|
204
|
+
|
|
205
|
+
**Report Details:**
|
|
206
|
+
- Request ID: ${result.data.requestId}
|
|
207
|
+
- Status: ${result.data.status}
|
|
208
|
+
- Report Type: ${reportUnitId}
|
|
209
|
+
- Generated: ${result.data.generatedAt}
|
|
210
|
+
|
|
211
|
+
**ISV Authentication:**
|
|
212
|
+
- ISV Partner ID: ${isvPartnerId}
|
|
213
|
+
- Merchant Partner ID: ${merchantPartnerId}
|
|
214
|
+
- OAuth2 Token: ${oauth2Token.substring(0, 20)}...
|
|
215
|
+
|
|
216
|
+
**Next Steps:**
|
|
217
|
+
1. Save the Request ID: \`${result.data.requestId}\`
|
|
218
|
+
2. Use "Get Report Status" tool to monitor progress
|
|
219
|
+
3. When status is "READY", use "Export Report" tool to get the data
|
|
220
|
+
|
|
221
|
+
**⚠️ Production Only & ISV Authorization Required:**
|
|
222
|
+
This feature requires proper OAuth2 authorization from the merchant and is only available in production.`
|
|
223
|
+
}]
|
|
224
|
+
};
|
|
225
|
+
} catch (error) {
|
|
226
|
+
throw new Error(`Failed to generate ISV report: ${error.message}`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// Create all other ISV data tools
|
|
232
|
+
export const getReportStatusTool = createISVDataTool('get_report_status', getReportStatus, 'Get Report Status', {
|
|
233
|
+
requestId: {
|
|
234
|
+
type: "string",
|
|
235
|
+
description: "The request ID returned from the report generation request (UUID format)"
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
export const exportReportTool = createISVDataTool('export_report', exportReport, 'Export Report', {
|
|
240
|
+
requestId: {
|
|
241
|
+
type: "string",
|
|
242
|
+
description: "The request ID from the report generation (UUID format)"
|
|
243
|
+
},
|
|
244
|
+
outputFormat: {
|
|
245
|
+
type: "string",
|
|
246
|
+
description: "Export format",
|
|
247
|
+
enum: Object.values(EXPORT_FORMATS),
|
|
248
|
+
default: EXPORT_FORMATS.PDF
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
export const getExportStatusTool = createISVDataTool('get_export_status', getExportStatus, 'Get Export Status', {
|
|
253
|
+
exportId: {
|
|
254
|
+
type: "string",
|
|
255
|
+
description: "The export ID returned from the export request (UUID format)"
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
export const downloadExportTool = createISVDataTool('download_export', downloadExport, 'Download Export', {
|
|
260
|
+
exportId: {
|
|
261
|
+
type: "string",
|
|
262
|
+
description: "The export ID from the export request (UUID format)"
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
export const cancelReportTool = createISVDataTool('cancel_report', cancelReport, 'Cancel Report', {
|
|
267
|
+
requestId: {
|
|
268
|
+
type: "string",
|
|
269
|
+
description: "The request ID of the report to cancel (UUID format)"
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
export const cancelExportTool = createISVDataTool('cancel_export', cancelExport, 'Cancel Export', {
|
|
274
|
+
exportId: {
|
|
275
|
+
type: "string",
|
|
276
|
+
description: "The export ID of the export to cancel (UUID format)"
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* All ISV data tools
|
|
282
|
+
*/
|
|
283
|
+
export const isvDataTools = [
|
|
284
|
+
generateReportTool,
|
|
285
|
+
getReportStatusTool,
|
|
286
|
+
exportReportTool,
|
|
287
|
+
getExportStatusTool,
|
|
288
|
+
downloadExportTool,
|
|
289
|
+
cancelReportTool,
|
|
290
|
+
cancelExportTool
|
|
291
|
+
];
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { deleteProductDeepLink } from '../../shared/deep-links/api.js';
|
|
2
|
+
import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Delete deep link for a product (ISV on behalf of merchant)
|
|
6
|
+
*/
|
|
7
|
+
export const deleteProductLinkTool = {
|
|
8
|
+
name: "payware_deep_links_delete_product_link",
|
|
9
|
+
description: `Delete an active deep link for a product on behalf of a merchant. Once deleted, the deep link URL will no longer redirect to the payware mobile app.
|
|
10
|
+
|
|
11
|
+
**ISV Authentication:**
|
|
12
|
+
- Requires ISV JWT token with merchant partner ID in 'aud' claim
|
|
13
|
+
- Requires OAuth2 token in 'sub' claim
|
|
14
|
+
|
|
15
|
+
**Use Cases:**
|
|
16
|
+
- Remove expired product links
|
|
17
|
+
- Clean up after product removal
|
|
18
|
+
- Security cleanup for discontinued products
|
|
19
|
+
|
|
20
|
+
**Important Notes:**
|
|
21
|
+
- Deep links are only supported in production environment
|
|
22
|
+
- Once deleted, the link cannot be recovered - you'll need to create a new one
|
|
23
|
+
- This operation is irreversible`,
|
|
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
|
+
merchantPartnerId: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "Partner ID of the merchant for whom the product is being deleted"
|
|
36
|
+
},
|
|
37
|
+
oauth2Token: {
|
|
38
|
+
type: "string",
|
|
39
|
+
description: "OAuth2 access token for merchant authorization"
|
|
40
|
+
},
|
|
41
|
+
isvPartnerId: {
|
|
42
|
+
type: "string",
|
|
43
|
+
description: "ISV Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default.",
|
|
44
|
+
default: getPartnerIdSafe()
|
|
45
|
+
},
|
|
46
|
+
privateKey: {
|
|
47
|
+
type: "string",
|
|
48
|
+
description: "ISV RSA private key for JWT token creation. Uses environment-specific private key as default.",
|
|
49
|
+
default: getPrivateKeySafe()
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
required: ["productId", "merchantPartnerId", "oauth2Token"]
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
async handler(args) {
|
|
56
|
+
const {
|
|
57
|
+
productId,
|
|
58
|
+
merchantPartnerId,
|
|
59
|
+
oauth2Token,
|
|
60
|
+
isvPartnerId = getPartnerIdSafe(),
|
|
61
|
+
privateKey = getPrivateKeySafe()
|
|
62
|
+
} = args;
|
|
63
|
+
|
|
64
|
+
if (!productId) {
|
|
65
|
+
throw new Error("productId is required");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!merchantPartnerId) {
|
|
69
|
+
throw new Error("merchantPartnerId is required for ISV operations");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!oauth2Token) {
|
|
73
|
+
throw new Error("oauth2Token is required for ISV operations");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!isvPartnerId) {
|
|
77
|
+
throw new Error("ISV Partner ID is required. Provide via 'isvPartnerId' parameter or set PAYWARE_PARTNER_ID environment variable.");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!privateKey) {
|
|
81
|
+
throw new Error("Private key is required. Provide via 'privateKey' parameter or set PAYWARE_PRIVATE_KEY environment variable.");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
const result = await deleteProductDeepLink({
|
|
86
|
+
productId,
|
|
87
|
+
partnerType: 'isv',
|
|
88
|
+
isvPartnerId,
|
|
89
|
+
privateKey,
|
|
90
|
+
merchantPartnerId,
|
|
91
|
+
oauth2Token
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
content: [{
|
|
96
|
+
type: "text",
|
|
97
|
+
text: `✅ **Product Deep Link Deleted (ISV)**
|
|
98
|
+
|
|
99
|
+
**Deletion Details:**
|
|
100
|
+
- Product ID: ${productId}
|
|
101
|
+
- Merchant: ${merchantPartnerId}
|
|
102
|
+
- Status: Successfully deleted
|
|
103
|
+
- Link URL: https://url.payware.eu/${productId} (now inactive)
|
|
104
|
+
|
|
105
|
+
**ISV Authentication:**
|
|
106
|
+
- ISV Partner ID: ${isvPartnerId}
|
|
107
|
+
- Merchant Partner ID: ${merchantPartnerId}
|
|
108
|
+
- OAuth2 Token: ${oauth2Token.substring(0, 10)}...
|
|
109
|
+
|
|
110
|
+
**API Call Details:**
|
|
111
|
+
- Endpoint: DELETE ${result.requestInfo.url}
|
|
112
|
+
- Status: ${result.requestInfo.statusCode}
|
|
113
|
+
- Method: ${result.requestInfo.method}
|
|
114
|
+
|
|
115
|
+
**Result:**
|
|
116
|
+
- The deep link is no longer active
|
|
117
|
+
- Mobile redirects will no longer work
|
|
118
|
+
- URL will return an error if accessed
|
|
119
|
+
|
|
120
|
+
**Important Notes:**
|
|
121
|
+
⚠️ This operation is irreversible
|
|
122
|
+
⚠️ Create a new link if needed using \`payware_deep_links_get_product_link\`
|
|
123
|
+
⚠️ Any existing shared links will stop working immediately`
|
|
124
|
+
}]
|
|
125
|
+
};
|
|
126
|
+
} catch (error) {
|
|
127
|
+
return {
|
|
128
|
+
content: [{
|
|
129
|
+
type: "text",
|
|
130
|
+
text: `❌ **Failed to Delete Product Deep Link (ISV)**
|
|
131
|
+
|
|
132
|
+
**Error Details:**
|
|
133
|
+
- Product ID: ${productId}
|
|
134
|
+
- Merchant: ${merchantPartnerId}
|
|
135
|
+
- Message: ${error.message}
|
|
136
|
+
|
|
137
|
+
**Common Issues:**
|
|
138
|
+
1. **Link not found**: Deep link may already be deleted or never existed
|
|
139
|
+
2. **Authentication failed**: Verify ISV partner ID, private key, and OAuth2 token
|
|
140
|
+
3. **Authorization failed**: Ensure OAuth2 token authorizes access to merchant
|
|
141
|
+
4. **Sandbox environment**: Deep links are production-only
|
|
142
|
+
5. **Invalid product ID**: Ensure product ID format is correct
|
|
143
|
+
|
|
144
|
+
**Troubleshooting:**
|
|
145
|
+
1. Check if deep link exists using \`payware_deep_links_get_product_link\`
|
|
146
|
+
2. Check OAuth2 token is valid and not expired
|
|
147
|
+
3. Ensure ISV has permission to access merchant data
|
|
148
|
+
4. Verify running in production environment
|
|
149
|
+
5. Ensure JWT authentication is working`
|
|
150
|
+
}]
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { deleteTransactionDeepLink } from '../../shared/deep-links/api.js';
|
|
2
|
+
import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Delete deep link for a transaction (ISV on behalf of merchant)
|
|
6
|
+
*/
|
|
7
|
+
export const deleteTransactionLinkTool = {
|
|
8
|
+
name: "payware_deep_links_delete_transaction_link",
|
|
9
|
+
description: `Delete an active deep link for a transaction on behalf of a merchant. Once deleted, the deep link URL will no longer redirect to the payware mobile app.
|
|
10
|
+
|
|
11
|
+
**ISV Authentication:**
|
|
12
|
+
- Requires ISV JWT token with merchant partner ID in 'aud' claim
|
|
13
|
+
- Requires OAuth2 token in 'sub' claim
|
|
14
|
+
|
|
15
|
+
**Use Cases:**
|
|
16
|
+
- Remove expired transaction links
|
|
17
|
+
- Clean up after transaction completion
|
|
18
|
+
- Security cleanup for sensitive transactions
|
|
19
|
+
|
|
20
|
+
**Important Notes:**
|
|
21
|
+
- Deep links are only supported in production environment
|
|
22
|
+
- Once deleted, the link cannot be recovered - you'll need to create a new one
|
|
23
|
+
- This operation is irreversible`,
|
|
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
|
+
merchantPartnerId: {
|
|
34
|
+
type: "string",
|
|
35
|
+
description: "Partner ID of the merchant for whom the transaction is being deleted"
|
|
36
|
+
},
|
|
37
|
+
oauth2Token: {
|
|
38
|
+
type: "string",
|
|
39
|
+
description: "OAuth2 access token for merchant authorization"
|
|
40
|
+
},
|
|
41
|
+
isvPartnerId: {
|
|
42
|
+
type: "string",
|
|
43
|
+
description: "ISV Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default.",
|
|
44
|
+
default: getPartnerIdSafe()
|
|
45
|
+
},
|
|
46
|
+
privateKey: {
|
|
47
|
+
type: "string",
|
|
48
|
+
description: "ISV RSA private key for JWT token creation. Uses environment-specific private key as default.",
|
|
49
|
+
default: getPrivateKeySafe()
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
required: ["transactionId", "merchantPartnerId", "oauth2Token"]
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
async handler(args) {
|
|
56
|
+
const {
|
|
57
|
+
transactionId,
|
|
58
|
+
merchantPartnerId,
|
|
59
|
+
oauth2Token,
|
|
60
|
+
isvPartnerId = getPartnerIdSafe(),
|
|
61
|
+
privateKey = getPrivateKeySafe()
|
|
62
|
+
} = args;
|
|
63
|
+
|
|
64
|
+
if (!transactionId) {
|
|
65
|
+
throw new Error("transactionId is required");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!merchantPartnerId) {
|
|
69
|
+
throw new Error("merchantPartnerId is required for ISV operations");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (!oauth2Token) {
|
|
73
|
+
throw new Error("oauth2Token is required for ISV operations");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (!isvPartnerId) {
|
|
77
|
+
throw new Error("ISV Partner ID is required. Provide via 'isvPartnerId' parameter or set PAYWARE_PARTNER_ID environment variable.");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!privateKey) {
|
|
81
|
+
throw new Error("Private key is required. Provide via 'privateKey' parameter or set PAYWARE_PRIVATE_KEY environment variable.");
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
const result = await deleteTransactionDeepLink({
|
|
86
|
+
transactionId,
|
|
87
|
+
partnerType: 'isv',
|
|
88
|
+
isvPartnerId,
|
|
89
|
+
privateKey,
|
|
90
|
+
merchantPartnerId,
|
|
91
|
+
oauth2Token
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
content: [{
|
|
96
|
+
type: "text",
|
|
97
|
+
text: `✅ **Transaction Deep Link Deleted (ISV)**
|
|
98
|
+
|
|
99
|
+
**Deletion Details:**
|
|
100
|
+
- Transaction ID: ${transactionId}
|
|
101
|
+
- Merchant: ${merchantPartnerId}
|
|
102
|
+
- Status: Successfully deleted
|
|
103
|
+
- Link URL: https://url.payware.eu/${transactionId} (now inactive)
|
|
104
|
+
|
|
105
|
+
**ISV Authentication:**
|
|
106
|
+
- ISV Partner ID: ${isvPartnerId}
|
|
107
|
+
- Merchant Partner ID: ${merchantPartnerId}
|
|
108
|
+
- OAuth2 Token: ${oauth2Token.substring(0, 10)}...
|
|
109
|
+
|
|
110
|
+
**API Call Details:**
|
|
111
|
+
- Endpoint: DELETE ${result.requestInfo.url}
|
|
112
|
+
- Status: ${result.requestInfo.statusCode}
|
|
113
|
+
- Method: ${result.requestInfo.method}
|
|
114
|
+
|
|
115
|
+
**Result:**
|
|
116
|
+
- The deep link is no longer active
|
|
117
|
+
- Mobile redirects will no longer work
|
|
118
|
+
- URL will return an error if accessed
|
|
119
|
+
|
|
120
|
+
**Important Notes:**
|
|
121
|
+
⚠️ This operation is irreversible
|
|
122
|
+
⚠️ Create a new link if needed using \`payware_deep_links_get_transaction_link\`
|
|
123
|
+
⚠️ Any existing shared links will stop working immediately`
|
|
124
|
+
}]
|
|
125
|
+
};
|
|
126
|
+
} catch (error) {
|
|
127
|
+
return {
|
|
128
|
+
content: [{
|
|
129
|
+
type: "text",
|
|
130
|
+
text: `❌ **Failed to Delete Transaction Deep Link (ISV)**
|
|
131
|
+
|
|
132
|
+
**Error Details:**
|
|
133
|
+
- Transaction ID: ${transactionId}
|
|
134
|
+
- Merchant: ${merchantPartnerId}
|
|
135
|
+
- Message: ${error.message}
|
|
136
|
+
|
|
137
|
+
**Common Issues:**
|
|
138
|
+
1. **Link not found**: Deep link may already be deleted or never existed
|
|
139
|
+
2. **Authentication failed**: Verify ISV partner ID, private key, and OAuth2 token
|
|
140
|
+
3. **Authorization failed**: Ensure OAuth2 token authorizes access to merchant
|
|
141
|
+
4. **Sandbox environment**: Deep links are production-only
|
|
142
|
+
5. **Invalid transaction ID**: Ensure transaction ID format is correct
|
|
143
|
+
|
|
144
|
+
**Troubleshooting:**
|
|
145
|
+
1. Check if deep link exists using \`payware_deep_links_get_transaction_link\`
|
|
146
|
+
2. Check OAuth2 token is valid and not expired
|
|
147
|
+
3. Ensure ISV has permission to access merchant data
|
|
148
|
+
4. Verify running in production environment
|
|
149
|
+
5. Ensure JWT authentication is working`
|
|
150
|
+
}]
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
};
|