Note that there are some explanatory texts on larger screens.

plurals
  1. POActiveMerchant payment/CC failing when there is a paperclip attachment in order form
    primarykey
    data
    text
    <p>I am able to create and order and successfully run it and save it. I am using an order model and an order_transaction model. I added a field so that when filling out the order form and subscribing, the user can upload a photo of themselves that will be featured on the site. The whole process still works fine, except in the case where the user attaches a photo. When that happens, it just fails the credit card validation. Take off the attachment, and then it works again just fine.</p> <p>order.rb</p> <pre><code>class Order &lt; ActiveRecord::Base has_many :transactions, :class_name =&gt; "OrderTransaction" attr_accessor :card_number, :card_verification, :card_expires_on, :response after_create :log_transaction attr_accessible :first_name, :last_name, :address_one, :address_two, :city, :state, :zip, :country, :email, :verify_email, :term, :shirt_color, :shirt_size, :card_type, :card_number, :card_verification, :transactions_attributes, :card_expires_on_month, :card_expires_on_year, :photo has_attached_file :photo, :styles =&gt; { :medium =&gt; "320x320&gt;", :thumb =&gt; "100x100#" } validates :first_name, :last_name, :address_one, :city, :state, :zip, :country, :presence = &gt; true validate :validate_card, :on =&gt; :create validate :require_shirt_size, :on =&gt; :create def purchase self.response = GATEWAY.purchase(price_in_cents, credit_card) errors.add(:base, response.message) unless self.response.success? self.response.success? end def credit_card @credit_card ||= ActiveMerchant::Billing::CreditCard.new( :type =&gt; card_type, :number =&gt; card_number, :verification_value =&gt; card_verification, :month =&gt; card_expires_on_month, :year =&gt; card_expires_on_year, :first_name =&gt; first_name, :last_name =&gt; last_name ) end def price_in_cents total = 0 if term == '1' total = 2000 elsif term == '2' total = 3500 elsif term == '3' total = 4500 end unless shirt_color == 'none' total += 1599 end total end def require_shirt_size unless shirt_color == 'none' if shirt_size == '' errors.add(:base, "Shirt Size required if ordering a shirt.") end end end private def log_transaction self.transactions.create!(:action =&gt; "purchase", :amount =&gt; price_in_cents, :response = &gt; self.response) end def validate_card unless credit_card.valid? credit_card.errors.full_messages.each do |message| errors.add(:base, message) end end end end </code></pre> <p>order_transaction.rb</p> <pre><code>class OrderTransaction &lt; ActiveRecord::Base attr_accessible :action, :amount, :response belongs_to :order serialize :params def response=(response) self.success = response.success? self.authorization = response.authorization self.message = response.message self.params = response.params rescue ActiveMerchant::ActiveMerchantError =&gt; e self.success = false self.authorization = nil self.message = e.message self.params = {} end end </code></pre> <p>orders_controller.rb</p> <pre><code>def create @order = Order.new(params[:order]) if @order.valid? &amp;&amp; @order.purchase render :success and return else render :action =&gt; 'new' end end </code></pre> <p>It's as if somehow, attaching a photo causes it to lose its ability to pass on the credit card data. I'm not sure where it's losing it, but it is. It feels like a bug in paperclip. Anyone had similar issues with uploading files while making a transaction with activemerchant? It's a fairly simple order type, there's three subscription options.</p> <p>Even suggestions on how to better test and see what's going on would be very helpful, it's got me pretty stuck right now.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload