Fluentcart orders transactions

From Lonsdale201/wp-agent-skills · View interactive version

Fluentcart orders transactions is an AI agent skill from the GitHub repository Lonsdale201/wp-agent-skills. Implements and audits FluentCart order, order-item, transaction, status, payment-settlement, refund, renewal-order, and lifecycle-hook behavior. Use when reading or mutating fct_orders or fct_order_transactions, selecting order_created, order_paid, order_paid_done, order_payment_failed, order_refund

How to use this skill

Skill file

FluentCart orders and transactions

Drive order state from verified transactions and FluentCart lifecycle services.

Do not equate order creation, successful payment, fulfillment, and subscription

renewal.

Read order-event-map.md before attaching an

irreversible side effect or updating any status.

Keep state dimensions separate

An order independently carries:

Use Status, StatusHelper, OrderResource, Orders, PaymentInstance, and Refund as

appropriate. A direct update to payment_status does not create/reconcile a

transaction, recount totals, complete the cart, reserve/release stock, activate

a subscription, or dispatch the normal events.

Choose the event by guarantee

| Requirement | Use |

|---|---|

| Durable order aggregate created/updated for checkout | fluent_cart/order_created |

| Initial order transitioned to paid | fluent_cart/order_paid |

| Deferred normal post-payment processing point | fluent_cart/order_paid_done |

| Payment attempt became failed | fluent_cart/order_payment_failed |

| Refund recorded and totals/status synchronized | fluent_cart/order_refunded |

| Any subscription renewal settled | fluent_cart/subscription_renewed |

| Store-managed renewal invoice transitioned to paid | fluent_cart/renewal_paid |

| One status dimension changed | fluent_cart/{dimension}_status_changed |

order_created does not mean paid. order_paid is synchronous and its internal

listener recounts order/customer state and may create a WP user.

order_paid_done is emitted later by Action Scheduler after a valid paid order is

reloaded. Use it for third-party fulfillment/integration work that belongs after

the standard deferred path.

Never hook business logic to

fluent_cart/order_paid_async_private_handle. Core labels it private. The legacy

misspelled ansyc variant exists only to drain old queued jobs.

Make event callbacks replay-safe

~~~php

add_action('fluent_cart/order_paid_done', static function (array $data): void {

$order = $data['order'] ?? null;

if (!$order || $order->mode !== 'live') {

return;

}

// Atomically claim an addon-owned idempotency record keyed by order ID

// and operation before sending or granting anything.

});

~~~

StatusHelper atomically claims the pending-to-paid transition to reduce webhook

and browser-confirmation races. That does not make downstream callbacks

exactly-once. Store an addon-owned operation key and make retries converge.

Handle transactions and refunds

number as a provider idempotency key.

reference, and prior processed state.

redirect.

gateway's processRefund implementation for the provider operation.

by provider refund ID and can match a pending local refund.

refundable ceilings.

Query and authorize

unique key; legacy rows and the current schema use a non-unique index.

Cross-references

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.