Sebastian
08/18/2022, 9:02 AMsolidus_paypal_braintree
gem. I followed instructions from their github: https://github.com/solidusio/solidus_paypal_braintree and it seems to be incomplete. I can’t access any of the routes generated by gem (e.g. /solidus_paypal_braintree
) and Braintree nav item hasn’t been added to admin dashboard. My routes file have this line but it doesn’t seem to be working mount SolidusPaypalBraintree::Engine, at: '/solidus_paypal_braintree'
Ryan Woods
08/18/2022, 9:18 AMSebastian
08/18/2022, 9:20 AMgem "solidus", "~> 3.1"
gem 'rails', '~> 6.1.6', '>= 6.1.6.1'
Ryan Woods
08/18/2022, 9:26 AMbundle exec rails routes | grep 'solidus_paypal_braintree'
give any results?Sebastian
08/18/2022, 9:27 AMRyan Woods
08/18/2022, 9:28 AMlocalhost:3000/solidus_paypal_braintree/configurations/list
Ryan Woods
08/18/2022, 9:29 AMSebastian
08/18/2022, 9:34 AM<http://localhost:3001/solidus_paypal_braintree/configurations/list>
actually worked. LOL, I tried it like 50 times yesterday. Thanks!
Now, I have another problem tho. The docs is saying this:
1. Visit /admin/payment_methods/new
2. Set provider
to SolidusPaypalBraintree::Gateway
3. Click “Save”
4. Choose braintree_credentials
from the Preference Source
select
5. Click Update
to save
But neither SolidusPaypalBraintree::Gateway
nor braintree_credentials
is not there when creating a new payment method.Ryan Woods
08/18/2022, 9:38 AMBraintree
for the type
?Sebastian
08/18/2022, 9:39 AMPreference Source
I can only choose (custom)
Ryan Woods
08/18/2022, 9:41 AMbraintree_credentials
to appear in admin for the preference_source
of the payment method, this would need to be added to config/initializers/spree.rb
:
# config/initializers/spree.rb
Spree.config do |config|
config.static_model_preferences.add(
SolidusPaypalBraintree::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
What you’re seeing here is Solidus’ static preferences, where preferences are created on load, and they have a key which refers to them, in this case braintree_credentials
. So it wasn’t appearing as a preference source as it didn’t exist yet.
The alternative is to skip this static preference code, and not choose a preference source in admin ((custom)
). Then you can type/control the credentials/preferences from admin (they get saved on the DB).
I have noticed some confusion on this area, so I will make a PR to update it this week 👍Sebastian
08/18/2022, 9:49 AMSpree::Config.config
`solidus_fresh_test_1/config/initializers/spree.rb77in `<main>': undefined method config' for #<Spree::AppConfiguration:0x00007f996a60b160> (NoMethodError)
but works when I do Spree.config
Sebastian
08/18/2022, 9:49 AMbraintree_credentials
is still not appearing on the listRyan Woods
08/18/2022, 9:53 AM_Spree_.config do |config|
is correct. Thanks 👍 I’ll update that tooSebastian
08/18/2022, 9:53 AMBraintree
payment method has been automatically added by the gem and it uses braintree_credentials
. But it’s not appearing if I want to create a new one. That’s fine thenRyan Woods
08/18/2022, 9:55 AMSebastian
08/18/2022, 9:56 AM/checkout/payment
Braintree appears as payment method but it’s not rendering anything to do with paypal. It’s just empty. Console gives me this and when I go to <http://localhost:3001/solidus_paypal_braintree/client_token>
it actually is saying No route matches [GET]…
Ryan Woods
08/18/2022, 9:58 AM….ENV['BRAINTREE_MERCHANT_ID']
)Sebastian
08/18/2022, 10:03 AM.env
file. Obviously cropped to hide the credentialsRyan Woods
08/18/2022, 10:10 AMSebastian
08/18/2022, 10:11 AMSebastian
08/18/2022, 10:12 AMSebastian
08/18/2022, 10:16 AMRyan Woods
08/18/2022, 10:32 AMSolidusPaypalBraintree::Gateway.first.preferences
return the credentials you expect?
2. And are they exactly the same as you see in the Braintree sandbox panel?Sebastian
08/18/2022, 10:43 AMnil
even if I directly put credentials into spree.rb
instead of reading from ENV fileRyan Woods
08/18/2022, 10:44 AMSolidusPaypalBraintree::Gateway.first.update(preference_source: 'braintree_credentials')
Ryan Woods
08/18/2022, 10:46 AMSolidusPaypalBraintree::Gateway.count
is only 1
right?Sebastian
08/18/2022, 10:47 AMSolidusPaypalBraintree::Gateway.first
returns a result where preference_source
is set to braintree_credentials
but SolidusPaypalBraintree::Gateway.first.preferences
is an empty object reallySebastian
08/18/2022, 10:52 AMRyan Woods
08/18/2022, 10:53 AMRyan Woods
08/18/2022, 10:53 AMpreference_source
to (custom)
in admin, save it, change the credentials then save it againSebastian
08/18/2022, 10:55 AMENV[…]
but it didn’t work. Will now try directly through the console to DBSebastian
08/18/2022, 11:12 AMSolidusPaypalBraintree::Gateway.first.preferences
? I’m a front end dev just fighting with Rails unfortunatelyRyan Woods
08/18/2022, 11:15 AMSolidusPaypalBraintree::Gateway.first.update(preferred_merchant_id: 'new_value'
I recommend checking out: https://guides.solidus.io/developers/preferences/add-model-preferenceswaiting_for_dev
08/19/2022, 3:47 AMwaiting_for_dev
08/19/2022, 3:48 AM(custom)
as source, and then edit it.Ryan Woods
08/19/2022, 6:45 AMSebastian
08/19/2022, 10:41 AMcheckout/payment
page loads I get the red error & then when I click on paypal button it shows further 4 warnings about credentials not matching but credentials are definitely correct. This is the exact same thing that happens with the actual project I’m working on. I even created a new Paypal developer account with new credentials and still the same thing is happening.Sebastian
08/19/2022, 10:43 AMmerchant-id=DV33…
or merchant-id=<mailto:payee@merchant.com|payee@merchant.com>
from as my credentials are completely different.Kurtis
08/19/2022, 1:03 PMKurtis
08/19/2022, 1:04 PMKurtis
08/19/2022, 1:04 PMRyan Woods
08/19/2022, 1:21 PMKurtis
08/19/2022, 1:26 PMKurtis
08/19/2022, 1:27 PMKurtis
08/19/2022, 1:27 PMRyan Woods
08/19/2022, 2:15 PMKurtis
08/19/2022, 2:17 PMKurtis
08/19/2022, 2:17 PMKurtis
08/19/2022, 2:17 PMSebastian
08/19/2022, 2:22 PMSebastian
08/19/2022, 2:22 PMRyan Woods
08/19/2022, 2:37 PMKurtis
08/19/2022, 2:43 PMKurtis
08/19/2022, 2:43 PMRyan Woods
08/19/2022, 2:45 PMRyan Woods
08/19/2022, 2:46 PMKurtis
08/19/2022, 3:08 PMRyan Woods
08/19/2022, 3:12 PMKurtis
08/19/2022, 3:13 PMKurtis
08/19/2022, 3:14 PMKurtis
08/19/2022, 3:17 PMRyan Woods
08/19/2022, 3:21 PMRyan Woods
08/19/2022, 3:21 PM//= require rails-ujs
should be after itRyan Woods
08/19/2022, 3:27 PMsolidus_frontend
normally has a file that looks like this:
vendor/assets/javascripts/spree/frontend/all.js
Which contains
//= require jquery3
//= require rails-ujs
//= require spree/frontend
Then the the Braintree extension adds this to it:
//= require_tree .
//= require solidus_paypal_braintree/frontend
Sebastian
08/19/2022, 3:27 PM//= require jquery
here we require jquery_ujs or rails-ujs (getting confused here what is what LOL) as when having both, it shows an error saying to only have rails-ujs
//= require checkout/payment/spree
//= require checkout/payment/braintree
//= require checkout/payment/stripe
Ryan Woods
08/19/2022, 3:28 PMjquery_ujs
is the old one, my bad, that’s what I needed a while ago for an old project :grin
You’ll need rails-ujs
Sebastian
08/19/2022, 3:29 PMSebastian
08/19/2022, 3:30 PM