Merx

Hooks

Hooks can be useful if you want to send confirmation emails or log certain events.

initializePayment:before

site/config.php

return [
  'hooks' => [
    'ww.merx.initializePayment:before' => function ($data, $cart) {
      // your code goes here
    },
  ],
];

initializePayment:after

site/config.php

return [
  'hooks' => [
    'ww.merx.initializePayment:after' => function ($virtualOrderPage, $redirect) {
      // your code goes here
    },
  ],
];

Be careful! Updating $virtualOrderPage does not have any effect.

completePayment:before

site/config.php

return [
  'hooks' => [
    'ww.merx.completePayment:before' => function ($virtualOrderPage, $gateway, $data) {
      // your code goes here
    },
  ],
];

completePayment:after

site/config.php

return [
  'hooks' => [
    'ww.merx.completePayment:after' => function ($orderPage) {
      // your code goes here
    },
  ],
];

cart

Since Merx 1.1

The cart hook is executed on Cart::_construct().
You can find an example in the Shipping Costs and Discounts cookbook.

site/config/config.php

return [
  'hooks' => [
    'ww.merx.cart' => function ($cart) {
      // manipulate cart here
    }
  ],
];