Skip to main content

PaymentsConfig

Struct PaymentsConfig 

Source
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: String

none (default) or stripe.

§secret_key: String

Stripe secret key (sk_live_… / sk_test_…). Required once enabled.

§publishable_key: String

Stripe 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: String

Signing 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: String

ISO 4217 currency for prices that don’t name one, e.g. eur.

§automatic_tax: bool

Let 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: String

Collect 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: String

Where Stripe returns the buyer after a completed checkout. Empty falls back to the dashboard’s billing screen — see ServerConfig::public_origin.

§cancel_url: String

Where Stripe returns a buyer who backed out. Empty falls back to the dashboard’s billing screen.

§portal_return_url: String

Where the Stripe customer portal returns to. Empty falls back to the dashboard’s billing screen.

§timeout_secs: u64

How long one Stripe API call may take before it is abandoned.

Implementations§

Source§

impl PaymentsConfig

Source

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”.

Source

pub fn default_currency(&self) -> String

The currency to use for an amount that didn’t name one, lowercased the way Stripe wants it.

Source

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.

Source

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

Source§

fn clone(&self) -> PaymentsConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PaymentsConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PaymentsConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for PaymentsConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more