Sha256: 0f22f15d8867fb00ef17d3bdda830f0ebca983c6e5c20e3dbff46af32aaf82c4

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module Spree
  class PaymentMethod::Mercadopago < PaymentMethod
    preference :sandbox, :boolean, default: true
    preference :client_id, :string, default: ENV['Mercadopago_CLIENT_ID']
    preference :client_secret, :string, default: ENV['Mercadopago_CLIENT_SECRET']

    def payment_profiles_supported?
      false
    end

    def provider_class
      ::Mercadopago::Client
    end

    def provider(additional_options = {})
      @provider ||= begin
                      options = { sandbox: preferred_sandbox }
                      client = provider_class.new(self, options.merge(additional_options))
                      client.authenticate
                      client
                    end
    end

    def source_required?
      false
    end

    def auto_capture?
      false
    end

    ## Admin options

    def can_void?(payment)
      payment.state != 'void'
    end

    def actions
      %w[void]
    end

    def void(*_args)
      ActiveMerchant::Billing::Response.new(true, '', {}, {})
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
solidus_mercadopago-1.0.0 app/models/spree/payment_method/mercadopago.rb