@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.
Files changed (106) hide show
  1. package/.env.example +92 -0
  2. package/MCP-SETUP.md +190 -0
  3. package/README.md +483 -0
  4. package/check-keys.js +52 -0
  5. package/keys/README.md +112 -0
  6. package/mcp-config.json +9 -0
  7. package/package.json +66 -0
  8. package/payware-mcp-config.json +12 -0
  9. package/src/auth/rsa-keys.js +82 -0
  10. package/src/auth/sandbox-setup.js +187 -0
  11. package/src/config/env.js +229 -0
  12. package/src/config/partner-types.js +143 -0
  13. package/src/core/auth/jwt-factory.js +182 -0
  14. package/src/core/auth/jwt-token.js +735 -0
  15. package/src/core/utils/json-serializer.js +100 -0
  16. package/src/core/utils/key-utils.js +133 -0
  17. package/src/index.js +237 -0
  18. package/src/isv/data/index.js +291 -0
  19. package/src/isv/deep-links/delete-product-link.js +154 -0
  20. package/src/isv/deep-links/delete-transaction-link.js +154 -0
  21. package/src/isv/deep-links/get-product-link.js +167 -0
  22. package/src/isv/deep-links/get-transaction-link.js +167 -0
  23. package/src/isv/deep-links/index.js +23 -0
  24. package/src/isv/index.js +103 -0
  25. package/src/isv/oauth2/create-token-simple.js +46 -0
  26. package/src/isv/oauth2/get-token-info.js +157 -0
  27. package/src/isv/oauth2/obtain-token.js +189 -0
  28. package/src/isv/oauth2/token-helper.js +151 -0
  29. package/src/isv/products/audios.js +470 -0
  30. package/src/isv/products/create-product.js +314 -0
  31. package/src/isv/products/delete-product.js +119 -0
  32. package/src/isv/products/get-product-image.js +247 -0
  33. package/src/isv/products/get-product.js +168 -0
  34. package/src/isv/products/index.js +65 -0
  35. package/src/isv/products/list-products.js +136 -0
  36. package/src/isv/products/schedules.js +522 -0
  37. package/src/isv/products/update-product.js +265 -0
  38. package/src/isv/transactions/cancel-transaction.js +129 -0
  39. package/src/isv/transactions/create-transaction.js +361 -0
  40. package/src/isv/transactions/get-status.js +217 -0
  41. package/src/isv/transactions/process-transaction.js +145 -0
  42. package/src/isv/transactions/simulate-callback.js +146 -0
  43. package/src/isv/transactions/transaction-history.js +186 -0
  44. package/src/isv/utils/auth.js +159 -0
  45. package/src/mcp-proxy.js +150 -0
  46. package/src/merchant/data/export-report.js +108 -0
  47. package/src/merchant/data/generate-report.js +151 -0
  48. package/src/merchant/data/get-report-status.js +120 -0
  49. package/src/merchant/data/index.js +351 -0
  50. package/src/merchant/deep-links/delete-product-link.js +121 -0
  51. package/src/merchant/deep-links/delete-transaction-link.js +121 -0
  52. package/src/merchant/deep-links/get-product-link.js +134 -0
  53. package/src/merchant/deep-links/get-transaction-link.js +134 -0
  54. package/src/merchant/deep-links/index.js +23 -0
  55. package/src/merchant/index.js +92 -0
  56. package/src/merchant/products/audios.js +606 -0
  57. package/src/merchant/products/create-product.js +288 -0
  58. package/src/merchant/products/delete-product.js +111 -0
  59. package/src/merchant/products/get-product-image.js +252 -0
  60. package/src/merchant/products/get-product.js +144 -0
  61. package/src/merchant/products/index.js +65 -0
  62. package/src/merchant/products/list-products.js +112 -0
  63. package/src/merchant/products/schedules.js +646 -0
  64. package/src/merchant/products/update-product.js +282 -0
  65. package/src/merchant/transactions/cancel-transaction.js +241 -0
  66. package/src/merchant/transactions/create-transaction.js +482 -0
  67. package/src/merchant/transactions/get-status.js +196 -0
  68. package/src/merchant/transactions/process-transaction.js +349 -0
  69. package/src/merchant/transactions/simulate-callback.js +246 -0
  70. package/src/merchant/transactions/transaction-history.js +258 -0
  71. package/src/payment-institution/data/index.js +280 -0
  72. package/src/payment-institution/deep-links/delete-transaction-link.js +128 -0
  73. package/src/payment-institution/deep-links/get-transaction-link.js +141 -0
  74. package/src/payment-institution/deep-links/index.js +17 -0
  75. package/src/payment-institution/index.js +92 -0
  76. package/src/payment-institution/transactions/create-pi-transaction.js +484 -0
  77. package/src/payment-institution/transactions/finalize-transaction.js +340 -0
  78. package/src/payment-institution/transactions/get-transaction-history.js +269 -0
  79. package/src/payment-institution/transactions/get-transaction-status.js +234 -0
  80. package/src/payment-institution/transactions/process-pi-transaction.js +421 -0
  81. package/src/payment-institution/transactions/simulate-pi-callback.js +326 -0
  82. package/src/payment-institution/transactions/soundbite-transaction.js +269 -0
  83. package/src/proxy-server.js +205 -0
  84. package/src/shared/data/data-api.js +372 -0
  85. package/src/shared/deep-links/api.js +214 -0
  86. package/src/shared/index.js +44 -0
  87. package/src/shared/products/products-api.js +872 -0
  88. package/src/tools/advanced-code-generator.js +2247 -0
  89. package/src/utils/code-examples/common/auth-examples.js +1482 -0
  90. package/src/utils/code-examples/common/helpers.js +416 -0
  91. package/src/utils/code-examples/common/utils-examples.js +591 -0
  92. package/src/utils/code-examples/frameworks/examples.js +859 -0
  93. package/src/utils/code-examples/index.js +441 -0
  94. package/src/utils/code-examples/isv/oauth2.js +600 -0
  95. package/src/utils/code-examples/isv/products.js +666 -0
  96. package/src/utils/code-examples/isv/transactions.js +813 -0
  97. package/src/utils/code-examples/merchant/products.js +497 -0
  98. package/src/utils/code-examples/merchant/transactions.js +623 -0
  99. package/src/utils/code-examples/payment-institution/transactions.js +388 -0
  100. package/src/utils/code-examples/shared/data.js +607 -0
  101. package/src/utils/code-examples/shared/deep-links.js +662 -0
  102. package/src/utils/code-examples/shared/soundbites.js +808 -0
  103. package/src/utils/code-examples.js +646 -0
  104. package/src/utils/format-request.js +363 -0
  105. package/src/utils/json-formatter.js +249 -0
  106. package/src/utils/server-info.js +132 -0
