@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,144 @@
|
|
|
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 merchants
|
|
6
|
+
*/
|
|
7
|
+
export const getProductTool = {
|
|
8
|
+
name: "payware_products_get_product",
|
|
9
|
+
description: "Get detailed information about a specific product by ID",
|
|
10
|
+
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
productId: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "Product identifier (starts with 'pr')",
|
|
17
|
+
pattern: "^pr[a-zA-Z0-9]+$"
|
|
18
|
+
},
|
|
19
|
+
partnerId: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "Merchant partner ID (uses PAYWARE_PARTNER_ID env var as default)",
|
|
22
|
+
default: getPartnerIdSafe()
|
|
23
|
+
},
|
|
24
|
+
privateKey: {
|
|
25
|
+
type: "string",
|
|
26
|
+
description: "RSA private key for authentication (uses environment-specific private key as default)",
|
|
27
|
+
default: getPrivateKeySafe()
|
|
28
|
+
},
|
|
29
|
+
useSandbox: {
|
|
30
|
+
type: "boolean",
|
|
31
|
+
description: "Use sandbox environment",
|
|
32
|
+
default: true
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
required: ["productId"]
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
async handler(args) {
|
|
39
|
+
const {
|
|
40
|
+
productId,
|
|
41
|
+
partnerId = getPartnerIdSafe(),
|
|
42
|
+
privateKey = getPrivateKeySafe(),
|
|
43
|
+
useSandbox = true
|
|
44
|
+
} = args;
|
|
45
|
+
|
|
46
|
+
if (!productId) {
|
|
47
|
+
throw new Error("Product ID is required");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!partnerId) {
|
|
51
|
+
throw new Error("Partner ID is required. Provide via 'partnerId' parameter or set PAYWARE_PARTNER_ID environment variable.");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (!privateKey) {
|
|
55
|
+
throw new Error("Private key is required. Provide via 'privateKey' parameter or set environment-specific private key variable.");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const result = await getProduct({
|
|
60
|
+
productId,
|
|
61
|
+
partnerType: 'merchant',
|
|
62
|
+
partnerId,
|
|
63
|
+
privateKey,
|
|
64
|
+
useSandbox
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const product = result.data;
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
content: [{
|
|
71
|
+
type: "text",
|
|
72
|
+
text: `📦 **Product Details**
|
|
73
|
+
|
|
74
|
+
**Basic Information:**
|
|
75
|
+
- ID: ${product.productId}
|
|
76
|
+
- Name: ${product.name}
|
|
77
|
+
- Type: ${product.type}
|
|
78
|
+
- Status: ${product.active ? '✅ Active' : '⏸️ Inactive'}
|
|
79
|
+
- Shop: ${product.shopCode} (${product.shopName})
|
|
80
|
+
|
|
81
|
+
**Description:**
|
|
82
|
+
${product.shortDescription ? `- Short: ${product.shortDescription}` : ''}
|
|
83
|
+
${product.longDescription ? `- Long: ${product.longDescription}` : ''}
|
|
84
|
+
|
|
85
|
+
**Identifiers:**
|
|
86
|
+
${product.sku ? `- SKU: ${product.sku}` : ''}
|
|
87
|
+
${product.upc ? `- UPC: ${product.upc}` : ''}
|
|
88
|
+
|
|
89
|
+
**Pricing:**
|
|
90
|
+
- Regular Price: ${product.regularPrice} ${product.currencyCode}
|
|
91
|
+
- Current Sale Price: ${product.salePrice} ${product.currencyCode}
|
|
92
|
+
- Time to Live: ${product.timeToLive} seconds
|
|
93
|
+
|
|
94
|
+
**Settings:**
|
|
95
|
+
- Shippable: ${product.shippable ? 'Yes (requires delivery address)' : 'No (digital product)'}
|
|
96
|
+
|
|
97
|
+
**Active Period:**
|
|
98
|
+
- From: ${product.activeFromZoned || product.activeFrom}
|
|
99
|
+
- To: ${product.activeToZoned || product.activeTo}
|
|
100
|
+
- Timezone: ${product.timeZone}
|
|
101
|
+
|
|
102
|
+
**Resources:**
|
|
103
|
+
${product.imageUrl ? `- Image: ${product.imageUrl}` : ''}
|
|
104
|
+
${product.termsUrl ? `- Terms URL: ${product.termsUrl}` : ''}
|
|
105
|
+
${product.termsText ? `- Terms Text: ${product.termsText.substring(0, 100)}${product.termsText.length > 100 ? '...' : ''}` : ''}
|
|
106
|
+
${product.deepLink && product.deepLink !== '-' ? `- Deep Link: ${product.deepLink}` : ''}
|
|
107
|
+
|
|
108
|
+
**API Response:**
|
|
109
|
+
\`\`\`json
|
|
110
|
+
${JSON.stringify(product, null, 2)}
|
|
111
|
+
\`\`\`
|
|
112
|
+
|
|
113
|
+
**API Call Details:**
|
|
114
|
+
- Endpoint: ${result.requestInfo.method} ${result.requestInfo.url}
|
|
115
|
+
- Status: ${result.requestInfo.statusCode}
|
|
116
|
+
|
|
117
|
+
**Available Actions:**
|
|
118
|
+
- \`payware_products_update_product\` - Update this product
|
|
119
|
+
- \`payware_products_delete_product\` - Delete this product
|
|
120
|
+
- \`payware_products_get_product_image\` - Generate QR/barcode image
|
|
121
|
+
- \`payware_products_get_schedules\` - View price schedules
|
|
122
|
+
- \`payware_products_get_audios\` - View registered audios`
|
|
123
|
+
}]
|
|
124
|
+
};
|
|
125
|
+
} catch (error) {
|
|
126
|
+
return {
|
|
127
|
+
content: [{
|
|
128
|
+
type: "text",
|
|
129
|
+
text: `❌ **Failed to Get Product**
|
|
130
|
+
|
|
131
|
+
**Error Details:**
|
|
132
|
+
- Message: ${error.message}
|
|
133
|
+
- Product ID: ${productId}
|
|
134
|
+
|
|
135
|
+
**Troubleshooting:**
|
|
136
|
+
1. Verify the product ID is correct and starts with 'pr'
|
|
137
|
+
2. Ensure the product exists and belongs to your account
|
|
138
|
+
3. Check JWT token validity
|
|
139
|
+
4. Verify partner ID and API access`
|
|
140
|
+
}]
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merchant Products Tools
|
|
3
|
+
* Complete implementation of the Products API for merchants
|
|
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 merchant product tools
|
|
34
|
+
*/
|
|
35
|
+
export const merchantProductTools = [
|
|
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 merchant product tools with proper naming
|
|
61
|
+
* @returns {Array} Array of merchant product tools
|
|
62
|
+
*/
|
|
63
|
+
export function getMerchantProductTools() {
|
|
64
|
+
return merchantProductTools;
|
|
65
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
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 merchants
|
|
6
|
+
*/
|
|
7
|
+
export const listProductsTool = {
|
|
8
|
+
name: "payware_products_list_products",
|
|
9
|
+
description: "Get a list of all products for the merchant account",
|
|
10
|
+
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
partnerId: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "Merchant partner ID (uses PAYWARE_PARTNER_ID env var as default)",
|
|
17
|
+
default: getPartnerIdSafe()
|
|
18
|
+
},
|
|
19
|
+
privateKey: {
|
|
20
|
+
type: "string",
|
|
21
|
+
description: "RSA private key for authentication (uses environment-specific private key as default)",
|
|
22
|
+
default: getPrivateKeySafe()
|
|
23
|
+
},
|
|
24
|
+
useSandbox: {
|
|
25
|
+
type: "boolean",
|
|
26
|
+
description: "Use sandbox environment",
|
|
27
|
+
default: true
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
required: []
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
async handler(args) {
|
|
34
|
+
const {
|
|
35
|
+
partnerId = getPartnerIdSafe(),
|
|
36
|
+
privateKey = getPrivateKeySafe(),
|
|
37
|
+
useSandbox = true
|
|
38
|
+
} = args;
|
|
39
|
+
|
|
40
|
+
if (!partnerId) {
|
|
41
|
+
throw new Error("Partner ID is required. Provide via 'partnerId' parameter or set PAYWARE_PARTNER_ID environment variable.");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!privateKey) {
|
|
45
|
+
throw new Error("Private key is required. Provide via 'privateKey' parameter or set environment-specific private key variable.");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const result = await getProducts({
|
|
50
|
+
partnerType: 'merchant',
|
|
51
|
+
partnerId,
|
|
52
|
+
privateKey,
|
|
53
|
+
useSandbox
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const products = result.data;
|
|
57
|
+
const productCount = Array.isArray(products) ? products.length : 0;
|
|
58
|
+
|
|
59
|
+
let productsList = '';
|
|
60
|
+
if (Array.isArray(products) && products.length > 0) {
|
|
61
|
+
productsList = products.map(product =>
|
|
62
|
+
`- **${product.name}** (${product.productId})
|
|
63
|
+
- Type: ${product.type} | Price: ${product.salePrice} ${product.currencyCode}
|
|
64
|
+
- Status: ${product.active ? '✅ Active' : '⏸️ Inactive'} | Shop: ${product.shopCode}
|
|
65
|
+
- TTL: ${product.timeToLive}s | ${product.shippable ? 'Shippable' : 'Digital'}`
|
|
66
|
+
).join('\n\n');
|
|
67
|
+
} else {
|
|
68
|
+
productsList = 'No products found.';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
content: [{
|
|
73
|
+
type: "text",
|
|
74
|
+
text: `📦 **Products List**
|
|
75
|
+
|
|
76
|
+
**Summary:**
|
|
77
|
+
- Total Products: ${productCount}
|
|
78
|
+
- Environment: ${useSandbox ? 'Sandbox' : 'Production'}
|
|
79
|
+
|
|
80
|
+
**Products:**
|
|
81
|
+
${productsList}
|
|
82
|
+
|
|
83
|
+
**API Call Details:**
|
|
84
|
+
- Endpoint: ${result.requestInfo.method} ${result.requestInfo.url}
|
|
85
|
+
- Status: ${result.requestInfo.statusCode}
|
|
86
|
+
|
|
87
|
+
**Available Actions:**
|
|
88
|
+
- \`payware_products_get_product\` - Get detailed product information
|
|
89
|
+
- \`payware_products_create_product\` - Create a new product
|
|
90
|
+
- \`payware_products_update_product\` - Update existing product
|
|
91
|
+
- \`payware_products_delete_product\` - Delete a product`
|
|
92
|
+
}]
|
|
93
|
+
};
|
|
94
|
+
} catch (error) {
|
|
95
|
+
return {
|
|
96
|
+
content: [{
|
|
97
|
+
type: "text",
|
|
98
|
+
text: `❌ **Failed to List Products**
|
|
99
|
+
|
|
100
|
+
**Error Details:**
|
|
101
|
+
- Message: ${error.message}
|
|
102
|
+
|
|
103
|
+
**Troubleshooting:**
|
|
104
|
+
1. Verify JWT token is valid and not expired
|
|
105
|
+
2. Ensure private key matches public key registered with payware
|
|
106
|
+
3. Verify partner ID and API access
|
|
107
|
+
4. Check sandbox API status`
|
|
108
|
+
}]
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|