diff --git a/app/models/spree/billing_integration/paypal_express_base.rb b/app/models/spree/billing_integration/paypal_express_base.rb index 393dfb3..f326a5a 100644 --- a/app/models/spree/billing_integration/paypal_express_base.rb +++ b/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 \ No newline at end of file +end diff --git a/app/models/spree/paypal_account.rb b/app/models/spree/paypal_account.rb index 8980ab1..be03636 100644 --- a/app/models/spree/paypal_account.rb +++ b/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" diff --git a/config/locales/en.yml b/config/locales/en.yml index 423c8df..bb8c445 100644 --- a/config/locales/en.yml +++ b/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