should a new store use solidus_stripe v4 or would ...
# support
e
should a new store use solidus_stripe v4 or would folks suggest v5 RC 2? assuming 5 should work, i have this in my
config/solidus_stripe.rb
Copy code
Spree::Config.static_model_preferences.add(
  "SolidusStripe::PaymentMethod",
  "solidus_stripe_env_credentials",
  api_key: Rails.application.credentials.stripe.api_key!,
  publishable_key: Rails.application.credentials.stripe.publishable_key!,
  test_mode: Rails.application.credentials.stripe.api_key!.start_with?("sk_test_"),
  webhook_endpoint_signing_secret: Rails.application.credentials.stripe.webhook_signing_secret!,
)
for some reason in
app/views/orders/payment_info/_stripe.html.erb
,
Copy code
stripe_payment_method = payment.source.stripe_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
isn't working because
stripe_payment_method
is nil.
seems the value is an empty string
Copy code
SolidusStripe::PaymentSource Create -- { :sql => "INSERT INTO \"solidus_stripe_payment_sources\" (\"payment_method_id\", \"stripe_payment_method_id\", \"created_at\", \"updated_at\", \"tenant_id\") VALUES ($1, $2, $3, $4, $5) RETURNING \"id\"", :binds => { :payment_method_id => 3, :stripe_payment_method_id => "", :created_at => "2023-06-16 22:32:55.502506", :updated_at => "2023-06-16 22:32:55.502506", :tenant_id => 1 }, :allocations => 929, :cached => nil }
when i first go through the checkout, the payment step does show the stripe inputs, but the
#update
is failing
looking at the starter front-end i see i'm expecting a value such as
pm_1NJqq9LPxMF9XGLKpVzp7mTF
🤔
looking at the stripe logs for my test account, i do see the request i expect as part of checkout and the response looks to include a
payment_method
but somehow it isn't making it into solidus
Copy code
{
  "capture_method": "manual",
  "metadata": {
    "solidus_order_number": "R529472096"
  },
  "currency": "USD",
  "customer": "cus_O62wMmve74c61l",
  "payment_method": "pm_1NK0s3LPxMF9XGLKwdhcdaoU",
  "amount": "2624",
  "payment_method_types": {
    "0": "card"
  }
}
l
did you create the stripe payment method in your admin settings page ?
e
I did 👍
l
locally do you have the stripe CLI listenning to webhooks ?
stripe listen …
e
No! I didn't realize that was required for the checkout flow, i thought it was only required to handle later phases
l
might not be the solution…
e
Yeah, I don't think that's it because the front end starter is working and I'm not tunneling there either
something is going wrong because after i submit the stripe payment form, the
existing_payment/stripe/_default
partial is being used rather than what i expect,
_card
. when the
_default
template loads, the line
Copy code
<%= stripe_payment_method.type.humanize %>
fails because
Copy code
Rails -- Exception: ActionView::Template::Error: undefined method `type' for nil:NilClass
but i am not sure exactly what is going wrong
l
can you screenshot the settings page of your admin stripe payment method to check how it’s configured
e
this ends with the failure where the payment method can't be found
here's my settings
I don't know where it goes off the rails
this line seems wrong because it appears
stripe_payment_method_id
is empty, which seems wrong 🤷
Copy code
Completed #update -- { :controller => "CheckoutsController", :action => "update", :params => { "authenticity_token" => "[FILTERED]", "order" => { "payments_attributes" => [ { "payment_method_id" => "3" } ] }, "payment_source" => { "3" => { "stripe_payment_method_id" => "" } }, "commit" => "", "state" => "payment" }, :format => "TURBO_STREAM", :method => "PATCH", :path => "/checkout/update/payment", :status => 302, :view_runtime => 0.0, :db_runtime => 189.95, :allocations => 86196, :status_message => "Found" }
2023-06-18 08:00:12.017479 D [15279:puma srv tp 003] Rack -- Started -- { :method => "GET", :path => "/checkout/confirm", :ip => "127.0.0.1" }
ok it works after i disable turbo drive ... i added
<div data-turbo="false">
in my
application.html.erb
just inside the
<body>
... but i'd like to keep using turbo drive if possible
how do folks make turbo drive play nicely with stripe v5?
l
good you found it, that would be a bug for the gem repo I guess…
👍 1
e
I could try to fix it once i know how it should be handled
k
I don’t think the payment page (and the whole checkout) is tested with turbo enabled to be honest
usually I suggest to keep it disabled in the checkout, the reliability of those pages are generally more important of the UX improvements turbo can give, but I understand that it could be a requirement sometimes
e
no, i understand that... it's more that i didn't know the suggestion that turbo should be disabled for checkout ... maybe that would be good to add to a readme or something? makes sense to me!
k
yes, or we can add that html tag to the checkout pages in the starter frontend
if you want to contribute on that, it would be awesome
e
i do!
any suggestions for the best place to put the disabling? maybe in the checkout wrapper rather than in any individual steps?