spree-contrib / spree_store_credits

This Spree extension allows admins to issue arbitrary amounts of store credit to users.
http://guides.spreecommerce.org
BSD 3-Clause "New" or "Revised" License
71 stars 134 forks source link

Issue with partial credit cart payment and :auto_capture => true #4

Closed victor-ono closed 12 years ago

victor-ono commented 13 years ago

There is a terrible issue with your plugin - if Spree credit card setting :auto_capture is set to true: Spree::Config.set(:auto_capture => true)

preference :auto_capture, :boolean, :default => false # automatically capture the creditcard (as opposed to just authorize and capture later)

and someone places an order paying partly with their store credit and partly with a credit card, that order's payment_state is set to 'balance_due' instead of 'paid' and there's no way to change it in the admin. It happens because order's payment_total is not updated and is always 0 in this case, when it must be equal to the amount paid with the credit card. update_payment_state method in order.rb sets payment_state to 'balance_due' when payment_total is less than total:

  # Updates the +payment_state+ attribute according to the following logic:
  #
  # paid          when +payment_total+ is equal to +total+
  # balance_due   when +payment_total+ is less than +total+
  # credit_owed   when +payment_total+ is greater than +total+
  # failed        when most recent payment is in the failed state
  #
  # The +payment_state+ value helps with reporting, etc. since it provides a quick and easy way to locate Orders needing attention.
  def update_payment_state
    if payment_total < total
      self.payment_state = "balance_due"
      self.payment_state = "failed" if payments.present? and payments.last.state == "failed"
    elsif payment_total > total
      self.payment_state = "credit_owed"
    else
      self.payment_state = "paid"
    end
  end

We moved our store into production and now half of our orders are a mess. Please fix this as soon as possible.

Thanks

BDQ commented 13 years ago

I'm not able to reproduce this issue. I've set auto_capture to true and done a partial store credit / partial credit card payment for the order and the payment gets set correctly to "paid".

What version of Spree and Gateway are you using?

victor-ono commented 13 years ago

I'm using Spree 0.40.0. with Authorize.net. I fixed this problem by adding self.reload to update! method in core/app/models/order.rb. See my ticket on lighthouseapp.com - http://railsdog.lighthouseapp.com/projects/31096/tickets/1855-issue-with-spree_store_credits-gem-partial-credit-cart-payment-and-auto_capture-true Can you give some insight on what might be wrong?

Thanks

BDQ commented 12 years ago

Closing, not supporting 0.40 any longer.