Method.stripe.charge
One-time payments via Shared Payment Tokens
Creates a Stripe charge payment method for client-side SPT-based payments.
Usage
import { } from '@stripe/stripe-js'
import { , } from 'mppx/client'
const = (await ('pk_test_...'))!
.({
: [
.({
: ,
: async ({ , , , , , }) => {
const = await ('/api/create-spt', {
: 'POST',
: { 'Content-Type': 'application/json' },
: .({ , , , , , }),
})
return (await .()).spt
},
}),
],
})Return type
import type { Method } from 'mppx'
type ReturnType = Method.ClientParameters
client (optional)
- Type:
StripeJs
Stripe.js instance from @stripe/stripe-js. Forwarded to the createToken callback for use with Stripe Elements.
import { } from '@stripe/stripe-js'
import { } from 'mppx/client'
const = (await ('pk_test_...'))!
const = .({
: ,
: async () => '...',
})createToken
- Type:
(params: OnChallengeParameters) => Promise<string>
Callback invoked when a Stripe Challenge is received. Must return an SPT token string (spt_...). Typically proxied through a server endpoint since SPT creation requires a Stripe secret key.
The callback receives:
| Field | Type | Description |
|---|---|---|
amount | string | Payment amount in smallest currency unit |
challenge | Challenge | The parsed Challenge from the server |
client | StripeJs | undefined | Stripe.js instance, if provided |
currency | string | Three-letter ISO currency code |
expiresAt | number | SPT expiration as a Unix timestamp (seconds) |
metadata | Record<string, string> | Optional metadata from the Challenge |
networkId | string | undefined | Stripe Business Network profile ID |
paymentMethod | string | undefined | Stripe payment method ID |
externalId (optional)
- Type:
string
Client reference ID included in the Credential payload.
paymentMethod (optional)
- Type:
string
Default Stripe payment method ID (for example pm_card_visa). Overridden by context.paymentMethod at Credential-creation time.
import { } from 'mppx/client'
const = .({
: async () => '...',
: 'pm_card_visa',
})