Sha256: 67c0bfe1dc76d2a8edc3db21b1495f77cf1124a5d3a82812f0a1cda89a1ab055

Contents?: true

Size: 1.57 KB

Versions: 8

Compression:

Stored size: 1.57 KB

Contents

# frozen_string_literal: true

module Spree
  # Bogus Gateway that doesn't support payment profiles.
  class PaymentMethod::SimpleBogusCreditCard < PaymentMethod::BogusCreditCard
    def payment_profiles_supported?
      false
    end

    def authorize(_money, credit_card, _options = {})
      message_detail = " - #{__method__}"

      if VALID_CCS.include? credit_card.number
        ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE + message_detail, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'A' })
      else
        ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE + message_detail, { message: FAILURE_MESSAGE }, test: true)
      end
    end

    def purchase(_money, credit_card, _options = {})
      message_detail = " - #{__method__}"

      if VALID_CCS.include? credit_card.number
        ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE + message_detail, {}, test: true, authorization: AUTHORIZATION_CODE, avs_result: { code: 'A' })
      else
        ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE + message_detail, message: FAILURE_MESSAGE, test: true)
      end
    end

    def void(_response_code, options = {})
      message_detail = " - #{__method__}"

      if options[:originator].completed?
        ActiveMerchant::Billing::Response.new(false, FAILURE_MESSAGE + message_detail, {}, test: true, authorization: AUTHORIZATION_CODE)
      else
        ActiveMerchant::Billing::Response.new(true, SUCCESS_MESSAGE + message_detail, {}, test: true, authorization: AUTHORIZATION_CODE)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
solidus_core-4.4.2 app/models/spree/payment_method/simple_bogus_credit_card.rb
solidus_core-4.4.1 app/models/spree/payment_method/simple_bogus_credit_card.rb
solidus_core-4.4.0 app/models/spree/payment_method/simple_bogus_credit_card.rb
solidus_core-4.3.4 app/models/spree/payment_method/simple_bogus_credit_card.rb
solidus_core-4.3.3 app/models/spree/payment_method/simple_bogus_credit_card.rb
solidus_core-4.3.2 app/models/spree/payment_method/simple_bogus_credit_card.rb
solidus_core-4.3.1 app/models/spree/payment_method/simple_bogus_credit_card.rb
solidus_core-4.3.0 app/models/spree/payment_method/simple_bogus_credit_card.rb