我正在尝试一种转换方法:
<form action="https://secure.paylane.com/order/cart.html" method="post">
<input type="hidden" name="amount" value="19.99">
<input type="hidden" name="currency" value="EUR">
<input type="hidden" name="merchant_id" value="john_test">
<input type="hidden" name="description" value="TR001" />
<input type="hidden" name="transaction_description" value="Product 1 transaction" />
<input type="hidden" name="transaction_type" value="S">
<input type="hidden" name="back_url" value="http://johns-shop.com/purchased">
<input type="hidden" name="language" value="pl">
<input type="hidden" name="hash" value="6926ed14d1ae4d8eb2350d3c15e6a420e3bb7052" />
<button type="submit">Zapłać z PeP</button>
</form>
进入Axios请求。我试过了,但是得到了CORS错误(当我使用上面的示例时不会发生):
async handlePep ({ description, transaction_description, amount, merchant_id, currency, transaction_type, hash}) {
let formData = new FormData()
formData.append('amount', amount)
formData.append('currency', currency)
formData.append('merchant_id', merchant_id)
formData.append('description', description)
formData.append('transaction_description', transaction_description)
formData.append('transaction_type', transaction_type)
formData.append('back_url', 'https://localhost:8081')
formData.append('language', 'pl')
formData.append('hash', hash)
const response = await this.$axios.post('https://secure.paylane.com/order/cart.html', formData)
}
也尝试了fetch
的方式:
await fetch(
'https://secure.paylane.com/order/cart.html',
{
method: 'POST',
body: formData,
mode: 'no-cors',
redirect: 'follow'
}
)
但仍然没有运气。我认为必须有一种方法可以不将表单放入模板中。而且-我不想动态生成表单。