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

Use transaction status to decide if payment can_void? #109

Merged
merged 2 commits into from
Oct 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/models/solidus_paypal_braintree/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ def can_capture?(payment)
end

def can_void?(payment)
!payment.failed? && !payment.void?
return false unless payment.response_code
transaction = braintree_client.transaction.find(payment.response_code)
Gateway::VOIDABLE_STATUSES.include?(transaction.status)
rescue Braintree::NotFoundError
false
end

def can_credit?(payment)
Expand Down
Loading