문제

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
도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top