Following a hyperlink from an event

Hi,

I’m trying to implement Gov.UK Pay and when running the API I get a next_url for payments. Currently I can only follow it after saving it to a link then clicking on it. Is there a way to follow the URL straight up (I have a return URL so I can already get back to Netcall). I have tried window in code studio event actions but it’s coming out as undefined

Thanks
Robin

Hi. Try

cs.redirect(url);

in a Code Studio event action instead. You will need to ensure that the rule which triggers the action is not set to run in the background.

For reference the “window” class will not be available in Event Actions as the code is run server-side rather than in your browser. The same applies for any other browser specific features, including the DOM.

1 Like

Hey Bob,
Tried that in 2 different ways

var n_url = params.custom.next_url;

cs.redirect(n_url);

then

cs.redirect(‘https://www.payments.service.gov.uk/secure/3e12ff00-83b3-43a7-9372-14f9bb202580’);

neither worked

the examples seemed to imply you use a reference which can’t get an external page.

Apologies, it appears cs.redirect() is only for other pages within the app, not external URLs.

Another option would be to create a Presenter in Code Studio, which just displays the link, but you can then have frontend JS code that runs in the browser that automatically redirects you to that link when shown. So it could be shown like you often see on other payment pages:

Please click this link if not redirected in 5 seconds…
https://www.payments.service.gov.uk/secure/3e12ff00-83b3-43a7-9372-14f9bb202580

Morning Robin,

We have an operational Gov UK Pay integration working in a Citizen Hub Environment as part of a Bulky Waste application.

We are looking to document and convert this into a Module which will be shared on AppShare in the near future.

If you have any further questions please let me know.