Sha256: 08ecad8c048c08b5d6ef623a478b8abb468eeb4132be76cae84763af940b55d6

Contents?: true

Size: 958 Bytes

Versions: 1

Compression:

Stored size: 958 Bytes

Contents

module Spree
  class Gateway::BraintreeVzeroDropInUi < Spree::Gateway::BraintreeVzeroBase
    include ::Spree::Gateway::BraintreeVzero::LegacyRailsPatch

    preference :dropin_container, :string, default: 'payment-form'
    preference :checkout_form_id, :string, default: 'checkout_form_payment'
    preference :error_messages_container_id, :string, default: 'content'
    preference :store_payments_in_vault, :select, default: -> { { values: [:do_not_store, :store_only_on_success, :store_all] } }
    preference :'3dsecure', :boolean_select, default: false

    after_save :disable_hosted_gateways, if: proc {
      active? && (attributes_after_save.keys & %w[active id]).any?
    }

    def method_type
      'braintree_vzero_dropin_ui'
    end

    private

    # we cannot have Hosted and DropInUI both active at the same time
    def disable_hosted_gateways
      Spree::Gateway::BraintreeVzeroHostedFields.update_all(active: false)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spree_braintree_vzero-3.6.0 app/models/spree/gateway/braintree_vzero_drop_in_ui.rb