@payware/mcp-server 1.5.1 → 2.0.1
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 +1 -1
- package/README.md +1 -5
- package/package.json +1 -1
- package/src/config/toolsets.js +0 -2
- package/src/isv/index.js +0 -6
- package/src/isv/products/get-product.js +0 -1
- package/src/isv/transactions/create-transaction.js +1 -1
- package/src/merchant/index.js +0 -6
- package/src/merchant/products/get-product.js +0 -1
- package/src/merchant/transactions/transaction-history.js +1 -1
- package/src/payment-institution/index.js +1 -9
- package/src/payment-institution/transactions/get-transaction-history.js +1 -2
- package/src/payment-institution/transactions/get-transaction-status.js +3 -4
- package/src/payment-institution/transactions/simulate-pi-callback.js +0 -9
- package/src/payment-institution/transactions/soundbite-transaction.js +1 -2
- package/src/shared/auth-headers.js +7 -6
- package/src/shared/placements/tools.js +4 -17
- package/src/tools/advanced-code-generator.js +2 -28
- package/src/utils/code-examples/common/helpers.js +1 -11
- package/src/utils/code-examples/index.js +1 -18
- package/src/isv/deep-links/delete-product-link.js +0 -155
- package/src/isv/deep-links/delete-transaction-link.js +0 -155
- package/src/isv/deep-links/get-product-link.js +0 -169
- package/src/isv/deep-links/get-transaction-link.js +0 -169
- package/src/isv/deep-links/index.js +0 -23
- package/src/merchant/deep-links/delete-product-link.js +0 -122
- package/src/merchant/deep-links/delete-transaction-link.js +0 -122
- package/src/merchant/deep-links/get-product-link.js +0 -136
- package/src/merchant/deep-links/get-transaction-link.js +0 -136
- package/src/merchant/deep-links/index.js +0 -23
- package/src/payment-institution/deep-links/delete-transaction-link.js +0 -129
- package/src/payment-institution/deep-links/get-transaction-link.js +0 -143
- package/src/payment-institution/deep-links/index.js +0 -17
- package/src/shared/deep-links/api.js +0 -215
- package/src/utils/code-examples/shared/deep-links.js +0 -662
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { getTransactionDeepLink } from '../../shared/deep-links/api.js';
|
|
2
|
-
import { getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
|
|
3
|
-
import { ADDS } from '../../shared/tool-annotations.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Get deep link for a payment institution transaction
|
|
7
|
-
*/
|
|
8
|
-
export const getTransactionLinkTool = {
|
|
9
|
-
name: "payware_deep_links_get_transaction_link",
|
|
10
|
-
annotations: ADDS,
|
|
11
|
-
description: `Get an active deep link for a transaction where the payment institution acts as source (SRC) or destination (DST). Returns a clickable URL that redirects to the payware mobile app.
|
|
12
|
-
|
|
13
|
-
**Deep Link Format:**
|
|
14
|
-
- Web URL: https://go.payware.eu/{transactionId}
|
|
15
|
-
- Mobile Redirect: payware:/{transactionId} (one slash: the identifier is case-sensitive, so it must not sit in the URI host, which redirect services lowercase)
|
|
16
|
-
|
|
17
|
-
**Use Cases:**
|
|
18
|
-
- P2P payments initiated via messaging services
|
|
19
|
-
- Transaction notifications with direct links
|
|
20
|
-
- Transaction status sharing
|
|
21
|
-
|
|
22
|
-
**Important Notes:**
|
|
23
|
-
- Deep links are only supported in production environment
|
|
24
|
-
- Apps that open payware links must accept \`payware:\` followed by one, two or three slashes (QR codes and NFC tags carry \`payware://{id}\`): read the identifier after the scheme and any slashes, up to \`/\`, \`?\` or \`#\`, and keep its case
|
|
25
|
-
- Link expiration is synchronized with the referenced transaction
|
|
26
|
-
- Payment institutions only manage transaction links (no product links)
|
|
27
|
-
- Traditional deep links that route to app content when app is installed`,
|
|
28
|
-
|
|
29
|
-
inputSchema: {
|
|
30
|
-
type: "object",
|
|
31
|
-
properties: {
|
|
32
|
-
transactionId: {
|
|
33
|
-
type: "string",
|
|
34
|
-
description: "The transaction identifier (e.g., 'pw7e4rCToG')",
|
|
35
|
-
pattern: "^[a-zA-Z0-9]+$"
|
|
36
|
-
},
|
|
37
|
-
partnerId: {
|
|
38
|
-
type: "string",
|
|
39
|
-
description: "Payment Institution Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default.",
|
|
40
|
-
default: getPartnerIdSafe()
|
|
41
|
-
},
|
|
42
|
-
privateKey: {
|
|
43
|
-
type: "string",
|
|
44
|
-
description: "RSA private key for JWT token creation. Uses environment-specific private key as default."
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
required: ["transactionId"]
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
async handler(args) {
|
|
51
|
-
const {
|
|
52
|
-
transactionId,
|
|
53
|
-
partnerId = getPartnerIdSafe(),
|
|
54
|
-
privateKey = getPrivateKeySafe()
|
|
55
|
-
} = args;
|
|
56
|
-
|
|
57
|
-
if (!transactionId) {
|
|
58
|
-
throw new Error("transactionId is required");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (!partnerId) {
|
|
62
|
-
throw new Error("Partner ID is required. Provide via 'partnerId' parameter or set PAYWARE_PARTNER_ID environment variable.");
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!privateKey) {
|
|
66
|
-
throw new Error("Private key is required. Provide via 'privateKey' parameter or set PAYWARE_PRIVATE_KEY environment variable.");
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
try {
|
|
70
|
-
const result = await getTransactionDeepLink({
|
|
71
|
-
transactionId,
|
|
72
|
-
partnerType: 'payment_institution',
|
|
73
|
-
partnerId,
|
|
74
|
-
privateKey
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Extract the URL - API returns either string directly or object with link property
|
|
78
|
-
const linkUrl = typeof result.data === 'string' ? result.data : (result.data.link || result.data)
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
content: [{
|
|
82
|
-
type: "text",
|
|
83
|
-
text: `🔗 **Transaction Deep Link Retrieved (Payment Institution)**
|
|
84
|
-
|
|
85
|
-
**Deep Link Details:**
|
|
86
|
-
- Transaction ID: ${transactionId}
|
|
87
|
-
- Web URL: ${linkUrl}
|
|
88
|
-
- Mobile Redirect: payware:/${transactionId}
|
|
89
|
-
|
|
90
|
-
**Payment Institution Info:**
|
|
91
|
-
- Partner ID: ${partnerId}
|
|
92
|
-
- Role: SRC/DST for P2P transactions
|
|
93
|
-
|
|
94
|
-
**Link Information:**
|
|
95
|
-
- Status: Active
|
|
96
|
-
- Expiration: Synchronized with transaction
|
|
97
|
-
- Platform: Production only
|
|
98
|
-
|
|
99
|
-
**API Response:**
|
|
100
|
-
\`\`\`json
|
|
101
|
-
${JSON.stringify(result.data, null, 2)}
|
|
102
|
-
\`\`\`
|
|
103
|
-
|
|
104
|
-
**API Call Details:**
|
|
105
|
-
- Endpoint: GET ${result.requestInfo.url}
|
|
106
|
-
- Status: ${result.requestInfo.statusCode}
|
|
107
|
-
- Method: ${result.requestInfo.method}
|
|
108
|
-
|
|
109
|
-
**Usage:**
|
|
110
|
-
1. Share the web URL: \`${linkUrl}\`
|
|
111
|
-
2. On mobile devices, it will redirect to: \`payware:/${transactionId}\`
|
|
112
|
-
3. Link expires when the transaction expires
|
|
113
|
-
4. Use for P2P transaction notifications and sharing`
|
|
114
|
-
}]
|
|
115
|
-
};
|
|
116
|
-
} catch (error) {
|
|
117
|
-
return {
|
|
118
|
-
content: [{
|
|
119
|
-
type: "text",
|
|
120
|
-
text: `❌ **Failed to Get Transaction Deep Link (Payment Institution)**
|
|
121
|
-
|
|
122
|
-
**Error Details:**
|
|
123
|
-
- Transaction ID: ${transactionId}
|
|
124
|
-
- Message: ${error.message}
|
|
125
|
-
|
|
126
|
-
**Common Issues:**
|
|
127
|
-
1. **Transaction not found**: Check if transaction exists and is not expired
|
|
128
|
-
2. **Authentication failed**: Verify partner ID and private key
|
|
129
|
-
3. **Authorization failed**: Ensure PI is SRC or DST for this transaction
|
|
130
|
-
4. **Sandbox environment**: Deep links are production-only
|
|
131
|
-
5. **Invalid transaction ID**: Ensure transaction ID format is correct
|
|
132
|
-
|
|
133
|
-
**Troubleshooting:**
|
|
134
|
-
1. Verify transaction exists using \`payware_operations_get_transaction_status\`
|
|
135
|
-
2. Check if running in production environment
|
|
136
|
-
3. Ensure JWT authentication is working
|
|
137
|
-
4. Confirm payment institution role in transaction
|
|
138
|
-
5. Verify transaction is not expired`
|
|
139
|
-
}]
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Payment Institution Deep Links Tools
|
|
3
|
-
* Deep link management for payment institutions (transaction links only)
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { getTransactionLinkTool } from './get-transaction-link.js';
|
|
7
|
-
import { deleteTransactionLinkTool } from './delete-transaction-link.js';
|
|
8
|
-
|
|
9
|
-
export const paymentInstitutionDeepLinksTools = [
|
|
10
|
-
getTransactionLinkTool,
|
|
11
|
-
deleteTransactionLinkTool
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
getTransactionLinkTool,
|
|
16
|
-
deleteTransactionLinkTool
|
|
17
|
-
};
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import { createJWTToken } from '../../core/auth/jwt-token.js';
|
|
3
|
-
import { createJWTForPartner } from '../../core/auth/jwt-factory.js';
|
|
4
|
-
import { getProductionUrl } from '../../config/env.js';
|
|
5
|
-
import { describeApiError } from '../api-errors.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Create authentication headers based on partner type
|
|
9
|
-
* @param {string} partnerType - merchant, isv, or payment_institution
|
|
10
|
-
* @param {Object} authParams - Authentication parameters
|
|
11
|
-
* @returns {Object} Headers for API request
|
|
12
|
-
*/
|
|
13
|
-
async function createAuthHeaders(partnerType, authParams) {
|
|
14
|
-
const baseHeaders = {
|
|
15
|
-
'Content-Type': 'application/json',
|
|
16
|
-
'Api-Version': '1'
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
let tokenData;
|
|
20
|
-
|
|
21
|
-
switch (partnerType) {
|
|
22
|
-
case 'merchant':
|
|
23
|
-
case 'payment_institution':
|
|
24
|
-
// Standard JWT authentication
|
|
25
|
-
tokenData = createJWTToken(
|
|
26
|
-
authParams.partnerId,
|
|
27
|
-
authParams.privateKey,
|
|
28
|
-
authParams.requestBody || ''
|
|
29
|
-
);
|
|
30
|
-
break;
|
|
31
|
-
|
|
32
|
-
case 'isv':
|
|
33
|
-
// ISV JWT with OAuth2 - note the parameter mapping
|
|
34
|
-
tokenData = await createJWTForPartner({
|
|
35
|
-
partnerId: authParams.isvPartnerId,
|
|
36
|
-
privateKey: authParams.privateKey,
|
|
37
|
-
merchantId: authParams.merchantPartnerId, // Map merchantPartnerId to merchantId
|
|
38
|
-
oauth2Token: authParams.oauth2Token,
|
|
39
|
-
requestBody: authParams.requestBody || ''
|
|
40
|
-
});
|
|
41
|
-
break;
|
|
42
|
-
|
|
43
|
-
default:
|
|
44
|
-
throw new Error(`Unknown partner type: ${partnerType}`);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
...baseHeaders,
|
|
49
|
-
'Authorization': `Bearer ${tokenData.token}`
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Get deep link for a transaction
|
|
55
|
-
* @param {Object} params - Parameters
|
|
56
|
-
* @param {string} params.transactionId - Transaction ID
|
|
57
|
-
* @param {string} params.partnerType - Partner type (merchant, isv, payment_institution)
|
|
58
|
-
* @param {Object} params.authParams - Authentication parameters
|
|
59
|
-
* @returns {Object} Deep link response
|
|
60
|
-
*/
|
|
61
|
-
export async function getTransactionDeepLink({
|
|
62
|
-
transactionId,
|
|
63
|
-
partnerType,
|
|
64
|
-
...authParams
|
|
65
|
-
}) {
|
|
66
|
-
if (!transactionId) {
|
|
67
|
-
throw new Error('transactionId is required');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const headers = await createAuthHeaders(partnerType, authParams);
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
const response = await axios.get(
|
|
74
|
-
`${getProductionUrl()}/transactions/${transactionId}/link`,
|
|
75
|
-
{ headers }
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
success: true,
|
|
80
|
-
data: response.data,
|
|
81
|
-
requestInfo: {
|
|
82
|
-
url: `${getProductionUrl()}/transactions/${transactionId}/link`,
|
|
83
|
-
method: 'GET',
|
|
84
|
-
statusCode: response.status
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
} catch (error) {
|
|
88
|
-
throw describeApiError(error, 'get transaction deep link');
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Get deep link for a product
|
|
94
|
-
* @param {Object} params - Parameters
|
|
95
|
-
* @param {string} params.productId - Product ID
|
|
96
|
-
* @param {string} params.partnerType - Partner type (merchant, isv)
|
|
97
|
-
* @param {Object} params.authParams - Authentication parameters
|
|
98
|
-
* @returns {Object} Deep link response
|
|
99
|
-
*/
|
|
100
|
-
export async function getProductDeepLink({
|
|
101
|
-
productId,
|
|
102
|
-
partnerType,
|
|
103
|
-
...authParams
|
|
104
|
-
}) {
|
|
105
|
-
if (!productId) {
|
|
106
|
-
throw new Error('productId is required');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (partnerType === 'payment_institution') {
|
|
110
|
-
throw new Error('Payment institutions do not manage products');
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const headers = await createAuthHeaders(partnerType, authParams);
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
const response = await axios.get(
|
|
117
|
-
`${getProductionUrl()}/products/${productId}/link`,
|
|
118
|
-
{ headers }
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
success: true,
|
|
123
|
-
data: response.data,
|
|
124
|
-
requestInfo: {
|
|
125
|
-
url: `${getProductionUrl()}/products/${productId}/link`,
|
|
126
|
-
method: 'GET',
|
|
127
|
-
statusCode: response.status
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
} catch (error) {
|
|
131
|
-
throw describeApiError(error, 'get product deep link');
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Delete deep link for a transaction
|
|
137
|
-
* @param {Object} params - Parameters
|
|
138
|
-
* @param {string} params.transactionId - Transaction ID
|
|
139
|
-
* @param {string} params.partnerType - Partner type (merchant, isv, payment_institution)
|
|
140
|
-
* @param {Object} params.authParams - Authentication parameters
|
|
141
|
-
* @returns {Object} Delete response
|
|
142
|
-
*/
|
|
143
|
-
export async function deleteTransactionDeepLink({
|
|
144
|
-
transactionId,
|
|
145
|
-
partnerType,
|
|
146
|
-
...authParams
|
|
147
|
-
}) {
|
|
148
|
-
if (!transactionId) {
|
|
149
|
-
throw new Error('transactionId is required');
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const headers = await createAuthHeaders(partnerType, authParams);
|
|
153
|
-
|
|
154
|
-
try {
|
|
155
|
-
const response = await axios.delete(
|
|
156
|
-
`${getProductionUrl()}/transactions/${transactionId}/link`,
|
|
157
|
-
{ headers }
|
|
158
|
-
);
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
success: true,
|
|
162
|
-
data: response.data,
|
|
163
|
-
requestInfo: {
|
|
164
|
-
url: `${getProductionUrl()}/transactions/${transactionId}/link`,
|
|
165
|
-
method: 'DELETE',
|
|
166
|
-
statusCode: response.status
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
} catch (error) {
|
|
170
|
-
throw describeApiError(error, 'delete transaction deep link');
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Delete deep link for a product
|
|
176
|
-
* @param {Object} params - Parameters
|
|
177
|
-
* @param {string} params.productId - Product ID
|
|
178
|
-
* @param {string} params.partnerType - Partner type (merchant, isv)
|
|
179
|
-
* @param {Object} params.authParams - Authentication parameters
|
|
180
|
-
* @returns {Object} Delete response
|
|
181
|
-
*/
|
|
182
|
-
export async function deleteProductDeepLink({
|
|
183
|
-
productId,
|
|
184
|
-
partnerType,
|
|
185
|
-
...authParams
|
|
186
|
-
}) {
|
|
187
|
-
if (!productId) {
|
|
188
|
-
throw new Error('productId is required');
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (partnerType === 'payment_institution') {
|
|
192
|
-
throw new Error('Payment institutions do not manage products');
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const headers = await createAuthHeaders(partnerType, authParams);
|
|
196
|
-
|
|
197
|
-
try {
|
|
198
|
-
const response = await axios.delete(
|
|
199
|
-
`${getProductionUrl()}/products/${productId}/link`,
|
|
200
|
-
{ headers }
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
return {
|
|
204
|
-
success: true,
|
|
205
|
-
data: response.data,
|
|
206
|
-
requestInfo: {
|
|
207
|
-
url: `${getProductionUrl()}/products/${productId}/link`,
|
|
208
|
-
method: 'DELETE',
|
|
209
|
-
statusCode: response.status
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
} catch (error) {
|
|
213
|
-
throw describeApiError(error, 'delete product deep link');
|
|
214
|
-
}
|
|
215
|
-
}
|