spree / spree_wombat

Connect your Spree Commerce storefront to Wombat
BSD 3-Clause "New" or "Revised" License
31 stars 53 forks source link

SourceSerializer should support non-CC payments: #26

Closed BDQ closed 10 years ago

BDQ commented 10 years ago

A customer reported the following error:

NoMethodError: undefined method `cc_type' for #<Spree::PaypalExpressCheckout:0x007f84df820be8> 
from /usr/local/Cellar/ruby/2.1.1_1/lib/ruby/gems/2.1.0/gems/activemodel-4.0.0/lib/active_model/attribute_methods.rb:436:in `method_missing' 
from /usr/local/Cellar/ruby/2.1.1_1/lib/ruby/gems/2.1.0/gems/activerecord-4.0.0/lib/active_record/attribute_methods.rb:131:in `method_missing' 
from /usr/local/lib/ruby/gems/2.1.0/bundler/gems/spree_wombat-25106a392984/app/serializers/spree/wombat/source_serializer.rb:9:in `cc_type' 

Their workaround was:

module Spree 
  module Wombat 
    SourceSerializer.class_eval do 
      def cc_type 
        object.try(:cc_type) || "N/A" 
      end 

     def last_digits 
       object.try(:last_digits) || "N/A" 
     end 
   end 
 end 
end
JDutil commented 10 years ago

Should we add another field though to indicate what the source was? If the source is a paypal express checkout, check, bitcoin, or anything else would be useful to know what it was rather than just have source reading "N/A" for it's attributes.

peterberkenbosch commented 10 years ago

So adding a "source" key there as well? @JDutil?

JDutil commented 10 years ago

I was going to make it "source_type" as that is the field in spree. I have a work in progress I started a few minutes ago that I'm finishing up specs for.

peterberkenbosch commented 10 years ago

:+1: I'm still messing with the other failing spec.. so go for it! :)

JDutil commented 10 years ago

Should be all set 2-2-stable+