Sha256: ce31cc9085f087285f285ad82dcd9582db61dbe35c9d65f53cf0e22f24fd84a3

Contents?: true

Size: 825 Bytes

Versions: 9

Compression:

Stored size: 825 Bytes

Contents

module Spree
  class Gateway::Linkpoint < Gateway
    preference :login, :string
    preference :pem, :text

    def provider_class
      ActiveMerchant::Billing::LinkpointGateway
    end

    [:authorize, :purchase, :capture, :void, :credit].each do |method|
      define_method(method) do |*args|
        options = add_discount_to_subtotal(args.extract_options!)
        provider.public_send(method, *args << options)
      end
    end

    private

    # Linkpoint ignores the discount, but it will return an error if the
    # chargetotal is different from the sum of the subtotal, tax and
    # shipping totals.
    def add_discount_to_subtotal(options)
      subtotal = options.fetch(:subtotal)
      discount = options.fetch(:discount)
      options.merge(subtotal: subtotal + discount, discount: 0)
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
solidus_gateway-1.3.0 app/models/spree/gateway/linkpoint.rb
solidus_gateway-1.2.0 app/models/spree/gateway/linkpoint.rb
solidus_gateway-1.1.1 app/models/spree/gateway/linkpoint.rb
solidus_gateway-1.1.0 app/models/spree/gateway/linkpoint.rb
solidus_gateway-1.0.1 app/models/spree/gateway/linkpoint.rb
solidus_gateway-0.9.0 app/models/spree/gateway/linkpoint.rb
solidus_gateway-1.0.0 app/models/spree/gateway/linkpoint.rb
spree_gateway-2.2.1 app/models/spree/gateway/linkpoint.rb
spree_gateway-2.1.1 app/models/spree/gateway/linkpoint.rb