接入教程
1. 登录Adyen账户并获取API密钥
2. 调用配置端点设置通知接收URL
3. 使用测试端点验证通知连接
4. 配置通知签名验证
5. 处理接收到的JSON格式通知
6. 监控通知日志确保投递成功
Python示例:配置通知URL
python
import requests
url = "https://api.example.com/v1/notification-configuration"
headers = {
"Content-Type": "application/json",
"X-API-Key": "YOUR_API_KEY"
}
payload = {
"notificationUrl": "https://your-webhook-server.com/notifications",
"active": true,
"description": "Production notification endpoint"
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
PHP示例:测试通知配置
php
<?php
$url = 'https://api.example.com/v1/notification-configuration/test';
$apiKey = 'YOUR_API_KEY';
$data = [
'notificationId' => 'test_123',
'eventType' => 'payment.captured',
'testData' => ['amount' => 100, 'currency' => 'USD']
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'X-API-Key: ' . $apiKey
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP Code: " . $httpCode . "\n";
echo "Response: " . $response . "\n";
?>
JavaScript示例:获取配置列表
javascript
const fetch = require('node-fetch');
async function getNotificationConfigs() {
const url = 'https://api.example.com/v1/notification-configuration';
const options = {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'YOUR_API_KEY'
}
};
try {
const response = await fetch(url, options);
const data = await response.json();
console.log('Status:', response.status);
console.log('Configurations:', data);
return data;
} catch (error) {
console.error('Error:', error);
}
}
getNotificationConfigs();
常见问题
经典集成方案和新集成方案有什么区别?
经典集成方案适用于已在使用旧版API的商户,提供向后兼容的通知配置。新集成方案采用了更新的架构和功能,建议新项目直接参考新版集成指南进行实施。
通知配置支持哪些事件类型?
API支持多种交易状态事件,如支付成功、支付失败、退款处理等。具体事件类型请参考官方文档中的事件类型列表。
如何确保通知接收的安全性?
建议使用HTTPS端点接收通知,并在服务器端验证通知签名。API文档提供了签名验证的详细方法和示例代码。
Aitishiku.com