New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot transition state via :complete from "completed" (Reason(s): State cannot transition via "complete") #2119

Closed
sushantmittal opened this Issue Oct 19, 2012 · 4 comments

Comments

Projects
None yet
2 participants
@sushantmittal

sushantmittal commented Oct 19, 2012

Issue in spree / core / app / controllers / spree / admin / payments_controller.rb(action : fire)

Steps to reproduce the issue

  1. Open (/admin/orders/R326056115/payments) in two tabs.
  2. First capture the payment in one tab
  3. Again try to capture payment in the second tab, then error occurs

We can handle this situation by rescued (StateMachine::InvalidTransition)

  def fire
    return unless event = params[:e] and @payment.payment_source

    # Because we have a transition method also called void, we do this to avoid conflicts.
    event = "void_transaction" if event == "void"
    if @payment.send("#{event}!")
      flash.notice = t(:payment_updated)
    else
      flash[:error] = t(:cannot_perform_operation)
    end
  rescue Spree::Core::GatewayError, StateMachine::InvalidTransition => ge
    flash[:error] = "#{ge.message}"
  ensure
    respond_with(@payment) { |format| format.html { redirect_to admin_order_payments_path(@order) } }
  end

@radar

This comment has been minimized.

Show comment
Hide comment
@radar

radar Oct 19, 2012

Member

Rescuing the StateMachine::InvalidTransation exception within the controller seems like a very dirty hack. I would much rather that capture! just didn't perform when the payment was already complete.

Member

radar commented Oct 19, 2012

Rescuing the StateMachine::InvalidTransation exception within the controller seems like a very dirty hack. I would much rather that capture! just didn't perform when the payment was already complete.

@sushantmittal

This comment has been minimized.

Show comment
Hide comment
@sushantmittal

sushantmittal Oct 23, 2012

Thanks, for changing capture! method.

sushantmittal commented Oct 23, 2012

Thanks, for changing capture! method.

@sushantmittal

This comment has been minimized.

Show comment
Hide comment
@sushantmittal

sushantmittal Oct 23, 2012

@radar

For above solution to work, we have to change (void_transaction!) method also. So, it does not operate when payment is already void.

sushantmittal commented Oct 23, 2012

@radar

For above solution to work, we have to change (void_transaction!) method also. So, it does not operate when payment is already void.

radar added a commit that referenced this issue Oct 24, 2012

radar added a commit that referenced this issue Oct 24, 2012

radar added a commit that referenced this issue Oct 24, 2012

@radar

This comment has been minimized.

Show comment
Hide comment
@radar

radar Oct 24, 2012

Member

Thanks, I've just fixed this up in 1-1-stable, 1-2-stable and master.

On Tue, Oct 23, 2012 at 11:14 PM, sushant mittal
notifications@github.comwrote:

@radar https://github.com/radar

For above solution to work, we have to change (void_transaction!) method
also. So, it does not operate when payment is already void.


Reply to this email directly or view it on GitHubhttps://github.com/spree/spree/issues/2119#issuecomment-9699509.

Member

radar commented Oct 24, 2012

Thanks, I've just fixed this up in 1-1-stable, 1-2-stable and master.

On Tue, Oct 23, 2012 at 11:14 PM, sushant mittal
notifications@github.comwrote:

@radar https://github.com/radar

For above solution to work, we have to change (void_transaction!) method
also. So, it does not operate when payment is already void.


Reply to this email directly or view it on GitHubhttps://github.com/spree/spree/issues/2119#issuecomment-9699509.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment