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:
parent
4883afb265
commit
bab9d6b8a7
|
@ -33,6 +33,12 @@ class Spree::BillingIntegration::PaypalExpressBase < Spree::BillingIntegration
|
||||||
provider.credit(amount, response_code, :currency => preferred_currency)
|
provider.credit(amount, response_code, :currency => preferred_currency)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def adjust(payment, account_or_response_code, gateway_options)
|
||||||
|
payment.amount = payment.order.total
|
||||||
|
payment.save
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def find_authorization(payment)
|
def find_authorization(payment)
|
||||||
logs = payment.log_entries.all(:order => 'created_at DESC')
|
logs = payment.log_entries.all(:order => 'created_at DESC')
|
||||||
logs.each do |log|
|
logs.each do |log|
|
||||||
|
|
|
@ -3,13 +3,17 @@ class Spree::PaypalAccount < ActiveRecord::Base
|
||||||
has_many :payments, :as => :source
|
has_many :payments, :as => :source
|
||||||
|
|
||||||
def actions
|
def actions
|
||||||
%w{capture credit}
|
%w{capture credit adjust}
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_capture?(payment)
|
def can_capture?(payment)
|
||||||
!echeck?(payment) && payment.state == "pending"
|
!echeck?(payment) && payment.state == "pending"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_adjust?(payment)
|
||||||
|
can_capture?(payment)
|
||||||
|
end
|
||||||
|
|
||||||
def can_credit?(payment)
|
def can_credit?(payment)
|
||||||
return false unless payment.state == "completed"
|
return false unless payment.state == "completed"
|
||||||
return false unless payment.order.payment_state == "credit_owed"
|
return false unless payment.order.payment_state == "credit_owed"
|
||||||
|
|
|
@ -23,6 +23,7 @@ en:
|
||||||
verified: verified
|
verified: verified
|
||||||
unverified: unverified
|
unverified: unverified
|
||||||
comment: Comment
|
comment: Comment
|
||||||
|
adjust: Adjust
|
||||||
account_details: Account Details
|
account_details: Account Details
|
||||||
finalize:
|
finalize:
|
||||||
paypalexpress: Capture Payment
|
paypalexpress: Capture Payment
|
||||||
|
|
Loading…
Reference in New Issue