Magento 2 Experten — Hyvä Theme, Tailwind CSS & SEO aus einer Hand ›

Testing the Payment and Shipping Method Together in Checkout

Testing the Payment and Shipping Method Together in Checkout

~5 Min. Lesezeit Zuletzt aktualisiert am August 9, 2026

Both building blocks are done individually - chapters 62-65 the payment method, chapters 66-68 the shipping method. Because both operate on the same points balance and book through the same observer, a combined, end-to-end test run pays off before chapter 70 goes through the typical mistakes.

One-time preparation

A new database column (chapter 63), a new data patch (chapter 63), new configuration groups (chapters 64/67) - all of that needs a regular setup upgrade, followed by clearing the config and full page caches:

cd src
bin/magento setup:upgrade
bin/cache-clean config full_page

In the admin under Stores > Configuration > Sales > Payment Methods and Shipping Methods respectively, enable both new building blocks, and assign a test customer a points balance above the configured points_cost (shipping) and enough for at least one test item (payment), either via the console command from chapter 9 (mironsoft:loyalty:recalculate) or directly via SQL.

Test scenario 1: shipping via points only

  1. Add an item to the cart, go to checkout, enter a shipping address.
  2. In the shipping method step, "Free shipping via points" (chapter 67) must appear alongside the regular shipping methods, priced at 0.
  3. Complete the order with a regular payment method.
  4. After completion: the customer's points history (chapters 51/45) must show a new TYPE_REDEEM entry equal to the configured points_cost, with loyalty_points_balance reduced accordingly.

Test scenario 2: points cover the entire order total

  1. Add a cheap test item to the cart whose price is entirely covered by the available points.
  2. In the payment method step, first click "Redeem all points" (chapter 65) - the displayed order total must drop to 0.
  3. Only THEN should "Pay with loyalty points" (chapters 62-64) appear in the payment method list - before that, isAvailable() (chapter 64) correctly returned false.
  4. Complete the order without any real payment gateway being contacted.
  5. Points history: a TYPE_REDEEM entry for the payment, sales_order.loyalty_points_redeemed (chapter 63) correctly populated.

Test scenario 3: both at once

Partially redeem points (payment) AND choose the points-based shipping method (shipping) in the same order. After completion, the points history must show EXACTLY TWO new TYPE_REDEEM entries for the same order_id (chapter 67's bookRedemption(), called twice), and loyalty_points_balance reduced by the sum of both amounts - not just one of the two.

Tipp: The dedicated log channel from chapter 34 (var/log/mironsoft_loyalty.log) is so far only wired into ExpirePoints - RedeemPointsOnOrderPlaced deliberately uses the standard logger channel (exception.log/system.log), just like AwardPointsOnOrderPlaced and ReversePointsOnCreditmemoSave from chapter 34. So for troubleshooting in this chapter:

bin/log mironsoft_loyalty.log

Achtung: A common wrong assumption when testing manually: an empty cart cache (chapter 40, reward catalog) has nothing to do with payment/shipping method visibility - bin/cache-clean config is enough for the system configuration changes from chapters 64/67. If a newly enabled payment or shipping method is still invisible, the cause is almost always one of the traps collected in chapter 70, not a caching problem.

All three scenarios green - block 8 works fully. Chapter 70 wraps up by collecting the mistakes that happen most often while building these nine chapters.