@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
package/.env.example CHANGED
File without changes
package/README.md CHANGED
@@ -10,10 +10,11 @@ Official MCP (Model Context Protocol) server for payware payment API integration
10
10
  - **ISVs (Independent Software Vendors)** - Build multi-merchant platforms with OAuth2 token management
11
11
  - **Payment Institutions** - Process A2A transfers, handle Payment Choice Architecture with multiple payment methods
12
12
 
13
- ## What's New in v1.1.0
13
+ ## What's New in v1.2.0
14
14
 
15
- - **Point of Interaction (POI)** - Full POI management: set prices, get status, generate QR codes, list and manage POIs
16
- - **Payment Choice Architecture** - Support for `paymentMethod` field (A2A, CARD_FUNDED, BNPL, INSTANT_CREDIT) in transaction processing
15
+ - **SHA-256 Authentication** - Upgraded from MD5 to SHA-256 for JWT content hashing (`contentSha256` header)
16
+ - **Updated Error Codes** - New error codes: `ERR_INVALID_CONTENT_HASH`, `ERR_MISSING_CONTENT_HASH`
17
+ - **Backward Compatibility** - Deprecated MD5 functions retained for legacy support
17
18
 
18
19
  ## Features
19
20
 
@@ -37,6 +38,11 @@ Official MCP (Model Context Protocol) server for payware payment API integration
37
38
  - **Get QR Code**: Generate QR code for POI payments
38
39
  - **List POIs**: List all POIs for a merchant
39
40
 
41
+ ### 📋 Logs Tools (Premium)
42
+ - **Query Logs**: Search and filter application logs by level, logger, message content, and date range
43
+ - **Log Status**: Check log availability and storage information
44
+ - **Download Logs**: Get compressed archive of logs for offline analysis
45
+
40
46
  ### 🛠️ Utility Tools
