我尝试付款。我在https://docs.adyen.com/checkout/drop-in-web指南中使用了直接插入。然后,我将加密的卡数据(例如,添加“ 4000 0200 0000 0000”测试卡)作为json字符串发送到服务器(它使用“ @ adyen / api-library”:“ ^ 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。 Screen shot