Decrement value on current page before routing

Hi I’m trying to change a value on some content on the current page before my page routes. I was wondering if it is possible?

Here’s my code. Im using $page->decrement(‘Quantity’, 1); to change the value.

c::set('routes', array(
array(
'pattern' => c::get('stripe_redirect_to_page'),
'action'  => function() {

  $data = array(
  'stripeAmount' => s::get('stripeAmount')
  );

  $page->decrement('Quantity', 1);

  return array('stripe-checkout-complete', $data);
})
));

$page is not defined, therefore this doesn’t work

What’s the best way to make it point to the current page before it routes? It works when I define the page manually though.

You can pass the page uri as part of the pattern or you save the page uri in the session prior to calling your route.