GoPay and Phoenix LiveView - is it possible to do in LiveViews or only dead views?

Originally sent in Elixir Chat
Piye

Hi, does anybody have experience with implementing GoPay in a Phoenix LiveView? Here are docs for their inline payment gate way GoPay REST API Any experienced Elixir/Phoenix users who could skim through the page and let me know whether it will be possible to do in LiveViews or only on dead view pages in Phoenix?

JohnnyCurran

You can make HTTP requests whether or not you use a "dead" view or a regular LiveView. Doesn't make a difference

Piye

So, it shouldn't be a problem? They say you have to have https (SSL certificate) which I have, but I am not sure how the web socket thing of liveview will mess with it and the response after payment when returning back to my website after a successful payment.

I am using nginx for proxy and certificate handling.

Here is their demo payment gateway: GoShop

Try with some fake email, like info@example.com and after clicking on Continue it should open in an overview layer.

The question is whether the integration will be possible on Phoenix LiveView pages or there is some catch.

Based off my quick skim through, I don’t think there’s anything that would prevent you using LiveView mechanically. The real nuance is when you make the calls as the calls themselves are quite simple.

  1. When do you make the Oauth2 call?
  2. When do you get the gw_url URL as part of /api/payments/payment?
  3. Will rendering the form with the gw_url work as intended?

As for the redirects themselves, I don’t think you can control that, but you could experiment with providing a notification endpoint that broadcasts something that your LiveView could indirectly listen to.

The inline bit should work as intended; once your LiveView decides to render the script tag with the embed.js src, it should just kick in and the control should be driven by the iframe. However, you also might need to add a phx-ignore attribute to ensure that the form that you’ve rendered doesn’t react to any change as it might have unforeseen consequences.

2 Likes