app/views/carts/show.html.erb
<h2>Your Shopping Cart</h2>
<table class="table">
<thead>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Unit Price</th>
<th>Total Price</th>
</tr>
</thead>
<tbody>
<% @cart.line_items.each do |item| %>
<tr>
<td><%= item.product.name %></td>
<td><%= item.quantity %> ×</td>
<td><%= number_to_currency item.product.price %></td>
<td><%= number_to_currency item.total_price %></td>
</tr>
<% end %>
</tbody>
</table>
<h3>Order Subtotal: <%= number_to_currency @cart.subtotal %></h3>
<%= link_to "Continue Shopping", root_path, class: "btn btn-success btn-sm" %>
<%= button_to "Empty Cart", @cart, method: :delete, data: {confirm: "Are you sure?"}, class: "btn btn-danger btn-sm", form: {style: 'display:inline-block;'} %>
<div style = 'display:inline-block;'>
<%= form_tag order_complete_path do %>
<div>
<%= hidden_field_tag :cart_id, @cart.id %>
</div>
<script src="https://checkout.stripe.com/checkout.js"
class="stripe-button"
data-key="<%= Rails.configuration.stripe[:publishable_key] %>"
data-description="Order #<%= @cart.id %>"
data-amount="<%= (@cart.subtotal.to_f.round(2) * 100) %>"></script>
<% end %>
</div>