Skip to content

Commit

Permalink
feat: Adding information about customer_email when creating Stripe Ch…
Browse files Browse the repository at this point in the history
…eckout session. #1
  • Loading branch information
LuchoTurtle committed Dec 28, 2022
1 parent 5f9d1cf commit 913a217
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,7 @@ defmodule AppWeb.CheckoutSessionController do
# https://stripe.com/docs/payments/checkout/custom-success-page
success_url: url <> ~p"/purchase/success?session_id={CHECKOUT_SESSION_ID}",
cancel_url: url <> ~p"/purchase/cancel?session_id={CHECKOUT_SESSION_ID}",
# user_email: conn.assigns.person.email,
automatic_tax: %{enabled: true}
}

Expand Down Expand Up @@ -802,6 +803,8 @@ upon completion or cancellation.](https://stripe.com/docs/payments/checkout/cust
- we set `**automatic_tax**` to be enabled so it makes tax conversions automatically.
- the `**line_items**` array refer to the list of items the customer is purchasing.
We are passing the item `id` and the `quantity`.
- you can optionally pass a `customer_email`,
so the field is already defined within the checkout session from the get-go.

We are then creating a session
and redirecting the user to the `Checkout` page.
Expand Down
3 changes: 1 addition & 2 deletions lib/app_web/controllers/checkout_session_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ defmodule AppWeb.CheckoutSessionController do
def create(conn, _params) do
url = AppWeb.Endpoint.url()

# TODO email

params = %{
line_items: [
%{
Expand All @@ -18,6 +16,7 @@ defmodule AppWeb.CheckoutSessionController do
# https://stripe.com/docs/payments/checkout/custom-success-page
success_url: url <> ~p"/purchase/success?session_id={CHECKOUT_SESSION_ID}",
cancel_url: url <> ~p"/purchase/cancel?session_id={CHECKOUT_SESSION_ID}",
# user_email: conn.assigns.person.email,
automatic_tax: %{enabled: true}
}

Expand Down

0 comments on commit 913a217

Please sign in to comment.