Repository navigation
Immutable
release. Only release title and notes can be modified.
Payment gateways that share one provider webhook endpoint can settle their
siblings' checkouts, providers can record refunds and payment failures they
made on their own, and API storefronts can pass gateway payment options when
they open a payment session. Marketing notifications now need the
customer's marketing consent.
Added
Contracts\SharesWebhookEndpoint(optional, on aPaymentGateway):webhookGatewayKeys()lists the gateway keys whose sessions a gateway's webhooks report on, so one provider endpoint (such aswebhooks/paypal) can settle checkouts made through its sibling gateways (paypal-card,paypal-apple-pay, …). Declared keys that aren't registered inPaymentGatewayRegistryare dropped, and the gateway's own key is always included (#207).PaymentReconciler::webhookGatewayKeys( $gatewayKey ): the key set a reported outcome may settle (#207).RefundService::recordProviderRefund( $order, $amount, $gatewayReference, $reason, $issuedRefundId )records a refund the payment provider already made, such as a dashboard refund reported by webhook, without calling the gateway. It writes asucceededamount-only refund, updates the order's refunded total andpayment_status, writes anorder.refundedtimeline entry withsource: provider, and firesap.ecommerce.payment.refunded/ap.ecommerce.order.refundedand thePaymentRefunded/OrderRefundedevents. It is idempotent ongateway_reference, and on$issuedRefundId(the engine refund id the provider echoes back), which also matches a refund the store issued that is still pending (#209). A refund the store issued that was markedfailed(the gateway call errored or timed out) is settled when the provider reports it completed and echoes back its id: the same guards apply, its restock lines are restocked, and the order's totals,payment_statusand timeline (settled_failed_refund: true) are updated as for a refund that succeeded the first time. When the provider's amount differs, arefund.amount_mismatchentry is written andRefundNotAllowedExceptionis thrown.PaymentGatewayContractTestchecks that a gateway implementingSharesWebhookEndpointlists its own key and that every key it lists is registered; the check is skipped for other gateways (#207).Contracts\AcceptsPaymentOptions(optional, on aPaymentGateway):paymentOptionRules( $cart )andpaymentOptionsChanged( $cart, $session, $options )let API storefronts send gateway-specific choices, such as saving a payment method or paying with a saved one, when they create a payment session.POST checkout/{cart}/sessionand the GraphQLcreatePaymentSessionmutation acceptpayment_options.CheckoutService::createPaymentSession()validates them against the gateway's rules, refuses unknown keys and invalid values (payment-options-invalid, 422), passes the validated keys to the gateway as$context['payment_options'], and reuses the cart's session only while the gateway says it matches them.PaymentGatewayContractTestchecks the rules of gateways that implement the contract (#211).PaymentOrchestrator::recordProviderPaymentFailure( $order, $captureReference, $code, $message )records that the provider failed a payment the store already counted as paid, such as a pending capture it later denied. Apaidorder with nothing refunded moves topayment_status = failed,meta.payment.capture_failurerecords the reference, code and time, apayment.capture_failedtimeline entry is written withsource: provider, andap.ecommerce.payment.failedandPaymentFailedfire after commit (a throwing listener is reported, not rethrown). It does nothing for a refunded order or a different capture reference, and leaves the order's status, stock and deliverables to store policy.Refund::settleFailedAsSucceeded( $gatewayReference ): the one change a failed refund allows, used when the provider reports it completed.NotificationPreferenceService::withdrawMarketing( $customer )andNotificationPreferenceService::CATEGORY_MARKETING.PaymentGatewayContractTest::paymentOptionsCart(): satellites whose gateway only returns payment-option rules for some carts (a signed-in owner's, say) override it so their rules are checked.
Changed
PaymentReconciler(webhooks throughJobs\ReconcilePaymentSession, andecommerce:reconcile-payments) matches carts and pending orders on that key set. When a reference matches more than one checkout, the most recently updated one is settled and a warning is logged to theecommercechannel.PaymentReconcilertakes an optionalPaymentGatewayRegistryconstructor argument. Gateways without the contract behave as before (#207).
Fixed
- Marketing notifications need the customer's marketing consent (#194). A stored preference can turn marketing off but no longer on without
accepts_marketing;NotificationPreferenceService::update()refuses to turn marketing on without consent (PATCH me/notification-preferencesanswers 422), and withdrawing consent (throughPATCH meor the adminPATCH customers/{id}) stores marketing off on every channel.