Sha256: ebc5ea29927998d366d9b63991d77f372a3d821ffef82826beb0f64b83866769

Contents?: true

Size: 710 Bytes

Versions: 5

Compression:

Stored size: 710 Bytes

Contents

module BraintreeViewHelpers
  # Returns a link to the Braintree web UI for the given Braintree +payment_id+
  # (e.g. from Spree::Payment#response_code), or just the +payment_id+ if
  # Braintree's merchant ID is not configured or +payment_id+ is blank
  def braintree_transaction_link(payment_id)
    env = ENV['BRAINTREE_ENV'] == 'production' ? 'www' : 'sandbox'
    merchant = ENV['BRAINTREE_MERCHANT_ID']

    if payment_id.present? && merchant.present?
      link_to(
        payment_id,
        "https://#{env}.braintreegateway.com/merchants/#{merchant}/transactions/#{payment_id}",
        title: 'Show payment on Braintree',
        target: '_blank'
      )
    else
      payment_id
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_braintree-1.4.0 app/helpers/braintree_view_helpers.rb
solidus_braintree-1.3.0 app/helpers/braintree_view_helpers.rb
solidus_braintree-1.2.0 app/helpers/braintree_view_helpers.rb
solidus_braintree-1.1.0 app/helpers/braintree_view_helpers.rb
solidus_braintree-1.0.0 app/helpers/braintree_view_helpers.rb