Sha256: 619d41879b06b3ed8fc2b1f1ed6d379951428b89bacaff0b67200a32de0fd6cf

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require "active_support/core_ext/hash"

module Datatrans::Web
  class Transaction
    include Datatrans::Common

    attr_accessor :request
    attr_reader :response, :params, :datatrans

    def initialize(datatrans, params)
      warn "DEPRECATION WARNING: Support for the payment page is deprecated and will be removed in the next major version. Please use the JSON API instead."

      @datatrans = datatrans
      params = params.to_hash
      params.symbolize_keys!
      params.reverse_merge!(reqtype: "NOA", useAlias: "yes", hiddenMode: "yes")
      @params = params
    end

    def signature
      sign(datatrans.merchant_id, params[:amount], params[:currency], params[:refno])
    end

    def authorize
      @response = AuthorizeResponse.new(datatrans, params)
      @response.successful?
    end

    def respond_to_missing?(method, *)
      response.respond_to?(method.to_sym) || super
    end

    def method_missing(method, *args, &block)
      if response.respond_to? method.to_sym
        response.send(method)
      else
        super
      end
    end
  end
end

require "datatrans/web/transaction/authorize"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
datatrans-5.2.0 lib/datatrans/web/transaction.rb