Paytabs payment gateway Api not working

2.5k Views Asked by At

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}
2

There are 2 best solutions below

0
Manavendra Singh On BEST ANSWER

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)
3
Ali Kazmi On

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
      )