-
Notifications
You must be signed in to change notification settings - Fork 176
/
paypal_express_extension.rb
37 lines (30 loc) · 1.28 KB
/
paypal_express_extension.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application'
class PaypalExpressExtension < Spree::Extension
version "1.0"
description "Describe your extension here"
url "http://yourwebsite.com/paypal_express"
def activate
BillingIntegration::PaypalExpress.register
BillingIntegration::PaypalExpressUk.register
# Load up over-rides for ActiveMerchant files
# these will be submitted to ActiveMerchant some time...
require File.join(PaypalExpressExtension.root, "lib", "active_merchant", "billing", "gateways", "paypal", "paypal_common_api.rb")
require File.join(PaypalExpressExtension.root, "lib", "active_merchant", "billing", "gateways", "paypal_express_uk.rb")
# inject paypal code into orders controller
CheckoutsController.class_eval do
include Spree::PaypalExpress
end
Checkout.class_eval do
private
def complete_order
order.complete!
# do not transition echeck order to paid regardless of auto-capture
# echecks are finalized via IPN callback only
if Spree::Config[:auto_capture] && !order.checkout.payments.any? {|p| payment.source.is_a?(PaypalAccount) && p.source.echeck?(p) }
order.pay!
end
end
end
end
end