bheki
bheki

Reputation: 31

How do you go back to a Flutter app from a Web payment gateway

I am developing a Flutter mobile application with a payment Screen. I must use an internet payment gateway (provided by the bank's IPG page). After customer presses the PAYMENT button on the gateway web page, control must come back to the the Flutter App PaymentResultScreen. I call the bank URL using WebView. code on WebView:

static String testHtmlString = '''
<form action="https://www.mybank.com/eng/payments" method="post">
  <input type="hidden" name="merchant_id" value="2481000974560100">
  <input type="hidden" name="merchant_key" value="4sl4o153ihep1m7sdf6f0c5h781ad84j">
  <input type="hidden" name="return_url" value="https://www.example.com/result">
  <input type="hidden" name="cancel_url" value="https://www.example.com/cancel">
  <input type="hidden" name="notify_url" value="https://www.example.com/notify">
  <input type="hidden" name="amount" value="100.00">
  <input type="hidden" name="item_name" value="Test Product">
  <input type="submit" value="PAY NOW">
</form>
''';

Problem/s:

  1. I don't know what must must go to return_url
  2. What must the app PaymentResultScreen have to map/link to what is stated in the return-url
  3. How to invoke my-app to show the PaymentResultScreen.

N.B Still new to flutter.

I have tired the html package

Upvotes: 1

Views: 85

Answers (1)

adinas
adinas

Reputation: 4550

You can put any URL you want. Let's use what you have in your example (it does not matter if this URL exists since we will catch the request to go to it and do something else)

onNavigationRequest: (NavigationRequest request) {
        if (request.url.startsWith('https://www.example.com/result')) {
          Navigator.pushNamed(context, '/PaymentResultPage');
        }
       if (request.url.startsWith('https://www.example.com/cancel')) {
          Navigator.pushNamed(context, '/PaymentCancelPage');
        }
        return NavigationDecision.navigate;
      },

Upvotes: 0

Related Questions