stripe.recordPayment
Record a settled stablecoin payment
Records an already-settled stablecoin payment as a Stripe PaymentIntent.
Usage
The mppx stripe.create integration records settled stablecoin payments in Stripe automatically. Use this helper if that recording doesn't complete after the on-chain payment settles, for example because the process stops. Confirm settlement on the specified network before calling it; the helper doesn't transfer funds.
import from 'stripe'
import { } from 'mppx/server'
const = new (..!)
const = await .(, {
: '1000000', // 1 USDC.e, with 6 decimals
: 'tempo',
: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
})
.(.)
createdThe helper creates a USD PaymentIntent in Stripe's transaction_verification mode, which asks Stripe to verify the on-chain transaction rather than charge the payer again. It floors six-decimal token units to whole US cents. Amounts below one cent return below_minimum without calling Stripe.
Retry safely
- Retries:
referenceis the transaction hash and Stripe idempotency key, matching automatic recording. Stripe retains keys for at least 24 hours; equivalent parameters returnreplayedwithin that period. - Conflicts: Different parameters, including omitted automatic metadata, return
key_conflict. Stripe caches failed responses too, so a conflict doesn't prove aPaymentIntentexists. Look it up before marking the payment recorded. - Expired keys: Reconcile Stripe records before retrying older payments; expired keys no longer prevent duplicates.
- Fallback records: Automatic recording uses
<reference>_fallbackonly after Stripe definitively rejects optionalpaymentIntentOptions(customer, tax, metadata, or receipt-email fields). Check both keys during reconciliation. This helper neither searches Stripe nor uses the fallback key. - Other errors: Unlike automatic recording, this helper throws other Stripe errors so your recovery worker can retry.
- Verification:
createdandreplayedmean Stripe returned aPaymentIntent, not that verification succeeded. OnlypaymentIntentStatus: 'succeeded'confirms it. Recheckprocessingorrequires_actionrecords later.
Return type
type ReturnType =
| {
paymentIntentId: string
paymentIntentStatus: string
status: 'created' | 'replayed'
}
| { status: 'key_conflict' }
| { status: 'below_minimum' }
| Status | Meaning |
|---|---|
below_minimum | Amount floors below one US cent; no Stripe request. |
created | Stripe returned a new PaymentIntent; inspect paymentIntentStatus. |
key_conflict | The key was previously used with different parameters; reconcile in Stripe. |
replayed | Stripe replayed an earlier result for the same key and parameters; inspect paymentIntentStatus. |
Parameters
Call stripe.recordPayment(client, parameters). client is the first argument; all other entries below are fields of the second argument.
amount
- Type:
string
Settled amount in the token's raw six-decimal units, as in the Challenge request. For a Session settlement, use the newly settled amount rather than the cumulative total.
client
- Type:
StripeClient
Pre-configured Stripe SDK client with paymentIntents.create support.
connect (optional)
- Type:
{ applicationFeeAmount?: number; onBehalfOf?: string; stripeAccount: string; transferData?: { amount?: number; destination: string }; transferGroup?: string }
Stripe Connect settings for the settled payment. Use the same connected account and settlement parameters as the original recording.
| Field | Type | Description |
|---|---|---|
applicationFeeAmount (optional) | number | Application fee in cents. |
onBehalfOf (optional) | string | Connected account used as settlement merchant. |
stripeAccount | string | Account that owns the recorded PaymentIntent. |
transferData (optional) | { amount?: number; destination: string } | Transfer destination and optional amount in cents. |
transferGroup (optional) | string | Group that associates related transfers. |
metadata (optional)
- Type:
Record<string, string> - Default:
{}
Metadata attached to the PaymentIntent. This helper doesn't add automatic mppx analytics metadata: machine_payment, mpp_intent, mpp_sdk, and (for charges) mpp_challenge_id. Use equivalent metadata when recovering an existing recording attempt to avoid an idempotency conflict.
network
- Type:
'base' | 'solana' | 'tempo'
Network where the stablecoin payment settled.
reference
- Type:
string
Settled transaction hash, used as Stripe's idempotency key.