Pure helper functions for payment provider logic — no I/O, no side effects.
Pure helper functions for payment provider logic — no I/O, no side effects.
(cents->euro cents)Convert integer cents to a euro amount string (e.g. 11900 -> "119.00"). Always uses a period as decimal separator regardless of JVM locale.
Convert integer cents to a euro amount string (e.g. 11900 -> "119.00"). Always uses a period as decimal separator regardless of JVM locale.
(mollie-status->event-type status)Map a Mollie payment status string to an internal event-type keyword.
Map a Mollie payment status string to an internal event-type keyword.
(mollie-status->payment-status status)Map a Mollie payment status string to a PaymentStatusResult :status keyword. Returns :pending for unrecognised statuses (e.g. "open").
Map a Mollie payment status string to a PaymentStatusResult :status keyword. Returns :pending for unrecognised statuses (e.g. "open").
(normalize-event-type raw-type provider)Map provider-specific event strings to internal event-type keywords.
Map provider-specific event strings to internal event-type keywords.
(stripe-checkout-params {:keys [amount-cents currency description redirect-url
success-url cancel-url checkout-id metadata
setup-future-usage customer-email
provider-customer-id]})Build the flat form-params map for a Stripe Checkout Session (mode=payment).
Build the flat form-params map for a Stripe Checkout Session (mode=payment). - :success-url / :cancel-url override :redirect-url when given. - :setup-future-usage :off-session|:on-session is sent as payment_intent_data[setup_future_usage] so the payment method is saved for later charges. In payment mode Stripe only creates a Customer when asked, so customer_creation=always is added when a mandate is requested and no :provider-customer-id is supplied. - :provider-customer-id reuses an existing Stripe Customer; Stripe rejects customer + customer_email together, so :customer-email is only sent when there is no existing customer. - :metadata is propagated to both the session and the underlying PaymentIntent (payment_intent_data[metadata]) so webhook payment_intent.* events carry it. The internal :checkout-id correlation key always wins.
(stripe-event->event-type event-type)Map a Stripe event type string to an internal event-type keyword.
Map a Stripe event type string to an internal event-type keyword.
(stripe-intent-status->payment-status status)(stripe-intent-status->payment-status status {:keys [off-session?]})Map a Stripe PaymentIntent status string to a PaymentStatus keyword.
succeeded → :paid, canceled → :cancelled; in-flight statuses (requires_payment_method, requires_confirmation, requires_capture, processing) and unknown statuses → :pending.
requires_action and canceled depend on context: in the default (poll) context requires_action maps to :pending (the customer may still complete authentication) and canceled to :cancelled. With {:off-session? true} both map to :failed — an off-session charge that needs SCA cannot be completed unattended (bring the customer on-session), and a canceled charge collected no money; the off-session port contract is :pending|:paid|:failed.
Map a Stripe PaymentIntent status string to a PaymentStatus keyword.
succeeded → :paid, canceled → :cancelled; in-flight statuses
(requires_payment_method, requires_confirmation, requires_capture,
processing) and unknown statuses → :pending.
requires_action and canceled depend on context: in the default (poll)
context requires_action maps to :pending (the customer may still complete
authentication) and canceled to :cancelled. With {:off-session? true} both
map to :failed — an off-session charge that needs SCA cannot be completed
unattended (bring the customer on-session), and a canceled charge collected
no money; the off-session port contract is :pending|:paid|:failed.(stripe-object-id x)Stripe expandable fields are either a string id or an expanded object map. Returns the id in both cases, nil otherwise.
Stripe expandable fields are either a string id or an expanded object map. Returns the id in both cases, nil otherwise.
(stripe-off-session-params {:keys [amount-cents currency description
provider-customer-id
provider-payment-method-id metadata]})Build the flat form-params map for an off-session PaymentIntent charge: confirm=true + off_session=true against a stored customer. When :provider-payment-method-id is omitted Stripe falls back to the customer's default payment method (it must have one, or the confirm fails).
Build the flat form-params map for an off-session PaymentIntent charge: confirm=true + off_session=true against a stored customer. When :provider-payment-method-id is omitted Stripe falls back to the customer's default payment method (it must have one, or the confirm fails).
(stripe-payment-intent-id? id)True when the id names a Stripe PaymentIntent (pi_...). Used by get-payment-status to dispatch: pi_ ids are polled via /v1/payment_intents, everything else (cs_... Checkout Session ids) via /v1/checkout/sessions.
True when the id names a Stripe PaymentIntent (pi_...). Used by get-payment-status to dispatch: pi_ ids are polled via /v1/payment_intents, everything else (cs_... Checkout Session ids) via /v1/checkout/sessions.
(stripe-session-status->payment-status session-status payment-status)Map Stripe Checkout Session status + payment_status to a PaymentStatus.
expired session → :expired; payment_status paid/no_payment_required → :paid;
anything else (open, or complete-but-unpaid) → :pending.
Map Stripe Checkout Session `status` + `payment_status` to a PaymentStatus. expired session → :expired; payment_status paid/no_payment_required → :paid; anything else (open, or complete-but-unpaid) → :pending.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |