英文:
Go - redirect to specific url with payload
问题
我正在尝试在我的应用程序中实现支付方法,需要帮助。
为了显示支付页面,我需要向他们的URL执行POST
请求,并附带支付负载。通常,他们会响应一个HTML响应,然后我需要将其渲染到屏幕上。然而,我得到的是一个错误,说会话无效。
我的问题是:是否可能使用POST
和请求负载重定向到另一个URL?
POST http://payment.api.net/merchant/init?corpid=CN000001
<order>
<corp>NN01</corp>
<amount>20.0</amount>
<currency>USD</currency>
<ordernumber>10010111</ordernumber>
<redirect>http://mycallback.api.net/store/payment/callback</redirect>
<randomstring>NnwLRINzhOgvmvyunzZIrUtCgvmvy</randomstring>
<hash>4792e72f5e1860b220420ad3f22f005c9d2fce83f3a138336869780153145700</hash>
</order>
英文:
I'm trying to implement payment method on my application, and I need help.
To show the payment page, I need to perform POST
request to their url with a payment payload. Normally they will response with a html response, and after that I need to render it to screen. However, what I got is an error saying that session is invalid.
My question: is it possible to redirect to another url with POST
and a request payload?
POST http://payment.api.net/merchant/init?corpid=CN000001
<order>
<corp>NN01</corp>
<amount>20.0</amount>
<currency>USD</currency>
<ordernumber>10010111</ordernumber>
<redirect>http://mycallback.api.net/store/payment/callback</redirect>
<randomstring>NnwLRINzhOgvmvyunzZIrUtCgvmvy</randomstring>
<hash>4792e72f5e1860b220420ad3f22f005c9d2fce83f3a138336869780153145700</hash>
</order>
答案1
得分: 1
请尝试使用以下代码:
<html>
<body>
<form action="http://payment.api.net/merchant/init?corpid=CN000001" method="post" enctype='text/plain'>
<input type="hidden" name="order" value="<order><corp>NN01</corp><amount>20.0</amount><currency>USD</currency><ordernumber>10010111</ordernumber><redirect>http://mycallback.api.net/store/payment/callback</redirect><randomstring>NnwLRINzhOgvmvyunzZIrUtCgvmvy</randomstring><hash>4792e72f5e1860b220420ad3f22f005c9d2fce83f3a138336869780153145700</hash></order>">
<button type="submit">Submit</button>
</form>
</body>
</html>
希望这能解决你的问题。
英文:
Try to use this code..
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<html>
<body>
<form action="http://payment.api.net/merchant/init?corpid=CN000001" method="post" enctype='text/plain'>
<input type="hidden" name="order" value='<order><corp>NN01</corp><amount>20.0</amount><currency>USD</currency><ordernumber>10010111</ordernumber><redirect>http://mycallback.api.net/store/payment/callback</redirect><randomstring>NnwLRINzhOgvmvyunzZIrUtCgvmvy</randomstring><hash>4792e72f5e1860b220420ad3f22f005c9d2fce83f3a138336869780153145700</hash></order>'>
<button type="submit">Submit</button>
</form>
</body>
</html>
<!-- end snippet -->
May it solve your problem..
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论