Paytabs支付网关Api无法正常工作

时间:2018-05-24 06:00:15

标签: php ruby-on-rails ruby-on-rails-3 ruby-on-rails-4 paytabs

我正在使用Paytabs支付网关。使用其余API验证密钥提供所有参数,但每次在“缺少参数merchant_email”消息中返回API。

 result = HTTParty.post("https://www.paytabs.com/apiv2/validate_secret_key",
   :body=>{merchant_email: params[:merchant_email],
           merchant_secretKey: params[:secret_key]}.to_json,
           :headers => { 'Content-Type' => 'application/json',
           'Accept' =>'application/json' } )    
          render :json => {:code=>345, :result => result}

2 个答案:

答案 0 :(得分:0)

你可以在标题中发送参数而不是身体吗?

像这样:

     headers = { 
        "key"  => "8781974720909019987" 
     }

     HTTParty.post(
         "https://www.acb.com/api/v2/market/LTC_BTC/",
          :headers => headers
      )

答案 1 :(得分:0)

通过此过程解决问题。

url = URI.parse('https://www.paytabs.com/apiv2/validate_secret_key')        
data = {        
        :merchant_email=> params[:merchant_email],
        :secret_key=> params[:secret_key]       
        }
    x = Net::HTTP.post_form(url, data)
    render :json => eval(x.body)