# Changelog - Hyvä Checkout - Stripe Integration

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [2.1.0]

### Added

- **Compatibility with Hyvä Checkout 3**

  - Require `hyva-themes/magento2-hyva-checkout:^1.1.2 || ^3.0`. Hyvä Checkout 1.x stays supported.
  - On Hyvä Checkout 3, the Stripe Payment Element and the Express Checkout Element work in the checkout. The
    express buttons on the product page, the cart and the minicart stay inactive: Hyvä Checkout 3 starts Magewire
    on checkout pages only, and starting it on other pages replaces the theme's Alpine.js with Magewire's CSP build.
  - The "My Payment Methods" page in the customer account no longer uses Magewire. It calls the Stripe module's
    REST API instead, so it works with both Hyvä Checkout versions. On Hyvä Checkout 3 it showed an endless
    loading spinner. Its labels and behaviour now match the Stripe module's page: "Add / Update" button,
    "Add or update a payment method" heading, and deleting a card also deletes its duplicates.
  - With Hyvä Checkout 3.0.0, going to the payment step failed with a 500 whenever Stripe's payment module was
    installed. A plugin on the front controller fixes this for Magewire update requests.

### Changed

- The module now loads after `StripeIntegration_Payments` and `Hyva_Checkout`: `etc/module.xml` declared its
  sequence in a form Magento ignores.

### Fixed

- The Stripe card form didn't load with the Payment Element flow (Elements with Checkout Sessions off), and the
  express and cart button templates failed when their location was disabled: Magewire 3 needs the first HTML of
  a component template outside of a condition. Each template now has one root element.
- The Express Checkout Element at the checkout and in the minicart looked up their Magewire components by an id
  Magewire 3 doesn't use. They now use the component's own id.
- Address, shipping method and coupon changes in the checkout failed with a 500 on Magewire 3 while the
  Express Checkout Element was enabled: `dispatchBrowserEvent()` is now called with an empty data array.
- The product page express button registered its Alpine component under a name its `x-data` didn't use.
- The Express Checkout Element at the checkout no longer tries to mount before the payment step's HTML is in
  place, and its validation events carry the step's `route`.
- The payment form didn't load when Stripe was the pre-selected payment method on Hyvä Checkout 3.
- Placing an order with Bank Transfers failed with an empty `payment_method` error.
- Vouchers (Boleto, OXXO, Konbini, Multibanco) and ACH microdeposits now go to the success page after their
  instructions are shown, so the pending payment notice from Stripe Payments 4.7 is displayed.
- After a failed 3D Secure authentication, redirect-based payment methods skipped their redirect, the Express
  Checkout Element disappeared, and paying with it failed with an "already used confirmation token" error.
- Express Checkout at the checkout failed with a "payment method is missing" error when no payment method was
  selected.
- Previous success or error messages are cleared before a new one is shown.
- The "My Payment Methods" link in the customer account sidebar is listed under "Newsletter Subscriptions" instead
  of below "Sign Out".

### Removed

- `Hyva\CheckoutStripe\Magewire\Customer\PaymentMethods`: the "My Payment Methods" page no longer uses Magewire.

## [2.0.19]

### Changed

- **Compatibility with Stripe Payments 4.8**

  - Require `stripe/stripe-payments:~4.8.0`.

## [2.0.18]

### Added

- **Adaptive Pricing / Elements with Checkout Sessions (EwCS) support**

  - When the Stripe Payments module enables Adaptive Pricing
    (`payment/stripe_payments/adaptive_pricing`) — and neither CVC recollection for saved cards nor
    payment line items are enabled — the checkout now renders the embedded **Checkout Elements**
    (Checkout Sessions) flow instead of the legacy confirmation-token Payment Element.
  - The Stripe **Currency Selector** is mounted above the Payment Element when the Checkout Session
    exposes currency options, allowing the customer to pay in their local currency.
  - The Checkout Session is invalidated and re-created when the quote changes (addresses, shipping
    method, coupon/discount, totals).
  - Manual-authentication payment methods (e.g. cards requiring 3D Secure) confirm the Stripe payment
    before the Magento order is placed; all other methods place the order first and confirm
    afterwards, then return to the Stripe return URL.

## [2.0.13]

### Added

- Nothing was added.

### Changed

