Browse Source

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%.
1-2-stable-sysmocom
Holger Hans Peter Freyther 10 years ago
parent
commit
bab9d6b8a7
  1. 8
      app/models/spree/billing_integration/paypal_express_base.rb
  2. 6
      app/models/spree/paypal_account.rb
  3. 1
      config/locales/en.yml

8
app/models/spree/billing_integration/paypal_express_base.rb

@ -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

6
app/models/spree/paypal_account.rb

@ -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"

1
config/locales/en.yml

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

Loading…
Cancel
Save