我试着付款。我在这里面用的是顺便拜访https://docs.adyen.com/checkout/drop-in-web指导然后,我将加密的卡数据(例如,我添加了一张"4000 0200 0000 0000"测试卡(作为json字符串发送到服务器(它使用"@adyen/api库":"^2.1.6"(。然后,我尝试付款:
const config = new Config()
config.apiKey = MY_API_KEY
config.merchantAccount = MY_ACCOUNT
const client = new Client({ config })
client.setEnvironment('TEST')
const checkout = new CheckoutAPI(client)
try {
const paymentsResponse = await checkout.payments({
amount: {
currency: 'USD',
value: 10
},
paymentMethod: JSON.parse(paymentMethod),
reference: "123456",
merchantAccount: MY_ACCOUNT,
returnUrl: 'http://localhost:3003/'
})
console.info(JSON.stringify(paymentsResponse))
在控制台中我看到:
HttpClientException {
statusCode: 422,
name: 'HttpClientException',
message:
'HTTP Exception: 422. Unprocessable Entity: Invalid shopper interaction',
errorCode: '000',
.............................................................. (other)
我做错了什么?
好的,我找到了答案。"shopperInteraction"不是必填字段。但如果我们不发送,我们会收到一个错误"无效的购物者交互"。看见https://docs.adyen.com/api-reference/payments-api/paymentrequest.屏幕截图
我是adyen节点api库的作者,我在最新版本(v2.1.7(上测试了相同的请求,但没有发送shopperInteraction,它成功了。您正在使用哪种付款方式?我的请求是使用信用卡付款。此字段对于其他付款方式类型可能是必需的,对于某些付款方式可能是可选的。
请求:
{
"amount": {
"currency": "USD",
"value": 10
},
"paymentMethod": {
"type": "scheme",
"cvc": "737",
"expiryMonth": "10",
"expiryYear": "2020",
"holderName": "John Smith",
"number": "4111111111111111"
},
"reference": "123456",
"merchantAccount": MY_MERCHANT_ACCOUNT,
"returnUrl": "http://localhost:3003/"
}
响应:
{
...
"pspReference": PSP_REFERENCE,
"resultCode": "Authorised",
"merchantReference": "123456"
}
尝试在末尾添加字段
"returnUrl": "https: //your-company.com/...",
"shopperInteraction":"ContAuth"
我试过这个
{
"amount": {
"currency": "USD",
"value": 10
},
"paymentMethod": {
"type": "scheme",
"number": "5555444433331111",
"expiryMonth": "10",
"expiryYear": "2020",
"holderName": "John Smith",
"cvc": "737"
},
"reference": "123456",
"merchantAccount": "HugHubUK",
"returnUrl": "www.google.com"
}
但是会出现类似的错误
{
"status": 422,
"errorCode": "000",
"message": "Please supply paymentDetails",
"errorType": "validation",
"pspReference": "881576842443252F"
}