我正在尝试将我们的网站与Converge API
和Hosted Payments Page
集成在一起。这是他们的文档https://developer.elavon.com/#/api/eb6e9106-0172-4305-bc5a-b3ebe832f823.rcosoomi/versions/5180a9f2-741b-439c-bced-5c84a822f39b.rcosoomi/documents?converge-integration-guide/book/integration_methods/../../book/integration_methods/hosted_payments.html
我无法通过第一步,即从其API端点请求交易令牌。我使用正确的参数和URL使用POST
从服务器发送了axios
请求,但是当我尝试和POST
时,我得到了400 Bad Request
。当我在POSTMAN
中发出相同的请求时,我得到了带有交易令牌的200 response
。我与他们的开发人员进行了交谈,他们说我所做的一切都是正确的,并且我的代码中似乎没有什么奇怪的,所以即使他们对为什么我无法向其端点发出POST
请求也感到困惑。显然,在我的代码中有一些他们的API不喜欢的东西,否则我不会在这里试图找到答案。
这是我发出POST请求的方式:
app.get('/converge_token_req', (request, response) => {
let params = {
ssl_merchant_id: '*****',
ssl_user_id: '*****',
ssl_pin: '*****',
ssl_transaction_type: 'ccsale',
ssl_amount: '1.00'
}
axios.post('https://api.demo.convergepay.com/hosted-payments/transaction_token', params, {
headers: { 'Content_Type' : 'application/x-www-form-urlencoded' }
}).then((res) => {
response.send(res.data)
}).catch((error) => {
console.log('there was an error getting transaction token')
response.send(error.message)
})
})
以下是请求标头:
老实说,我没有尝试的想法。开发人员说,一切看起来都很好,但是我无法向其API发出成功请求。如果有人对此有任何想法,那就太好了。谢谢!
答案 0 :(得分:0)
下面的代码对我有用:
app.get('/converge_token_req', (request, response) => {
let params = {
ssl_merchant_id: '*****',
ssl_user_id: '*****',
ssl_pin: '*****',
ssl_transaction_type: 'ccsale',
ssl_amount: '1.00'
}
axios({
method: 'post',
url: 'https://api.demo.convergepay.com/hosted-payments/transaction_token',
params: params
}).then((res) => { response.send(res.data)
}).catch((error) => {
console.log('there was an error getting transaction token: ',
error)
})
})