Sébastien Ternest
07/17/2023, 5:40 PMJared Norman
Sébastien Ternest
07/17/2023, 5:49 PMkennyadsl
Sébastien Ternest
07/18/2023, 7:34 AMSébastien Ternest
07/18/2023, 7:39 AMSébastien Ternest
07/18/2023, 7:41 AMsource '<https://rubygems.org>'
git_source(:github) { |repo| "<https://github.com/#{repo}.git>" }
ruby '3.0.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
gem 'rails', '~> 7.0.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3', '~> 1.4'
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Build JSON APIs with ease. Read more: <https://github.com/rails/jbuilder>
gem 'jbuilder', '~> 2.7'
gem 'pg'
gem "dotenv-rails"
# gem 'newrelic_rpm'
gem 'image_processing', '~> 1.2'
gem 'cloudinary'
gem 'activestorage-cloudinary-service'
gem "solidus_core", "~> 3.4"
gem "solidus_backend", "~> 3.4"
gem "solidus_api", "~> 3.4"
gem "solidus_sample", "~> 3.4"
gem 'canonical-rails'
gem 'solidus_support', '~> 0.8'
gem 'truncate_html'
gem 'view_component', '~> 2.46'
gem 'solidus_auth_devise'
gem 'solidus_paypal_commerce_platform'
gem 'stripe', '~> 8.0'
gem "simple_form", github: "heartcombo/simple_form"
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 4.1.0'
# Display performance information such as SQL time and flame graphs for each request in your browser.
# Can be configured to work on production as well see: <https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md>
gem 'rack-mini-profiler', '~> 2.0'
gem 'listen', '~> 3.3'
# Spring speeds up development by keeping your application running in the background. Read more: <https://github.com/rails/spring>
gem 'spring'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 3.26'
gem 'selenium-webdriver', '>= 4.0.0.rc1'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
group :development, :test do
gem 'rspec-rails'
gem 'apparition', '~> 0.6.0', github: 'twalpole/apparition'
gem 'rails-controller-testing', '~> 1.0.5'
gem 'rspec-activemodel-mocks', '~> 1.1.0'
gem 'capybara-screenshot', '~> 1.0'
gem 'database_cleaner', '~> 1.7'
gem 'factory_bot', '>= 4.8'
gem 'factory_bot_rails'
gem 'ffaker', '~> 2.13'
gem 'redcarpet'
gem 'rubocop', '~> 1.0'
gem 'rubocop-performance', '~> 1.5'
gem 'rubocop-rails', '~> 2.3'
gem 'rubocop-rspec', '~> 2.0'
gem 'yard'
end
gem 'solidus_stripe', '5.0.0.rc.3'
kennyadsl
When I type “bundle add solidus” and bin/rails g solidus:install or bin/rails g solidus:update, nothing happens.are you running these commands on a new rails application?
Sébastien Ternest
07/18/2023, 11:36 AMkennyadsl
Sébastien Ternest
07/18/2023, 3:01 PMkennyadsl
bin/rails app:template LOCATION=<https://github.com/solidusio/solidus_starter_frontend/raw/v3.4/template.rb>
You can also try to use the latest version with Solidus 3.4 but I’m not sure it works (I’d still try, if doesn’t work you can go back to the other version) with:
bin/rails app:template LOCATION=<https://github.com/solidusio/solidus_starter_frontend/raw/v4.1/template.rb>
kennyadsl
bundle add solidus_stripe
bin/rails generate solidus_stripe:install
kennyadsl
Sébastien Ternest
07/19/2023, 10:35 AMSébastien Ternest
07/19/2023, 11:41 PMkennyadsl
kennyadsl
stimulus-rails
gem to your Gemfile: gem 'stimulus-rails'
2. Run ./bin/bundle install
.
3. Run ./bin/rails stimulus:install
kennyadsl
importmap-rails
, which will make the stimulus installation using importmapskennyadsl
./bin/bundle add importmap-rails
2. Run ./bin/rails importmap:install
kennyadsl
<%= javascript_importmap_tags %>
in the headSébastien Ternest
07/20/2023, 11:30 AM<head>
<meta charset="utf-8">
<title><%= title %></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<%== meta_data_tags %>
<%= canonical_tag(current_store.url) %>
<%= csrf_meta_tags %>
<%= javascript_importmap_tags %>
<script src="<https://js.stripe.com/v3/>"></script>
<%= javascript_include_tag 'solidus_starter_frontend' %>
<%= stylesheet_link_tag 'solidus_starter_frontend', media: 'screen' %>
<%= favicon_link_tag 'favicon.ico' %>
<%= yield :head %>
</head>
Sébastien Ternest
07/20/2023, 11:32 AM<!DOCTYPE html>
<html>
<head>
<title>Edb091122</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="preconnect" href="<https://fonts.googleapis.com>">
<link rel="preconnect" href="<https://fonts.gstatic.com>" crossorigin>
<link href="<https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200&display=swap>" rel="stylesheet">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<script src="<https://js.stripe.com/v3/>"></script>
<%= javascript_include_tag '<https://js.stripe.com/v3/>', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_importmap_tags %>
</head>
<body>
<%= yield %>
</body>
</html>
Sébastien Ternest
07/20/2023, 1:04 PMkennyadsl
kennyadsl
Sébastien Ternest
07/20/2023, 3:56 PMSébastien Ternest
07/20/2023, 3:58 PMkennyadsl
kennyadsl
Sébastien Ternest
07/20/2023, 4:25 PMSébastien Ternest
07/20/2023, 6:09 PMkennyadsl
Sébastien Ternest
07/20/2023, 6:17 PMSébastien Ternest
07/20/2023, 6:18 PMkennyadsl
Sébastien Ternest
07/20/2023, 6:34 PMkennyadsl
Sébastien Ternest
07/20/2023, 7:02 PMsolidus_stripe_payment_controller:29 Uncaught (in promise) IntegrationError: In order to create a payment element, you must pass a clientSecret or mode when creating the Elements group.
kennyadsl
Sébastien Ternest
07/21/2023, 8:24 AMSébastien Ternest
07/21/2023, 8:25 AMkennyadsl
kennyadsl
<div
class="solidus-stripe-payment"
data-controller="solidus-stripe-payment"
data-solidus-stripe-payment-publishable-key-value="<%= payment_method.preferred_publishable_key %>"
data-solidus-stripe-payment-options-value="<%= options.to_json %>"
data-solidus-stripe-payment-radio-selector-value="#order_payments_attributes__payment_method_id_<%= payment_method.id %>"
data-solidus-stripe-payment-submit-selector-value="#checkout_form_payment [type='submit']"
data-action="submit@window->solidus-stripe-payment#handleSubmit"
>
kennyadsl
Sébastien Ternest
07/21/2023, 8:57 AMkennyadsl
kennyadsl
Sébastien Ternest
07/21/2023, 9:13 AMSébastien Ternest
07/21/2023, 9:15 AMSébastien Ternest
07/21/2023, 9:15 AMrainer
07/21/2023, 12:02 PMthis.optionsValue.elementsInitialization
.
This might be tied to the fact that, for some reason, the various options (which at first look seem correctly initialized from the screenshot of the rendering that you shared) don’t arrive at the StimulusJS controller.
The next step could be setting a debugger before that line to verify if this is the case.
(Another minor observation is that your pk_test_
key appears to be longer compared to the working one I’m using. However, this could be related to this, so consider this as a potential issue rather than a definitive one - I can’t say for certain)Sébastien Ternest
07/25/2023, 5:07 PM<%
stripe_payment_method= payment.source.stripe_payment_method
# stripe_payment_method = payment.source.payment_method
# <https://stripe.com/docs/api/payment_methods/object#payment_method_object-type>
partial_base = "checkouts/existing_payment/stripe"
payment_type = stripe_payment_method.type
# Fallback on the default partial if a specialized partial is not available.
payment_type = 'default' if lookup_context.find_all("#{partial_base}/_#{payment_type}").none?
%>
<%= render(
"#{partial_base}/#{payment_type}",
stripe_payment_method: stripe_payment_method,
partial_base: partial_base,
payment_type: payment_type
) %>
<% if current_order&.confirm? %>
<% stripe_intent =
SolidusStripe::PaymentIntent.prepare_for_payment(payment).stripe_intent %>
<input
type="hidden"
data-controller="solidus-stripe-confirm"
data-solidus-stripe-confirm-publishable-key-value="<%= payment.payment_method.preferred_publishable_key %>"
data-solidus-stripe-confirm-client-secret-value="<%= stripe_intent.client_secret %>"
data-solidus-stripe-confirm-return-url-value="<%= solidus_stripe.after_confirmation_url(payment.payment_method.slug) %>"
data-solidus-stripe-confirm-error-base-url-value="<%= solidus_stripe.after_confirmation_url(payment.payment_method.slug, payment_intent: stripe_intent.id) %>"
data-action="submit@window->solidus-stripe-confirm#confirm"
>
<% end %>
rainer
07/27/2023, 11:21 AMYou have lead me to the good path. Now I get the stripe elements mounted.I’m glad to hear that! 🙌 About the mentioned problem, as you can see your
stripe_payment_method
is a string for some reason 🤔
Have you debugged this line to find out more details?
stripe_payment_method = payment.source.stripe_payment_method
Particularly, if payment.source
is present and is a SolidusStripe::PaymentSource
, it’s unusual that stripe_payment_method
returns a string.
The method responsible for extracting the stripe payment method from the source is the following:
https://github.com/solidusio/solidus_stripe/blob/22034357450e7712e9581b28b9658454a80175b6/app/models/solidus_stripe/payment_source.rb#L7-L13
Unless it’s been modified, you might want to check if your source has a stripe_payment_method_id
with:
payment.source.stripe_payment_method_id
And if it does, you can try to extract the stripe payment method in the same way it is done in the method I mentioned but starting from the payment:
payment.payment_method.gateway.request do
Stripe::PaymentMethod.retrieve(payment.source.stripe_payment_method_id)
end
From the results of these operations, we could try to figure out why this problem is occurring 🤞Sébastien Ternest
08/10/2023, 9:06 AMstripe_payment_method = payment.source.stripe_payment_method
it returns nil
>> stripe_payment_method
=> nil
when I modify with this
stripe_payment_method = payment.source.stripe_payment_method_id
it returns ” ” I don’t know why
>> payment.source.stripe_payment_method_id
=> ""
This what my console looks like when I type “payment”
> payment
=> #<Spree::Payment id: 22, amount: 0.1e1, order_id: 14, source_type: "SolidusStripe::PaymentSource", source_id: 13, payment_method_id: 16, state: "processing", response_code: nil, avs_response: nil, created_at: "2023-07-18 14:01:59.069126000 +0000", updated_at: "2023-07-18 14:02:03.752910000 +0000", number: "QQ9FXZ9X", cvv_response_code: nil, cvv_response_message: nil>
Do you have any idea what the problem is ?
Thank yourainer
08/21/2023, 4:40 PMstripe_payment_method_id
(needed to retrieve the payment from Stripe).
Check if:
• You have this section in your `app/views/checkouts/payment/_stripe.html.erb`:
https://github.com/solidusio/solidus_stripe/blob/90894c8d74d14e42907493ea9ee249d75[…]/install/templates/app/views/checkouts/payment/_stripe.html.erb
<input
type="hidden"
name="payment_source[<%= payment_method.id %>][stripe_payment_method_id]"
value=""
data-solidus-stripe-payment-target="paymentMethodInput"
>
• This input gets correctly initialized before this.paymentMethodInputTarget.form.submit()
in your solidus_stripe_payment_controller.js
:
https://github.com/solidusio/solidus_stripe/blob/90894c8d74d14e42907493ea9ee249d75[…]app/javascript/controllers/solidus_stripe_payment_controller.js
If you spot the “stripe_payment_method_id” and everything appears to be configured correctly, I’d check the logs errors indicating an unpermitted parameter like:
Unpermitted parameter: :stripe_payment_method_id
I don’t think so, but just to be sure that the issue isn’t with the parameters.
Keep me posted 👍