I'm trying to install the solidus_braintree gem. I...
# support
e
I'm trying to install the solidus_braintree gem. I've setup everything as in the readme says but I'm getting this error:
Copy code
Missing partial checkouts/payment/_braintree with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}.
Could someone help me?
k
Hello! Are you using Solidus Starter Frontend or Solidus Frontend? Which version of
solidus_braintree
did you pick up?
e
I'm using the starter frontend
I tried the branch version but it returns an error that tells something like "you should use solidus_api_ 4.dev " I tried to use that but returns more errors. So I decided to use simply "gem solidus_braintree" and it installed the v2. With version 2 the problem is that something is not installed correctly and I don't know why.
k
I see, unfortunately at the moment there is no version compatible with Solidus 3.3 installed with the starter frontend
1
e
To install solidus I did it from scratch you know:
Copy code
bundle add solidus
bin/rails g solidus:install
It installed this gems gem "solidus_auth_devise", "~> 2.5" gem "solidus_core", "~> 3.3" gem "solidus_backend", "~> 3.3" gem "solidus_api", "~> 3.3" gem "solidus_sample", "~> 3.3" gem "canonical-rails" gem "solidus_support" then I continue adding these gems: gem 'solidus_dynamic_variants', github: 'hefan/solidus_dynamic_variants', branch: 'master' gem 'solidus_product_assembly' And Finally I tried to install this: gem 'solidus_braintree'
Ohhhh got it...
k
BTW, there might be ways to make it work, for example the issue you are having is because it’s looking at
checkout/payments/_braintree
but on v2, it’s under
spree/checkout/payments/_braintree
so if you create the same files in your application under
app/views/checkout/payments/_braintree
copying the content, it should work
e
I just copied it into my local
but another problem comes with that...
the javascripts files...
k
which error?
e
I did the exact thing for the javascripts...
let me do the changes again and I'll copy the message here..
k
👍
e
Copy code
undefined local variable or method `wallet_payment_source' for #<ActionView::Base:0x0000000006d308>
k
which view did you copy exactly?
can you post a GitHub link, please?
e
I just copied the view from the gem that rails installed..
k
ok thanks, give me 1 second
e
thanks man!
k
Can you please show me the content of this file in your application:
app/views/checkouts/steps/payment_step/_existing_cards.html.erb
?
e
sure
k
Ah i think I got it. Please rename this
in the same file, without the
spree
part
e
sorry, which file?
k
app/views/spree/checkout/existing_payment/_braintree.html.erb
should be called
app/views/checkout/existing_payment/_braintree.html.erb
e
it is the same
ohh got it
you remove spree
ok
k
is it working now?
e
but the path is :
that's why I'm a little confused
k
it’s ok like this, you should have a
_braintree
file into the
existing_payment
folder as well
it represents what to render for existing payments (saved cards) done with braintree
e
ok
e
k
checkouts
not
checkout
e
Showing _/Users/ernesto/bitbucket/bmt_solidus/app/views/checkouts/payment/_braintree.html.erb_ where line #1 raised:
Copy code
undefined local variable or method `wallet_payment_source' for #<ActionView::Base:0x00000000072970>
k
can you please show the content of _app/views/checkouts/payment/_braintree.html.erb?_
e
I did it in checkout
k
I think you copied the partial for existing payment into the one for creating new payments
e
k
yep, it’s that. you need this content in _app/views/checkouts/payment/_braintree.html.erb_
you copied the same content in both partials, but they serve different purposes and they are different
1
e
Copy code
Asset `solidus_braintree/checkout.js` was not declared to be precompiled in production.
k
• _app/views/checkouts/payment/_braintree.html.erb_ is used to create new payments, and needs to have this content: https://github.com/solidusio/solidus_braintree/blob/v2.x/lib/views/frontend/spree/checkout/payment/_braintree.html.erb • _app/views/checkouts/existing_payment/_braintree.html.erb_ is used to re-use an existing payment saved in the user wallet, and needs to have this content: https://github.com/solidusio/solidus_braintree/blob/v2.x/app/views/spree/checkout/existing_payment/_braintree.html.erb
1
e
I understand now thanks man!
👍 1
k
let’s see the JS error now
👍 1
e
this is the other error I told you when I did this before
Copy code
Asset `solidus_braintree/checkout.js` was not declared to be precompiled in production.
k
ok, that’s because you don’t have a supported frontend, so this code is not executed: https://github.com/solidusio/solidus_braintree/blob/v2.x/lib/solidus_braintree/engine.rb#L26-L33
you can manage to add those lines in your
config/application.rb
and it should work (after a server restart)
e
ok, let me see!
restarting..
done!
I did, it works the frontend.. But I didn't receive the payment in my braintree sandbox env...
k
nice. in the solidus admin, how does the payment of that order look like?
e
k
did you create the braintree payment method in settings -> payment method?
you need to create a new payment method, and assign it the braintree gateway to it
after saving it, you can select the braintree preferences from the credentials dropdown
e
yest
k
ok, you also need to disable the test credit card, I think you used that
e
ok, let me check that..
k
because “bogus credit card” refers to the test payment method
e
i put this on initializers/spree.rb Rails.application.config.to_prepare do Spree::Config.static_model_preferences.add( SolidusBraintree::Gateway, 'braintree_credentials', { environment: Rails.env.production? ? 'production' : 'sandbox', merchant_id: ENV['BRAINTREE_MERCHANT_ID'], public_key: ENV['BRAINTREE_PUBLIC_KEY'], private_key: ENV['BRAINTREE_PRIVATE_KEY'], paypal_flow: 'vault', # 'checkout' is accepted too use_data_collector: true # Fingerprint the user's browser when using Paypal } ) end
👍 1
at the beginning.
k
you paid with the payment method called “Credit Card”, not “Braintree”
e
and I've created that envs too
ok, let me check that...
Now I've inactive all the other payment types..
k
if you use a new card?
e
LOL that's the other issue I founded
k
can you check the JS console?
e
I could not type in the credit card.
Uncaught ReferenceError: Spree is not defined at checkout-cce69f431e6e07749e06ca06279e41f32a7975c95eda0126b137f008a09d833c.js621 payment:176 Uncaught ReferenceError: BraintreeError is not defined at payment1763
k
let me take a look 🙂
🙌 1
can you please copy the full backtrace of the error?
e
sorry, I'm not following you...
what do you need exactly?
k
I mean the full error in the JS console
e
Look, I'm not a really JS expert. If you could guide me how to do that I'll appreciate it.
this is how I see the error.
k
If you click on the first error, it should show the file where this is happening, can you do that?
e
ok
is in the image
k
Oh you are already there!
1
e
yes
clientTokens: Spree.pathFor('solidus_braintree/client_token'),
k
ok, I think I know what’s happening. In the starter frontend we have that JS object called
Solidus
and not
Spree
. Let’s try to hack that. If you open
app/assets/javascripts/utils.js.rb
, you could try to add this line at the bottom of the file:
Copy code
window.Spree = Solidus;
e
the first error fixed it
but the second still there..
k
yep
e
I sent the image
k
it’s because you need jquery
Copy code
gem 'jquery-rails'
in your Gemfile +
Copy code
//= require jquery
somewhere in your asset pipeline files (probably
app/assets/javascripts/solidus_starter_frontend.js
)
e
when I tried to use jquery-rails the admin panel stopped working properly.
But I could check it again.
k
ah, probably because the admin needs a different jquery version, give me 1 sec
e
ok thanks
k
try with just
//= require jquery
without adding any gem
1
or
//= require jquery3
e
ok
same result