Problem/Motivation

#3639236 adds OrganizationOwnedInterface and OrganizationOwnedTrait, and orders implement them. Payment methods stay personal: PaymentMethodStorage::loadReusable() filters by uid, and the payment methods page lists the user's own cards.

B2B sites need cards that belong to an organization, so every buyer of that organization can reuse them at checkout.

Proposed resolution

To be designed. Questions to settle first:

  • Ownership or sharing? A card owned by the organization (organization_id on the payment method) and a personal card shared with an organization are different models. commerce_b2b's planned "shared payment methods" points to the second one, which may not need anything in core.
  • Reuse at checkout: loadReusable() would need an organization-aware variant. PaymentEvents::FILTER_PAYMENT_OPTIONS already lets contrib add or remove options per order, so check whether that's enough before adding API.
  • Access: who can view, use and delete an organization card. That's likely a commerce_b2b concern, through access hooks.
  • UI: where organization cards are listed and managed.

If ownership is the chosen model: PaymentMethodInterface extends OrganizationOwnedInterface, PaymentMethod uses the trait, and the field comes from the same install mechanism as orders.

Remaining tasks

  • Decide between ownership and sharing.
  • Implement, with tests.

User interface changes

To be determined, depending on the model.

API changes

If ownership is chosen, PaymentMethodInterface gains the three OrganizationOwnedInterface methods. A custom class that implements it without extending PaymentMethod would need use OrganizationOwnedTrait.

Data model changes

If ownership is chosen, an organization_id base field on payment methods.

Comments

jsacksick created an issue.