@payware/mcp-server 1.3.1 → 1.3.3
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/package.json +1 -1
- package/src/auth/sandbox-setup.js +1 -1
- package/src/core/auth/jwt-token.js +61 -51
- package/src/isv/invitations/index.js +2 -1
- package/src/isv/oauth2/get-token-info.js +7 -5
- package/src/isv/oauth2/obtain-token.js +6 -4
- package/src/isv/oauth2/token-helper.js +26 -26
- package/src/isv/poi/cancel-price.js +7 -2
- package/src/isv/poi/get-poi.js +2 -3
- package/src/isv/poi/get-status.js +194 -168
- package/src/isv/poi/list-pois.js +4 -6
- package/src/isv/poi/set-price.js +38 -53
- package/src/isv/products/create-product.js +1 -1
- package/src/isv/transactions/simulate-callback.js +19 -10
- package/src/merchant/transactions/create-transaction.js +1 -1
- package/src/merchant/transactions/simulate-callback.js +322 -313
- package/src/merchant/transactions/transaction-history.js +2 -2
- package/src/payment-institution/transactions/get-transaction-history.js +1 -1
- package/src/payment-institution/transactions/get-transaction-status.js +1 -1
- package/src/payment-institution/transactions/simulate-pi-callback.js +385 -375
- package/src/payment-institution/transactions/soundbite-transaction.js +1 -1
- package/src/shared/poi/poi-create-api.js +1 -1
- package/src/tools/advanced-code-generator.js +14 -265
- package/src/utils/code-examples/common/auth-examples.js +1 -1
- package/src/utils/code-examples/isv/products.js +1 -1
- package/src/utils/code-examples/isv/transactions.js +1 -1
- package/src/utils/code-examples/merchant/transactions.js +1 -1
- package/src/utils/code-examples.js +2 -2
|
@@ -148,7 +148,7 @@ export const soundbiteTransactionTool = {
|
|
|
148
148
|
|
|
149
149
|
if (result.success) {
|
|
150
150
|
const tx = result.transaction;
|
|
151
|
-
const createdDate = tx.created ? new Date(tx.created
|
|
151
|
+
const createdDate = tx.created ? new Date(tx.created).toISOString() : 'N/A';
|
|
152
152
|
const typeDisplay = tx.transactionType || 'DEFAULT';
|
|
153
153
|
const initiatorDisplay = tx.initiatedBy || 'UNKNOWN';
|
|
154
154
|
|
|
@@ -241,7 +241,7 @@ ${isIsv ? `
|
|
|
241
241
|
},
|
|
242
242
|
callbackUrl: {
|
|
243
243
|
type: 'string',
|
|
244
|
-
description: 'HTTPS URL for POI
|
|
244
|
+
description: 'HTTPS URL for this POI\'s callbacks: poi.scanned (with the new transaction id), poi.expired (price not scanned) and the sale\'s TRANSACTION_FINALIZED (final status, with poiId). Signed by the ISV that set the price, otherwise the merchant. A POI without one sends no callbacks - there is no per-price callback URL. Must present a publicly-trusted TLS certificate and resolve to a public address.',
|
|
245
245
|
format: 'uri'
|
|
246
246
|
},
|
|
247
247
|
useSandbox: {
|
|
@@ -324,22 +324,21 @@ class AdvancedCodeGenerator {
|
|
|
324
324
|
*/
|
|
325
325
|
generateAuthenticationExample(language, partnerType, options) {
|
|
326
326
|
const AuthGen = AuthGenerators[language];
|
|
327
|
-
if (AuthGen) {
|
|
328
|
-
|
|
329
|
-
const envTemplate = generator.getEnvironmentTemplate(partnerType, options);
|
|
330
|
-
const depsTemplate = generator.getDependenciesTemplate(options);
|
|
331
|
-
const authTemplate = generator.getAuthTemplate(partnerType, options);
|
|
332
|
-
|
|
333
|
-
return this.wrapCompleteExample(
|
|
334
|
-
`${envTemplate}\n\n${depsTemplate}\n\n${authTemplate}`,
|
|
335
|
-
'Authentication Setup',
|
|
336
|
-
language,
|
|
337
|
-
partnerType,
|
|
338
|
-
options
|
|
339
|
-
);
|
|
340
|
-
} else {
|
|
341
|
-
return this.generateBasicAuthExample(language, partnerType, options);
|
|
327
|
+
if (!AuthGen) {
|
|
328
|
+
throw new Error(`No authentication generator for language: ${language}`);
|
|
342
329
|
}
|
|
330
|
+
const generator = new AuthGen();
|
|
331
|
+
const envTemplate = generator.getEnvironmentTemplate(partnerType, options);
|
|
332
|
+
const depsTemplate = generator.getDependenciesTemplate(options);
|
|
333
|
+
const authTemplate = generator.getAuthTemplate(partnerType, options);
|
|
334
|
+
|
|
335
|
+
return this.wrapCompleteExample(
|
|
336
|
+
`${envTemplate}\n\n${depsTemplate}\n\n${authTemplate}`,
|
|
337
|
+
'Authentication Setup',
|
|
338
|
+
language,
|
|
339
|
+
partnerType,
|
|
340
|
+
options
|
|
341
|
+
);
|
|
343
342
|
}
|
|
344
343
|
|
|
345
344
|
/**
|
|
@@ -1455,256 +1454,6 @@ echo "✅ Request completed"`;
|
|
|
1455
1454
|
return this.wrapCodeExample(code, opDef.description, 'bash', partnerType, options);
|
|
1456
1455
|
}
|
|
1457
1456
|
|
|
1458
|
-
|
|
1459
|
-
generateBasicAuthExample(language, partnerType, options) {
|
|
1460
|
-
const { includeComments = true } = options;
|
|
1461
|
-
|
|
1462
|
-
const authExamples = {
|
|
1463
|
-
python: `${includeComments ? '# Basic Authentication Setup - Python' : ''}
|
|
1464
|
-
import jwt
|
|
1465
|
-
import json
|
|
1466
|
-
import hashlib
|
|
1467
|
-
import base64
|
|
1468
|
-
from datetime import datetime, timezone
|
|
1469
|
-
|
|
1470
|
-
def create_jwt_token(request_body=None):
|
|
1471
|
-
${includeComments ? '"""Create JWT token for payware API authentication"""' : ''}
|
|
1472
|
-
partner_id = "YOUR_PARTNER_ID"
|
|
1473
|
-
private_key = """-----BEGIN RSA PRIVATE KEY-----
|
|
1474
|
-
YOUR_PRIVATE_KEY_HERE
|
|
1475
|
-
-----END RSA PRIVATE KEY-----"""
|
|
1476
|
-
|
|
1477
|
-
# Create content SHA-256 for request body
|
|
1478
|
-
content_sha256 = ""
|
|
1479
|
-
if request_body:
|
|
1480
|
-
content_sha256 = base64.b64encode(hashlib.sha256(request_body.encode()).digest()).decode()
|
|
1481
|
-
|
|
1482
|
-
# JWT payload
|
|
1483
|
-
payload = {
|
|
1484
|
-
"iss": partner_id,
|
|
1485
|
-
"aud": "payware.eu",
|
|
1486
|
-
"iat": int(datetime.now(timezone.utc).timestamp()),
|
|
1487
|
-
"exp": int(datetime.now(timezone.utc).timestamp()) + 300,
|
|
1488
|
-
"contentSha256": content_sha256
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
# Create JWT token
|
|
1492
|
-
token = jwt.encode(payload, private_key, algorithm="RS256")
|
|
1493
|
-
return token
|
|
1494
|
-
|
|
1495
|
-
${includeComments ? '# Example usage' : ''}
|
|
1496
|
-
token = create_jwt_token()
|
|
1497
|
-
print(f"JWT Token: {token}")`,
|
|
1498
|
-
|
|
1499
|
-
nodejs: `${includeComments ? '// Basic Authentication Setup - Node.js' : ''}
|
|
1500
|
-
const jwt = require('jsonwebtoken');
|
|
1501
|
-
const crypto = require('crypto');
|
|
1502
|
-
|
|
1503
|
-
function createJWTToken(requestBody = null) {
|
|
1504
|
-
/**
|
|
1505
|
-
* Create JWT token for payware API authentication
|
|
1506
|
-
*/
|
|
1507
|
-
const partnerId = "YOUR_PARTNER_ID";
|
|
1508
|
-
const privateKey = \`-----BEGIN RSA PRIVATE KEY-----
|
|
1509
|
-
YOUR_PRIVATE_KEY_HERE
|
|
1510
|
-
-----END RSA PRIVATE KEY-----\`;
|
|
1511
|
-
|
|
1512
|
-
${includeComments ? '// Create content SHA-256' : ''} for request body
|
|
1513
|
-
let contentSha256 = "";
|
|
1514
|
-
if (requestBody) {
|
|
1515
|
-
contentSha256 = crypto.createHash('sha256').update(requestBody).digest('base64');
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1518
|
-
// JWT payload
|
|
1519
|
-
const payload = {
|
|
1520
|
-
iss: partnerId,
|
|
1521
|
-
aud: "payware.eu",
|
|
1522
|
-
iat: Math.floor(Date.now() / 1000),
|
|
1523
|
-
exp: Math.floor(Date.now() / 1000) + 300,
|
|
1524
|
-
contentSha256: contentSha256
|
|
1525
|
-
};
|
|
1526
|
-
|
|
1527
|
-
// Create JWT token
|
|
1528
|
-
const token = jwt.sign(payload, privateKey, { algorithm: 'RS256' });
|
|
1529
|
-
return token;
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
${includeComments ? '// Example usage' : ''}
|
|
1533
|
-
const token = createJWTToken();
|
|
1534
|
-
console.log(\`JWT Token: \${token}\`);`,
|
|
1535
|
-
|
|
1536
|
-
java: `${includeComments ? '// Basic Authentication Setup - Java' : ''}
|
|
1537
|
-
import io.jsonwebtoken.Jwts;
|
|
1538
|
-
import io.jsonwebtoken.SignatureAlgorithm;
|
|
1539
|
-
import java.security.PrivateKey;
|
|
1540
|
-
import java.security.spec.PKCS8EncodedKeySpec;
|
|
1541
|
-
import java.security.KeyFactory;
|
|
1542
|
-
import java.util.Date;
|
|
1543
|
-
import java.util.Map;
|
|
1544
|
-
import java.util.HashMap;
|
|
1545
|
-
import java.security.MessageDigest;
|
|
1546
|
-
import java.util.Base64;
|
|
1547
|
-
|
|
1548
|
-
public class PaywareAuth {
|
|
1549
|
-
|
|
1550
|
-
private static String createJWTToken(String requestBody) {
|
|
1551
|
-
try {
|
|
1552
|
-
String partnerId = "YOUR_PARTNER_ID";
|
|
1553
|
-
String privateKeyPEM = "-----BEGIN RSA PRIVATE KEY-----\\nYOUR_PRIVATE_KEY_HERE\\n-----END RSA PRIVATE KEY-----";
|
|
1554
|
-
|
|
1555
|
-
${includeComments ? '// Create content SHA-256' : ''}
|
|
1556
|
-
String contentSha256 = "";
|
|
1557
|
-
if (requestBody != null) {
|
|
1558
|
-
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
|
1559
|
-
byte[] digest = md.digest(requestBody.getBytes());
|
|
1560
|
-
contentSha256 = Base64.getEncoder().encodeToString(digest);
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
|
-
// JWT payload
|
|
1564
|
-
Map<String, Object> claims = new HashMap<>();
|
|
1565
|
-
claims.put("iss", partnerId);
|
|
1566
|
-
claims.put("aud", "payware.eu");
|
|
1567
|
-
claims.put("iat", new Date().getTime() / 1000);
|
|
1568
|
-
claims.put("exp", (new Date().getTime() / 1000) + 300);
|
|
1569
|
-
claims.put("contentSha256", contentSha256);
|
|
1570
|
-
|
|
1571
|
-
// Note: You'll need to implement private key loading
|
|
1572
|
-
// PrivateKey privateKey = loadPrivateKey(privateKeyPEM);
|
|
1573
|
-
|
|
1574
|
-
return "your-jwt-token"; // Placeholder - implement JWT creation
|
|
1575
|
-
|
|
1576
|
-
} catch (Exception e) {
|
|
1577
|
-
throw new RuntimeException("Failed to create JWT token", e);
|
|
1578
|
-
}
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
public static void main(String[] args) {
|
|
1582
|
-
String token = createJWTToken(null);
|
|
1583
|
-
System.out.println("JWT Token: " + token);
|
|
1584
|
-
}
|
|
1585
|
-
}`,
|
|
1586
|
-
|
|
1587
|
-
csharp: `${includeComments ? '// Basic Authentication Setup - C#' : ''}
|
|
1588
|
-
using System;
|
|
1589
|
-
using System.Text;
|
|
1590
|
-
using System.Security.Cryptography;
|
|
1591
|
-
using Microsoft.IdentityModel.Tokens;
|
|
1592
|
-
using System.IdentityModel.Tokens.Jwt;
|
|
1593
|
-
using System.Security.Claims;
|
|
1594
|
-
|
|
1595
|
-
public class PaywareAuth
|
|
1596
|
-
{
|
|
1597
|
-
private static string CreateJWTToken(string requestBody = null)
|
|
1598
|
-
{
|
|
1599
|
-
var partnerId = "YOUR_PARTNER_ID";
|
|
1600
|
-
var privateKeyPEM = @"-----BEGIN RSA PRIVATE KEY-----
|
|
1601
|
-
YOUR_PRIVATE_KEY_HERE
|
|
1602
|
-
-----END RSA PRIVATE KEY-----";
|
|
1603
|
-
|
|
1604
|
-
${includeComments ? '// Create content SHA-256' : ''}
|
|
1605
|
-
var contentSha256 = "";
|
|
1606
|
-
if (!string.IsNullOrEmpty(requestBody))
|
|
1607
|
-
{
|
|
1608
|
-
using (var sha256 = SHA256.Create())
|
|
1609
|
-
{
|
|
1610
|
-
var hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(requestBody));
|
|
1611
|
-
contentSha256 = Convert.ToBase64String(hash);
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
// JWT payload
|
|
1616
|
-
var claims = new[]
|
|
1617
|
-
{
|
|
1618
|
-
new Claim("iss", partnerId),
|
|
1619
|
-
new Claim("aud", "payware.eu"),
|
|
1620
|
-
new Claim("iat", DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer),
|
|
1621
|
-
new Claim("exp", DateTimeOffset.UtcNow.AddMinutes(5).ToUnixTimeSeconds().ToString(), ClaimValueTypes.Integer),
|
|
1622
|
-
new Claim("contentSha256", contentSha256)
|
|
1623
|
-
};
|
|
1624
|
-
|
|
1625
|
-
// Note: You'll need to implement RSA key loading
|
|
1626
|
-
// var rsa = RSA.Create();
|
|
1627
|
-
// rsa.ImportFromPem(privateKeyPEM);
|
|
1628
|
-
// var key = new RsaSecurityKey(rsa);
|
|
1629
|
-
|
|
1630
|
-
return "your-jwt-token"; // Placeholder - implement JWT creation
|
|
1631
|
-
}
|
|
1632
|
-
|
|
1633
|
-
public static void Main(string[] args)
|
|
1634
|
-
{
|
|
1635
|
-
var token = CreateJWTToken();
|
|
1636
|
-
Console.WriteLine($"JWT Token: {token}");
|
|
1637
|
-
}
|
|
1638
|
-
}`,
|
|
1639
|
-
|
|
1640
|
-
php: `${includeComments ? '<?php // Basic Authentication Setup - PHP' : '<?php'}
|
|
1641
|
-
require_once 'vendor/autoload.php';
|
|
1642
|
-
use Firebase\\JWT\\JWT;
|
|
1643
|
-
use Firebase\\JWT\\Key;
|
|
1644
|
-
|
|
1645
|
-
function createJWTToken($requestBody = null) {
|
|
1646
|
-
$partnerId = "YOUR_PARTNER_ID";
|
|
1647
|
-
$privateKey = "-----BEGIN RSA PRIVATE KEY-----
|
|
1648
|
-
YOUR_PRIVATE_KEY_HERE
|
|
1649
|
-
-----END RSA PRIVATE KEY-----";
|
|
1650
|
-
|
|
1651
|
-
${includeComments ? '// Create content SHA-256' : ''}
|
|
1652
|
-
$contentSha256 = "";
|
|
1653
|
-
if ($requestBody !== null) {
|
|
1654
|
-
$contentSha256 = base64_encode(hash('sha256', $requestBody, true));
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
// JWT payload
|
|
1658
|
-
$payload = [
|
|
1659
|
-
'iss' => $partnerId,
|
|
1660
|
-
'aud' => 'payware.eu',
|
|
1661
|
-
'iat' => time(),
|
|
1662
|
-
'exp' => time() + 300,
|
|
1663
|
-
'contentSha256' => $contentSha256
|
|
1664
|
-
];
|
|
1665
|
-
|
|
1666
|
-
// Create JWT token
|
|
1667
|
-
$token = JWT::encode($payload, $privateKey, 'RS256');
|
|
1668
|
-
return $token;
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
|
-
${includeComments ? '// Example usage' : ''}
|
|
1672
|
-
$token = createJWTToken();
|
|
1673
|
-
echo "JWT Token: " . $token . "\\n";
|
|
1674
|
-
?>`,
|
|
1675
|
-
|
|
1676
|
-
curl: `${includeComments ? '#!/bin/bash\n# Basic Authentication Setup - cURL' : '#!/bin/bash'}
|
|
1677
|
-
|
|
1678
|
-
# Configuration
|
|
1679
|
-
PARTNER_ID="YOUR_PARTNER_ID"
|
|
1680
|
-
PRIVATE_KEY_FILE="path/to/private-key.pem"
|
|
1681
|
-
|
|
1682
|
-
# Function to create JWT token (simplified)
|
|
1683
|
-
create_jwt_token() {
|
|
1684
|
-
local request_body="\$1"
|
|
1685
|
-
local content_sha256=""
|
|
1686
|
-
|
|
1687
|
-
if [ -n "\$request_body" ]; then
|
|
1688
|
-
content_sha256=\$(echo -n "\$request_body" | openssl dgst -sha256 -binary | base64)
|
|
1689
|
-
fi
|
|
1690
|
-
|
|
1691
|
-
echo "your-jwt-token" # Placeholder - implement JWT creation with openssl
|
|
1692
|
-
}
|
|
1693
|
-
|
|
1694
|
-
${includeComments ? '# Example usage' : ''}
|
|
1695
|
-
JWT_TOKEN=\$(create_jwt_token)
|
|
1696
|
-
echo "JWT Token: \$JWT_TOKEN"`
|
|
1697
|
-
};
|
|
1698
|
-
|
|
1699
|
-
return this.wrapCodeExample(
|
|
1700
|
-
authExamples[language] || authExamples.python,
|
|
1701
|
-
'Authentication Setup',
|
|
1702
|
-
language,
|
|
1703
|
-
partnerType,
|
|
1704
|
-
options
|
|
1705
|
-
);
|
|
1706
|
-
}
|
|
1707
|
-
|
|
1708
1457
|
// Helper methods for Java code generation
|
|
1709
1458
|
toPascalCase(str) {
|
|
1710
1459
|
return str.split(/[-_]/).map(word =>
|
|
@@ -68,7 +68,7 @@ from cryptography.hazmat.primitives import serialization`;
|
|
|
68
68
|
${options.includeComments ? '# Create JWT payload\n ' : ''}payload = {
|
|
69
69
|
'iss': partner_id,
|
|
70
70
|
'aud': 'https://payware.eu',
|
|
71
|
-
'iat': int(datetime.
|
|
71
|
+
'iat': int(datetime.now().timestamp())
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
${options.includeComments ? '# Create and return token\n ' : ''}token = jwt.encode(payload, private_key, algorithm='RS256', headers=header)
|
|
@@ -295,7 +295,7 @@ def create_isv_jwt_token(merchant_partner_id, oauth2_token, request_body=None, u
|
|
|
295
295
|
'iss': isv_partner_id, # ISV Partner ID
|
|
296
296
|
'aud': merchant_partner_id, # Target Merchant ID
|
|
297
297
|
'sub': oauth2_token, # OAuth2 access token
|
|
298
|
-
'iat': int(datetime.
|
|
298
|
+
'iat': int(datetime.now().timestamp())
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
# Create and return token
|
|
@@ -217,7 +217,7 @@ def create_isv_jwt_token(merchant_partner_id, oauth2_token, request_body=None, u
|
|
|
217
217
|
'iss': config['isv_partner_id'], # ISV Partner ID
|
|
218
218
|
'aud': merchant_partner_id, # Target Merchant ID
|
|
219
219
|
'sub': oauth2_token, # OAuth2 access token
|
|
220
|
-
'iat': int(datetime.
|
|
220
|
+
'iat': int(datetime.now().timestamp())
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
# Create token
|
|
@@ -171,7 +171,7 @@ def create_jwt_token(request_body=None, use_sandbox=True):
|
|
|
171
171
|
payload = {
|
|
172
172
|
'iss': config['partner_id'],
|
|
173
173
|
'aud': 'https://payware.eu',
|
|
174
|
-
'iat': int(datetime.
|
|
174
|
+
'iat': int(datetime.now().timestamp())
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
# Create token
|
|
@@ -58,7 +58,7 @@ def create_deterministic_json(data):
|
|
|
58
58
|
|
|
59
59
|
def create_jwt_token(request_body=None):
|
|
60
60
|
"""Create JWT token for authentication with payware API"""
|
|
61
|
-
now = int(datetime.
|
|
61
|
+
now = int(datetime.now().timestamp())
|
|
62
62
|
|
|
63
63
|
# JWT header
|
|
64
64
|
header = {
|
|
@@ -153,7 +153,7 @@ with open('private_key.pem', 'r') as f:
|
|
|
153
153
|
|
|
154
154
|
def create_jwt_token(request_body=None):
|
|
155
155
|
"""Create JWT token with proper payware format"""
|
|
156
|
-
now = int(datetime.
|
|
156
|
+
now = int(datetime.now().timestamp())
|
|
157
157
|
|
|
158
158
|
# JWT header
|
|
159
159
|
header = {
|