Closed jakemumu closed 1 year ago
Why has this been closed? We're still running into it on 0.6
Cause support or even conversations on extensions is pretty non-existent unfortunately
@mamhoff I'm reopening this since you're still running into it on 0.6.
@jakemumu We're sorry we weren't able to respond promptly to this issue last year. We're in the process of updating the extensions. The goal is to move critical extensions to solidusio and ensure that they are always compatible with the latest Solidus versions.
For solidus_paypal_commerce_platform
, we have recently released 1.0.0.beta2. We'll test if it still has this issue that you reported.
I've confirmed that the issue is still present in 1.0.0.beta2.
Thanks @gsmendoza . Flagging as bug, let's see if we can fix this in the current or upcoming sprint. Perhaps @elia may help since he has worked on redoing the extension?
Looks like we'll need to implement SolidusPaypalCommercePlatform::PaymentMethod#try_void
in order for cancel to work, here's a tentative implementation that I spiked looking at solidus_stripe and cleaning up the older APIs that are no longer supported.
def try_void(payment)
if payment.completed?
cancellation_reason = ::Spree::RefundReason.where(
name: ::Spree::Payment::Cancellation::DEFAULT_REASON
).first_or_create!
refund = payment.refunds.build(
amount: payment.credit_allowed,
reason: cancellation_reason,
).tap do |refund|
refund.save!
refund.perform!
end
refund.perform_response
else
void(payment.response_code, nil)
end
end
It looks to me that this function above does too much: See https://github.com/solidusio/solidus/blob/e878076f2ed670d07654ab6293a16588743f2fa6/core/app/models/spree/payment/cancellation.rb#L28-L34 . try_void
should only check whether a void can be performed and perform it, otherwise to return false
. Spree::Payment::Cancellation
will take care of creating the refund if necessary.
If this is inspired by the solidus_stripe
gem, then there might be work there, too.
@mamhoff good call, not sure why stripe used to do that, but since I'm working on rebuilding I'll keep that in mind 🙏
Fix released in 0.7.0 and 1.0.0.beta3
Version:
solidus_paypal_commerce_platform (0.3.0)
Steps:
NotImplementedError (You need to implement try_void for SolidusPaypalCommercePlatform::PaymentMethod. In that return a ActiveMerchant::Billing::Response object if the void succeeds or
false|nilif the void is not possible anymore. Solidus will refund the amount of the payment then.):