0

I am using the Paytabs payment gateway. Using the rest API Validate Secret Key providing all parameter but API returns every time in "missing parameter merchant_email" message.

 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}
Jagdeep Singh
  • 4,880
  • 2
  • 17
  • 22
manu
  • 199
  • 3
  • 10
  • Why this API give this message { parsed_response={"result"=>"missing merchant_email parameter", "response_code"=>"4001"}} – manu May 24 '18 at 06:20
  • Api docs link : http://developers.paytabs.com/docs-apis/#rest-api – manu May 24 '18 at 06:45
  • Because of this API support php language. I use this API on rails app through HTTParty method. – manu May 24 '18 at 06:53

2 Answers2

0

Can you send parameters in header rather then the body?

Like this:

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

     HTTParty.post(
         "https://www.acb.com/api/v2/market/LTC_BTC/",
          :headers => headers
      )
Ali Kazmi
  • 35
  • 5
  • headers = { "merchant_email" => params[:merchant_email], "merchant_secretKey" => params[:secret_key] } result = HTTParty.post( "https://www.paytabs.com/apiv2/validate_secret_key", :headers => headers ) render :json => {:code=>345, :result => result} Like this? – manu May 24 '18 at 06:18
  • Still the same message. – manu May 24 '18 at 07:02
  • Same message also try this method Net::HTTP – manu May 24 '18 at 09:50
0

Resolve the issue through this process.

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)
manu
  • 199
  • 3
  • 10