Problem/Motivation

yoyaku wrote queries against kessai_payment by hand in nine places: the payments taken for an order, the one carrying a stored token, the held guarantees, the refundable captures, whether a checkout took any money, which other orders share a payer's token, and the purge when an order is deleted.

Those are another project's rows. They can only be read by a yoyaku sharing kessai's database, they go wrong the moment kessai changes how it stores a payment, and the delete left each payment's claims, refunds and reversals behind - records of money nobody can read any more.

The reason they existed is that kessai's contract could create a payment and settle it, and could not find one.

Proposed resolution

Kessai answers all nine now, so ask it.

  • Every lookup goes through findPayments(), each with a PaymentQuery naming what it wants: the order as the subject, the kind and the states, a token exactly or at all. The narrowing that is not kessai's business stays here - whether a balance is left to refund, and taking the first of what comes back, which is the most recent because the finder says so.
  • The order's payments are deleted through the contract, which takes their claims, refunds and reversals with them.
  • The payment client is injected as Drupal\kessai\PaymentClientInterface rather than fetched by service id. A client bound in the engine's place is bound to the interface, and a caller naming the service id walks straight past it.
  • The dependency is the contract, kessai:kessai, not the engine. Which module settles a site's payments is the site's decision.
  • The request and the subject are values. create() takes a PaymentRequest, and the thing being paid for is named with PaymentSubject.

What is left is yoyaku_payment_views, which joins kessai_payment to an order in Views data. That is a join in a database and only ever works in one, so it stays as it is.

Remaining tasks

None. Depends on kessai !79 and orchestra !498, both merged.

User interface changes

None.

API changes

TransactionPayments::getPaymentIds() becomes ::getPayments() and answers with payments rather than ids. The class is this project's own.

Data model changes

None.

AI-Generated: Yes (Claude Code was used to help produce this change.)

Issue fork yoyaku-3623038

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

mably’s picture

Title: Follow kessai's move of the consumer contract into kessai_api » Follow kessai's split: the engine's types are Drupal\kessai_engine now
Issue summary: View changes

mably’s picture

Status: Active » Needs review
mably’s picture

Title: Follow kessai's split: the engine's types are Drupal\kessai_engine now » Ask kessai for its payments instead of querying its tables
Issue summary: View changes

  • mably committed f15f20db on 1.x
    task: #3623038 Follow kessai's split: the engine's types are Drupal\...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.