- **Compatibility with Stripe Payments 4.6**

  - Require `stripe/stripe-payments:~4.6.1`.
  - Load Stripe.js from the `dahlia` channel (`https://js.stripe.com/dahlia/stripe.js`).
  - The standard checkout now tokenizes the Payment Element into a single-use **confirmation token**
    instead of a payment method id + CVC token.
  - Saved payment methods, the "save card" consent checkbox and CVC recollection are now rendered
    inside the Payment Element (via a Stripe customer session). The custom saved-cards selector and
    the standalone CVC Element have been removed.
  - Express Checkout Element wallet-button parameters are now read from `expressCheckoutOptions` and
    passed at element creation time (they were previously read from `resolvePayload`).
  - `elements.update()` is now awaited before resolving Express Checkout Element events.
  - The customer "My Payment Methods" page initializes the Payment Element with the Stripe customer
    session options and saves methods via confirmation tokens.
  - The place-order service no longer depends on the (now factory-created) `PaymentElement`
    singleton to decide whether to redirect. The success-page redirect and the 3DS/redirect client
    secret are derived from the order placement outcome instead, fixing checkouts that completed but
    did not redirect to the success page.

- **Front-end changes**

  - Under the "My Payment Methods" section, the "Save" button is rendered as a primary button.
  - Selecting a payment method radio at the checkout was causing Express Checkout Element to disappear
    and re-initialize, which was unnecessary.
  - The Payment Element at the checkout is now automatically expanded when Stripe is the only
    available payment method.

- **Fixes**

  - Retrying a payment after a failed external redirect would place the order successfully if the
    country had no regions. The fix ensures that another external redirect triggers on the retry.

### Removed

- Legacy dropdown for selecting a saved payment method. Now rendered inside the PaymentElement.

## [1.0.3] - 2024-02-12

### Added

- Nothing was added.

### Changed

- **Fixed a Stripe element not rendering when the wallet button is turn off**

  For more information, please refer to [merge request #14](https://gitlab.hyva.io/hyva-checkout/checkout-integrations/magento2-hyva-checkout-stripe/-/merge_requests/14)

  Many thanks to Jacob Nguyen (JaJuMa GmbH) for the contribution!

- **Fixed throwing an exception after installing strip with no public key**

  For more information, please refer to [merge request #15](https://gitlab.hyva.io/hyva-checkout/checkout-integrations/magento2-hyva-checkout-stripe/-/merge_requests/15)

  Many thanks to Tjitse Efdé (Vendic) for the contribution!

### Removed

- Nothing was removed.

## [1.0.2] - 2023-10-24

[1.0.2]: https://gitlab.hyva.io/hyva-checkout/checkout-integrations/magento2-hyva-checkout-stripe/-/compare/1.0.1...1.0.2

### Added

- Nothing added.

### Changed

- **Return an empty element when the feature is disabled**

  For more information, please refer to [merge request #10](https://gitlab.hyva.io/hyva-checkout/checkout-integrations/magento2-hyva-checkout-stripe/-/merge_requests/10).

- **Moved product page payment button to shortcuts**

  For more information, please refer to [issue #4](https://gitlab.hyva.io/hyva-checkout/checkout-integrations/magento2-hyva-checkout-stripe/-/issues/4).

  Many thanks to Christoph Hendreich (In-session) for the contribution!

- **Fix to check if the cart contains contents before loading the cart payment button**

  For more information, please refer to [issue #5](https://gitlab.hyva.io/hyva-checkout/checkout-integrations/magento2-hyva-checkout-stripe/-/issues/5).

  Many thanks to Christoph Hendreich (In-session) for the contribution!

- **Fix for fetching quote information on initialization**

  For more information, please refer to [merge request #7](https://gitlab.hyva.io/hyva-checkout/checkout-integrations/magento2-hyva-checkout-stripe/-/merge_requests/7).

### Removed

- **Remove layout instructions**

  For more information, please refer to [merge request #9](https://gitlab.hyva.io/hyva-checkout/checkout-integrations/magento2-hyva-checkout-stripe/-/merge_requests/9).

## [1.0.1] - 2023-08-18

[1.0.1]: https://gitlab.hyva.io/hyva-checkout/checkout-integrations/magento2-hyva-checkout-stripe/-/compare/1.0.0...1.0.1

### Added

- Nothing added.

### Changed

- **Use hyva_ prefixed layout handles**

  Previously regular layout handles were used, causing Luma checkouts in the same instance trying to load Magewire.

  For more information, please refer to [issue #2](https://gitlab.hyva.io/hyva-checkout/checkout-integrations/magento2-hyva-checkout-stripe/-/issues/2).

### Removed

- Nothing was removed.

## 1.0.0 - 2023-08-10

### Added

- Initial Release.

### Changed

- Nothing was changed.

### Removed

- Nothing was removed.
