Rails 在 post 请求中将参数发送给第三方
我在 Rails 应用程序中使用支付网关,如何从控制器重定向到网关并传递网关所需的所有参数?基本上这是一个 post
请求。
I am using a payment gateway in my rails application, how can I redirect to gateway from my controller and pass all the parameters required by the gateway? Basically it's a post
request.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能不想通过 ActionController 框架来完成此操作,而是使用单独的 HTTP 客户端库。
Net::HTTP 是此类库的一个示例,但您的支付网关可能会提供用于与其交互的 ruby gem(如 TrustCommerce 那样),或者 ActiveMerchant 的某些部分可能会与您的网关配合使用。
无论哪种方式,实际上将用户直接重定向到支付网关可能都不是最好的(因为支付网关可能返回 xml,然后用户会看到它);而是与服务器上的网关建立单独的连接,然后处理该调用并将结果返回给您的用户。
You probably want to do this not through the ActionController framework, but using a seperate HTTP Client library.
Net::HTTP is an example of such a library, but your payment gateway may provide a ruby gem for interacting with it (like TrustCommerce does) or perhaps some portion of ActiveMerchant will work with your gateway.
Either way, it's probably not best to actually redirect your users directly to your payment gateway (since the payment gateway probably returns xml, and the user would then see this); but rather make a seperate connection to the gateway on your server, then process that call and return the results to your users.