接入教程
1. 在Adyen平台注册并获取API密钥
2. 调用交易查询端点获取历史记录
3. 使用余额转移端点进行内部调拨
4. 配置转账工具并执行外部汇款
5. 通过Webhook接收转账状态通知
6. 查看API文档处理错误代码
使用Python发起转账
python
import requests
import json
url = "https://api.example.com/transfers"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
}
payload = {
"amount": {"currency": "USD", "value": 1000},
"source": {"type": "balanceAccount", "id": "BA1234567890"},
"destination": {"type": "transferInstrument", "id": "TI0987654321"},
"reference": "ORDER_12345"
}
response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.status_code)
print(response.json())
使用PHP查询交易记录
php
<?php
$url = 'https://api.example.com/transfers';
$apiKey = 'YOUR_API_KEY';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode == 200) {
$data = json_decode($response, true);
print_r($data);
} else {
echo "Request failed with status: $httpCode";
}
?>
使用JavaScript获取转账详情
javascript
const fetchTransferDetails = async (transferId) => {
const url = `https://api.example.com/transfers/${transferId}`;
const options = {
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
try {
const response = await fetch(url, options);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
console.log(data);
return data;
} catch (error) {
console.error('Error fetching transfer details:', error);
}
};
// Example usage
fetchTransferDetails('TR_ABC123XYZ');
常见问题
转账API的主要用途是什么?
转账API主要用于在余额平台内转移资金、查询所有交易信息,以及将资金从余额平台发送至指定的转账工具。
调用API时如何认证身份?
需要在请求头中使用Bearer Token进行身份认证,格式为:Authorization: Bearer YOUR_API_KEY。请将YOUR_API_KEY替换为您的实际API密钥。
API支持哪些货币和金额格式?
API支持多种货币,金额需以对象形式提供,包含currency(如USD)和value字段。value单位为最小货币单位(例如美分为分)。
Aitishiku.com