Skip to content

Commit e3fc56a

Browse files
committed
feat(101-01): lock local checkout session contract
- reject persisted local checkout sessions for non-braintree processors - document portal base URL as the required absolute host for local portal URLs
1 parent 8696052 commit e3fc56a

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

accrue/lib/accrue/checkout/local_session.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,14 @@ defmodule Accrue.Checkout.LocalSession do
4949
status price_id
5050
]a
5151

52+
@processors ["braintree"]
53+
5254
@spec changeset(t(), map()) :: Ecto.Changeset.t()
5355
def changeset(session, attrs \\ %{}) do
5456
session
5557
|> cast(attrs, @cast_fields)
5658
|> validate_required(@required_fields)
59+
|> validate_inclusion(:processor, @processors, message: "must be braintree")
5760
|> foreign_key_constraint(:customer_id)
5861
|> unique_constraint(:session_token)
5962
|> unique_constraint(:operation_id)

accrue/lib/accrue/config.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,10 @@ defmodule Accrue.Config do
167167
type: {:or, [:string, nil]},
168168
default: nil,
169169
doc:
170-
"Optional absolute base URL (for example `https://app.example.com`) " <>
171-
"required for returned local portal checkout and billing-portal URLs."
170+
"Absolute base URL (for example `https://app.example.com`) used to " <>
171+
"generate returned local portal checkout and billing-portal URLs. " <>
172+
"Leave unset only when those local portal URLs are not in use; " <>
173+
"`portal_url/1` raises instead of falling back to a relative path."
172174
],
173175
braintree_client_token_generator: [
174176
type: :atom,

0 commit comments

Comments
 (0)