-
Notifications
You must be signed in to change notification settings - Fork 3
/
mollie_ideal_extension.rb
47 lines (38 loc) · 1.38 KB
/
mollie_ideal_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
38
39
40
41
42
43
44
45
46
47
# Uncomment this if you reference any of your controllers in activate
# require_dependency 'application'
class MollieIdealExtension < Spree::Extension
version "1.0"
description "Describe your extension here"
url "http://yourwebsite.com/mollie_ideal"
# Please use mollie_ideal/config/routes.rb instead for extension routes.
def self.require_gems(config)
config.gem "mollie-ideal", :version => '0.1.0', :lib => "mollie-ideal"
end
def activate
# make your helper avaliable in all views
#Spree::BaseController.class_eval do
# helper MollieIdealHelper
#end
BillingIntegration::MollieIdeal.register
PaymentMethod.class_eval do
def payment_profiles_supported?
true
end
end
#open up CheckoutsController so I can do a proper redirection.
CheckoutsController.class_eval do
def complete_checkout
complete_order
order_params = {:checkout_complete => true}
if @checkout.payments.first.source_type == "IdealPayment"
redirect_to @checkout.payments.first.source.payment_redirect_url
else
session[:order_id] = nil
flash[:commerce_tracking] = I18n.t("notice_messages.track_me_in_GA")
redirect_to order_url(@order, {:checkout_complete => true, :order_token => @order.token})
end
end
end
#END CheckoutsController
end
end