This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #252 from nebulab/mm/fix-helpers
Fix Braintree checkout helpers
- Loading branch information
Showing
8 changed files
with
44 additions
and
32 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
app/controllers/solidus_paypal_braintree/admin_payments_controller_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
10 changes: 10 additions & 0 deletions
10
app/controllers/solidus_paypal_braintree/orders_controller_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
app/helpers/solidus_paypal_braintree/braintree_admin_helper.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters