Payment flow
Create a PaymentIntent
Call
stripe_create_payment_intent with the order amount and currency. Receive a client_secret to pass to your Stripe.js client.Collect card details on the client
Use the Stripe.js SDK with the
client_secret to show a payment form and collect the card. Stripe handles PCI compliance.Confirm the payment
After the client-side payment succeeds, call
stripe_confirm_payment with the payment_intent_id to verify the payment status server-side.stripe_create_payment_intent
Creates a Stripe PaymentIntent for a given amount.
Endpoint
Request
Payment amount in the base currency unit (e.g., dollars, not cents). The function converts to cents internally:
Math.round(amount * 100).ISO 4217 currency code, lowercased. Defaults to
"usd".Human-readable payment description. Defaults to
"Compra de tickets".Key-value metadata attached to the PaymentIntent. Merged with
{ platform: "TMT", timestamp: <ISO string> }.Response
200 on success, 400 if amount is invalid, 500 on Stripe error.The Stripe
client_secret to pass to stripe.confirmCardPayment() on the frontend.The PaymentIntent ID (e.g.,
pi_xxx). Store this to confirm or retrieve the payment later.stripe_confirm_payment
Retrieves a PaymentIntent by ID and confirms whether it has succeeded.
Endpoint
Request
The Stripe PaymentIntent ID (e.g.,
pi_3xxx).Response
Payment succeeded:stripe_get_payment_intent
Retrieves a PaymentIntent’s current state without asserting its status.
Endpoint
Request
The Stripe PaymentIntent ID.
Response
stripe_webhook
Receives and verifies Stripe webhook events. Configure this URL in your Stripe Dashboard under Webhooks.
Endpoint
Handled event types
| Event | Description |
|---|---|
payment_intent.succeeded | Payment completed successfully |
payment_intent.payment_failed | Payment attempt failed |
Webhook secret
Set theSTRIPE_WEBHOOK_SECRET environment variable to the whsec_... secret from your Stripe Dashboard. This is used to verify the Stripe-Signature header.
Response
400 if signature verification fails.