Skip to content

v1.4.0

Latest

Choose a tag to compare

@github-actions github-actions released this 22 Nov 23:38
Immutable release. Only release title and notes can be modified.
3aa1db2

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 a ProductType) and Support\LineOptionDescriber (describe(), forCartItem(), forOrderItem()): human-readable label / value rows 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 expose option_lines (LineOption); placement copies the rows into order_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, and disabled; a swatch field type; field-level visible_when and meta.disables. Support\StorefrontOptionSchema (normalize(), isVisible(), visibleFields(), stripHidden(), rules(), validate()) drops malformed fields with a logged warning and lets types skip hidden fields. purchase-options serves normalized fields, and the new GraphQL productPurchaseOptions query returns the same data (#223).
  • Services\PriceQuoteService::quote(), ValueObjects\PriceQuote, and the optional Contracts\QuotesPrice: list-price quotes for a product and its options with no side effects, over POST products/{product}/quote (catalog.read, 422 with options.* errors) and GraphQL productQuote (#224).
  • Back-in-stock subscriptions: Models\BackInStockSubscription (ecommerce_back_in_stock_subscriptions), Services\BackInStockService (subscribe(), unsubscribe(), isSubscribed(), notifyRestocked(), exportFor(), eraseFor()), the inventory.back-in-stock.customer notification (category back-in-stock), the ap.ecommerce.inventory.backInStock hook fired by InventoryService when available stock rises from zero, ap.ecommerce.backInStock.subscribed / .unsubscribed / .notified / .shouldNotify / .productUrl hooks, the ecommerce.backInStock.subscribe rate policy, and the notifications.product_url config 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 by CheckoutService::createPaymentSession(); carts.payment_reference stays the current one. Rows hold only references, amounts and statuses (active, superseded, canceled, stranded, held, refunded, voided, completed). Cart::paymentSessions().
    • checkout.stranded_payments config key and store setting (env ECOMMERCE_STRANDED_PAYMENTS): hold (default) places the order for staff review (pending, payment_status = paid when captured, meta.payment_mismatch with both amounts and the session, a payment.stranded timeline entry); refund refunds a captured payment or voids an authorized one through the gateway's refund() / voidPendingPayment() (always the same request and idempotency key), holds it when nothing can be sent (no gateway or no refund support), and leaves it stranded and 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 ): ?PaymentSession returns 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 from createPaymentSession(), finalize(), strandedPayment(), and PaymentReconciler.
    • Contracts\CancelsPaymentSessions (optional, on a PaymentGateway): cancelPaymentSession( $reference ) cancels an unconfirmed session the cart is replacing or dropping. Only for providers that refuse to cancel a confirmed session atomically; StripeGateway doesn't implement it (Stripe cancels an authorization in requires_capture).
    • PaymentReconciler::STRANDED: what reconcile() returns when it settled a stranded payment.
    • StrandedPaymentService::acceptHold( $order, $actorUserId ) and ::rejectHold( $order, $actorUserId ) resolve a hold, like the fraud review's accept_challenge: accept captures an authorized session, marks the order paid with the session pinned, commits its stock, moves it to processing and fires the usual paid hooks and PaymentSucceeded; 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, write payment.stranded_accepted / payment.stranded_rejected timeline entries, and fire the new ap.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 implements CancelsPaymentSessions, and kept in the history. When the provider can't say how the current session stands, it throws payment-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 by checkout.stranded_payments before totals-changed is thrown, instead of only being unpinned; an unconfirmed one is cancelled at the provider where possible. A replaced $paymentReference the provider reports confirmed is settled the same way before payment-reference-mismatch, or before payment-session-required when the cart has no current session. A zero-total cart's confirmed session is settled before the free order is placed (#231).
  • PaymentReconciler matches a succeeded session 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; a failed one is marked cancelled only once the provider confirms the cancellation. ecommerce:reconcile-payments also polls replaced, stranded and pruned-cart sessions, and a cart's current session after the cart left payment_pending; its summary adds Handled N stranded payment(s); M still need settling. (#231).
  • CheckoutService::setPaymentGateway() and a cart currency change keep the dropped session in the history as superseded (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_id becomes null) (#231).
  • CheckoutService and PaymentReconciler take an optional StrandedPaymentService constructor argument (the container's when omitted).
  • PATCH orders/{order} (UpdateOrderRequest) refuses writes to the engine-owned meta.payment_mismatch, as it does meta.fraud_decision (#231).
  • StorefrontCartService refuses options that fail a type's StorefrontOptionSchema::validate() (a ValidationException) as options-invalid with the schema's first message, as it already did for InvalidArgumentException.
  • AddCartItemRequest::optionRules() exposes the cart's option payload limits, shared by the quote endpoint and GraphQL productQuote: 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's StorefrontOptionSchema instead of being refused.
  • A product type that throws a TypeError on an option's shape (a nested value where it reads a scalar) is refused as options-invalid by the cart and as an invalid quote, instead of erroring.