Checkout
Requires Clarity 1.2.0 or newer. The skeleton pins
monad/clarity: ^1.0, which also resolves to releases without this service —
run composer update monad/clarity if Services\Checkout is missing.
Checkout is an abstract facade every payment gateway adapter implements, in the same
shape as LLM: four methods, taking and returning
gateway-agnostic value objects, so switching gateway changes one constructor call and nothing
else. Two adapters ship:
CheckoutAdapters\StripeCheckout (1.2.0), Stripe's hosted Checkout Sessions, and
CheckoutAdapters\PaddleCheckout (1.3.0), Paddle Billing one-time payments.
Recurring billing is a separate adapter for each gateway:
PaddleSubscription (1.4.0) and StripeSubscription (1.11.0).
They are not interchangeable in every respect, and the difference is not cosmetic: Stripe is a payment processor, Paddle is a merchant of record — it is the legal seller, and it calculates and remits sales tax for you. That is the reason to choose it, and the reason it behaves differently in the three places noted under Paddle below.
use Monad\Clarity\Services\CheckoutAdapters\StripeCheckout;
use Monad\Clarity\Services\Checkout\{CheckoutRequest, Money};
use Monad\Clarity\Services\HttpClient;
$checkout = new StripeCheckout(
apiKey: $stripeSecretKey,
httpClient: new HttpClient(),
webhookSecret: $stripeWebhookSecret,
);
$session = $checkout->createCheckout(new CheckoutRequest(
reference: 'ORDER-1001', // your own order reference
amount: new Money(2500, 'USD'), // 2500 cents
successUrl: 'https://shop.test/thanks',
cancelUrl: 'https://shop.test/cart',
));
$session->redirectUrl; // send the customer here
Amounts are integer minor units
Money holds a whole number of a currency's smallest unit beside its ISO 4217 code.
No decimal or float type appears anywhere in Checkout, and that is deliberate: JPY
and KRW have no minor unit, and BHD and KWD have three
decimal places, so any "multiply by 100" conversion layer is a rounding bug waiting for the
first non-USD merchant.
new Money(2500, 'USD'); // $25.00
new Money(2500, 'JPY'); // ¥2500 — not ¥25, and never multiplied
The four operations
$checkout->createCheckout(CheckoutRequest $request): CheckoutSession;
$checkout->retrieveStatus(string $reference, int $timeoutSeconds = 30): TransactionSnapshot;
$checkout->parseCallback(string $rawBody, array $headers): CallbackEvent;
$checkout->refund(RefundRequest $request): RefundResult;
Every one throws Checkout\CheckoutException rather than returning a failure value,
so a gateway error cannot be mistaken for a declined payment.
From Clarity 1.11.0 the message of a CheckoutException raised
for a gateway error is '<gateway> request failed with HTTP <status>: '
followed by a one-line summary of the gateway's error object — its type, code and
message. A body without one is redacted and cut to 500 characters, and any
_secret_ token is masked. The raw body is never carried: a declined Stripe card's
body includes the whole PaymentIntent, client_secret included, and exception
messages reach your logs. This holds for every Checkout adapter. Read the gateway's state
through the adapter rather than parsing it out of the message.
Two Stripe refusals about idempotency keys get Clarity's own explanation in place of that
summary, because Stripe's text gives advice that is wrong or incomplete for them. One is a key
already used on a different request, covered next. From Clarity 1.12.1 the
other is HTTP 409 with code idempotency_key_in_use, meaning an earlier request
under the same key is still being processed. The refused request did nothing, and the message
says to retry with the same key, which then receives the earlier request's outcome.
Stripe's own text only says to try again later, and a new key would be a second request: for
a refund, a second refund. It is still a plain CheckoutException.
From Clarity 1.12.0 Stripe's refusal of a reused idempotency key is its own
type, Checkout\IdempotencyKeyReusedException. It is a subclass of
CheckoutException, so a catch you already have still catches it. It means a
different request was already made under that key, and this one was not carried out: nothing
was created, charged or refunded by it. $e->idempotencyKey is the key. That is
the one you passed, or, if you passed none, the order reference for a checkout and
refund:{reference}:{amount or "full"} for a refund.
What is safe next depends on the call, and the message says which. A new key for
createCheckout() charges nothing, but the earlier session stays payable until it
expires, so make sure the order can be paid only once. Since a checkout's key is its order
reference, the usual cause is asking again for an order whose cart changed. On
refund() a new key is a new refund, so check the refunds already made first. For
changePlan() see below. Paddle takes no keys and never throws it.
try {
$session = $checkout->createCheckout($request);
} catch (IdempotencyKeyReusedException $e) {
// The order changed under the same reference: retry with a new reference or idempotencyKey.
} catch (CheckoutException $e) {
// Every other failure, as before.
}
Paddle
Requires Clarity 1.3.0 or newer. Same four methods, same value objects; what follows is only where Paddle differs from Stripe.
use Monad\Clarity\Services\CheckoutAdapters\PaddleCheckout;
$checkout = new PaddleCheckout(
apiKey: $paddleApiKey, // pdl_live_apikey_... / pdl_sdbx_apikey_...
httpClient: new HttpClient(),
webhookSecret: $paddleNotificationSecret, // pdl_ntfset_... — not the API key
hostedCheckoutUrl: 'https://pay.paddle.io/checkout/hsc_...',
taxCategory: 'standard',
baseUri: 'https://sandbox-api.paddle.com', // omit for live
);
Two ways to reach the payment page — pick exactly one
Paddle has no gateway-hosted page by default; it renders checkout through Paddle.js. So the adapter takes one of two arguments and refuses to create a checkout with neither or both:
-
hostedCheckoutUrl— the link copied from Paddle › Checkout › Hosted checkout. Paddle hosts the page; you build nothing. Pass the whole URL verbatim. Its post-payment redirect is configured on the link itself, sosuccessUrlandcancelUrlcannot be honoured per checkout in this mode — they travel in the transaction'scustom_data, where your reconciliation code can still read them. -
paymentPageUrl— your own page running Paddle.js. Honours the wholeCheckoutRequest, at the cost of hosting a page.
Two account settings must be in place first, or transaction creation fails
outright rather than at the redirect. Set a default payment link under Paddle ›
Checkout › Checkout settings — without one Paddle refuses to create any
transaction, and a per-transaction override does not substitute for it. And if you use
paymentPageUrl, approve that domain under Paddle › Checkout ›
Website approval. These are two separate lists, in sandbox as much as in live: Paddle.js
will happily render on a domain the API still rejects as a checkout URL.
No idempotency keys
Stripe takes an Idempotency-Key on every write. Paddle takes one on none, so
CheckoutRequest's key is carried as metadata for auditing and cannot be enforced.
A retried createCheckout() creates a second Paddle transaction — harmless in
itself, since it is a draft and no money moves, but do not retry blindly. For refunds, where a
blind retry costs real money, the adapter reads the transaction's line items and every
adjustment already made against it and refuses one that would exceed the remaining balance.
Refunds are asynchronous
A live Paddle refund is created pending_approval and reviewed by Paddle before the
money moves; sandbox approves automatically on a timer, which is exactly the difference that
hides this in testing. RefundResult::$status carries Paddle's own word verbatim, so
check it rather than assuming a returned RefundResult means refunded. While one
refund is pending, Paddle refuses any further adjustment against that transaction — so
partial refunds on one transaction are serialised behind its review.
taxCategory is worth a moment: Paddle is the merchant of record, so this decides
how the sale is taxed. The default standard is right for ordinary goods and
services and wrong for ebooks, SaaS, and software, each of which has its own category.
Subscriptions
Requires Clarity 1.4.0 or newer. PaddleSubscription sits beside
PaddleCheckout — one gateway, two genuinely different flows, one class each. It
implements the same four methods, which stay strictly transaction-scoped because a
subscription's money movements are transactions, and adds seven of its own.
use Monad\Clarity\Services\Checkout\{BillingCycle, BillingInterval};
use Monad\Clarity\Services\CheckoutAdapters\PaddleSubscription;
$plan = new PaddleSubscription(
apiKey: $paddleApiKey,
httpClient: new HttpClient(),
billingCycle: new BillingCycle(BillingInterval::Month, 1), // every month
trialPeriod: new BillingCycle(BillingInterval::Day, 14), // optional
webhookSecret: $paddleNotificationSecret,
paymentPageUrl: 'https://your-approved-domain.example/subscribe',
taxCategory: 'saas', // 'standard' is wrong for most subscriptions
);
The billing cycle is constructor configuration, not request data.
createCheckout()'s signature is fixed by the facade and
CheckoutRequest is frozen, so one adapter instance means one plan's terms — a
merchant with monthly and annual tiers constructs two, which is the same shape as
constructing one adapter per gateway.
Billing a plan you publish in Paddle
Requires Clarity 1.7.0 or newer. The adapter above describes its plan inline, which needs no Paddle catalogue at all. If you already maintain your tiers in the Paddle dashboard, name the price instead and let the catalogue state the terms:
use Monad\Clarity\Services\CheckoutAdapters\PaddleSubscription;
$plan = PaddleSubscription::forCatalogPrice(
apiKey: $paddleApiKey,
httpClient: new HttpClient(),
catalogPriceId: 'pri_01hxxxxxxxxxxxxxxxxxxxxxxx',
webhookSecret: $paddleNotificationSecret,
paymentPageUrl: 'https://your-approved-domain.example/subscribe',
taxCategory: 'saas', // only for a later inline changePlan() — see below
);
No billing cycle and no trial period — the price in Paddle carries both, which is the
point. An application that bills published plans should not restate their prices in its
own code, because the two disagree the first time one of them changes.
PaddleCheckout takes the same catalogPriceId: argument for one-time
sales, and one instance still means one plan: three tiers on two cycles is six adapters.
taxCategory is the one apparent exception, and only apparent.
The catalogue checkout ignores it and reads the category off the catalogue product. It
matters for one later path: a changePlan() onto a
SubscriptionItem::inline() plan describes its price in your code, so it must
state how that price is taxed in your code too. Pass the same category your catalogue
product carries and a customer moved onto a bespoke plan is taxed as before. Omitting it
leaves that path on standard — ordinary goods, and wrong for the SaaS a
recurring charge usually is. Requires Clarity 1.7.1; in 1.7.0 this argument did not
exist and that path was pinned to standard.
Two consequences worth knowing before you meet them in a settlement report:
-
CheckoutRequest::$amountis neither sent nor believed. Passnew Money(0, $currency)— read as "the catalogue owns this" — and read the real figure back offCheckoutSession::$amount. Passing the true price compiles and works, and is exactly the duplication catalogue mode removes. A request carryinglineItemsis refused rather than silently overridden. - The currency comes from the price, not the request. Paddle does not refuse a currency that disagrees with a catalogue price — it silently converts, turning a 4900 USD price into 4218 EUR. Clarity therefore omits the field entirely in catalogue mode, so Paddle bills the price exactly as you published it.
Quantity is fixed at 1. Seat counts are set after the fact through
changePlan() with
SubscriptionItem::catalogPrice($priceId, $quantity).
One thing to get right yourself, because Clarity cannot check it: give a recurring
price to PaddleSubscription, not to PaddleCheckout. A
price id does not say whether it recurs — only Paddle knows — so a recurring
pri_… passed to the one-time adapter creates a real subscription on a class
that has no cancel(), pause() or changePlan() to
manage it, and that reads Paddle's past_due as a dead payment rather than as
dunning still in progress.
A subscription is born from a transaction
There is no POST /subscriptions. Paddle creates the subscription when a
transaction whose price carries a billing cycle is actually paid — so
createCheckout() returns a txn_, and the sub_ every
operation below acts on does not exist yet. Two routes lead from one to the other,
and it is worth handling both, because either delivery can be dropped:
// once the transaction settles — null means "not yet", never "never"
$subscriptionRef = $plan->subscriptionReferenceOf($snapshot);
// or off the subscription.created delivery, which also names its transaction
$event = $plan->parseSubscriptionCallback($rawBody, $headers);
$event->subscription->gatewayReference; // sub_...
$event->subscription->transactionReference; // txn_... (callbacks only)
Paddle creates the subscription asynchronously: a transaction read back the instant it settles can still report no subscription, and carry one seconds later. Poll again, or let the callback bring it.
A cancellation is a scheduled change, not a status
This is the one thing most likely to be got wrong, and it costs a paying customer their
service. A customer who clicks cancel does not become Cancelled.
They have paid through the end of the period, so the subscription stays Active
with a pending change until that period runs out:
$s = $plan->cancel($subscriptionRef, SubscriptionEffectiveFrom::NextBillingPeriod);
$s->status; // SubscriptionStatus::Active — still!
$s->status->isTerminal(); // false
$s->isCancelling(); // true — what a billing page shows
$s->accessEndsAt(); // when service actually stops
Gate access on the status, and show isCancelling() in the UI. Reading "a change
is scheduled" as "revoke now" takes away something already paid for; reading only the status
is right by accident until someone cancels immediately.
There is deliberately no grantsAccess(). Whether a
PastDue customer keeps the product while Paddle retries their card is a product
decision — most merchants allow a few days and show a banner, some cut off at once, and both
are defensible. Clarity gives you the status, the pending change, and the date; the judgement
stays yours.
Changing, pausing, resuming
$plan->changePlan($ref, $items, ProrationBillingMode::ProratedImmediately);
$plan->pause($ref, SubscriptionEffectiveFrom::NextBillingPeriod);
$plan->resume($ref, SubscriptionEffectiveFrom::Immediately);
$plan->removeScheduledChange($ref); // withdraw a pending cancel or pause
changePlan() replaces the subscription's whole item set rather
than adding to it — anything you leave out is removed, so pass add-ons again alongside a new
tier. Its ProrationBillingMode is required and has no default, because Paddle
has none and the five values differ by real money charged to a real customer:
ProratedImmediately for an upgrade, ProratedNextBillingPeriod for a
downgrade, and never DoNotBill for self-serve. Items may be catalogue prices or
described inline, so no Paddle catalogue is needed for either.
While any change is scheduled, Paddle refuses every further change to that
subscription. A cancellation set for the end of the period therefore blocks pausing,
re-planning and cancelling immediately for as long as it stands — which is what
removeScheduledChange() exists for, and why a customer who changes their mind is
not stuck waiting out their own cancellation. Two smaller constraints, both found against the
live API and both contradicting Paddle's documentation: a subscription can only be resumed
Immediately, and it must already be paused rather than merely scheduled
to pause.
Dunning is not failure
PaddleSubscription maps Paddle's past_due to
TransactionStatus::Pending, where PaddleCheckout maps it to
Failed. That difference is deliberate. On a one-time payment past_due
is a dead payment; on a renewal it is dunning — Paddle keeps retrying and the charge often
completes days later. Failed is terminal and the ledger will not move a
transaction away from it, so sharing the mapping would strand every recovered renewal at
failed in your books for good.
The subscription ledger
Checkout\SubscriptionLedger mirrors subscription state into
checkout_subscriptions, the fourth table
checkout:install creates. It is separate from
TransactionLedger because a subscription is one mutable row, where a transaction
has an insert-only status history — different invariants, so a different class rather than one
whose guarantees have exceptions.
$subs = new SubscriptionLedger();
$subs->record($event); // false on a redelivery or an out-of-order event
$subs->recordSnapshot($snapshot); // reconcile a callback that never arrived
$subs->statusOf($subscriptionRef); // null if never seen — never throws
$subs->linkTransaction($subscriptionRef, $txnRef);
Redeliveries and out-of-order deliveries are both refused, so record() returning
true means state genuinely moved and is a safe trigger for your own side effects.
One caveat worth knowing: built-in tables store timestamps to the second, and Paddle can emit
two distinct events inside one second, so within that window the events cannot be
ordered and the last writer wins.
Stripe subscriptions
Requires Clarity 1.11.0 or newer. StripeSubscription sits beside
StripeCheckout exactly as PaddleSubscription sits beside
PaddleCheckout: the same four methods, the same subscription methods, the same
value objects, the same ledger. Everything above about
reading a cancellation, past_due and the ledger holds here too; what follows is
where Stripe differs.
use Monad\Clarity\Services\CheckoutAdapters\StripeSubscription;
// An inline plan — no Stripe catalogue needed. One adapter per plan's terms.
$plan = new StripeSubscription(
apiKey: $stripeSecretKey,
httpClient: new HttpClient(),
billingCycle: new BillingCycle(BillingInterval::Month, 1),
trialPeriod: new BillingCycle(BillingInterval::Day, 14), // optional
webhookSecret: $stripeWebhookSecret,
);
// A recurring price_... you maintain in the Stripe dashboard.
$annual = StripeSubscription::forCatalogPrice(
apiKey: $stripeSecretKey,
httpClient: new HttpClient(),
catalogPriceId: 'price_1Pro...',
webhookSecret: $stripeWebhookSecret,
);
Pass exactly one of a billing cycle and a catalogue price. Catalogue mode follows the
Paddle idiom: new Money(0, $currency) for the
request's amount, and the real figure read back off CheckoutSession::$amount.
Unlike Paddle, a trial is allowed in catalogue mode, because a Stripe price
carries none.
Trials are whole days. Day is sent as it is and Week becomes seven
days per week; Month and Year are refused at construction, because
converting them would quietly turn “one month” into thirty days.
StripeSubscription pins Stripe API version 2026-09-30.endive, the
earliest with a real pause endpoint; StripeCheckout stays on
2024-06-20. Stripe renders a webhook in the endpoint's version rather than
the one the adapter sends, so both parsers read the older and the newer payload shapes, and an
endpoint created on an older account default works unchanged.
The session comes first, the subscription second
createCheckout() returns a cs_, never a sub_, which does
not exist until the customer completes the session. Unlike Paddle the bridge is synchronous:
subscriptionReferenceOf() reads the sub_ straight off a completed
session, and returns null only for one still open. A Stripe subscription never
names its session, so SubscriptionSnapshot::$transactionReference is always
null here; join them with SubscriptionLedger::linkTransaction().
Routing the webhooks
Two parsers, split by event family:
checkout.session.* and invoice.* go to parseCallback();
customer.subscription.* goes to parseSubscriptionCallback() and then
SubscriptionLedger::record().
Route::post('/webhooks/stripe', function (Request $request) use ($plan, $transactions, $subs) {
$rawBody = $request->rawBody();
$headers = ['Stripe-Signature' => $request->header('Stripe-Signature') ?? ''];
// The type is read only to choose a parser. Both verify the signature before trusting anything,
// and a body neither accepts is refused with a CheckoutException — answer that with a 400.
$peek = json_decode($rawBody, true);
$type = is_array($peek) && is_string($peek['type'] ?? null) ? $peek['type'] : '';
if (str_starts_with($type, 'customer.subscription.')) {
$subs->record($plan->parseSubscriptionCallback($rawBody, $headers));
} else {
$event = $plan->parseCallback($rawBody, $headers);
if (str_starts_with($event->gatewayReference, 'cs_')) {
$transactions->recordCallback($event); // the checkout you open()ed
}
// 'in_': the first invoice and every renewal. Yours to handle.
}
return Response::noContent();
});
One endpoint, because an adapter holds one webhookSecret and Stripe gives every
endpoint its own whsec_ key. If you register separate endpoints, construct one
adapter per endpoint, each with its own secret.
The branch on cs_ is not optional. Every signup raises
invoice.paid for its first invoice, trial included, and every renewal raises one
for an in_ that nobody open()ed. TransactionLedger
throws on a reference it never opened, so passing every parseCallback() result to
it fails on every signup, not only on renewals. Send cs_ to the ledger and handle
in_ in your application. A renewal's invoice.payment_failed reads as
Pending, not Failed — dunning, as on Paddle. The same gap exists for
Paddle renewals; it is simply wider on Stripe. The endpoint also receives
invoice.upcoming, which parseCallback() refuses by name: it previews
an invoice that does not exist yet.
Cancelling, pausing, changing
$plan->cancel($subRef, SubscriptionEffectiveFrom::NextBillingPeriod);
$plan->removeScheduledChange($subRef); // withdraw that pending cancel
$plan->pause($subRef, SubscriptionEffectiveFrom::Immediately);
$plan->resume($subRef, SubscriptionEffectiveFrom::Immediately);
$plan->changePlan($subRef, $items, ProrationBillingMode::ProratedImmediately,
idempotencyKey: $changeId);
cancel() at the end of the period leaves the subscription Active with
a pending change, exactly as on Paddle, so gate access the same way. An immediate
cancel refunds nothing on Stripe: a refund is a separate refund() call you decide
on.
-
Pause and resume are immediate only. A scheduled pause needs Stripe
Subscription Schedules, which Clarity does not use, and
pause()refuses both a resume date and an$onResume. Pausing credits the unused time — unlike Paddle, where a paused subscription keeps its period — and that credit lands on the invoice raised at resume. A subscription still in its trial cannot be paused; Stripe says so and Clarity passes it on. -
resume()may charge. Stripe resumes a subscription only when its invoice is paid and never attempts that itself, soresume()pays the invoice it raised. When nothing was raised to pay, it returns normally and the status can still bePaused: the returned status is authoritative, so check it. On an exception, follow its wording. If it says the subscription ispast_due, Stripe accepted the resume but could not collect: the invoice stays open, Stripe will not retry it, and a secondresume()is refused, so the customer must pay that invoice (from its hosted page when Stripe supplies one). Any other failure makes no claim about whether the card was charged; confirm withretrieveSubscription(). -
changePlan()replaces the whole item set, as on Paddle, and refuses a subscription whose item list Stripe reports as partial rather than drop items that would keep billing.ProratedImmediately,ProratedNextBillingPeriodandDoNotBillmap to Stripe's three proration behaviours;FullImmediatelyandFullNextBillingPeriodhave no equivalent and are refused rather than guessed, since a guess charges a real customer the wrong amount. An inline item creates a product, uses it and archives it afterwards, whether or not the change succeeded, so no catalogue is needed. If the change succeeds but archiving fails, the call still returns the successful snapshot, and the product may stay active in your Stripe catalogue.
Pass an idempotency key to any charging changePlan(). Stripe
takes keys where Paddle cannot, so a retry under the same key is safe. Never retry with a
fresh key, and send every outcome of the retry other than success, a replayed server error
included, to retrieveSubscription() before deciding anything. A refusal for
reusing a key means the change already happened: Stripe's own message advises trying
another key, which is exactly what must not be done, so Clarity replaces it with an
IdempotencyKeyReusedException that says so.
Refunds
refund() accepts a pi_, a cs_ or an in_ and
resolves it to the PaymentIntent behind it, but only to one that has paid. A session
that charged nothing, an unpaid invoice and a declined or still-processing attempt are refused
in plain words before anything reaches Stripe; the paymentReference on a snapshot
or event is likewise only ever a payment that has paid.
Verifying a callback
Pass Request's rawBody() — the exact bytes,
never a decoded-and-re-encoded body. Signatures are computed over the bytes as sent, so
re-serialising fails verification even for a genuine callback. A CallbackEvent only
ever exists for a callback whose signature already verified; construction is the proof.
Route::post('/webhooks/stripe', function (Request $request) {
$event = $checkout->parseCallback($request->rawBody(), [
'Stripe-Signature' => $request->header('Stripe-Signature') ?? '',
]);
$ledger->recordCallback($event); // idempotent — see below
return Response::noContent();
});
The header array is built explicitly because Request
exposes header() for a single header, not a bulk accessor. Names are matched
case-insensitively, so the casing you use here does not matter. For Paddle the header is
Paddle-Signature and the secret is the notification destination's
pdl_ntfset_... key — one per destination, and not the API key.
Both adapters accept only their own checkout events and throw on anything else, which matters
because an endpoint receives every event type enabled on it. Stripe sends every enabled type to
one URL by default; a Paddle notification destination does the same. Route only checkout events
to parseCallback(), or catch the exception and ignore the rest — otherwise an
unrelated customer.created is an error in your logs on a schedule.
Exclude that path from Csrf — a gateway has no session and no token. The route must also be publicly reachable and unauthenticated.
The transaction ledger
Checkout\TransactionLedger is the stateful half, kept out of the facade so every
gateway shares one persistence layer. It records transactions, an insert-only status history,
and refunds. Create its tables with
checkout:install.
$ledger = new TransactionLedger();
$transactionId = $ledger->open($request, $session); // status: pending
$ledger->recordCallback($event); // returns false on a redelivery
$ledger->recordSnapshot($snapshot); // reconcile a callback that never arrived
$ledger->recordRefund($transactionId, $refundResult);
$ledger->refundableAmount($transactionId); // Money
$ledger->statusHistory($transactionId); // every status the gateway ever reported
Both are safe to call twice. Gateways redeliver callbacks by design, and a gateway call that times out after being accepted gets retried — so callbacks and refunds are keyed on the gateway's own identifiers under unique indexes. A redelivery is recognised and ignored, not recorded again.
Four statuses, and refunds are not one of them
TransactionStatus::Pending | Success | Failed | Cancelled
A refund is its own record, not a fifth status. A partially refunded transaction has no honest
single-status answer, so a transaction that succeeded stays Success for its
lifetime while refunds accumulate against it — which is also what makes partial and repeated
refunds representable.
Reconciling a callback that never arrived
Callbacks get dropped, delayed, or arrive while your site is down. retrieveStatus()
asks the gateway directly and is the authoritative path; the ledger treats a snapshot exactly as
it treats a callback. Run it for any transaction still Pending after a sensible
interval rather than trusting the webhook to be your only signal.
Events
The ledger dispatches Event::PAYMENT_COMPLETED
when a transaction settles as successful — once per transaction, never on a redelivered
callback, so a listener that ships goods or emails a receipt runs exactly once.
What's deliberately not here
No custom checkout page (Stripe Elements/PaymentIntents) and no built-in reporting — both are
specified but unbuilt. StripeCheckout covers one-time payments only, as does
PaddleCheckout, which never sends a billing cycle so a subscription cannot be
created by accident; recurring billing is the job of PaddleSubscription and
StripeSubscription. Neither subscription adapter records renewals in
TransactionLedger yet. Tracking a Paddle refund from
pending_approval to its final state is also not built — the adapter initiates
refunds and reports what Paddle returned.
Eight further gateway adapters are reserved and unbuilt; an unbuilt
adapter is an absent file, never a stub, so a missing class means it genuinely does not exist
yet rather than existing and silently doing nothing.
Next steps
- checkout:install — creating the four tables the ledgers need.
- HttpClient — what every adapter sends requests over.
- Csrf — excluding your callback route.