PaymentIntents: create, confirm, capture, cancel, list, and search payments. See https://docs.stripe.com/api/payment_intents.

Functions

cancel-payment-intent

fn (payment-intent: Str): Map
fn (payment-intent: Str, options: ::stripe::api/RequestOptions | Map): Map
fn (payment-intent: Str, cancellation-reason: Str): Map
fn (payment-intent: Str, cancellation-reason: Str, options: ::stripe::api/RequestOptions | Map): Map

POST /v1/payment_intents/{intent}/cancel - Cancel a PaymentIntent that hasn't succeeded. Optional cancellation-reason: "duplicate", "fraudulent", "requested_by_customer", or "abandoned".

Example

::pi ::stripe::payment-intents

canceled ::pi/cancel-payment-intent("pi_123", "requested_by_customer")
canceled.status

// With no reason, for a connected account
::pi/cancel-payment-intent("pi_456", {stripe-account: "acct_123"})

capture-payment-intent

fn (payment-intent: Str): Map
fn (payment-intent: Str, request: CapturePaymentIntentRequest): Map
fn (payment-intent: Str, request: CapturePaymentIntentRequest, options: ::stripe::api/RequestOptions | Map): Map

POST /v1/payment_intents/{intent}/capture - Capture the funds of a PaymentIntent created with capture_method: "manual" (status "requires_capture"). Omit amount_to_capture to capture the full amount. Uncaptured card authorizations are canceled automatically after 7 days by default.

Example

::pi ::stripe::payment-intents

// Capture part of the authorization
captured ::pi/capture-payment-intent("pi_123",
  ::pi/CapturePaymentIntentRequest({amount_to_capture: 1500}),
  ::stripe::api/RequestOptions({idempotency_key: "order-42-capture"}))
captured.amount_received

confirm-payment-intent

fn (payment-intent: Str): Map
fn (payment-intent: Str, request: ConfirmPaymentIntentRequest): Map
fn (payment-intent: Str, request: ConfirmPaymentIntentRequest, options: ::stripe::api/RequestOptions | Map): Map

POST /v1/payment_intents/{intent}/confirm - Confirm a PaymentIntent to attempt payment. Server-side confirmation needs a payment_method; return_url is required for redirect-based methods. Check status afterwards: "succeeded", "requires_action" (3DS: hand client_secret to Stripe.js), or "requires_capture" for manual capture.

Example

::pi ::stripe::payment-intents

confirmed ::pi/confirm-payment-intent("pi_...",
  ::pi/ConfirmPaymentIntentRequest({payment_method: "pm_card_visa"}),
  ::stripe::api/RequestOptions({idempotency_key: "order-42-confirm"}))
confirmed.status  // => "succeeded"

create-payment-intent

fn (request: CreatePaymentIntentRequest): Map
fn (request: CreatePaymentIntentRequest, options: ::stripe::api/RequestOptions | Map): Map

POST /v1/payment_intents - Create a PaymentIntent. amount is in the smallest currency unit (cents for USD). Pass confirm: true with a payment_method to charge in one call. To limit which methods can be used, pass allowed_payment_method_types (the API removed payment_method_types in 2026-09-30.endive); it can't be combined with automatic_payment_methods, excluded_payment_method_types, or payment_method_configuration. Always pass an idempotency key when the call might be retried.

Example

::pi ::stripe::payment-intents

intent ::pi/create-payment-intent(::pi/CreatePaymentIntentRequest({
  amount: 2000,
  currency: "usd",
  customer: "cus_...",
  automatic_payment_methods: {enabled: true}
}), ::stripe::api/RequestOptions({idempotency_key: "order-42"}))
intent.client_secret  // => "pi_..._secret_..." (pass to Stripe.js)
intent.status         // => "requires_payment_method"

get-payment-intent

fn (payment-intent: Str): Map
fn (payment-intent: Str, params: Map): Map
fn (payment-intent: Str, params: Map, opts: Map): Map

GET /v1/payment_intents/{intent} - Retrieve a PaymentIntent by ID. Optional params such as {expand: ["latest_charge"]}.

Example

::pi ::stripe::payment-intents

