Repository navigation
Immutable
release. Only release title and notes can be modified.
Product types can describe a cart line's options in words, offer a richer
add-to-cart schema (swatches, option metadata, conditional fields), and quote
a price for a set of options without side effects. Shoppers can sign up to
hear when a sold-out product is back in stock. A payment the provider
confirmed that no order can take is now held for review or refunded instead
of being left with no order, refund, or record, and staff can accept or
reject that hold.
This is the engine release ecommerce-storefront-livewire 2.0.0 builds on
for rich options, "Notify me", line summaries, and stranded payments.
Added
Contracts\DescribesLineOptions(optional, on aProductType) andSupport\LineOptionDescriber(describe(),forCartItem(),forOrderItem()): human-readablelabel/valuerows for a line's options, with a default (variant name plus headlined scalar options) for other types. The cart item and order item REST resources and GraphQL types exposeoption_lines(LineOption); placement copies the rows intoorder_items.product_snapshot.option_lines, and the order confirmation, admin order-paid, shipped, and refunded templates list them under each line. Filter:ap.ecommerce.lineOptions.described(#222).- Richer add-to-cart field schema: options may carry
price_delta,image,swatch,hint, anddisabled; aswatchfield type; field-levelvisible_whenandmeta.disables.Support\StorefrontOptionSchema(normalize(),isVisible(),visibleFields(),stripHidden(),rules(),validate()) drops malformed fields with a logged warning and lets types skip hidden fields.purchase-optionsserves normalized fields, and the new GraphQLproductPurchaseOptionsquery returns the same data (#223). Services\PriceQuoteService::quote(),ValueObjects\PriceQuote, and the optionalContracts\QuotesPrice: list-price quotes for a product and its options with no side effects, overPOST products/{product}/quote(catalog.read, 422 withoptions.*errors) and GraphQLproductQuote(#224).- Back-in-stock subscriptions:
Models\BackInStockSubscription(ecommerce_back_in_stock_subscriptions),Services\BackInStockService(subscribe(),unsubscribe(),isSubscribed(),notifyRestocked(),exportFor(),eraseFor()), theinventory.back-in-stock.customernotification (categoryback-in-stock), theap.ecommerce.inventory.backInStockhook fired byInventoryServicewhen available stock rises from zero,ap.ecommerce.backInStock.subscribed/.unsubscribed/.notified/.shouldNotify/.productUrlhooks, theecommerce.backInStock.subscriberate policy, and thenotifications.product_urlconfig key. Subscriptions are deleted on customer erasure and added to artisanpack-ui/privacy exports (#229). - Stranded payments (#231): a payment the provider confirmed that no order can take (the cart's total changed after its session was made, or a newer session replaced it) is no longer left with no order, refund, or record.
Models\CartPaymentSession(ecommerce_cart_payment_sessions, with a factory) keeps every payment session a cart was given, written byCheckoutService::createPaymentSession();carts.payment_referencestays the current one. Rows hold only references, amounts and statuses (active,superseded,canceled,stranded,held,refunded,voided,completed).Cart::paymentSessions().checkout.stranded_paymentsconfig key and store setting (envECOMMERCE_STRANDED_PAYMENTS):hold(default) places the order for staff review (pending,payment_status = paidwhen captured,meta.payment_mismatchwith both amounts and the session, apayment.strandedtimeline entry);refundrefunds a captured payment or voids an authorized one through the gateway'srefund()/voidPendingPayment()(always the same request and idempotency key), holds it when nothing can be sent (no gateway or no refund support), and leaves itstrandedand retried, never held as paid, when a refund or void was sent but not confirmed.Services\StrandedPaymentService(policy(),handle(),flag(),record(),retire(),supersede(),markCanceled(),markCompleted(),find()) settles each session at most once under the cart and session row locks, so finalize and a webhook can race.CheckoutService::strandedPayment( $cart ): ?PaymentSessionreturns a cart's stranded payment, recorded or found live at the provider.- The
ap.ecommerce.checkout.paymentStranded( Cart $cart, PaymentSession $session, string $reason )action fires once per session fromcreatePaymentSession(),finalize(),strandedPayment(), andPaymentReconciler. Contracts\CancelsPaymentSessions(optional, on aPaymentGateway):cancelPaymentSession( $reference )cancels an unconfirmed session the cart is replacing or dropping. Only for providers that refuse to cancel a confirmed session atomically;StripeGatewaydoesn't implement it (Stripe cancels an authorization inrequires_capture).PaymentReconciler::STRANDED: whatreconcile()returns when it settled a stranded payment.StrandedPaymentService::acceptHold( $order, $actorUserId )and::rejectHold( $order, $actorUserId )resolve a hold, like the fraud review'saccept_challenge: accept captures an authorized session, marks the order paid with the session pinned, commits its stock, moves it toprocessingand fires the usual paid hooks andPaymentSucceeded; reject voids or refunds the session, fails the order and releases its stock as a fraud block does. Both are idempotent, refuse orders that aren't unresolved holds, writepayment.stranded_accepted/payment.stranded_rejectedtimeline entries, and fire the newap.ecommerce.checkout.strandedPaymentResolved( Order $order, string $resolution )action.isHold( $order ).
Changed
CheckoutService::createPaymentSession()retrieves the session it would replace: one the provider reports confirmed for another total is never replaced (payment-already-confirmed, 409, cart unchanged); an unconfirmed one is cancelled where the gateway implementsCancelsPaymentSessions, and kept in the history. When the provider can't say how the current session stands, it throwspayment-status-unknown(503) and keeps the session (#231).CheckoutService::finalize(): when the cart's total or currency changed, a session the shopper already confirmed is settled bycheckout.stranded_paymentsbeforetotals-changedis thrown, instead of only being unpinned; an unconfirmed one is cancelled at the provider where possible. A replaced$paymentReferencethe provider reports confirmed is settled the same way beforepayment-reference-mismatch, or beforepayment-session-requiredwhen the cart has no current session. A zero-total cart's confirmed session is settled before the free order is placed (#231).PaymentReconcilermatches asucceededsession no cart or pending order points at through the payment session history and settles it instead of dropping it, unless an order owns the session (a paid one marks it completed, a finalize in flight defers it); a confirmed session on a cart that can't become an order (cart-empty,cart-closed, …) is settled too; afailedone is marked cancelled only once the provider confirms the cancellation.ecommerce:reconcile-paymentsalso polls replaced, stranded and pruned-cart sessions, and a cart's current session after the cart leftpayment_pending; its summary addsHandled N stranded payment(s); M still need settling.(#231).CheckoutService::setPaymentGateway()and a cart currency change keep the dropped session in the history assuperseded(recording a pre-1.4 reference first, with an unknown amount), so it is still matched if it's confirmed. History rows outlive pruned carts (cart_idbecomes null) (#231).CheckoutServiceandPaymentReconcilertake an optionalStrandedPaymentServiceconstructor argument (the container's when omitted).PATCH orders/{order}(UpdateOrderRequest) refuses writes to the engine-ownedmeta.payment_mismatch, as it doesmeta.fraud_decision(#231).StorefrontCartServicerefuses options that fail a type'sStorefrontOptionSchema::validate()(aValidationException) asoptions-invalidwith the schema's first message, as it already did forInvalidArgumentException.AddCartItemRequest::optionRules()exposes the cart's option payload limits, shared by the quote endpoint and GraphQLproductQuote: at most 20 top-level options, values of up to 255 characters, and now nested values for dot- or bracket-named fields (up to 3 levels deep, 100 values in all) so they reach the type'sStorefrontOptionSchemainstead of being refused.- A product type that throws a
TypeErroron an option's shape (a nested value where it reads a scalar) is refused asoptions-invalidby the cart and as an invalid quote, instead of erroring.