package/.env.example ADDED
@@ -0,0 +1,92 @@
1
+ # payware MCP Server Configuration
2
+ # Copy this file to .env and configure for your partner type
3
+
4
+ # =============================================================================
5
+ # PARTNER TYPE CONFIGURATION (Required)
6
+ # =============================================================================
7
+ # Specify your partner type: merchant, isv, or payment_institution
8
+ # This determines which tools are available and how authentication works
9
+ PAYWARE_PARTNER_TYPE=merchant
10
+
11
+ # =============================================================================
12
+ # COMMON CONFIGURATION (All Partner Types)
13
+ # =============================================================================
14
+
15
+ # Partner ID from payware dashboard (Required)
16
+ PAYWARE_PARTNER_ID=YOUR_PARTNER_ID
17
+
18
+ # Path to private key files - relative to project root (Required)
19
+ # Choose the appropriate private key path for your partner type and environment
20
+ PAYWARE_SANDBOX_PRIVATE_KEY_PATH=keys/sandbox-your-partner-private-key.pem
21
+ PAYWARE_PRODUCTION_PRIVATE_KEY_PATH=keys/production-your-partner-private-key.pem
22
+
23
+ # Sandbox base URL (Optional - defaults to https://sandbox.payware.eu/api)
24
+ PAYWARE_SANDBOX_URL=https://sandbox.payware.eu/api
25
+
26
+ # Production base URL (Optional - defaults to https://api.payware.eu/api)
27
+ PAYWARE_PRODUCTION_URL=https://api.payware.eu/api
28
+
29
+ # =============================================================================
30
+ # ISV-SPECIFIC CONFIGURATION (Only when PAYWARE_PARTNER_TYPE=isv)
31
+ # =============================================================================
32
+
33
+ # OAuth2 Client ID from payware dashboard (Required for ISV)
34
+ PAYWARE_OAUTH_CLIENT_ID=YOUR_CLIENT_ID
35
+
36
+ # OAuth2 Client Secret from payware dashboard (Required for ISV)
37
+ PAYWARE_OAUTH_CLIENT_SECRET=YOUR_CLIENT_SECRET
38
+
39
+ # Default merchant ID to use when not specified (Optional for ISV)
40
+ PAYWARE_DEFAULT_MERCHANT_ID=DEFAULT_MERCHANT_PARTNER_ID
41
+
42
+ # =============================================================================
43
+ # PAYMENT INSTITUTION SPECIFIC (Only when PAYWARE_PARTNER_TYPE=payment_institution)
44
+ # =============================================================================
45
+
46
+ # Additional configuration for Payment Institutions can be added here
47
+ # Currently uses same configuration as merchants
48
+
49
+ # =============================================================================
50
+ # CONFIGURATION EXAMPLES BY PARTNER TYPE
51
+ # =============================================================================
52
+
53
+ # EXAMPLE: Merchant Configuration
54
+ # PAYWARE_PARTNER_TYPE=merchant
55
+ # PAYWARE_PARTNER_ID=MERCHANT123
56
+ # PAYWARE_SANDBOX_PRIVATE_KEY_PATH=keys/sandbox-merchant-private.pem
57
+ # PAYWARE_PRODUCTION_PRIVATE_KEY_PATH=keys/production-merchant-private.pem
58
+
59
+ # EXAMPLE: ISV Configuration
60
+ # PAYWARE_PARTNER_TYPE=isv
61
+ # PAYWARE_PARTNER_ID=ISV456
62
+ # PAYWARE_SANDBOX_PRIVATE_KEY_PATH=keys/sandbox-isv-private.pem
63
+ # PAYWARE_PRODUCTION_PRIVATE_KEY_PATH=keys/production-isv-private.pem
64
+ # PAYWARE_OAUTH_CLIENT_ID=client_abc123
65
+ # PAYWARE_OAUTH_CLIENT_SECRET=secret_xyz789
66
+ # PAYWARE_DEFAULT_MERCHANT_ID=MERCHANT001
67
+
68
+ # EXAMPLE: Payment Institution Configuration
69
+ # PAYWARE_PARTNER_TYPE=payment_institution
70
+ # PAYWARE_PARTNER_ID=PI789
71
+ # PAYWARE_SANDBOX_PRIVATE_KEY_PATH=keys/sandbox-pi-private.pem
72
+ # PAYWARE_PRODUCTION_PRIVATE_KEY_PATH=keys/production-pi-private.pem
73
+
74
+ # =============================================================================
75
+ # PARTNER TYPE DESCRIPTIONS
76
+ # =============================================================================
77
+
78
+ # merchant: Direct businesses accepting payments
79
+ # - Standard JWT authentication (iss=partnerId, aud="https://payware.eu")
80
+ # - Transaction creation, status checking, history
81
+ # - Tools: create/cancel transactions, check status, view history
82
+
83
+ # isv: Independent Software Vendors serving multiple merchants
84
+ # - OAuth2 + JWT hybrid authentication
85
+ # - JWT includes: iss=isvId, aud=merchantId, sub=oauth2Token
86
+ # - Multi-merchant management capabilities
87
+ # - Tools: merchant onboarding, OAuth2 management, transaction creation for merchants
88
+
89
+ # payment_institution: Banks, e-wallets, financial institutions
90
+ # - Standard JWT authentication (same as merchants)
91
+ # - Consumer-facing payment processing and P2P capabilities
92
+ # - Tools: consumer payments, P2P transfers, cross-institution transactions
package/MCP-SETUP.md ADDED
@@ -0,0 +1,190 @@
1
+ # payware MCP Server Configuration
2
+
3
+ This document explains how to configure the payware MCP server for use with Claude Code or other MCP clients.
4
+
5
+ ## Configuration Files
6
+
7
+ ### 1. `mcp-config.json` - Simple Configuration
8
+ Basic MCP server configuration for Claude Code:
9
+
10
+ ```json
11
+ {
12
+ "mcpServers": {
13
+ "payware": {
14
+ "command": "node",
15
+ "args": ["src/index.js"],
16
+ "cwd": "."
17
+ }
18
+ }
19
+ }
20
+ ```
21
+
22
+ ### 2. `payware-mcp-config.json` - Production Configuration
23
+ Enhanced configuration with environment variables:
24
+
25
+ ```json
26
+ {
27
+ "mcpServers": {
28
+ "payware": {
29
+ "command": "node",
30
+ "args": ["src/index.js"],
31
+ "cwd": "/mnt/d/git/payware/mcp",
32
+ "env": {
33
+ "NODE_ENV": "production"
34
+ }
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ ### 3. `claude-code-config.json` - Full Documentation
41
+ Complete configuration with metadata and documentation.
42
+
43
+ ## Setup Instructions
44
+
45
+ ### For Claude Code Users
46
+
47
+ 1. **Choose Configuration File**
48
+ - Use `mcp-config.json` for simple setup
49
+ - Use `payware-mcp-config.json` for production
50
+ - Use `claude-code-config.json` for full documentation
51
+
52
+ 2. **Configure Claude Code**
53
+ - Copy the chosen configuration to your Claude Code MCP settings
54
+ - Update the `cwd` path to match your payware MCP server location
55
+ - Ensure Node.js is available in your PATH
56
+
57
+ 3. **Start payware MCP Server**
58
+ ```bash
59
+ cd /path/to/payware/mcp
60
+ npm install
61
+ node src/index.js
62
+ ```
63
+
64
+ 4. **Test Connection**
65
+ - Open Claude Code
66
+ - Try using `payware_generate_code_example` tool
67
+ - Verify the server responds correctly
68
+
69
+ ### Environment Setup
70
+
71
+ Create a `.env` file in the payware MCP directory:
72
+
73
+ ```env
74
+ # API Configuration
75
+ PAYWARE_SANDBOX_URL=https://sandbox.payware.eu/api
76
+ PAYWARE_PRODUCTION_URL=https://api.payware.eu/api
77
+
78
+ # Partner Configuration (set these for testing)
79
+ PAYWARE_PARTNER_ID=your_partner_id
80
+ PAYWARE_PRIVATE_KEY_FILE=keys/private-key.pem
81
+
82
+ # Server Configuration
83
+ NODE_ENV=development
84
+ PORT=3000
85
+ ```
86
+
87
+ ## Available Tools
88
+
89
+ ### 1. `payware_generate_code_example`
90
+ Generate production-ready code examples for payware API integration.
91
+
92
+ **Parameters:**
93
+ - `operation`: API operation (create_transaction, get_product, etc.)
94
+ - `language`: Programming language (python, nodejs, php, java, csharp, curl)
95
+ - `partner_type`: Partner type (merchant, isv, payment_institution)
96
+ - `include_comments`: Include detailed comments (default: true)
97
+ - `include_error_handling`: Include error handling (default: true)
98
+
99
+ **Example:**
100
+ ```javascript
101
+ payware_generate_code_example({
102
+ operation: "create_transaction",
103
+ language: "python",
104
+ partner_type: "merchant"
105
+ })
106
+ ```
107
+
108
+ ### 2. `payware_generate_documentation`
109
+ Generate comprehensive integration documentation.
110
+
111
+ **Parameters:**
112
+ - `language`: Programming language focus
113
+ - `partner_type`: Partner type for documentation scope
114
+
115
+ **Example:**
116
+ ```javascript
117
+ payware_generate_documentation({
118
+ language: "nodejs",
119
+ partner_type: "merchant"
120
+ })
121
+ ```
122
+
123
+ ## Supported Features
124
+
125
+ - **18+ Operations**: Complete API coverage
126
+ - **6 Languages**: python, nodejs, php, java, csharp, curl
127
+ - **3 Partner Types**: merchant, isv, payment_institution
128
+ - **JWT Authentication**: RS256 with content MD5
129
+ - **Error Handling**: Comprehensive try/catch patterns
130
+ - **Production Ready**: Immediately usable code
131
+
132
+ ## Troubleshooting
133
+
134
+ ### Common Issues
135
+
136
+ 1. **"Command not found: node"**
137
+ - Ensure Node.js is installed and in PATH
138
+ - Update `command` in config to full path: `/usr/bin/node`
139
+
140
+ 2. **"Cannot find module"**
141
+ - Run `npm install` in the payware MCP directory
142
+ - Check that `cwd` path is correct in configuration
143
+
144
+ 3. **"Server not responding"**
145
+ - Verify the server starts without errors
146
+ - Check that port 3000 (or configured port) is available
147
+ - Review server logs for error messages
148
+
149
+ ### Verification Steps
150
+
151
+ 1. **Manual Server Test**
152
+ ```bash
153
+ cd /path/to/payware/mcp
154
+ node src/index.js
155
+ # Should start without errors
156
+ ```
157
+
158
+ 2. **MCP Protocol Test**
159
+ ```bash
160
+ # Test MCP communication (if tools available)
161
+ echo '{"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}}' | node src/index.js
162
+ ```
163
+
164
+ 3. **Claude Code Integration Test**
165
+ - Add server to Claude Code settings
166
+ - Open new conversation
167
+ - Try: `payware_generate_code_example({operation: "authentication", language: "python"})`
168
+
169
+ ## Support
170
+
171
+ For issues with MCP server configuration or integration:
172
+
173
+ 1. Check server logs for error messages
174
+ 2. Verify Node.js and npm versions
175
+ 3. Ensure all dependencies are installed
176
+ 4. Test with simple configuration first
177
+ 5. Review Claude Code MCP documentation
178
+
179
+ ## Security Notes
180
+
181
+ - Store private keys securely outside the repository
182
+ - Use environment variables for sensitive configuration
183
+ - Test with sandbox environment before production
184
+ - Regularly rotate API credentials and private keys
185
+
186
+ ---
187
+
188
+ **Version**: 1.0.0
189
+ **Last Updated**: 2024-01-20
190
+ **Compatible with**: Claude Code, MCP Protocol v1.0