Skip to content

Payments in Hyvä Checkout

The Hyvä Checkout payment integration API provides a framework to implement any payment scenario.

Because every payment method is different, it is not possible to provide simple step-by-step instructions that are always applicable.
How a PSP API can be implemented using the Hyvä Checkout Payment Method API has to be determined in each project individually.

A Hyvä Checkout payment integration is responsible for the front-end user interaction.
It complements the underlying matching Magento Payment Method.

If there is an existing Magento Payment integration for the PSP, much of the backend PHP code can be reused for the Hyvä Checkout integration, for example validating payment tokens or capturing payments via the PSP Web API.
Only the frontend part has to be implemented for Hyvä Checkout.

When a visitor selects a payment method in Hyvä Checkout, it is stored as the selected payment method on the customer quote automatically.
The logic to create the order in Magento is the same that is used with the Luma front-end and can probably be reused.

The Hyvä Checkout payment component's responsibility is to gather the required data for the payment.
As described above, this will be some interaction with a PSP that results in a payment authorization token.
The actual capture then happens via a Magento Payment Method.

Payment methods differ in terms of responsibilities compared to Luma

Understanding the difference between payment method responsibilities in Luma and in Hyvä Checkout is crucial.

In the Luma checkout, payment methods are responsible for order placement, which forced payment data to be collected on the last step.
However, Hyvä Checkout offers greater flexibility, allowing other steps to be configured to be after the payment step.
A 'Place Order Service' is responsible for placing the order, allowing the payment step to be positioned freely throughout the checkout process.

Hyvä Checkout allows the creation of payment integrations mainly using JavaScript or mainly using PHP, or a mixture of both.
The former can be useful if the PSP provides an SDK, which most of the time happens to be JavaScript, but it also depends on the preference of the developer building the payment method.

The Hyvä API consists of hook methods, that will be called automatically at the appropriate time if they are implemented by a payment method.

From a very high-level point of view, the steps are as follows:

  1. register the payment method in the checkout
  2. implement the template
  3. implement the required hook methods
  4. set the gathered payment data on the Magento payment method
  5. place the order
  6. profit