Pergunta

I'm busy integrating with a payment gateway, and one of the steps in the authentication process requires me to repost the variables I've received back to payment gateway.

So in simple terms, the payment gateway POSTs to my controller, and I should return the POST using the original parameters (save one parameter).

This is a bit of a newby question, but is there a quick way in which I could populate the fields in the Net::HTTP.post_form method with the parameters I've received (my_action_params below)?

uri = URI('https://mypaymentgateway.com/validation')
res = Net::HTTP.post_form(uri, my_action_params)
puts res.body
Foi útil?

Solução

Managed to figure it out. Once can simply use the existing parameters and use the rails except command to remove that one parameter. I now have the following:

my_action_params = original_action_params.except('excluded_parameter')

uri = URI('https://mypaymentgateway.com/validation')
res = Net::HTTP.post_form(uri, my_action_params)
puts res.body
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top