41
47
  - **Advanced Code Generation**: Generate complete integration code across 8 languages (Python, Node.js, PHP, Java, C#, Go, Ruby, cURL) with 16+ framework support
42
48
  - **Framework Integration**: Framework-specific examples for Django, FastAPI, Express, NestJS, Laravel, Spring Boot, ASP.NET, and more
@@ -375,7 +381,7 @@ Generate comprehensive API documentation with code examples.
375
381
  - `outputFormat` (optional): markdown, html, json (default: markdown)
376
382
 
377
383
  #### `payware_utils_format_request`
378
- Format and validate API requests with deterministic JSON serialization for MD5 consistency.
384
+ Format and validate API requests with deterministic JSON serialization for SHA-256 consistency.
379
385
 
380
386
  **Parameters:**
381
387
  - `type` (required): transaction, headers, or curl
@@ -386,7 +392,7 @@ Format and validate API requests with deterministic JSON serialization for MD5 c
386
392
  - `method` (optional): HTTP method (default: POST)
387
393
 
388
394
  #### `payware_utils_format_json_deterministic`
389
- Format JSON with deterministic property ordering for consistent MD5 calculation.
395
+ Format JSON with deterministic property ordering for consistent SHA-256 calculation.
390
396
 
391
397
  **Parameters:**
392
398
  - `data` (required): Object to serialize
@@ -395,7 +401,7 @@ Format JSON with deterministic property ordering for consistent MD5 calculation.
395
401
  #### `payware_utils_server_info`
396
402
  Get MCP server information and configuration.
397
403
 
398
- **Note:** All transaction data is serialized using consistent property ordering to prevent MD5 mismatch errors.
404
+ **Note:** All transaction data is serialized using consistent property ordering to prevent content hash mismatch errors.
399
405
 
400
406
  ## Dependencies
401
407
 
@@ -435,12 +441,12 @@ Get MCP server information and configuration.
435
441
  - Validate all input parameters
436
442
  - Implement rate limiting and monitoring
437
443
 
438
- ### JSON Serialization & MD5 Consistency
439
- ⚠️ **CRITICAL**: payware API requires deterministic JSON serialization for MD5 calculation
444
+ ### JSON Serialization & SHA-256 Consistency
445
+ ⚠️ **CRITICAL**: payware API requires deterministic JSON serialization for SHA-256 calculation
440
446
 
441
447
  - **Property Order**: JSON objects must have consistent property ordering
442
448
  - **Minimized Format**: No whitespace or formatting in request bodies
443
- - **MD5 Calculation**: Must be calculated from the exact same JSON string sent to API
449
+ - **SHA-256 Calculation**: Must be calculated from the exact same JSON string sent to API
444
450
  - **Implementation**: This server uses deterministic JSON serialization to ensure consistency
445
451
 
446
452
  **Example of correct JSON format:**
@@ -449,9 +455,9 @@ Get MCP server information and configuration.
449
455
  ```
450
456
 
451
457
  **Why this matters:**
452
- - Different property orders produce different MD5 hashes
453
- - MD5 mismatch results in `ContentMd5 mismatch` errors
454
- - Server validates that JWT contentMd5 matches request body MD5
458
+ - Different property orders produce different SHA-256 hashes
459
+ - Hash mismatch results in `ERR_INVALID_CONTENT_HASH` errors
460
+ - Server validates that JWT `contentSha256` matches request body SHA-256
455
461
 
456
462
  ## Troubleshooting
457
463
 
@@ -463,11 +469,11 @@ Get MCP server information and configuration.
463
469
  - **Verification**: Use `openssl rsa -in privateKey.pem -pubout` to extract public key from private key
464
470
  - **Status**: ✅ Resolved - Keys must be properly registered on payware partner portal
465
471
 
466
- 2. **ContentMd5 Mismatch Error**
472
+ 2. **Content Hash Mismatch Error (ERR_INVALID_CONTENT_HASH)**
467
473
  - **Root Cause**: Inconsistent JSON property ordering
468
474
  - **Solution**: Use deterministic JSON serialization (implemented in this server)
469
- - **Symptoms**: Server logs show different expected vs actual MD5 hashes
470
- - **Prevention**: Always use `createMinimizedJSON()` from `/src/utils/json-serializer.js`
475
+ - **Symptoms**: Server logs show different expected vs actual SHA-256 hashes
476
+ - **Prevention**: Always use `createMinimizedJSON()` from `/src/core/utils/json-serializer.js`
471
477
  - **Status**: ✅ Fixed - Deterministic JSON serialization implemented
472
478
 
473
479
  3. **Transaction Creation Failed**
@@ -500,7 +506,7 @@ Get MCP server information and configuration.
500
506
  - JWT token creation with RS256 algorithm
501
507
  - Transaction creation (POST /api/transactions)
502
508
  - Transaction cancellation (PATCH /api/transactions/{id})
503
- - Deterministic JSON serialization for MD5 consistency
509
+ - Deterministic JSON serialization for SHA-256 consistency
504
510
  - Public/private key pair validation
505
511
 
506
512
  **🧪 Test Results:**
package/check-keys.js CHANGED
File without changes
package/keys/README.md CHANGED
File without changes
package/mcp-config.json CHANGED
File without changes
package/package.json CHANGED
@@ -1,66 +1,69 @@
1
- {
2
- "name": "@payware/mcp-server",
3
- "version": "1.1.1",
4
- "description": "Official MCP server for payware payment API integration",
5
- "main": "src/index.js",
6
- "type": "module",
7
- "bin": {
8
- "payware-mcp": "./src/index.js"
9
- },
10
- "scripts": {
11
- "start": "node src/index.js",
12
- "dev": "node --watch src/index.js",
13
- "proxy": "node src/proxy-server.js",
14
- "proxy:dev": "node --watch src/proxy-server.js",
15
- "bridge": "node src/mcp-proxy.js",
16
- "inspector": "npx @modelcontextprotocol/inspector node src/mcp-proxy.js"
17
- },
18
- "dependencies": {
19
- "@modelcontextprotocol/sdk": "^0.5.0",
20
- "axios": "^1.6.0",
21
- "cors": "^2.8.5",
22
- "dotenv": "^17.2.2",
23
- "express": "^5.1.0",
24
- "http-proxy-middleware": "^3.0.5",
25
- "jsonwebtoken": "^9.0.0",
26
- "node-forge": "^1.3.1"
27
- },
28
- "engines": {
29
- "node": ">=18.0.0"
30
- },
31
- "keywords": [
32
- "mcp",
33
- "model-context-protocol",
34
- "payware",
35
- "payments",
36
- "payment-gateway",
37
- "payment-processing",
38
- "api",
39
- "fintech",
40
- "pos",
41
- "terminal",
42
- "merchant",
43
- "isv",
44
- "oauth2"
45
- ],
46
- "author": "payware <support@payware.com>",
47
- "license": "MIT",
48
- "repository": {
49
- "type": "git",
50
- "url": "git+https://github.com/payware/mcp-server.git"
51
- },
52
- "bugs": {
53
- "url": "https://github.com/payware/mcp-server/issues"
54
- },
55
- "homepage": "https://github.com/payware/mcp-server#readme",
56
- "files": [
57
- "src/",
58
- "keys/README.md",
59
- "README.md",
60
- "check-keys.js",
61
- "mcp-config.json",
62
- "payware-mcp-config.json",
63
- ".env.example",
64
- "MCP-SETUP.md"
65
- ]
66
- }
1
+ {
2
+ "name": "@payware/mcp-server",
3
+ "version": "1.3.0",
4
+ "description": "Official MCP server for payware payment API integration",
5
+ "main": "src/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "payware-mcp": "src/index.js"
9
+ },
10
+ "scripts": {
11
+ "start": "node src/index.js",
12
+ "dev": "node --watch src/index.js",
13
+ "proxy": "node src/proxy-server.js",
14
+ "proxy:dev": "node --watch src/proxy-server.js",
15
+ "bridge": "node src/mcp-proxy.js",
16
+ "inspector": "npx @modelcontextprotocol/inspector node src/mcp-proxy.js",
17
+ "test": "node --test tests/api-errors.test.js tests/json-serializer.test.js tests/request-contract.test.js tests/tool-contract.test.js",
18
+ "test:watch": "node --test --watch tests/api-errors.test.js tests/json-serializer.test.js tests/request-contract.test.js tests/tool-contract.test.js",
19
+ "check": "node --check src/index.js && npm test"
20
+ },
21
+ "dependencies": {
22
+ "@modelcontextprotocol/sdk": "^0.5.0",
23
+ "axios": "^1.6.0",
24
+ "cors": "^2.8.5",
25
+ "dotenv": "^17.2.2",
26
+ "express": "^5.1.0",
27
+ "http-proxy-middleware": "^3.0.5",
28
+ "jsonwebtoken": "^9.0.0",
29
+ "node-forge": "^1.3.1"
30
+ },
31
+ "engines": {
32
+ "node": ">=18.0.0"
33
+ },
34
+ "keywords": [
35
+ "mcp",
36
+ "model-context-protocol",
37
+ "payware",
38
+ "payments",
39
+ "payment-gateway",
40
+ "payment-processing",
41
+ "api",
42
+ "fintech",
43
+ "pos",
44
+ "terminal",
45
+ "merchant",
46
+ "isv",
47
+ "oauth2"
48
+ ],
49
+ "author": "payware <support@payware.com>",
50
+ "license": "MIT",
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "git+https://github.com/payware/mcp-server.git"
54
+ },
55
+ "bugs": {
56
+ "url": "https://github.com/payware/mcp-server/issues"
57
+ },
58
+ "homepage": "https://github.com/payware/mcp-server#readme",
59
+ "files": [
60
+ "src/",
61
+ "keys/README.md",
62
+ "README.md",
63
+ "check-keys.js",
64
+ "mcp-config.json",
65
+ "payware-mcp-config.json",
66
+ ".env.example",
67
+ "MCP-SETUP.md"
68
+ ]
69
+ }
File without changes
File without changes
@@ -1,187 +1,187 @@
1
- /**
2
- * Setup sandbox authentication configuration
3
- */
4
-
5
- import { getPartnerIdSafe, getPrivateKeySafe } from '../config/env.js';
6
-
7
- const SANDBOX_CONFIG = {
8
- baseUrl: 'https://sandbox.payware.eu/api',
9
- apiVersion: '1',
10
- environment: 'sandbox',
11
- supportedCurrencies: [
12
- // Major currencies
13
- 'EUR', 'USD', 'GBP', 'JPY', 'CHF', 'CAD', 'AUD', 'CNY', 'SEK', 'NOK', 'DKK',
14
- // All other supported currencies (100+ total)
15
- 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AWG', 'AZN',
16
- 'BAM', 'BBD', 'BDT', 'BGN', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BRL', 'BSD', 'BTC', 'BTN', 'BWP', 'BYN', 'BZD',
17
- 'CDF', 'CLP', 'COP', 'CRC', 'CUP', 'CVE', 'CZK',
18
- 'DJF', 'DOP', 'DZD',
19
- 'EGP', 'ERN', 'ETB',
20
- 'FJD', 'FKP',
21
- 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD',
22
- 'HKD', 'HNL', 'HRK', 'HTG', 'HUF',
23
- 'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK',
24
- 'JMD', 'JOD',
25
- 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT',
26
- 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LYD',
27
- 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MUR', 'MVR', 'MWK', 'MXN', 'MYR', 'MZN',
28
- 'NAD', 'NGN', 'NIO', 'NPR', 'NZD',
29
- 'OMR',
30
- 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG',
31
- 'QAR',
32
- 'RON', 'RSD', 'RUB', 'RWF',
33
- 'SAR', 'SBD', 'SCR', 'SDG', 'SGD', 'SHP', 'SLL', 'SOS', 'SRD', 'STD', 'SVC', 'SYP', 'SZL',
34
- 'THB', 'TJS', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS',
35
- 'UAH', 'UGX', 'UYU', 'UZS',
36
- 'VND', 'VUV',
37
- 'WST',
38
- 'XAF', 'XCD', 'XOF', 'XPF',
39
- 'YER',
40
- 'ZAR', 'ZMW', 'ZWL'
41
- ], // ISO 3-character codes
42
- supportedTransactionTypes: ['PLAIN', 'QR', 'BARCODE'], // trOptions.type values
43
- transactionTypes: ['DEFAULT', 'SHIPPABLE'], // transactionType values
44
- maxAmount: 'Unlimited', // Limited by Java type implementation
45
- minAmount: '0.00', // Zero allowed for flexible amounts
46
- maxTTL: 600, // seconds
47
- minTTL: 60, // seconds
48
- defaultTTL: 120, // seconds
49
- audience: 'https://payware.eu', // Required JWT audience
50
- transactionIdPrefix: 'pw' // All transaction IDs start with 'pw'
51
- };
52
-
53
- /**
54
- * Generate sandbox configuration
55
- * @param {string} partnerId - Partner ID
56
- * @param {string} privateKey - Private key (optional, for validation)
57
- * @returns {Object} Sandbox configuration object
58
- */
59
- export function generateSandboxConfig(partnerId, privateKey = null) {
60
- const config = {
61
- ...SANDBOX_CONFIG,
62
- partnerId,
63
- endpoints: {
64
- createTransaction: `${SANDBOX_CONFIG.baseUrl}/transactions`,
65
- getTransactionStatus: `${SANDBOX_CONFIG.baseUrl}/transactions/{id}`,
66
- processTransaction: `${SANDBOX_CONFIG.baseUrl}/transactions/{id}`,
67
- cancelTransaction: `${SANDBOX_CONFIG.baseUrl}/transactions/{id}`,
68
- getTransactionHistory: `${SANDBOX_CONFIG.baseUrl}/transactions-history/{id}`,
69
- callback: 'https://your-callback-url' // Provided by merchant
70
- },
71
- headers: {
72
- 'Content-Type': 'application/json',
73
- 'Api-Version': '1'
74
- },
75
- authentication: {
76
- type: 'JWT',
77
- algorithm: 'RS256',
78
- audience: 'https://payware.eu',
79
- requiresContentMd5: 'For POST/PUT/PATCH requests',
80
- hasPrivateKey: !!privateKey
81
- },
82
- generatedAt: new Date().toISOString()
83
- };
84
-
85
- return config;
86
- }
87
-
88
- /**
89
- * Setup sandbox auth tool implementation
90
- */
91
- export const setupSandboxAuthTool = {
92
- name: "payware_authentication_setup_sandbox_auth",
93
- description: "Setup sandbox authentication configuration for payware API",
94
- inputSchema: {
95
- type: "object",
96
- properties: {
97
- partnerId: {
98
- type: "string",
99
- description: "Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default."
100
- },
101
- privateKey: {
102
- type: "string",
103
- description: "RSA private key in PEM format (optional, for validation). Uses environment-specific private key as default."
104
- }
105
- },
106
- additionalProperties: false
107
- },
108
-
109
- async handler(args) {
110
- const {
111
- partnerId = getPartnerIdSafe(),
112
- privateKey = getPrivateKeySafe()
113
- } = args;
114
-
115
- if (!partnerId) {
116
- throw new Error("Partner ID is required. Provide via 'partnerId' parameter or set PAYWARE_PARTNER_ID environment variable.");
117
- }
118
-
119
- const config = generateSandboxConfig(partnerId, privateKey);
120
-
121
- return {
122
- content: [{
123
- type: "text",
124
- text: `🔧 **Sandbox Authentication Setup Complete**
125
-
126
- **Configuration:**
127
- \`\`\`json
128
- ${JSON.stringify(config, null, 2)}
129
- \`\`\`
130
-
131
- **Environment Details:**
132
- - Base URL: ${config.baseUrl}
133
- - API Version: ${config.apiVersion}
134
- - Environment: ${config.environment}
135
- - Partner ID: ${config.partnerId}
136
-
137
- **Supported Features:**
138
- - Request Types (trOptions.type): ${config.supportedTransactionTypes.join(', ')}
139
- - Transaction Types: ${config.transactionTypes.join(', ')}
140
- - Currencies: ${config.supportedCurrencies.join(', ')} (ISO 3-char codes)
141
- - Amount Range: €${config.minAmount} - ${config.maxAmount} (currency values)
142
- - TTL Range: ${config.minTTL}-${config.maxTTL} seconds (default: ${config.defaultTTL})
143
- - Transaction ID Format: Starts with '${config.transactionIdPrefix}'
144
- - QR Options: Format (PNG/JPEG/SVG), Border, Error Correction (L/M/Q/H), Scale, Version
145
- - Barcode Options: Format (CODE128/CODE39/EAN13), Width, Height, Font Size, Text Location
146
- - Additional: passbackParams for custom callback data
147
-
148
- **API Endpoints:**
149
- - Create Transaction: \`POST ${config.endpoints.createTransaction}\`
150
- - Get Transaction Status: \`GET ${config.endpoints.getTransactionStatus}\`
151
- - Process Transaction: \`POST ${config.endpoints.processTransaction}\` (merchants only)
152
- - Cancel Transaction: \`PATCH ${config.endpoints.cancelTransaction}\` (creators only)
153
- - Transaction History: \`GET ${config.endpoints.getTransactionHistory}\` (completed/expired)
154
- - Callback Endpoint: \`POST [your-callback-url]\` (configured by you)
155
-
156
- **Required Headers (All Requests):**
157
- ${Object.entries(config.headers).map(([key, value]) => `- ${key}: ${value}`).join('\n')}
158
- - Authorization: Bearer {JWT_TOKEN} (with contentMd5 for POST/PATCH)
159
-
160
- **JWT Requirements:**
161
- - Algorithm: RS256
162
- - Issuer (iss): Your Partner ID
163
- - Audience (aud): https://payware.eu
164
- - Content-MD5: Required in JWT header for POST/PATCH requests
165
- - Private Key: RSA 2048-bit minimum
166
-
167
- **Required Fields for Transaction Creation:**
168
- - trData.currency: ISO 3-character code (required)
169
- - trData.reasonL1: Description, max 100 chars (required)
170
- - trData.reasonL2: Continuation, max 100 chars (optional)
171
- - trData.amount: Currency value as string/number, 0.00+ (optional for flexible)
172
- - trOptions.type: PLAIN, QR, or BARCODE (default: PLAIN)
173
- - trOptions.timeToLive: 60-600 seconds (default: 120)
174
-
175
- **Next Steps:**
176
- 1. Generate RSA key pair (2048-bit minimum)
177
- 2. Register public key in payware portal
178
- 3. Create JWT token with proper structure
179
- 4. Test with create transaction endpoint
180
- 5. Implement callback handler for status updates
181
-
182
- **⚠️ Sandbox Only:**
183
- This configuration is for sandbox testing only. Do not use in production.`
184
- }]
185
- };
186
- }
1
+ /**
2
+ * Setup sandbox authentication configuration
3
+ */
4
+
5
+ import { getPartnerIdSafe, getPrivateKeySafe } from '../config/env.js';
6
+
7
+ const SANDBOX_CONFIG = {
8
+ baseUrl: 'https://sandbox.payware.eu/api',
9
+ apiVersion: '1',
10
+ environment: 'sandbox',
11
+ supportedCurrencies: [
12
+ // Major currencies
13
+ 'EUR', 'USD', 'GBP', 'JPY', 'CHF', 'CAD', 'AUD', 'CNY', 'SEK', 'NOK', 'DKK',
14
+ // All other supported currencies (100+ total)
15
+ 'AED', 'AFN', 'ALL', 'AMD', 'ANG', 'AOA', 'ARS', 'AWG', 'AZN',
16
+ 'BAM', 'BBD', 'BDT', 'BHD', 'BIF', 'BMD', 'BND', 'BOB', 'BRL', 'BSD', 'BTC', 'BTN', 'BWP', 'BYN', 'BZD',
17
+ 'CDF', 'CLP', 'COP', 'CRC', 'CUP', 'CVE', 'CZK',
18
+ 'DJF', 'DOP', 'DZD',
19
+ 'EGP', 'ERN', 'ETB',
20
+ 'FJD', 'FKP',
21
+ 'GEL', 'GHS', 'GIP', 'GMD', 'GNF', 'GTQ', 'GYD',
22
+ 'HKD', 'HNL', 'HRK', 'HTG', 'HUF',
23
+ 'IDR', 'ILS', 'INR', 'IQD', 'IRR', 'ISK',
24
+ 'JMD', 'JOD',
25
+ 'KES', 'KGS', 'KHR', 'KMF', 'KPW', 'KRW', 'KWD', 'KYD', 'KZT',
26
+ 'LAK', 'LBP', 'LKR', 'LRD', 'LSL', 'LYD',
27
+ 'MAD', 'MDL', 'MGA', 'MKD', 'MMK', 'MNT', 'MOP', 'MRO', 'MUR', 'MVR', 'MWK', 'MXN', 'MYR', 'MZN',
28
+ 'NAD', 'NGN', 'NIO', 'NPR', 'NZD',
29
+ 'OMR',
30
+ 'PAB', 'PEN', 'PGK', 'PHP', 'PKR', 'PLN', 'PYG',
31
+ 'QAR',
32
+ 'RON', 'RSD', 'RUB', 'RWF',
33
+ 'SAR', 'SBD', 'SCR', 'SDG', 'SGD', 'SHP', 'SLL', 'SOS', 'SRD', 'STD', 'SVC', 'SYP', 'SZL',
34
+ 'THB', 'TJS', 'TMT', 'TND', 'TOP', 'TRY', 'TTD', 'TWD', 'TZS',
35
+ 'UAH', 'UGX', 'UYU', 'UZS',
36
+ 'VND', 'VUV',
37
+ 'WST',
38
+ 'XAF', 'XCD', 'XOF', 'XPF',
39
+ 'YER',
40
+ 'ZAR', 'ZMW', 'ZWL'
41
+ ], // ISO 3-character codes
42
+ supportedTransactionTypes: ['PLAIN', 'QR', 'BARCODE'], // trOptions.type values
43
+ transactionTypes: ['DEFAULT', 'SHIPPABLE'], // transactionType values
44
+ maxAmount: 'Unlimited', // Limited by Java type implementation
45
+ minAmount: '0.00', // Zero allowed for flexible amounts
46
+ maxTTL: 600, // seconds
47
+ minTTL: 60, // seconds
48
+ defaultTTL: 120, // seconds
49
+ audience: 'https://payware.eu', // Required JWT audience
50
+ transactionIdPrefix: 'pw' // All transaction IDs start with 'pw'
51
+ };
52
+
53
+ /**
54
+ * Generate sandbox configuration
55
+ * @param {string} partnerId - Partner ID
56
+ * @param {string} privateKey - Private key (optional, for validation)
57
+ * @returns {Object} Sandbox configuration object
58
+ */
59
+ export function generateSandboxConfig(partnerId, privateKey = null) {
60
+ const config = {
61
+ ...SANDBOX_CONFIG,
62
+ partnerId,
63
+ endpoints: {
64
+ createTransaction: `${SANDBOX_CONFIG.baseUrl}/transactions`,
65
+ getTransactionStatus: `${SANDBOX_CONFIG.baseUrl}/transactions/{id}`,
66
+ processTransaction: `${SANDBOX_CONFIG.baseUrl}/transactions/{id}`,
67
+ cancelTransaction: `${SANDBOX_CONFIG.baseUrl}/transactions/{id}`,
68
+ getTransactionHistory: `${SANDBOX_CONFIG.baseUrl}/transactions-history/{id}`,
69
+ callback: 'https://your-callback-url' // Provided by merchant
70
+ },
71
+ headers: {
72
+ 'Content-Type': 'application/json',
73
+ 'Api-Version': '1'
74
+ },
75
+ authentication: {
76
+ type: 'JWT',
77
+ algorithm: 'RS256',
78
+ audience: 'https://payware.eu',
79
+ requiresContentMd5: 'For POST/PUT/PATCH requests',
80
+ hasPrivateKey: !!privateKey
81
+ },
82
+ generatedAt: new Date().toISOString()
83
+ };
84
+
85
+ return config;
86
+ }
87
+
88
+ /**
89
+ * Setup sandbox auth tool implementation
90
+ */
91
+ export const setupSandboxAuthTool = {
92
+ name: "payware_authentication_setup_sandbox_auth",
93
+ description: "Setup sandbox authentication configuration for payware API",
94
+ inputSchema: {
95
+ type: "object",
96
+ properties: {
97
+ partnerId: {
98
+ type: "string",
99
+ description: "Partner ID from payware dashboard. Uses PAYWARE_PARTNER_ID env var as default."
100
+ },
101
+ privateKey: {
102
+ type: "string",
103
+ description: "RSA private key in PEM format (optional, for validation). Uses environment-specific private key as default."
104
+ }
105
+ },
106
+ additionalProperties: false
107
+ },
108
+
109
+ async handler(args) {
110
+ const {
111
+ partnerId = getPartnerIdSafe(),
112
+ privateKey = getPrivateKeySafe()
113
+ } = args;
114
+
115
+ if (!partnerId) {
116
+ throw new Error("Partner ID is required. Provide via 'partnerId' parameter or set PAYWARE_PARTNER_ID environment variable.");
117
+ }
118
+
119
+ const config = generateSandboxConfig(partnerId, privateKey);
120
+
121
+ return {
122
+ content: [{
123
+ type: "text",
124
+ text: `🔧 **Sandbox Authentication Setup Complete**
125
+
126
+ **Configuration:**
127
+ \`\`\`json
128
+ ${JSON.stringify(config, null, 2)}
129
+ \`\`\`
130
+
131
+ **Environment Details:**
132
+ - Base URL: ${config.baseUrl}
133
+ - API Version: ${config.apiVersion}
134
+ - Environment: ${config.environment}
135
+ - Partner ID: ${config.partnerId}
136
+
137
+ **Supported Features:**
138
+ - Request Types (trOptions.type): ${config.supportedTransactionTypes.join(', ')}
139
+ - Transaction Types: ${config.transactionTypes.join(', ')}
140
+ - Currencies: ${config.supportedCurrencies.join(', ')} (ISO 3-char codes)
141
+ - Amount Range: €${config.minAmount} - ${config.maxAmount} (currency values)
142
+ - TTL Range: ${config.minTTL}-${config.maxTTL} seconds (default: ${config.defaultTTL})
143
+ - Transaction ID Format: Starts with '${config.transactionIdPrefix}'
144
+ - QR Options: Format (PNG/JPEG/SVG), Border, Error Correction (L/M/Q/H), Scale, Version
145
+ - Barcode Options: Format (CODE128/CODE39/EAN13), Width, Height, Font Size, Text Location
146
+ - Additional: passbackParams for custom callback data
147
+
148
+ **API Endpoints:**
149
+ - Create Transaction: \`POST ${config.endpoints.createTransaction}\`
150
+ - Get Transaction Status: \`GET ${config.endpoints.getTransactionStatus}\`
151
+ - Process Transaction: \`POST ${config.endpoints.processTransaction}\` (merchants only)
152
+ - Cancel Transaction: \`PATCH ${config.endpoints.cancelTransaction}\` (creators only)
153
+ - Transaction History: \`GET ${config.endpoints.getTransactionHistory}\` (completed/expired)
154
+ - Callback Endpoint: \`POST [your-callback-url]\` (configured by you)
155
+
156
+ **Required Headers (All Requests):**
157
+ ${Object.entries(config.headers).map(([key, value]) => `- ${key}: ${value}`).join('\n')}
158
+ - Authorization: Bearer {JWT_TOKEN} (with contentSha256 for POST/PATCH)
159
+
160
+ **JWT Requirements:**
161
+ - Algorithm: RS256
162
+ - Issuer (iss): Your Partner ID
163
+ - Audience (aud): https://payware.eu
164
+ - Content-SHA256: Required in JWT header for POST/PATCH requests
165
+ - Private Key: RSA 2048-bit minimum
166
+
167
+ **Required Fields for Transaction Creation:**
168
+ - trData.currency: ISO 3-character code (required)
169
+ - trData.reasonL1: Description, max 100 chars (required)
170
+ - trData.reasonL2: Continuation, max 100 chars (optional)
171
+ - trData.amount: Currency value as string/number, 0.00+ (optional for flexible)
172
+ - trOptions.type: PLAIN, QR, or BARCODE (default: PLAIN)
173
+ - trOptions.timeToLive: 60-600 seconds (default: 120)
174
+
175
+ **Next Steps:**
176
+ 1. Generate RSA key pair (2048-bit minimum)
177
+ 2. Register public key in payware portal
178
+ 3. Create JWT token with proper structure
179
+ 4. Test with create transaction endpoint
180
+ 5. Implement callback handler for status updates
181
+
182
+ **⚠️ Sandbox Only:**
183
+ This configuration is for sandbox testing only. Do not use in production.`
184
+ }]
185
+ };
186
+ }
187
187
  };
package/src/config/env.js CHANGED
File without changes
File without changes