Sha256: bca256eeb6112b3019a1e0aff633f5735bbe75caa9fbb3e6b7c8c312881bcd34

Contents?: true

Size: 843 Bytes

Versions: 2

Compression:

Stored size: 843 Bytes

Contents

require 'cgi'
require 'open-uri'

module Tenpay
  module Service
    GATEWAY_URL = 'https://gw.tenpay.com/gateway/pay.htm'

    CREATE_INTERACTIVE_MODE_REQUIRED_OPTIONS = %w(body subject return_url notify_url partner out_trade_no total_fee fee_type spbill_create_ip)
    def self.create_interactive_mode_url(options)
      options = {
          'input_charset' => 'UTF-8',
          'partner' => Tenpay.pid,
          'fee_type' => '1'
      }.merge(Utils.stringify_keys(options))

      check_required_options(options, CREATE_INTERACTIVE_MODE_REQUIRED_OPTIONS)

      "#{GATEWAY_URL}?#{Utils.make_query_string(options)}"
    end

    private

    def self.check_required_options(options, names)
      names.each do |name|
        warn("Tenpay Warn: missing required option: #{name}") unless options.has_key?(name)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jasl_tenpay-1.0.0 lib/tenpay/service.rb
jasl_tenpay-0.0.2 lib/tenpay/service.rb