Pumpinglemma
Pumpinglemma

Reputation: 113

Adding a new ActiveMerchant Gateway (Elavon) to Spree

I'm attempting to implement a new payment gateway for Spree, one that is supported in ActiveMerchant (Elavon). On Spree's website, it seems very trivial to do, but it seems there's a step that I'm missing. I've written a model in /app/model/gateways/elavon.rb

class Gateway::Elavon < Gateway
      preference :login, :string
      preference :password, :string
      preference :user, :string
      def provider_class
        ActiveMerchant::Billing::ElavonGateway
      end
   end
end

I'm guessing I'm missing some way to load this gateway on startup? I also believe I need to set a specific setting for spree when it loads, and can't seem to get that working either.

Spree::Config.set( :auto_capture, true )

I've tried placing it in config/application.rb, but to no avail.

I've even tried using just this gem: https://github.com/baracek/spree_elavon_gateway

When I try to startup spree, I get the error:

/home/dave/.rvm/gems/ruby-1.9.2-p290/bundler/gems/spree_elavon_gateway-802ab1e3bf31/app/models/gateway/elavon.rb:1:in `<top (required)>': wrong argument type Module (expected Class) (TypeError)

Any help or pointers is greatly appreciated.

Upvotes: 2

Views: 1586

Answers (2)

thekingoftruth
thekingoftruth

Reputation: 1781

I would suggest fixing the spree_elavon_gateway gem in a fork and sending a pull request to the official repository on GitHub. Meanwhile, you can use your branch of it just fine :). I'm actually planning on using spree_elavon_gateway very soon, so I may fix it myself if you don't.

Upvotes: 1

ashga
ashga

Reputation: 269

I think your code should be like: -

also make sure you have added the spree_gateway gem in your gemfile.

module Spree
  class Gateway::Elavon < Gateway
    preference :login, :string
    preference :password, :string
    preference :user, :string

    def provider_class
      ActiveMerchant::Billing::ElavonGateway
    end
  end
end

re reading your error it could also be that the capital M in module is causing the error you can also try changing Module to module

Upvotes: 1

Related Questions