Currently payment entites don't allow other modules to react on a recently saved payment object with the line items and status items already saved. All hooks are invoked by EntityAPIController::save() which is called before the those database items are created.

This means there is currently no sane way to extend line items or status items with custom data.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

torotil created an issue. See original summary.

torotil’s picture

Here is a patch that fixes this by …

  • Moving the code for saving line items into a separate method in PaymentEntityController
  • Using hook_payment_update() and hook_payment_insert() to call this new method
  • Use hook_module_implements_alter() to ensure that payment’s own implementations of those hooks are called first.
torotil’s picture

Status: Needs review » Fixed

Tests pass locally and I don’t want to wait until tests pass as the testbot seems to be broken #2944458: payment-7.x-1.x tests started failing without change in the branch.

  • torotil committed c06a8d2 on 7.x-1.x
    Issue #2867820 by torotil: entity hooks invoked before line items and...

Status: Fixed » Closed (fixed)

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