@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.
- package/README.md +5 -0
- package/package.json +69 -66
- package/src/auth/sandbox-setup.js +186 -186
- package/src/isv/index.js +29 -1
- package/src/isv/invitations/index.js +471 -0
- package/src/isv/oauth2/obtain-token.js +19 -8
- package/src/isv/oauth2/token-helper.js +5 -2
- package/src/isv/poi/cancel-price.js +2 -10
- package/src/isv/poi/create.js +19 -0
- package/src/isv/poi/get-poi.js +2 -10
- package/src/isv/poi/get-qrcode.js +2 -10
- package/src/isv/poi/get-status.js +2 -10
- package/src/isv/poi/index.js +5 -0
- package/src/isv/poi/list-pois.js +2 -10
- package/src/isv/poi/set-price.js +217 -225
- package/src/isv/products/create-product.js +313 -313
- package/src/isv/products/update-product.js +264 -264
- package/src/isv/reference/index.js +249 -0
- package/src/isv/shops/index.js +22 -0
- package/src/isv/transactions/cancel-transaction.js +41 -10
- package/src/isv/transactions/create-transaction.js +20 -4
- package/src/isv/transactions/get-status.js +18 -11
- package/src/isv/transactions/process-transaction.js +160 -42
- package/src/isv/transactions/simulate-callback.js +128 -109
- package/src/isv/transactions/transaction-history.js +86 -90
- package/src/merchant/data/generate-report.js +19 -1
- package/src/merchant/index.js +21 -1
- package/src/merchant/logs/index.js +366 -0
- package/src/merchant/products/create-product.js +287 -287
- package/src/merchant/products/update-product.js +281 -281
- package/src/merchant/shops/index.js +18 -0
- package/src/merchant/transactions/cancel-transaction.js +10 -13
- package/src/merchant/transactions/create-transaction.js +88 -8
- package/src/merchant/transactions/get-status.js +40 -11
- package/src/merchant/transactions/process-transaction.js +2 -10
- package/src/merchant/transactions/simulate-callback.js +68 -9
- package/src/merchant/transactions/transaction-history.js +275 -257
- package/src/payment-institution/transactions/create-pi-transaction.js +2 -10
- package/src/payment-institution/transactions/finalize-transaction.js +333 -340
- package/src/payment-institution/transactions/get-transaction-history.js +2 -10
- package/src/payment-institution/transactions/get-transaction-status.js +38 -11
- package/src/payment-institution/transactions/process-pi-transaction.js +2 -10
- package/src/payment-institution/transactions/simulate-pi-callback.js +49 -9
- package/src/payment-institution/transactions/soundbite-transaction.js +2 -10
- package/src/shared/api-errors.js +188 -0
- package/src/shared/auth-headers.js +62 -0
- package/src/shared/data/data-api.js +11 -10
- package/src/shared/deep-links/api.js +5 -4
- package/src/shared/logs/logs-api.js +242 -0
- package/src/shared/poi/poi-create-api.js +419 -0
- package/src/shared/products/products-api.js +17 -16
- package/src/shared/shops/shops-api.js +155 -0
- package/src/tools/advanced-code-generator.js +2255 -2246
- package/src/utils/code-examples/common/auth-examples.js +1484 -1481
- package/src/utils/code-examples/common/helpers.js +7 -4
- package/src/utils/code-examples/isv/oauth2.js +458 -600
- package/src/utils/code-examples/isv/transactions.js +815 -812
- package/MCP-SETUP.md +0 -190
|
@@ -1,258 +1,276 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import { createJWTToken } from '../../core/auth/jwt-token.js';
|
|
3
|
-
import { getSandboxUrl, getProductionUrl, getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
'
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
**
|
|
97
|
-
|
|
98
|
-
**Note:** For ACTIVE transactions, use 'payware_transactions_get_transaction_status' instead
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
**
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
${result.transaction.
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
${result.transaction.
|
|
186
|
-
-
|
|
187
|
-
-
|
|
188
|
-
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
-
|
|
203
|
-
|
|
204
|
-
-
|
|
205
|
-
-
|
|
206
|
-
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
**
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { createJWTToken } from '../../core/auth/jwt-token.js';
|
|
3
|
+
import { getSandboxUrl, getProductionUrl, getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
|
|
4
|
+
import { apiErrorResult } from '../../shared/api-errors.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get transaction history from payware API (for completed/expired transactions)
|
|
8
|
+
* @param {Object} params - Parameters for history request
|
|
9
|
+
* @returns {Object} Transaction history response
|
|
10
|
+
*/
|
|
11
|
+
export async function getTransactionHistory({ transactionId, partnerId, privateKey, useSandbox = true }) {
|
|
12
|
+
if (!transactionId) {
|
|
13
|
+
throw new Error('Transaction ID is required');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (!partnerId || !privateKey) {
|
|
17
|
+
throw new Error('Partner ID and private key are required for proper JWT creation');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Create JWT token without body (GET request - no contentSha256 required)
|
|
21
|
+
const tokenData = createJWTToken(partnerId, privateKey, null);
|
|
22
|
+
|
|
23
|
+
// Required headers as per payware API documentation
|
|
24
|
+
const headers = {
|
|
25
|
+
'Authorization': `Bearer ${tokenData.token}`,
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
'Api-Version': '1' // Required: current API version
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const baseUrl = useSandbox ? getSandboxUrl() : getProductionUrl();
|
|
32
|
+
const response = await axios.get(`${baseUrl}/transactions-history/${transactionId}`, { headers });
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
success: true,
|
|
36
|
+
transaction: response.data,
|
|
37
|
+
requestId: response.headers['x-request-id'],
|
|
38
|
+
timestamp: new Date().toISOString()
|
|
39
|
+
};
|
|
40
|
+
} catch (error) {
|
|
41
|
+
const result = apiErrorResult(error);
|
|
42
|
+
// 429, not 415. The server's rate limiter answers TOO_MANY_REQUESTS
|
|
43
|
+
// (PartnerApiRateLimitFilter); 415 is an unsupported content type, which retrying can never
|
|
44
|
+
// fix. Labelling a genuine 415 "throttled" told integrators to retry a request that is
|
|
45
|
+
// permanently malformed, while a real throttle was reported as a hard failure.
|
|
46
|
+
//
|
|
47
|
+
// Kept as its own flag on top of apiErrorResult's `retryable`: `throttled` says specifically
|
|
48
|
+
// "slow down", where `retryable` is also true for a 503, which means "payware is missing
|
|
49
|
+
// configuration" and calls for a different response. apiErrorResult supplies retryAfterSeconds.
|
|
50
|
+
result.error.throttled = error.response?.status === 429;
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Format transaction history for display
|
|
57
|
+
*/
|
|
58
|
+
function formatTransactionHistory(transaction) {
|
|
59
|
+
const statusEmojis = {
|
|
60
|
+
'CONFIRMED': '✅',
|
|
61
|
+
'DECLINED': '❌',
|
|
62
|
+
'FAILED': '💥',
|
|
63
|
+
'CANCELLED': '🚫',
|
|
64
|
+
'EXPIRED': '⏰'
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const typeEmojis = {
|
|
68
|
+
'DEFAULT': '💳',
|
|
69
|
+
'SHIPPABLE': '📦',
|
|
70
|
+
'VOUCHER': '🎫',
|
|
71
|
+
'CHEQUE': '📝'
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const status = transaction.status || 'UNKNOWN';
|
|
75
|
+
const type = transaction.transactionType || 'DEFAULT';
|
|
76
|
+
const statusEmoji = statusEmojis[status] || '❓';
|
|
77
|
+
const typeEmoji = typeEmojis[type] || '💳';
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
statusEmoji,
|
|
81
|
+
typeEmoji,
|
|
82
|
+
status,
|
|
83
|
+
type,
|
|
84
|
+
formattedStatus: `${statusEmoji} ${status}`,
|
|
85
|
+
formattedType: `${typeEmoji} ${type}`
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get transaction history tool implementation
|
|
91
|
+
*/
|
|
92
|
+
export const getTransactionHistoryTool = {
|
|
93
|
+
name: "payware_operations_get_transaction_history",
|
|
94
|
+
description: `Get history of completed/finalized transactions with final statuses.
|
|
95
|
+
|
|
96
|
+
**Endpoint:** GET /transactions-history/{transactionId}
|
|
97
|
+
**Use Case:** Retrieve transactions with final statuses: CONFIRMED, DECLINED, FAILED, EXPIRED, CANCELLED.
|
|
98
|
+
**Note:** For ACTIVE transactions, use 'payware_transactions_get_transaction_status' instead.
|
|
99
|
+
|
|
100
|
+
📦 **This is where the delivery address lives.** For a SHIPPABLE transaction, \`deliveryAddress\`
|
|
101
|
+
(fullName, streetAddressLine1/2, zipCode, city, region, country, phoneNumber, email) is returned
|
|
102
|
+
here and **only** here. It was removed from the finalized callback on 2026-08-07: a callback is
|
|
103
|
+
delivered to whatever certificate the merchant's endpoint happens to present, which is an acceptable
|
|
104
|
+
trade for a transaction id and an amount and not one for a shopper's home address. This endpoint is
|
|
105
|
+
JWT-authenticated, tenant-scoped and runs over a verified channel. So the pattern is: the callback
|
|
106
|
+
tells you the shipment is ready, and this call gives you the address to ship to.
|
|
107
|
+
|
|
108
|
+
⚠️ **Requires Standard or Premium.** This endpoint was ungated until 2026-08-21 and is now on the
|
|
109
|
+
same plan gate as the rest of the transaction surface, so a **Basic** merchant - or an ISV acting on
|
|
110
|
+
behalf of one - now gets **403**. If reading history started failing without a code change, this is
|
|
111
|
+
why. Financial institutions are unaffected; banks are always Premium.
|
|
112
|
+
|
|
113
|
+
⏱️ **Rate limited, like every payware endpoint.** A 429 carries \`ERR_RATE_LIMIT_EXCEEDED\` and a
|
|
114
|
+
\`Retry-After\` header, in seconds; the request was not processed, so the identical request is safe to
|
|
115
|
+
retry once the window passes. The failure result exposes this as \`error.throttled\`,
|
|
116
|
+
\`error.retryable\` and \`error.retryAfterSeconds\`.`,
|
|
117
|
+
inputSchema: {
|
|
118
|
+
type: "object",
|
|
119
|
+
properties: {
|
|
120
|
+
transactionId: {
|
|
121
|
+
type: "string",
|
|
122
|
+
description: "Transaction ID to get history for. Format: 2-char prefix + 8-char ID. Supports: 'pw' (standard), 'pr' (product), 'ps' (soundbite)",
|
|
123
|
+
pattern: "^(pw|pr|ps)[0-9A-Za-z]{8}$"
|
|
124
|
+
},
|
|
125
|
+
partnerId: {
|
|
126
|
+
type: "string",
|
|
127
|
+
description: "Partner ID from payware dashboard. Can use PAYWARE_PARTNER_ID env var as default.",
|
|
128
|
+
default: getPartnerIdSafe()
|
|
129
|
+
},
|
|
130
|
+
privateKey: {
|
|
131
|
+
type: "string",
|
|
132
|
+
description: "RSA private key for JWT token creation. Can use PAYWARE_PRIVATE_KEY_PATH env var as default.",
|
|
133
|
+
default: getPrivateKeySafe()
|
|
134
|
+
},
|
|
135
|
+
useSandbox: {
|
|
136
|
+
type: "boolean",
|
|
137
|
+
description: "Use sandbox environment for testing",
|
|
138
|
+
default: true
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
required: ["transactionId"],
|
|
142
|
+
additionalProperties: false
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
async handler(args) {
|
|
146
|
+
const { transactionId, partnerId = getPartnerIdSafe(), privateKey = getPrivateKeySafe(args.useSandbox ?? true), useSandbox = true } = args;
|
|
147
|
+
|
|
148
|
+
if (!transactionId) {
|
|
149
|
+
throw new Error("Transaction ID is required");
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (!partnerId) {
|
|
153
|
+
throw new Error("Partner ID is required. Provide via 'partnerId' parameter or set PAYWARE_PARTNER_ID environment variable.");
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (!privateKey) {
|
|
157
|
+
throw new Error("Private key is required. Provide via 'privateKey' parameter or set PAYWARE_PRIVATE_KEY environment variable.");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const result = await getTransactionHistory({ transactionId, partnerId, privateKey, useSandbox });
|
|
161
|
+
|
|
162
|
+
if (result.success) {
|
|
163
|
+
const formatInfo = formatTransactionHistory(result.transaction);
|
|
164
|
+
|
|
165
|
+
// Format dates
|
|
166
|
+
const created = result.transaction.created ? new Date(result.transaction.created * 1000).toISOString() : 'N/A';
|
|
167
|
+
const finalized = result.transaction.finalized ? new Date(result.transaction.finalized * 1000).toISOString() : 'N/A';
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
content: [{
|
|
171
|
+
type: "text",
|
|
172
|
+
text: `📊 **Transaction History Retrieved**
|
|
173
|
+
|
|
174
|
+
**Transaction:** ${transactionId}
|
|
175
|
+
**Type:** ${formatInfo.formattedType}
|
|
176
|
+
**Status:** ${formatInfo.formattedStatus}
|
|
177
|
+
|
|
178
|
+
**Transaction Details:**
|
|
179
|
+
- ID: ${result.transaction.transactionId || 'N/A'}
|
|
180
|
+
- Initiated By: ${result.transaction.initiatedBy || 'N/A'}
|
|
181
|
+
- Amount: ${result.transaction.amount ? `${result.transaction.amount} ${result.transaction.currency}` : 'N/A'}
|
|
182
|
+
${result.transaction.paymentMethod ? `- Payment Method: ${result.transaction.paymentMethod}\n` : ''}- Reason: ${result.transaction.reasonL1 || 'N/A'}${result.transaction.reasonL2 ? ` (${result.transaction.reasonL2})` : ''}
|
|
183
|
+
|
|
184
|
+
**Parties:**
|
|
185
|
+
- Payee: ${result.transaction.payeeFriendlyName || 'N/A'} (${result.transaction.payeeAccount || 'N/A'})
|
|
186
|
+
- Payer: ${result.transaction.payerFriendlyName || 'N/A'} (${result.transaction.payerAccount || 'N/A'})
|
|
187
|
+
- Payee BIC: ${result.transaction.payeeBIC || 'N/A'}
|
|
188
|
+
- Payer BIC: ${result.transaction.payerBIC || 'N/A'}
|
|
189
|
+
|
|
190
|
+
**Timeline:**
|
|
191
|
+
- Created: ${created}
|
|
192
|
+
- Finalized: ${finalized}
|
|
193
|
+
- Time to Live: ${result.transaction.timeToLive || 'N/A'} seconds
|
|
194
|
+
|
|
195
|
+
**Status Information:**
|
|
196
|
+
${result.transaction.status ? `- Final Status: ${formatInfo.formattedStatus}` : ''}
|
|
197
|
+
${result.transaction.statusMessage ? `- Status Message: ${result.transaction.statusMessage}` : ''}
|
|
198
|
+
|
|
199
|
+
${result.transaction.deliveryAddress ? `
|
|
200
|
+
**Delivery Address:**
|
|
201
|
+
- Name: ${result.transaction.deliveryAddress.fullName || 'N/A'}
|
|
202
|
+
- Address: ${result.transaction.deliveryAddress.streetAddressLine1 || 'N/A'}
|
|
203
|
+
${result.transaction.deliveryAddress.streetAddressLine2 ? ` ${result.transaction.deliveryAddress.streetAddressLine2}` : ''}
|
|
204
|
+
- City: ${result.transaction.deliveryAddress.city || 'N/A'}, ${result.transaction.deliveryAddress.zipCode || 'N/A'}
|
|
205
|
+
- Region: ${result.transaction.deliveryAddress.region || 'N/A'}
|
|
206
|
+
- Country: ${result.transaction.deliveryAddress.country || 'N/A'}
|
|
207
|
+
- Phone: ${result.transaction.deliveryAddress.phoneNumber || 'N/A'}
|
|
208
|
+
- Email: ${result.transaction.deliveryAddress.email || 'N/A'}
|
|
209
|
+
` : ''}
|
|
210
|
+
|
|
211
|
+
**Full Response:**
|
|
212
|
+
\`\`\`json
|
|
213
|
+
${JSON.stringify(result.transaction, null, 2)}
|
|
214
|
+
\`\`\`
|
|
215
|
+
|
|
216
|
+
**Request ID:** ${result.requestId || 'N/A'}
|
|
217
|
+
**Timestamp:** ${result.timestamp}
|
|
218
|
+
|
|
219
|
+
**Status Meanings:**
|
|
220
|
+
- ✅ CONFIRMED: Successfully finalized
|
|
221
|
+
- ❌ DECLINED: Declined by the user, processing or finalizing payment institutions
|
|
222
|
+
- 💥 FAILED: Failed due to technical reasons or other
|
|
223
|
+
- 🚫 CANCELLED: Transaction canceled by the originator
|
|
224
|
+
- ⏰ EXPIRED: Time to live of the transaction has passed
|
|
225
|
+
|
|
226
|
+
**Note:** This endpoint is throttled and only returns transactions with final statuses. ACTIVE transactions cannot be retrieved here.`
|
|
227
|
+
}]
|
|
228
|
+
};
|
|
229
|
+
} else {
|
|
230
|
+
let errorText = `❌ **Failed to Get Transaction History**
|
|
231
|
+
|
|
232
|
+
**Transaction ID:** ${transactionId}
|
|
233
|
+
|
|
234
|
+
**Error Details:**
|
|
235
|
+
- Message: ${result.error.message}
|
|
236
|
+
- Status: ${result.error.status || 'N/A'}
|
|
237
|
+
- Code: ${result.error.code || 'N/A'}`;
|
|
238
|
+
|
|
239
|
+
if (result.error.throttled) {
|
|
240
|
+
errorText += `
|
|
241
|
+
|
|
242
|
+
**⚠️ THROTTLED REQUEST**
|
|
243
|
+
This endpoint has rate limiting. You've made too many requests recently.
|
|
244
|
+
Please wait before trying again.`;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
errorText += `
|
|
248
|
+
|
|
249
|
+
**Full Error Response:**
|
|
250
|
+
\`\`\`json
|
|
251
|
+
${JSON.stringify(result.error.details || result.error, null, 2)}
|
|
252
|
+
\`\`\`
|
|
253
|
+
|
|
254
|
+
**Timestamp:** ${result.timestamp}
|
|
255
|
+
|
|
256
|
+
**Common Issues:**
|
|
257
|
+
1. **ERR_MISSING_TRANSACTION**: Transaction ID not found
|
|
258
|
+
2. **Too Many Requests (429)**: API rate limit exceeded
|
|
259
|
+
3. **ERR_METHOD_NOT_ALLOWED**: HTTP method issue
|
|
260
|
+
|
|
261
|
+
**Troubleshooting:**
|
|
262
|
+
1. Verify transaction ID is correct: 10 characters total, starts with 'pw' (standard), 'pr' (product), or 'ps' (soundbite)
|
|
263
|
+
2. Ensure transaction exists and you have access to it
|
|
264
|
+
3. If getting rate limit errors, wait 60 seconds before retrying
|
|
265
|
+
4. For ACTIVE transactions, use 'payware_transactions_get_transaction_status' instead
|
|
266
|
+
5. This endpoint only returns transactions with final statuses (CONFIRMED, DECLINED, FAILED, EXPIRED, CANCELLED)`;
|
|
267
|
+
|
|
268
|
+
return {
|
|
269
|
+
content: [{
|
|
270
|
+
type: "text",
|
|
271
|
+
text: errorText
|
|
272
|
+
}]
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
258
276
|
};
|
|
@@ -2,6 +2,7 @@ import axios from 'axios';
|
|
|
2
2
|
import { createJWTToken } from '../../core/auth/jwt-token.js';
|
|
3
3
|
import { createMinimizedJSON } from '../../core/utils/json-serializer.js';
|
|
4
4
|
import { getSandboxUrl, getProductionUrl, getPartnerIdSafe, getPrivateKeySafe } from '../../config/env.js';
|
|
5
|
+
import { apiErrorResult } from '../../shared/api-errors.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Create a payment institution transaction via payware API
|
|
@@ -140,16 +141,7 @@ export async function createPITransaction({
|
|
|
140
141
|
timestamp: new Date().toISOString()
|
|
141
142
|
};
|
|
142
143
|
} catch (error) {
|
|
143
|
-
return
|
|
144
|
-
success: false,
|
|
145
|
-
error: {
|
|
146
|
-
message: error.response?.data?.message || error.message,
|
|
147
|
-
status: error.response?.status,
|
|
148
|
-
code: error.response?.data?.code,
|
|
149
|
-
details: error.response?.data
|
|
150
|
-
},
|
|
151
|
-
timestamp: new Date().toISOString()
|
|
152
|
-
};
|
|
144
|
+
return apiErrorResult(error);
|
|
153
145
|
}
|
|
154
146
|
}
|
|
155
147
|
|