参考资料

Adyen Checkout API

Adyen Checkout API 提供了一种简单灵活的方式来发起和授权在线支付。您可以使用同一集成来处理卡支付(包括3D Secure)、移动钱包和本地支付方式(例如iDEAL和Sofort)。

查看官方文档 ↗

接入教程

1. 注册Adyen账户并获取API密钥
2. 在您的网站或应用中集成Checkout SDK
3. 配置支付方式(信用卡、钱包等)
4. 调用API发起支付请求
5. 处理支付回调并更新订单状态
6. 在Adyen后台查看交易记录

使用Python发起支付

python
import requests

url = 'https://api.example.com/payments'
headers = {
    'X-API-Key': 'YOUR_API_KEY',
    'Content-Type': 'application/json'
}
payload = {
    'amount': {
        'currency': 'USD',
        'value': 1000
    },
    'reference': 'order-123',
    'returnUrl': 'https://your-website.com/return'
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())

使用PHP处理支付结果

php
<?php

$url = 'https://api.example.com/payments/result';
$apiKey = 'YOUR_API_KEY';

$data = [
    'paymentData' => $_POST['paymentData'] ?? null,
    'details' => [
        'redirectResult' => $_POST['redirectResult'] ?? null
    ]
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'X-API-Key: ' . $apiKey,
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>

使用JavaScript创建支付会话

javascript
const fetch = require('node-fetch');

const url = 'https://api.example.com/sessions';
const apiKey = 'YOUR_API_KEY';

const payload = {
  amount: {
    currency: 'EUR',
    value: 5000
  },
  reference: 'checkout-session-456',
  returnUrl: 'https://your-store.com/thank-you'
};

async function createSession() {
  const response = await fetch(url, {
    method: 'POST',
    headers: {
      'X-API-Key': apiKey,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(payload)
  });
  
  const data = await response.json();
  console.log(data);
}

createSession();

常见问题

如何获取API密钥?

API密钥需要在Adyen商户后台生成。登录您的Adyen账户,进入API和Webhooks部分,创建新的API密钥并妥善保管。

支付请求失败常见原因有哪些?

常见原因包括:API密钥无效或过期、请求格式不符合API规范、金额或货币代码错误、网络连接问题或Adyen服务临时不可用。

支持哪些支付方式?

Adyen Checkout API支持信用卡/借记卡(包括3D Secure)、Apple Pay、Google Pay、支付宝、微信支付以及iDEAL、Sofort等多种本地支付方式。

相似接口推荐

Amazon Braket API

Amazon Braket API提供了关于Amazon Braket支持的操作和结构的信息。它是一个用于量子计算的云服务接口,帮助开发者访问和管理量子计算资源。

待确认
Marketstack股票市场数据API

提供实时、盘中及历史股票市场数据的REST API服务,涵盖全球30,000+股票代码,同时新增EDGAR文件端点用于获取SEC公司申报文件。支持JSON格式响应,提供免费计划。

免费
eBird鸟类观测数据API

康奈尔鸟类学实验室提供的全球鸟类观测数据接口,支持查询特定区域近期或显著的鸟类观察记录

免费
Weatherstack

Weatherstack 是一款提供全球实时、历史和预测天气数据的API服务,以轻量级JSON格式返回准确的气象信息,支持数百万个地点查询。

免费