Ionic: Opening html content in Inapp Browser

2019-05-25 08:51发布

问题:

I'm trying to integrate payment gateway in an Ionic mobile app. I get the HTML code from the server which contains a form with all the post parameters and submit on page load to call the payment gateway.

  1. How can I open the in-app browser with the HTML content?

  2. After the transaction, the payment gateway will call the server URL & process the response. How can I now communicate back to Ionic app to close In-app browser & show the response?

回答1:

Check out the exceuteScript Api of the Cordova In-App-Browser plugin. You should be able to

  1. Add the required HTML to an empty document
  2. Poll the document location for completion of the payment flow

https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-inappbrowser/#inappbrowserexecutescript