diff --git a/app/controllers/solidus_paypal_braintree/admin_payments_controller_decorator.rb b/app/controllers/solidus_paypal_braintree/admin_payments_controller_decorator.rb new file mode 100644 index 00000000..eefe2392 --- /dev/null +++ b/app/controllers/solidus_paypal_braintree/admin_payments_controller_decorator.rb @@ -0,0 +1,10 @@ +module SolidusPaypalBraintree + module AdminPaymentsControllerDecorator + + def self.prepended(base) + base.helper ::SolidusPaypalBraintree::BraintreeAdminHelper + end + + ::Spree::Admin::PaymentsController.prepend(self) + end +end diff --git a/app/helpers/braintree_admin_helper.rb b/app/helpers/braintree_admin_helper.rb deleted file mode 100644 index 51e57353..00000000 --- a/app/helpers/braintree_admin_helper.rb +++ /dev/null @@ -1,18 +0,0 @@ -module BraintreeAdminHelper - # Returns a link to the Braintree web UI for the given Braintree payment - def braintree_transaction_link(payment) - environment = payment.payment_method.preferred_environment == 'sandbox' ? 'sandbox' : 'www' - merchant_id = payment.payment_method.preferred_merchant_id - response_code = payment.response_code - - return unless response_code.present? - return response_code unless merchant_id.present? - - link_to( - response_code, - "https://#{environment}.braintreegateway.com/merchants/#{merchant_id}/transactions/#{response_code}", - title: 'Show payment on Braintree', - target: '_blank' - ) - end -end diff --git a/app/helpers/solidus_paypal_braintree/braintree_admin_helper.rb b/app/helpers/solidus_paypal_braintree/braintree_admin_helper.rb new file mode 100644 index 00000000..7063c5b0 --- /dev/null +++ b/app/helpers/solidus_paypal_braintree/braintree_admin_helper.rb @@ -0,0 +1,20 @@ +module SolidusPaypalBraintree + module BraintreeAdminHelper + # Returns a link to the Braintree web UI for the given Braintree payment + def braintree_transaction_link(payment) + environment = payment.payment_method.preferred_environment == 'sandbox' ? 'sandbox' : 'www' + merchant_id = payment.payment_method.preferred_merchant_id + response_code = payment.response_code + + return unless response_code.present? + return response_code unless merchant_id.present? + + link_to( + response_code, + "https://#{environment}.braintreegateway.com/merchants/#{merchant_id}/transactions/#{response_code}", + title: 'Show payment on Braintree', + target: '_blank' + ) + end + end +end diff --git a/config/initializers/braintree.rb b/config/initializers/braintree.rb deleted file mode 100644 index 3cd773ae..00000000 --- a/config/initializers/braintree.rb +++ /dev/null @@ -1,3 +0,0 @@ -if SolidusSupport.backend_available? - Spree::Admin::PaymentsController.helper :braintree_admin -end