diff --git a/README.md b/README.md index 17103de..5405319 100644 --- a/README.md +++ b/README.md @@ -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} } @@ -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. diff --git a/lib/app_web/controllers/checkout_session_controller.ex b/lib/app_web/controllers/checkout_session_controller.ex index bcd3bf3..b18c853 100644 --- a/lib/app_web/controllers/checkout_session_controller.ex +++ b/lib/app_web/controllers/checkout_session_controller.ex @@ -4,8 +4,6 @@ defmodule AppWeb.CheckoutSessionController do def create(conn, _params) do url = AppWeb.Endpoint.url() - # TODO email - params = %{ line_items: [ %{ @@ -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} }