Skip to content
LogoLogo

stripe.create

Configure Stripe machine payments

Creates Stripe SPT and stablecoin server methods with automatic deposit-address resolution and payment recording.

Usage

Use defaultMethods() to offer Tempo stablecoins and Stripe Shared Payment Tokens. mppx resolves the Tempo deposit address from Stripe and records successful Tempo payments as Stripe PaymentIntent objects.

server.ts
import  from 'stripe'
import { ,  } from 'mppx/server'
 
const  = new (..!)
 
const  = .({
  ,
  : false,
  : ..!,
})
 
const  = .({
  : await .(),
  : ..!,
})
 
export async function (: Request) {
  const  = await .({
    : '1.00',
    : 'Premium API access',
  })()
 
  if (. === 402) return .
  return .(.({ : '...' }))
}

Test mode uses pathUSD on Tempo testnet. Live mode uses USDC.e on Tempo mainnet. The SPT method defaults to cards and Link in both modes.

Advanced options

With static deposit addresses

Provide deposit addresses to create the default methods synchronously and avoid Stripe API lookup during startup.

server.ts
import  from 'stripe'
import { ,  } from 'mppx/server'
 
const  = new (..!)
 
const  = .({
  ,
  : {
    : '0x20C0000000000000000000000000000000000001',
  },
  : true,
  : ..!,
})
 
const  = .({
  : .(),
  : ..!,
})

With selected default methods

Exclude spt or tempo when you don't want both default charge methods.

server.ts
import  from 'stripe'
import { ,  } from 'mppx/server'
 
const  = new (..!)
const  = .({
  ,
  : false,
  : ..!,
})
 
const  = .({
  : await .({ : ['spt'] }),
  : ..!,
})

Return type

type StripeMachinePayments = {
  base: {
    charge(parameters: BaseChargeParameters): Method.Server
  }
  defaultMethods(parameters?: {
    exclude?: ('spt' | 'tempo')[]
  }): readonly Method.Server[] | PromiseLike<readonly Method.Server[]>
  findOrCreateDepositAddress<N extends 'base' | 'solana' | 'tempo'>(
    network: N,
  ): Promise<stripe.DepositAddress<N>>
  spt: {
    charge(parameters?: { paymentMethodTypes?: string[] }): Method.Server
  }
  tempo: {
    charge(parameters: TempoChargeParameters): Method.Server
    session(parameters: TempoSessionParameters): Method.Server
  }
}

defaultMethods() returns Tempo charge followed by SPT charge. Chain .additional({ ... }) before awaiting to add Base charge, Tempo session, or a Solana method factory.

Returned methods

base.charge

Creates a Base x402 charge method for a Stripe Base deposit address. Pass the branded address from findOrCreateDepositAddress('base') and an x402 facilitator configuration.

defaultMethods

Returns Tempo charge and SPT charge methods. Pass { exclude: ['spt'] } or { exclude: ['tempo'] } to omit a default.

Call .additional(config) before awaiting asynchronous address resolution. The config accepts base, solana, and tempo.session entries. Stablecoin charge methods record successful payments in Stripe without replacing their existing onPaymentSuccess hooks.

findOrCreateDepositAddress

Returns a branded Stripe deposit address for 'base', 'solana', or 'tempo'. See stripe.findOrCreateDepositAddress.

spt.charge

Creates an SPT charge method. paymentMethodTypes defaults to ['card', 'link'].

tempo.charge

Creates a Tempo charge method for a Stripe deposit address. Currency and network derive from livemode.

tempo.session

Creates a Tempo session method for a Stripe deposit address. Pass the remaining tempo.session configuration.

Parameters

client

  • Type: StripeClient

Stripe SDK client with rawRequest() support. Use Stripe SDK v15 or newer.

connect (optional)

  • Type: { applicationFeeAmount?: number; onBehalfOf?: string; stripeAccount: string; transferData?: { amount?: number; destination: string }; transferGroup?: string }

Stripe Connect account and settlement configuration. stripeAccount scopes deposit-address lookup and recorded PaymentIntent objects to the connected account.

depositAddresses (optional)

  • Type: Partial<Record<'base' | 'solana' | 'tempo', string>> | ((network) => Promise<string>)

Static deposit addresses or an asynchronous resolver. By default, mppx finds or creates each required address through Stripe and caches it per client, network, and connected account.

livemode

  • Type: boolean

Selects live or test networks and currencies for built-in stablecoin methods.

networkId

  • Type: string

Stripe Business Network profile ID used by the SPT method.