On this page
Payment actions reference
Create, reuse and cancel payments and reserve capacity.
Before you begin: Rule publishing checklist.
Create a payment
payment.create({ amount, metadata }) creates a payment for the authenticated user. amount is a money value; metadata is an optional object describing what the payment is for. Other options are rejected.
Rule input (JSON)
Use a complete version 2 rule file. Select a post with “postType” and “action”, or an “endpoint” by name. Saved data, jobs, payments and email need the local server. Dedupe replay protection also needs a site.
Check complete rules or run schemas, permissions, hooks and calculations against the input above. Add excerpts to a complete rule before running.
Calculate the amount from trusted data and validate access before creating the payment. Metadata accompanies payment events; it does not reserve resources or enforce stock limits. Use dedupe to safely retry the same payment attempt, and create a new attempt ID for a new purchase. A completed deduplicated call returns its saved response even if the payment later expires; use the payment ID to load its current status and a new attempt ID to replace an expired payment. See Endpoints and dedupe.
Resume or cancel a pending payment
payment.findPending({ amount, metadata }) returns an existing payment response for the authenticated customer with the same normalized amount, currency and metadata, or null. It considers pending and review-pending payments while at least one payment-method deadline remains open. Expired, cancelled and completed payments are excluded. Metadata matches exactly, including array order. Use stable, trusted metadata and omit volatile timestamps when matching the same purchase.
Rule excerpt: add this to a complete FRL rule before running it. Try a complete example →
This lookup is available in endpoint processes. Keep lookup and creation in the same endpoint: concurrent requests for that customer are coordinated so this pattern can reuse one pending invoice. Reuse preserves the original deadlines and does not replace dedupe for retries of a particular request. Validate purchase rules before calling it.
payment.cancel(paymentId) cancels a pending payment owned by the authenticated customer. It returns { ok: true, payment }; an already cancelled payment succeeds again. Payments under review, completed payments, and payments with detected crypto funds cannot be cancelled. An unavailable payment fails without exposing another customer's data. Cancellation does not invoke your payment failed handler: explicitly release related resources in the same atomic block.
Reservations and atomic actions
Use reservation.hold(resourceKey, reservationKey, { capacity, quantity, expiresIn }), reservation.get(resourceKey, reservationKey), and reservation.release(resourceKey, reservationKey) in endpoint processes and payment events. Capacity accepts a number, { post, field }, or { userData, field }. Use atomic { ... } to commit supported database operations together or roll them back on failure. See Reservations and Atomic Actions for capacity rules, response shapes, permissions, expiry, and transaction limits.
Continue with Workflow helpers reference.