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 aPaymentQuerynaming 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\PaymentClientInterfacerather 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 aPaymentRequest, and the thing being paid for is named withPaymentSubject.
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
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
Comment #2
mably commentedComment #4
mably commentedComment #5
mably commentedComment #7
mably commented