Yoyaku decides what a payment means to a booking, but reads that meaning off a kessai constant. DefaultSettlementSubscriber scopes capture and refund to KIND_PAYMENT, which works for a security deposit and not for a no-show fee: the fee is charged through PaymentManager::chargeToken(), whose kind argument defaults to KIND_PAYMENT, so on the order it settled the fee is indistinguishable from the checkout payment.

The consequence is narrow but real. A captured fee is harmless, because by the time a no-show is charged no line is still held and settlement only ever touches held lines. A refunded fee is not: it reads as a refunded checkout payment, so waiving a fee after the fact would cancel a completed booking.

The fix is not another kessai kind. A deposit and a fee are yoyaku's concepts, and kessai has no business holding a vocabulary for them (see the kessai side, #3614434: Let the caller name a payment's purpose instead of choosing from kessai's two kinds). What yoyaku needs is to label the payments it creates in its own words - the booking, the caution, the no-show fee - and to scope settlement on that label instead of on a payment kind. The label can be a base field yoyaku adds to kessai_payment, the same way it adds its payment fields to the booking entities, so this lands without waiting for anything in kessai.

Two things fall out of doing it this way. A payment yoyaku did not label is the checkout payment, which is the one settlement should answer for, so the default is right for free. And once the label exists, the question "does this money come back" is answered by the payment's state rather than by its kind: a returned caution ends cancelled or refunded, a kept fee ends captured.

Related: refunding an order selects only KIND_PAYMENT captures (refundablePayments()), so a charge-mode caution captured at checkout is never returned. Whether a no-show fee should be refunded along with the booking is a policy question worth settling here, since the label makes it expressible either way.

Issue fork yoyaku-3614433

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: A no-show fee is created as a checkout payment, so refunding one would cancel the order » Yoyaku reads a payment's meaning off a kessai constant instead of labelling its own payments
Issue summary: View changes

mably’s picture

Status: Active » Needs review

  • mably committed 838b6e41 on 1.x
    fix: #3614433 Yoyaku reads a payment's meaning off a kessai constant...
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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.