androidweb-serviceswebviewonlinebanking

Android: Retrive payment information from receipt page of my website


I'm going to extend my website and develop an android application for it. I used payment gateway of a local bank for shopping inside my site and The flow of bank payment in simple word is as follows:

Step 1- I call bank payment page with required fields like merchant id, amount of payment and some other stuff like token and etc. My call would be like this:

http://bank/ebanking/payment?merchant_id=123&amount=1000&token=327tgfdshy

Step 2- If payment is successful, bank calls a page of my site and post payment results like payment reference number ,payment status code and etc like this:

http://mysite/payment/receiptPage?reference_number=74etgfg&status_code=1&...

Step 3- I process information posted by bank to receiptPage and follow internal shopping process.

However my problem in android is that calling bank payment gateway is only allowed from static ip of my website, so I should do step 1 using webview that loads my site and then my site server call http://bank/ebanking/payment and pass information to bank payment gateway. Here user can fill his/her card information inside webview of android.

My problem is how can I understand result of payment in android? Since information are posted to my website page i.e. http://mysite/payment/receiptPage and inside android webview I only see the receipt page which shows payment receipt as usual. Are there any methods to link webview, receipt page of my site and internal java codes of android application?

It comes to my mind when I detected that there is redirect to my receipt page, I close the webview and retrieve payment information inside android using a web-service provided by my site inside my site however it makes situation a bit complicated. I want know are there any other technical methods available for this case?


Solution

  • You could use the javascript interface option.

    Check the "Binding JavaScript code to Android code" https://developer.android.com/guide/webapps/webview.html

    In short: you can call java methods in your android app from javascript and send json parameters to it.

    So you could send your payment receipt data to your android app and do whatever you wish from there.