pub struct PaymentsConfig {
pub provider: String,
pub secret_key: String,
pub publishable_key: String,
pub webhook_secret: String,
pub currency: String,
pub automatic_tax: bool,
pub tax_id_collection: Option<bool>,
pub billing_address: String,
pub success_url: String,
pub cancel_url: String,
pub portal_return_url: String,
pub timeout_secs: u64,
}Expand description
Payments: who takes the money, and how the checkout is set up.
Off by default (provider = "none"). Turning it on does three things an
app would otherwise build by hand: it connects a Stripe client, it adds the
billing_* resources — catalogue, customers,
subscriptions, payments — so billing state is queryable through the same
permissions and roles as everything else, and it mounts the /billing
endpoints that start a checkout and receive Stripe’s webhooks.
Nothing here is a price. Prices live in billing_price rows, because a
price is data an operator changes on a Tuesday, not configuration that
wants a deployment.
Fields§
§provider: Stringnone (default) or stripe.
secret_key: StringStripe secret key (sk_live_… / sk_test_…). Required once enabled.
publishable_key: StringStripe publishable key (pk_live_…). Not a secret: it is handed to the
browser by GET <base>/billing/config, which is how a front end
mounts Stripe’s own elements without hardcoding a key per environment.
webhook_secret: StringSigning secret for the webhook endpoint (whsec_…).
Without it POST <base>/billing/webhook refuses every delivery — an
unverified webhook is an unauthenticated request that edits
subscriptions, and accepting one because it is inconvenient not to is
how somebody else grants themselves a plan.
currency: StringISO 4217 currency for prices that don’t name one, e.g. eur.
automatic_tax: boolLet Stripe Tax work out and apply the right tax for the customer’s location (default true).
On means the amounts here are what you charge before tax and Stripe adds what the buyer owes. It needs an origin address and active registrations in the Stripe dashboard; with none, Stripe adds nothing and the charge is the price.
tax_id_collection: Option<bool>Ask the buyer for a VAT/GST number at checkout (default true when
automatic_tax is on — a business buyer’s number is what makes the
reverse charge apply).
billing_address: StringCollect a full billing address at checkout rather than only what the
card requires. auto (default) or required; automatic tax needs an
address, so auto still collects enough to place the customer.
success_url: StringWhere Stripe returns the buyer after a completed checkout. Empty falls
back to the dashboard’s billing screen — see
ServerConfig::public_origin.
cancel_url: StringWhere Stripe returns a buyer who backed out. Empty falls back to the dashboard’s billing screen.
portal_return_url: StringWhere the Stripe customer portal returns to. Empty falls back to the dashboard’s billing screen.
timeout_secs: u64How long one Stripe API call may take before it is abandoned.
Implementations§
Source§impl PaymentsConfig
impl PaymentsConfig
Sourcepub fn enabled(&self) -> bool
pub fn enabled(&self) -> bool
Whether a provider is configured at all. none and the empty string
both mean “this app doesn’t take money”.
Sourcepub fn default_currency(&self) -> String
pub fn default_currency(&self) -> String
The currency to use for an amount that didn’t name one, lowercased the way Stripe wants it.
Sourcepub fn collects_tax_ids(&self) -> bool
pub fn collects_tax_ids(&self) -> bool
Whether checkout asks for a tax number. Unset follows automatic_tax:
collecting a VAT number is only useful to somebody computing tax with
it, and asking for one you ignore is a field that does nothing.
Sourcepub fn webhooks_enabled(&self) -> bool
pub fn webhooks_enabled(&self) -> bool
Whether the webhook endpoint can verify a delivery. Payments still work without it — the checkout completes and Stripe has the money — but nothing of ours would ever hear about it.
Trait Implementations§
Source§impl Clone for PaymentsConfig
impl Clone for PaymentsConfig
Source§fn clone(&self) -> PaymentsConfig
fn clone(&self) -> PaymentsConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more