diff --git a/app/models/solidus_paypal_braintree/gateway.rb b/app/models/solidus_paypal_braintree/gateway.rb index c316300e..2c0e2f17 100644 --- a/app/models/solidus_paypal_braintree/gateway.rb +++ b/app/models/solidus_paypal_braintree/gateway.rb @@ -171,16 +171,16 @@ def cancel(response_code) # Otherwise, we return false so Solidus creates a refund instead. # # @api public - # @param response_code [String] the transaction id of the payment to void + # @param payment [Spree::Payment] the payment to void # @return [Response|FalseClass] - def try_void(response_code) - transaction = braintree.transaction.find(response_code) + def try_void(payment) + transaction = braintree.transaction.find(payment.response_code) if transaction.status.in? SolidusPaypalBraintree::Gateway::VOIDABLE_STATUSES # Sometimes Braintree returns a voidable status although it is not voidable anymore. # When we try to void that transaction we receive an error and need to return false # so Solidus can create a refund instead. begin - void(response_code, nil, {}) + void(payment.response_code, nil, {}) rescue ActiveMerchant::ConnectionError => e e.message.match(NON_VOIDABLE_STATUS_ERROR_REGEXP) ? false : raise(e) end diff --git a/spec/models/solidus_paypal_braintree/gateway_spec.rb b/spec/models/solidus_paypal_braintree/gateway_spec.rb index 2d22cd5a..7eb3a27d 100644 --- a/spec/models/solidus_paypal_braintree/gateway_spec.rb +++ b/spec/models/solidus_paypal_braintree/gateway_spec.rb @@ -357,7 +357,7 @@ end describe '#try_void' do - subject { gateway.try_void(source.token) } + subject { gateway.try_void(instance_double('Spree::Payment', response_code: source.token)) } let(:transaction_request) do class_double('Braintree::Transaction',