Skip to content

Commit

Permalink
display data on checkout success
Browse files Browse the repository at this point in the history
  • Loading branch information
yshmarov committed Mar 9, 2021
1 parent 61f5dc7 commit 5a5d636
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/controllers/checkout_controller.rb
Expand Up @@ -19,11 +19,10 @@ def create
end

def success
# session_with_expand = Stripe::Checkout::Session.retrieve({ id: params[:session_id], expand: ["line_items"]})
# session_with_expand.line_items.data.each do |line_item|
# product = Product.find_by(stripe_product_id: line_item.price.product)
# product.increment!(:sales_count)
# end
@session_with_expand = Stripe::Checkout::Session.retrieve({ id: params[:session_id], expand: ["line_items"]})
@session_with_expand.line_items.data.each do |line_item|
product = Product.find_by(stripe_product_id: line_item.price.product)
end
end

def cancel
Expand Down
6 changes: 6 additions & 0 deletions app/views/checkout/success.html.erb
@@ -1 +1,7 @@
<h1>Success</h1>

Checkout status: <%= @session_with_expand.payment_status %>
<br>
Amount paid:
<%= @session_with_expand.amount_total/100.to_f %>
<%= @session_with_expand.currency %>

0 comments on commit 5a5d636

Please sign in to comment.