intent ::pi/get-payment-intent("pi_123", {expand: ["latest_charge"]})
intent.status
intent.latest_charge.receipt_url

list-payment-intents

fn (): Map
fn (request: ListPaymentIntentsRequest): Map
fn (request: ListPaymentIntentsRequest, opts: Map): Map

GET /v1/payment_intents - List PaymentIntents, most recent first. Filter by customer or created.

Example

::pi ::stripe::payment-intents

page ::pi/list-payment-intents(::pi/ListPaymentIntentsRequest({customer: "cus_123", limit: 10}))
statuses map(page.data, %.status)

search-payment-intents

fn (query: Str): Map
fn (query: Str, params: Map): Map
fn (query: Str, params: Map, opts: Map): Map

GET /v1/payment_intents/search - Search PaymentIntents with Stripe's search query language, e.g. status:"succeeded" AND metadata["order_id"]:"42". Pass next_page back as page in params to continue.

Example

::pi ::stripe::payment-intents

results ::pi/search-payment-intents(`status:"succeeded" AND metadata["order_id"]:"42"`)
ids map(results.data, %.id)

update-payment-intent

fn (payment-intent: Str, request: UpdatePaymentIntentRequest): Map
fn (payment-intent: Str, request: UpdatePaymentIntentRequest, options: ::stripe::api/RequestOptions | Map): Map

POST /v1/payment_intents/{intent} - Update a PaymentIntent before it is confirmed.

Example

::pi ::stripe::payment-intents

::pi/update-payment-intent("pi_123", ::pi/UpdatePaymentIntentRequest({
  amount: 2500,
  metadata: {order_id: "42"}
}))

Types

CapturePaymentIntentRequest

CapturePaymentIntentRequest type {
    amount_to_capture: Int?,
    application_fee_amount: Int?,
    final_capture: Bool?,
    metadata: Map?,
    statement_descriptor: Str?,
    statement_descriptor_suffix: Str?,
    expand: Vec<Str>?
}

ConfirmPaymentIntentRequest

ConfirmPaymentIntentRequest type {
    payment_method: Str?,
    return_url: Str?,
    off_session: Any?,
    error_on_requires_action: Bool?,
    capture_method: Str?,
    mandate_data: Map?,
    payment_method_options: Map?,
    receipt_email: Str?,
    setup_future_usage: Str?,
    shipping: Map?,
    expand: Vec<Str>?
}

CreatePaymentIntentRequest

CreatePaymentIntentRequest type {
    amount: Int,
    currency: Str,
    customer: Str?,
    payment_method: Str?,
    allowed_payment_method_types: Vec<Str>?,
    excluded_payment_method_types: Vec<Str>?,
    automatic_payment_methods: Map?,
    payment_method_configuration: Str?,
    payment_method_options: Map?,
    capture_method: Str?,
    confirm: Bool?,
    confirmation_method: Str?,
    description: Str?,
    metadata: Map?,
    off_session: Any?,
    error_on_requires_action: Bool?,
    receipt_email: Str?,
    return_url: Str?,
    setup_future_usage: Str?,
    shipping: Map?,
    statement_descriptor: Str?,
    statement_descriptor_suffix: Str?,
    transfer_group: Str?,
    transfer_data: Map?,
    application_fee_amount: Int?,
    on_behalf_of: Str?,
    expand: Vec<Str>?
}

ListPaymentIntentsRequest

ListPaymentIntentsRequest type {
    customer: Str?,
    created: Any?,
    limit: Int?,
    starting_after: Str?,
    ending_before: Str?,
    expand: Vec<Str>?
}

UpdatePaymentIntentRequest

UpdatePaymentIntentRequest type {
    amount: Int?,
    currency: Str?,
    customer: Str?,
    payment_method: Str?,
    allowed_payment_method_types: Vec<Str>?,
    excluded_payment_method_types: Vec<Str>?,
    payment_method_options: Map?,
    capture_method: Str?,
    description: Str?,
    metadata: Map?,
    receipt_email: Str?,
    setup_future_usage: Str?,
    shipping: Map?,
    statement_descriptor: Str?,
    statement_descriptor_suffix: Str?,
    transfer_group: Str?,
    expand: Vec<Str>?
}