【问题标题】:Paytabs payment gateway Api not workingPaytabs 支付网关 Api 无法正常工作
【发布时间】:2018-05-24 06:00:14
【问题描述】:

我正在使用 Paytabs 支付网关。使用其余 API 验证密钥提供所有参数,但 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}

【问题讨论】:

  • 为什么这个 API 会给出这个消息 { parsed_response={"result"=>"missing Merchant_email parameter", "response_code"=>"4001"}}
  • 因为这个API支持php语言。我通过 HTTParty 方法在 Rails 应用程序上使用此 API。

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


【解决方案1】:

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

像这样:

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

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

【讨论】:

  • headers = { "merchant_email" => params[:merchant_email], "merchant_secretKey" => params[:secret_key] } result = HTTParty.post("paytabs.com/apiv2/validate_secret_key", :headers => headers ) 渲染 :json => {:code=>345, :result => result} 像这样?
  • 还是同样的信息。
  • 同样的消息也试试这个方法 Net::HTTP
【解决方案2】:

通过此过程解决问题。

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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-22
    • 2016-06-23
    • 2015-05-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-23
    相关资源
    最近更新 更多