Go – redirect to specific url with payload

Issue

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>

Solution

Try to use this code..

<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>

May it solve your problem..

Answered By – Ainur Rochman

Answer Checked By – Timothy Miller (GoLangFix Admin)

Leave a Reply

Your email address will not be published.