接入教程
1. 访问Adyen官网并注册账户
2. 获取两组API凭证用于身份验证
3. 调用API端点存储支付明细
4. 根据业务逻辑确认或拒绝支付
5. 参考在线支付文档了解更多详情
使用Python发起支付请求
python
import requests
url = 'https://api.example.com/payout'
headers = {
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
}
data = {
'amount': {'value': 1000, 'currency': 'EUR'},
'reference': 'PAYOUT-REF-001',
'recipient': {'email': 'recipient@example.com'}
}
response = requests.post(url, headers=headers, json=data)
print(response.status_code)
print(response.json())
使用PHP确认支付
php
<?php
$url = 'https://api.example.com/payout/confirm';
$apiKey = 'YOUR_API_KEY';
$data = json_encode(['payoutId' => 'PO_123456789']);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'X-API-Key: ' . $apiKey,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
使用JavaScript获取支付详情
javascript
const url = 'https://api.example.com/payout/PAYOUT-REF-001';
const options = {
method: 'GET',
headers: {
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
fetch(url, options)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
常见问题
使用此API需要哪些认证凭证?
您需要配置两个API密钥:一个用于身份验证,另一个用于签名请求。详情请参阅Adyen官方文档。
API请求的响应时间通常是多少?
响应时间通常在几百毫秒内,但具体取决于网络状况和请求负载。
如何处理支付失败的情况?
API会返回详细的错误代码和消息。建议根据这些信息重试请求或联系支持团队。
Aitishiku.com