Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #252 from nebulab/mm/fix-helpers
Browse files Browse the repository at this point in the history
Fix Braintree checkout helpers
  • Loading branch information
kennyadsl authored Oct 15, 2020
2 parents a00774c + 69923ed commit b8bef75
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module SolidusPaypalBraintree
module AdminPaymentsControllerDecorator

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

::Spree::Admin::PaymentsController.prepend(self)
end
end
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
18 changes: 0 additions & 18 deletions app/helpers/braintree_admin_helper.rb

This file was deleted.

5 changes: 0 additions & 5 deletions app/helpers/braintree_checkout_helper.rb

This file was deleted.

20 changes: 20 additions & 0 deletions app/helpers/solidus_paypal_braintree/braintree_admin_helper.rb
Original file line number Diff line number Diff line change
@@ -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
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
8 changes: 0 additions & 8 deletions config/initializers/braintree.rb

This file was deleted.

2 changes: 1 addition & 1 deletion spec/helpers/braintree_admin_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

RSpec.describe BraintreeAdminHelper do
RSpec.describe SolidusPaypalBraintree::BraintreeAdminHelper do
describe '#braintree_transaction_link' do
let(:payment_method) { create_gateway }
let(:payment) do
Expand Down

0 comments on commit b8bef75

Please sign in to comment.