Ask A Question

Notifications

You’re not receiving notifications from this thread.

How to use Stripe Checkout in Rails Discussion

Thank you so much!

Reply

Hi Chris! Thank you for the super timely tutorial! Everything work fine and I have only one question:

How do I add a trial period to a subscription checkout request?

def show
current_user.processor = :stripe
current_user.customer
@checkout_session = current_user.payment_processor.checkout(
mode: "subscription",
line_items: "price_11111222223333344444",
-> TRIAL PARAMETER GOES HERE
)
end

Is there a way to do this somehow?
Thanks!

Reply

After webhooks have updated the Pay::Charge model, how do i check if payment was successful. Is this state saved in billable model ?

Reply

Hey Chris,
Way to go on an awesome gem. It was super easy to get it all set up!!

How do you add multiple line_items to your checkout?

It would be nice to see an example of an online shop too. 😀

Reply

Hello Amanda,

We have the same question - did you figure this out?

Thanks,

Gareth

Reply

Hello to all,
I have a problem.
The Stripe Checkout is running correctly, as well as the data being sent to Stripe correctly. But my current_user never has the subscription registered in my application.
The console gives me this error
Started POST "/pay/webhooks/stripe" for ::1 at 2021-04-29 21:39:26 +0200
Processing by Pay::Webhooks::StripeController#create as XML
Parameters: {"id"=>"evt_1IlfhnJ2Ha1IZpffsAQ0e77B", "object"=>"event", "api_version"=>"2020-08-27", "created"=>1619725161, "data"=>{"object"=>{"id"=>"in_1IlfhkJ2Ha1IZpffIhTJn2cv", "object"=>"invoice", "account_country"=>"CH", "account_name"=>"AssociaPlus+", "account_tax_ids"=>nil, "amount_due"=>20000, "amount_paid"=>0, "amount_remaining"=>20000, "application_fee_amount"=>nil, "attempt_count"=>0, "attempted"=>false, "auto_advance"=>false, "billing_reason"=>"subscription_create", "charge"=>nil, "collection_method"=>"charge_automatically", "created"=>1619725160, "currency"=>"chf", "custom_fields"=>nil, "customer"=>"cus_JOSCBrA3qA2Po2", "customer_address"=>nil, "customer_email"=>"blg@open-net.ch", "customer_name"=>nil, "customer_phone"=>nil, "customer_shipping"=>nil, "customer_tax_exempt"=>"none", "customer_tax_ids"=>[], "default_payment_method"=>nil, "default_source"=>nil, "default_tax_rates"=>[], "description"=>nil, "discount"=>nil, "discounts"=>[], "due_date"=>nil, "ending_balance"=>nil, "footer"=>nil, "hosted_invoice_url"=>nil, "invoice_pdf"=>nil, "last_finalization_error"=>nil, "lines"=>{"object"=>"list", "data"=>[{"id"=>"il_1IlfhkJ2Ha1IZpffH8FuRQG5", "object"=>"line_item", "amount"=>20000, "currency"=>"chf", "description"=>"1 × AssociaPlus+ (at CHF 200.00 / year)", "discount_amounts"=>[], "discountable"=>true, "discounts"=>[], "livemode"=>false, "metadata"=>{}, "period"=>{"end"=>1651261160, "start"=>1619725160}, "plan"=>{"id"=>"price_1Ihd0jJ2Ha1IZpffkjGEZ5el", "object"=>"plan", "active"=>true, "aggregate_usage"=>nil, "amount"=>20000, "amount_decimal"=>"20000", "billing_scheme"=>"per_unit", "created"=>1618761493, "currency"=>"chf", "interval"=>"year", "interval_count"=>1, "livemode"=>false, "metadata"=>{}, "nickname"=>nil, "product"=>"prod_JKHZndSsvxxzMo", "tiers_mode"=>nil, "transform_usage"=>nil, "trial_period_days"=>nil, "usage_type"=>"licensed"}, "price"=>{"id"=>"price_1Ihd0jJ2Ha1IZpffkjGEZ5el", "object"=>"price", "active"=>true, "billing_scheme"=>"per_unit", "created"=>1618761493, "currency"=>"chf", "livemode"=>false, "lookup_key"=>"[FILTERED]", "metadata"=>{}, "nickname"=>nil, "product"=>"prod_JKHZndSsvxxzMo", "recurring"=>{"aggregate_usage"=>nil, "interval"=>"year", "interval_count"=>1, "trial_period_days"=>nil, "usage_type"=>"licensed"}, "tiers_mode"=>nil, "transform_quantity"=>nil, "type"=>"recurring", "unit_amount"=>20000, "unit_amount_decimal"=>"20000"}, "proration"=>false, "quantity"=>1, "subscription"=>"sub_JOSdWdcro3d4yj", "subscription_item"=>"si_JOSdPHfRxLb4mP", "tax_amounts"=>[], "tax_rates"=>[], "type"=>"subscription"}], "has_more"=>false, "total_count"=>1, "url"=>"/v1/invoices/in_1IlfhkJ2Ha1IZpffIhTJn2cv/lines"}, "livemode"=>false, "metadata"=>{}, "next_payment_attempt"=>nil, "number"=>nil, "on_behalf_of"=>nil, "paid"=>false, "payment_intent"=>nil, "payment_settings"=>{"payment_method_options"=>nil, "payment_method_types"=>nil}, "period_end"=>1619725160, "period_start"=>1619725160, "post_payment_credit_notes_amount"=>0, "pre_payment_credit_notes_amount"=>0, "receipt_number"=>nil, "starting_balance"=>0, "statement_descriptor"=>nil, "status"=>"draft", "status_transitions"=>{"finalized_at"=>nil, "marked_uncollectible_at"=>nil, "paid_at"=>nil, "voided_at"=>nil}, "subscription"=>"sub_JOSdWdcro3d4yj", "subtotal"=>20000, "tax"=>nil, "total"=>20000, "total_discount_amounts"=>[], "total_tax_amounts"=>[], "transfer_data"=>nil, "webhooks_delivered_at"=>nil}, "previous_attributes"=>{"auto_advance"=>true, "next_payment_attempt"=>1619728760}}, "livemode"=>false, "pending_webhooks"=>2, "request"=>{"id"=>"req_df4snpYOQ43jDO", "idempotency_key"=>"[FILTERED]"}, "type"=>"invoice.updated", "stripe"=>{"id"=>"evt_1IlfhnJ2Ha1IZpffsAQ0e77B", "object"=>"event", "api_version"=>"2020-08-27", "created"=>1619725161, "data"=>{"object"=>{"id"=>"in_1IlfhkJ2Ha1IZpffIhTJn2cv", "object"=>"invoice", "account_country"=>"CH", "account_name"=>"AssociaPlus+", "account_tax_ids"=>nil, "amount_due"=>20000, "amount_paid"=>0, "amount_remaining"=>20000, "application_fee_amount"=>nil, "attempt_count"=>0, "attempted"=>false, "auto_advance"=>false, "billing_reason"=>"subscription_create", "charge"=>nil, "collection_method"=>"charge_automatically", "created"=>1619725160, "currency"=>"chf", "custom_fields"=>nil, "customer"=>"cus_JOSCBrA3qA2Po2", "customer_address"=>nil, "customer_email"=>"blg@open-net.ch", "customer_name"=>nil, "customer_phone"=>nil, "customer_shipping"=>nil, "customer_tax_exempt"=>"none", "customer_tax_ids"=>[], "default_payment_method"=>nil, "default_source"=>nil, "default_tax_rates"=>[], "description"=>nil, "discount"=>nil, "discounts"=>[], "due_date"=>nil, "ending_balance"=>nil, "footer"=>nil, "hosted_invoice_url"=>nil, "invoice_pdf"=>nil, "last_finalization_error"=>nil, "lines"=>{"object"=>"list", "data"=>[{"id"=>"il_1IlfhkJ2Ha1IZpffH8FuRQG5", "object"=>"line_item", "amount"=>20000, "currency"=>"chf", "description"=>"1 × AssociaPlus+ (at CHF 200.00 / year)", "discount_amounts"=>[], "discountable"=>true, "discounts"=>[], "livemode"=>false, "metadata"=>{}, "period"=>{"end"=>1651261160, "start"=>1619725160}, "plan"=>{"id"=>"price_1Ihd0jJ2Ha1IZpffkjGEZ5el", "object"=>"plan", "active"=>true, "aggregate_usage"=>nil, "amount"=>20000, "amount_decimal"=>"20000", "billing_scheme"=>"per_unit", "created"=>1618761493, "currency"=>"chf", "interval"=>"year", "interval_count"=>1, "livemode"=>false, "metadata"=>{}, "nickname"=>nil, "product"=>"prod_JKHZndSsvxxzMo", "tiers_mode"=>nil, "transform_usage"=>nil, "trial_period_days"=>nil, "usage_type"=>"licensed"}, "price"=>{"id"=>"price_1Ihd0jJ2Ha1IZpffkjGEZ5el", "object"=>"price", "active"=>true, "billing_scheme"=>"per_unit", "created"=>1618761493, "currency"=>"chf", "livemode"=>false, "lookup_key"=>"[FILTERED]", "metadata"=>{}, "nickname"=>nil, "product"=>"prod_JKHZndSsvxxzMo", "recurring"=>{"aggregate_usage"=>nil, "interval"=>"year", "interval_count"=>1, "trial_period_days"=>nil, "usage_type"=>"licensed"}, "tiers_mode"=>nil, "transform_quantity"=>nil, "type"=>"recurring", "unit_amount"=>20000, "unit_amount_decimal"=>"20000"}, "proration"=>false, "quantity"=>1, "subscription"=>"sub_JOSdWdcro3d4yj", "subscription_item"=>"si_JOSdPHfRxLb4mP", "tax_amounts"=>[], "tax_rates"=>[], "type"=>"subscription"}], "has_more"=>false, "total_count"=>1, "url"=>"/v1/invoices/in_1IlfhkJ2Ha1IZpffIhTJn2cv/lines"}, "livemode"=>false, "metadata"=>{}, "next_payment_attempt"=>nil, "number"=>nil, "on_behalf_of"=>nil, "paid"=>false, "payment_intent"=>nil, "payment_settings"=>{"payment_method_options"=>nil, "payment_method_types"=>nil}, "period_end"=>1619725160, "period_start"=>1619725160, "post_payment_credit_notes_amount"=>0, "pre_payment_credit_notes_amount"=>0, "receipt_number"=>nil, "starting_balance"=>0, "statement_descriptor"=>nil, "status"=>"draft", "status_transitions"=>{"finalized_at"=>nil, "marked_uncollectible_at"=>nil, "paid_at"=>nil, "voided_at"=>nil}, "subscription"=>"sub_JOSdWdcro3d4yj", "subtotal"=>20000, "tax"=>nil, "total"=>20000, "total_discount_amounts"=>[], "total_tax_amounts"=>[], "transfer_data"=>nil, "webhooks_delivered_at"=>nil}, "previous_attributes"=>{"auto_advance"=>true, "next_payment_attempt"=>1619728760}}, "livemode"=>false, "pending_webhooks"=>2, "request"=>{"id"=>"req_df4snpYOQ43jDO", "idempotency_key"=>"[FILTERED]"}, "type"=>"invoice.updated"}}
No signatures found matching the expected signature for payload
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/stripe-5.32.1/lib/stripe/webhook.rb:104:in verify_header'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/stripe-5.32.1/lib/stripe/webhook.rb:13:in
construct_event'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/pay-2.6.10/app/controllers/pay/webhooks/stripe_controller.rb:28:in block in verified_event'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/pay-2.6.10/app/controllers/pay/webhooks/stripe_controller.rb:27:in
each'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/pay-2.6.10/app/controllers/pay/webhooks/stripe_controller.rb:27:in each_with_index'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/pay-2.6.10/app/controllers/pay/webhooks/stripe_controller.rb:27:in
verified_event'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/pay-2.6.10/app/controllers/pay/webhooks/stripe_controller.rb:9:in create'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_controller/metal/basic_implicit_render.rb:6:in
send_action'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/abstract_controller/base.rb:228:in process_action'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_controller/metal/rendering.rb:30:in
process_action'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/abstract_controller/callbacks.rb:42:in block in process_action'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/callbacks.rb:117:in
block in run_callbacks'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actiontext-6.1.3.1/lib/action_text/rendering.rb:20:in with_renderer'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actiontext-6.1.3.1/lib/action_text/engine.rb:55:in
block (4 levels) in class:Engine'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/callbacks.rb:126:in instance_exec'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/callbacks.rb:126:in
block in run_callbacks'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/callbacks.rb:137:in run_callbacks'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/abstract_controller/callbacks.rb:41:in
process_action'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_controller/metal/rescue.rb:22:in process_action'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_controller/metal/instrumentation.rb:34:in
block in process_action'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/notifications.rb:203:in block in instrument'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/notifications/instrumenter.rb:24:in
instrument'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/notifications.rb:203:in instrument'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_controller/metal/instrumentation.rb:33:in
process_action'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_controller/metal/params_wrapper.rb:249:in process_action'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3.1/lib/active_record/railties/controller_runtime.rb:27:in
process_action'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/abstract_controller/base.rb:165:in process'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionview-6.1.3.1/lib/action_view/rendering.rb:39:in
process'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_controller/metal.rb:190:in dispatch'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_controller/metal.rb:254:in
dispatch'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/routing/route_set.rb:50:in dispatch'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/routing/route_set.rb:33:in
serve'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/journey/router.rb:50:in block in serve'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/journey/router.rb:32:in
each'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/journey/router.rb:32:in serve'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/routing/route_set.rb:842:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3.1/lib/rails/engine.rb:539:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3.1/lib/rails/railtie.rb:207:in
public_send'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3.1/lib/rails/railtie.rb:207:in method_missing'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/routing/mapper.rb:20:in
block in class:Constraints'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/routing/mapper.rb:49:in serve'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/journey/router.rb:50:in
block in serve'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/journey/router.rb:32:in each'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/journey/router.rb:32:in
serve'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/routing/route_set.rb:842:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/warden-1.2.9/lib/warden/manager.rb:36:in
block in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/warden-1.2.9/lib/warden/manager.rb:34:in catch'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/warden-1.2.9/lib/warden/manager.rb:34:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb:15:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/etag.rb:27:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/conditional_get.rb:40:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/head.rb:12:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/http/permissions_policy.rb:22:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/http/content_security_policy.rb:18:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:266:in context'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:260:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/middleware/cookies.rb:689:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activerecord-6.1.3.1/lib/active_record/migration.rb:601:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/middleware/callbacks.rb:27:in block in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/callbacks.rb:98:in
run_callbacks'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/middleware/callbacks.rb:26:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/middleware/executor.rb:14:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/middleware/debug_exceptions.rb:29:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/web-console-4.1.0/lib/web_console/middleware.rb:132:in call_app'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/web-console-4.1.0/lib/web_console/middleware.rb:28:in
block in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/web-console-4.1.0/lib/web_console/middleware.rb:17:in catch'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/web-console-4.1.0/lib/web_console/middleware.rb:17:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/middleware/show_exceptions.rb:33:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3.1/lib/rails/rack/logger.rb:37:in
call_app'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3.1/lib/rails/rack/logger.rb:26:in block in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/tagged_logging.rb:99:in
block in tagged'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/tagged_logging.rb:37:in tagged'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/tagged_logging.rb:99:in
tagged'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3.1/lib/rails/rack/logger.rb:26:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/quiet_assets.rb:13:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/middleware/remote_ip.rb:81:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/middleware/request_id.rb:26:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/method_override.rb:24:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/runtime.rb:22:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3.1/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/middleware/executor.rb:14:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/middleware/static.rb:24:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/actionpack-6.1.3.1/lib/action_dispatch/middleware/host_authorization.rb:98:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-mini-profiler-2.3.1/lib/mini_profiler/profiler.rb:373:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/bundler/gems/webpacker-b6c21802bfd4/lib/webpacker/dev_server_proxy.rb:25:in perform_request'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rack-proxy-0.6.5/lib/rack/proxy.rb:57:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/railties-6.1.3.1/lib/rails/engine.rb:539:in call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/puma-5.2.2/lib/puma/configuration.rb:248:in
call'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/puma-5.2.2/lib/puma/request.rb:76:in block in handle_request'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/puma-5.2.2/lib/puma/thread_pool.rb:337:in
with_force_shutdown'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/puma-5.2.2/lib/puma/request.rb:75:in handle_request'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/puma-5.2.2/lib/puma/server.rb:431:in
process_client'
/Users/benoitlegoff/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/puma-5.2.2/lib/puma/thread_pool.rb:145:in `block in spawn_thread'
Completed 400 Bad Request in 6ms (ActiveRecord: 0.0ms | Allocations: 1594)

Reply

Hi Chris,

Are there any additional steps that we need to do when pushing this the Heroku? Locally, when a payment is processed, Pay will save it to Pay::Charges and I see it sending out the email in my logs. I've pushed this to heroku and neither one of these two actions happen. Within the Stripe Dashboard, under Payments, I can see that the payments from Heroku are being saved and logged.

Thanks!

Reply

I have the same problem. I added the stripe public and private key, and also created and added the signing secret and the webook call by Stripe returns with a 404 from Heroku. Have you managed to solve this issue?

Reply

Hey

I was having the same problem, and the solution was to:

1) log in to Stripe
2) go to the page for the webhook that was failing
3) get the Signing secret from the middle of that page and set an env VAR called STRIPE_SIGNING_SECRET with the Signing secret as its value.

STRIPE_SIGNING_SECRET: Value ( add this on Heroku Config Vars)

Thanks
Ronak Bhatt

Reply

Ronak: I wish found this earlier. I kept using the signin secret at the user level but your line #2 was the key point. Thanks a lot.

Reply

how do you customise the checkout button?

Reply

how do you set the redirect url after checkout?

Reply

undefined method processor : stripe? how have you do? best regards

Reply

Hi Chris,

Thank you for making this movie. It was great.

I've been trying to figure out a way of doing the following, but failing:

when using the current_user.payment_processor.checkout(), is there a way of using,
success_url: checkout_success_url,
cancel_url: checkout_cancel_url

as you would when using:
@session = Stripe::Checkout::Session.create() ?

Reply

Hi again,

I'm not entirely sure what changed, but I managed to get the
checkout_success_url
checkout_cancel_url

working by using:

current_user.set_payment_processor :stripe
    current_user.id
      @checkout_session = current_user.payment_processor.checkout(
        mode: "subscription",
        line_items: "price_1KLwi9D3EGSDPVxu1I3KCLOp",
        success_url: checkout_success_url,
        cancel_url: checkout_cancel_url
      )

and creating the views files to go with these.

I'm in ore of your skills, and certainly appreciate your dedication to the community

Reply

Hey Chris,

How would you set up the controller for multiple prices? I'm currently creating 8 sessions for 4 monthly and 4 yearly prices, but it takes a while to load the page and I don't know that i need to call Stripe 8 times when only one price will be chosen by the user.

Reply

the pay gem doesn't persist the pay_charges table on postgres

Reply

Wish I understood how to deploy these keys better

Reply

not seeing much in the way of responses here.. but after starting at the beginning and following your instructions, i'm getting

rails g pay User
Could not find generator 'pay'.

version 6.8.1 is installed. i'm guessing this tutorial is out of date perchance?

Reply

I'm not understanding how the pay docs and this video are so different. ¯_(ツ)_/¯ Has it changed that much?

Reply

Also if the docs were less cryptic it would be helpful, maybe an example app.

Reply

ok, I was looking for section 8 in the stripe docs, was LOST in the first 7 md files.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,329+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.