Merx

Hooks

Hooks can be useful if you want to send confirmation emails, generate PDFs 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
    }
  ],
];

stripe-hooks

Since Merx 1.9

This hook is only triggered, when you implemented Stripe Webhooks.

Merx uses this hook to set paidDate and paymentComplete for payments with delayed notification of payment success.

site/config/config.php

return [
  'hooks' => [
    'ww.merx.stripe-hooks' => function ($stripeEvent) {
      // your code here
    }
  ],
];