Sha256: 001cfd4b2fa9b441f61701183fe09445b198fb60a4218b6d0e1b60e8954682b5

Contents?: true

Size: 1.73 KB

Versions: 9

Compression:

Stored size: 1.73 KB

Contents

# frozen_string_literal: true

module Bckbn
  module Transaction
    using Bckbn::CoreExt::StringExt

    RESPONSE_BASE = %i[
      customer_id
      id
      litle_txn_id
      message
      post_date
      report_group
      response
      response_time
      account_updater
      logs
    ].freeze

    AUTHORIZATION_RESPONSE_MEMBERS = [
      *RESPONSE_BASE,
      :approved_amount,
      :auth_code,
      :network_transaction_id,
      :order_id,
      :fraud_result
    ].freeze

    SALE_RESPONSE_MEMBERS = [
      *RESPONSE_BASE,
      :auth_code,
      :network_transaction_id,
      :order_id,
      :fraud_result
    ].freeze
    private_constant :RESPONSE_BASE,
                     :AUTHORIZATION_RESPONSE_MEMBERS,
                     :SALE_RESPONSE_MEMBERS

    AuthorizationResponse = Struct.new(*AUTHORIZATION_RESPONSE_MEMBERS, keyword_init: true)
    SaleResponse          = Struct.new(*SALE_RESPONSE_MEMBERS, keyword_init: true)

    %w[
      CaptureResponse
      CreditResponse
      EcheckCreditResponse
      EcheckVoidResponse
      EcheckSaleResponse
      VoidResponse
    ].each do |response|
      Bckbn::Transaction.const_set(response, Struct.new(*RESPONSE_BASE, keyword_init: true))
    end

    module ResponseShared
      def type
        self.class.name.split("::").last =~ /(.*)Response/
        ::Regexp.last_match(1).underscore.downcase
      end
    end

    [
      AuthorizationResponse,
      SaleResponse,
      CaptureResponse,
      CreditResponse,
      EcheckCreditResponse,
      EcheckVoidResponse,
      EcheckSaleResponse,
      VoidResponse
    ].each { |rc| rc.send(:include, ResponseShared) }

    FraudResult = Struct.new(:avs_result, :card_validation_result, :authentication_result, keyword_init: true)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bckbn-3.0.1 lib/bckbn/resources/transactions/models/responses.rb
bckbn-3.0.0 lib/bckbn/resources/transaction/models/responses.rb
bckbn-2.2.1 lib/bckbn/resources/transaction/models/responses.rb
bckbn-2.1.1 lib/bckbn/resources/transaction/models/responses.rb
bckbn-2.1.0 lib/bckbn/resources/transaction/models/responses.rb
bckbn-2.0.0 lib/bckbn/resources/transaction/models/responses.rb
bckbn-1.1.0 lib/bckbn/resources/transaction/models/responses.rb
bckbn-1.0.0 lib/bckbn/resources/transaction/models/responses.rb
bckbn-0.2.0 lib/bckbn/resources/transaction/models/responses.rb