Sha256: 90b49678cec2a64c8194d7b8e78eb517a2314fa0147adb937b719c57da60f1cb

Contents?: true

Size: 680 Bytes

Versions: 1

Compression:

Stored size: 680 Bytes

Contents

module WxPay
  module Utils
    def self.stringify_keys(hash)
      new_hash = {}
      hash.each do |key, value|
        new_hash[(key.to_s rescue key) || key] = value
      end
      new_hash
    end

    def self.make_payload(params)
      "<xml>#{params.map {|k, v| "<#{k}>#{v}</#{k}>"}.join}<sign>#{WxPay::Sign.generate(params)}</sign></xml>"
    end

    def self.invoke_remote(url, payload)
      Hash.from_xml(
        RestClient::Request.execute(
          {
            method: :post,
            url: url,
            payload: payload,
            headers: {content_type: 'application/xml'}
          }.merge(WxPay.extra_rest_client_options))
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wx_pay-0.0.1 lib/wx_pay/utils.rb