Skip to content

Commit

Permalink
Move paypal_button_preference helper method
Browse files Browse the repository at this point in the history
Ref. solidusio#251

Using `Spree::CheckoutController.helper` and
`Spree::OrdersController.helper` in `config/initializers/braintree.rb`
to include helper modules does not work: at `checkout/payement` step an
exception is raised

```
ActionView::Template::Error (undefined method `paypal_button_preference`)
```

This commit move `paypal_button_preferences` (introduced with [1]) in
the already present `SolidusPaypalBraintree::BraintreeCheckoutHelper`
module, and adds the same helper method to the
`Spree::OrdersController` (in the same way done here [2]) to enable
the button also in the cart page.

[1] solidusio#236
[2] solidusio@28d0de9
  • Loading branch information
Flavio Auciello committed Oct 15, 2020
1 parent a00774c commit a6e44bd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module SolidusPaypalBraintree
module OrdersControllerDecorator

def self.prepended(base)
base.helper ::SolidusPaypalBraintree::BraintreeCheckoutHelper
end

::Spree::OrdersController.prepend(self)
end
end
5 changes: 0 additions & 5 deletions app/helpers/braintree_checkout_helper.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,8 @@ def braintree_3ds_options_for(order)
}
end

def paypal_button_preference(key, store:)
store.braintree_configuration.preferences[key]
end
end
end
5 changes: 0 additions & 5 deletions config/initializers/braintree.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
if SolidusSupport.backend_available?
Spree::Admin::PaymentsController.helper :braintree_admin
end

if SolidusSupport.frontend_available?
Spree::CheckoutController.helper :braintree_checkout
Spree::OrdersController.helper :braintree_checkout
end

0 comments on commit a6e44bd

Please sign in to comment.