Skip to content

Comments

WA-NEW-006: Fix Payment#complete? to treat zero authorization as incomplete#630

Open
kitcommerce wants to merge 6 commits intonextfrom
wa-new-006-payment-complete-zero-amount
Open

WA-NEW-006: Fix Payment#complete? to treat zero authorization as incomplete#630
kitcommerce wants to merge 6 commits intonextfrom
wa-new-006-payment-complete-zero-amount

Conversation

@kitcommerce
Copy link

Summary

Fix Payment#complete? to return false when the credit card amount is zero (non-authorizing), preventing invalid orders from being placed.

Closes #629

Client impact

None expected. Internal fix to checkout logic — no public API changes.

Verify

bundle exec ruby -Icore/test core/test/models/workarea/checkout/steps/payment_test.rb

Note

This branch also includes earlier stabilization commits (WA-NEW-002 through WA-NEW-005) that have not yet been merged to next. Those should ideally land first or be reviewed as part of this stack.

@kitcommerce
Copy link
Author

Heads up: this PR was unstacked/rewritten as part of #637.

I extracted the earlier commits into separate PRs (#651, #646, #647, #648, #649) and force-pushed this branch so it now contains only the WA-NEW-006 commit.

If you had this branch checked out locally, you will need to re-fetch/reset.

Jason Hill added 6 commits February 20, 2026 14:17
…(ES7)

The use_dis_max parameter was removed from the Elasticsearch query_string
query in ES7. It caused a 400 parsing_exception:
  [query_string] query does not support [use_dis_max]

In ES7 the equivalent behavior is achieved via tie_breaker (default 0.0
gives pure dis_max scoring). Where tie_breaker was already present (product
search) only use_dis_max was removed; where it was absent (admin index search,
help search) removing the flag restores the ES7 default (tie_breaker=0).

Files changed:
- core/app/queries/workarea/search/admin_index_search.rb
- core/app/queries/workarea/search/help_search.rb
- core/app/queries/workarea/search/product_search.rb
…uthorizations

Two interrelated fixes:

1. Pricing::Request#save_order — Mongoid 7 as_document returns nested
   BSON::Document values (e.g. Money fields) that update_attributes!
   cannot properly deserialize. Using as_json performs a deep, recursive
   JSON-safe conversion so Money totals are correctly persisted after
   pricing runs. Also switch reverse_merge to use string key 'items'
   (not symbol) to avoid creating duplicate symbol/string key pairs.

2. Checkout::Steps::Payment#complete? — add credit_card_authorizable?
   guard: if a credit card tender is present its amount must be positive.
   A zero-amount credit card results in a no-op authorization and must
   not allow an order to proceed to placement. This is a defensive check
   on top of the purchasable? amount comparison.

Fixes: payment_test.rb test_complete? refute at line 95
Verified: payment_test, checkout_test, pricing/request_test all green
@kitcommerce kitcommerce force-pushed the wa-new-006-payment-complete-zero-amount branch from 8f991bc to 31b767f Compare February 20, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant