payment: Add a button to easily adjust the payment

In case the payment calculation is off.. one can manipulate the
adjustments and then press the adjust button to make the payment
match the total. PayPal allows to capture up to 115%.
This commit is contained in:
Holger Hans Peter Freyther 2011-12-02 21:37:42 +01:00
parent 4883afb265
commit bab9d6b8a7
3 changed files with 13 additions and 2 deletions

View File

@ -33,6 +33,12 @@ class Spree::BillingIntegration::PaypalExpressBase < Spree::BillingIntegration
provider.credit(amount, response_code, :currency => preferred_currency)
end
def adjust(payment, account_or_response_code, gateway_options)
payment.amount = payment.order.total
payment.save
end
def find_authorization(payment)
logs = payment.log_entries.all(:order => 'created_at DESC')
logs.each do |log|
@ -60,4 +66,4 @@ class Spree::BillingIntegration::PaypalExpressBase < Spree::BillingIntegration
(100 * amount).to_i
end
end
end

View File

@ -3,13 +3,17 @@ class Spree::PaypalAccount < ActiveRecord::Base
has_many :payments, :as => :source
def actions
%w{capture credit}
%w{capture credit adjust}
end
def can_capture?(payment)
!echeck?(payment) && payment.state == "pending"
end
def can_adjust?(payment)
can_capture?(payment)
end
def can_credit?(payment)
return false unless payment.state == "completed"
return false unless payment.order.payment_state == "credit_owed"

View File

@ -23,6 +23,7 @@ en:
verified: verified
unverified: unverified
comment: Comment
adjust: Adjust
account_details: Account Details
finalize:
paypalexpress: Capture Payment