douji2283 2016-08-24 12:17
浏览 87
已采纳

转到-使用有效负载重定向到特定的URL

I'm currently trying to implements payment method of my client onto my application. To show the payment page, I need to perform request to their url with body information about the payment. The response is html of the payment page. Then I print the html to the view.

But whenever I clicked pay button on the generated view, error occured say that session is invalid, it's because even the payment page is showing up it's still on our host (cross domain problem). I need to click the pay button from their host, it's mean that my application need to be redirected to their host.

Can we redirect to another url but attach body on the header of the request?

I want to redirect to this url "http://payment.api.net/merchant/init?corpid=CN000001", but including this body request.

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

How to achieve this?

UPDATE

It's impossible

SOLUTION

See ainur answer, I don't understand why, but it's working like a charm

  • 写回答

1条回答 默认 最新

  • dongzhuang6247 2016-08-25 04:41
    关注

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

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用ADS设计一款的射频功率放大器
  • ¥15 怎么求交点连线的理论解?
  • ¥20 软件开发方法学习来了
  • ¥15 微信小程序商城如何实现多商户收款 平台分润抽成
  • ¥15 HC32L176调试了一个通过TIMER5+DMA驱动WS2812B
  • ¥15 cocos的js代码调用wx.createUseInfoButton问题!
  • ¥15 关于自相关函数法和周期图法实现对随机信号的功率谱估计的matlab程序运行的问题,请各位专家解答!
  • ¥15 Python程序,深度学习,有偿私
  • ¥15 扫描枪扫条形码出现问题
  • ¥35 poi合并多个word成一个新word,原word中横版没了.