Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Solidus passes a Spree::Payment object not the payment response code #154

Closed
wants to merge 1 commit into from
Closed

Conversation

prdanelli
Copy link

Spree::Payment::Cancellation.cancel passes an instance of Spree::Payment to SolidusPaypalBraintree::Gateway.try_void and not the string text code.

  # Cancels a payment
  #
  # Tries to void the payment by asking the payment method to try a void,
  # if that fails create a refund about the allowed credit amount instead.
  #
  # @param payment [Spree::Payment] - the payment that should be canceled
  #
  def cancel(payment)
    # For payment methods already implemeting `try_void`
    if try_void_available?(payment.payment_method)
      if response = payment.payment_method.try_void(payment)
        payment.send(:handle_void_response, response)
      else
        payment.refunds.create!(amount: payment.credit_allowed, reason: refund_reason)
      end
    else
      # For payment methods not yet implemeting `try_void`
      deprecated_behavior(payment)
    end
  end

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, boy 😞 ! How could I have missed that...

Anyway. Thanks for reporting.

I would prefer to not add this line but fix the method signature instead. Meaning rename the response_code argument (and fix the yard documentation as well), as this is just an embarrassing bug, that should be fixed asap.

@alepore
Copy link
Contributor

alepore commented Jul 18, 2018

This can be closed for #173

@tvdeyen
Copy link
Member

tvdeyen commented Jul 18, 2018

@prwhitehead thanks for the contribution, but #173 superseded this

@tvdeyen tvdeyen closed this Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants