feat: add Stripe checkout, order persistence, and webhook handling
Stripe-hosted Checkout integration with full order lifecycle: - stripity_stripe ~> 3.2 with sandbox/prod config via env vars - Order and OrderItem schemas with price snapshots at purchase time - CheckoutController creates pending order then redirects to Stripe - StripeWebhookController verifies signatures and confirms payment - Success page with real-time PubSub updates from webhook - Shop flash messages for checkout error feedback - Cart cleared after successful payment Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -83,6 +83,9 @@ config :phoenix, :json_library, Jason
|
||||
# ex_money configuration for currency handling
|
||||
config :ex_money, default_cldr_backend: SimpleshopTheme.Cldr
|
||||
|
||||
# Stripe configuration
|
||||
config :stripity_stripe, api_version: "2024-12-18.acacia"
|
||||
|
||||
# Oban configuration for background jobs
|
||||
config :simpleshop_theme, Oban,
|
||||
engine: Oban.Engines.Lite,
|
||||
@@ -91,7 +94,7 @@ config :simpleshop_theme, Oban,
|
||||
{Oban.Plugins.Pruner, max_age: 60},
|
||||
{Oban.Plugins.Lifeline, rescue_after: :timer.minutes(5)}
|
||||
],
|
||||
queues: [images: 2, sync: 1]
|
||||
queues: [images: 2, sync: 1, checkout: 1]
|
||||
|
||||
# Import environment specific config. This must remain at the bottom
|
||||
# of this file so it overrides the configuration defined above.
|
||||
|
||||
@@ -86,3 +86,8 @@ config :phoenix_live_view,
|
||||
|
||||
# Disable swoosh api client as it is only required for production adapters.
|
||||
config :swoosh, :api_client, false
|
||||
|
||||
# Stripe test keys (set via environment variables)
|
||||
config :stripity_stripe,
|
||||
api_key: System.get_env("STRIPE_SECRET_KEY"),
|
||||
signing_secret: System.get_env("STRIPE_WEBHOOK_SECRET")
|
||||
|
||||
@@ -112,4 +112,13 @@ if config_env() == :prod do
|
||||
# config :swoosh, :api_client, Swoosh.ApiClient.Req
|
||||
#
|
||||
# See https://hexdocs.pm/swoosh/Swoosh.html#module-installation for details.
|
||||
|
||||
# Stripe payment processing
|
||||
config :stripity_stripe,
|
||||
api_key:
|
||||
System.get_env("STRIPE_SECRET_KEY") ||
|
||||
raise("Missing STRIPE_SECRET_KEY environment variable"),
|
||||
signing_secret:
|
||||
System.get_env("STRIPE_WEBHOOK_SECRET") ||
|
||||
raise("Missing STRIPE_WEBHOOK_SECRET environment variable")
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user