Skip to content
LogoLogo

stripe.spt

Accept Shared Payment Tokens

Creates the Stripe charge method for one-time payments with Shared Payment Tokens (SPTs).

Usage

server.ts
import  from 'stripe'
import { ,  } from 'mppx/server'
 
const  = new (..!)
 
const  = .({
  : [
    .({
      ,
      : ..!,
      : ['card', 'link'],
    }),
  ],
  : ..!,
})
 
export async function (: Request) {
  const  = await .({
    : '1',
    : 'usd',
    : 2,
    : 'Premium API access',
  })()
 
  if (. === 402) return .
  return .(.({ : '...' }))
}

With Stripe Connect

Set a fixed settlement policy or return one from a resolver for each verified Credential.

server.ts
import  from 'stripe'
import {  } from 'mppx/server'
 
const  = new (..!)
 
const  = .({
  ,
  : {
    : 10,
    : 'acct_123',
  },
  : ..!,
  : ['card'],
})

Return type

import type { Method } from 'mppx'
 
type ReturnType = Method.Server

Parameters

canOffer (optional)

  • Type: Method.CanOfferFn

Returns whether this offer is available when an HTTP handler composes multiple methods. Stripe's currency minimum runs before this hook.

client

  • Type: StripeClient

Pre-configured Stripe SDK client. Provide either client or secretKey.

connect (optional)

  • Type: ConnectSettlement | ((context) => MaybePromise<ConnectSettlement | undefined>)

Fixed or per-Credential Stripe Connect settlement policy. Properties are applicationFeeAmount, onBehalfOf, stripeAccount, transferData, and transferGroup.

html (optional)

  • Type: { createTokenUrl: string; publishableKey: string; ...Html.Config }

Renders a Stripe Elements payment form for browser requests. See the payment links guide.

metadata (optional)

  • Type: Record<string, string>

Metadata included in the Challenge and attached to the Stripe PaymentIntent.

networkId

  • Type: string

Stripe Business Network profile ID.

onPaymentSuccess (optional)

  • Type: (parameters: { input?: Request; receipt: DeepReadonly<Receipt>; request: DeepReadonly<StripeChargeRequest> }) => MaybePromise<void>

Runs after this SPT payment succeeds. The hook receives the normalized request, its Receipt, and the HTTP input when available. Hook errors are isolated from payment handling.

paymentMethodTypes

  • Type: string[]

Allowed Stripe payment method types, such as ['card', 'link'].

secretKey

  • Type: string

Stripe secret API key. Provide either client or secretKey.

Request parameters

amount

  • Type: string

Payment amount in human-readable units.

currency

  • Type: string

ISO currency code, such as 'usd'.

decimals

  • Type: number

Number of decimal places used to display the amount.

description (optional)

  • Type: string

Human-readable description of the payment request.

externalId (optional)

  • Type: string

External identifier bound to the Challenge and Credential.