Sha256: a138744f3ff1f72d970d2c86ac23a02cb6efbce074413668121bc50576f59a3f

Contents?: true

Size: 545 Bytes

Versions: 4

Compression:

Stored size: 545 Bytes

Contents

require 'digest/sha1'
require 'base64'

module Liqpay
  class BaseOperation
    attr_accessor :merchant_id, :merchant_signature

    def initialize(options={})
      options.replace(Liqpay.default_options.merge(options))

      @merchant_id = options[:merchant_id]
      @merchant_signature = options[:merchant_signature]
    end

    def signature
      @signature ||= sign(xml, @merchant_signature)
    end

  private
    def sign(xml, signature)
      Base64.encode64(Digest::SHA1.digest(signature + xml + signature)).strip
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
liqpay-0.1.2 lib/liqpay/base_operation.rb
liqpay-0.1.1 lib/liqpay/base_operation.rb
liqpay-0.1.0 lib/liqpay/base_operation.rb
liqpay-0.0.1 lib/liqpay/base_operation.rb