Sha256: 8e3661d4801192dac416e726154c046add675c1cb0652a8ec5b2375acf982a4f

Contents?: true

Size: 1015 Bytes

Versions: 1

Compression:

Stored size: 1015 Bytes

Contents

module Allinpay
  class Client
    attr_accessor :merchant, :username, :password, :conn

    class << self
      attr_accessor :private_path, :public_path, :private_password
    end

    def initialize(options)
      @merchant = options[:merchant]
      @username = options[:username]
      @password = options[:password]
      env = options[:env] || 'development'
      @conn = Allinpay::Service.connection(env, options)
    end

    private

    def set_infomation(code, options = {})
      info = {
        TRX_CODE: code,
        VERSION: '03', 
        DATA_TYPE: '2',
        USER_NAME: username, 
        USER_PASS: password, 
        REQ_SN: req_sn
      }.merge(options)
      return { INFO: info }
    end

    def req_sn
      merchant + timestamps + rand(1000).to_s.ljust(4, '0')
    end

    def timestamps
      Time.now.strftime('%Y%m%d%H%M%S')
    end

    def result_wrap(status, data, request = nil)
      return { "status" => status.to_s, "data" => data, "request" => request }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
allinpay-0.1.0 lib/allinpay/client.rb