Skip to main content

Ionic 3 Payment gateway integration(HDFC)

Ionic payment gateway provides a payment transaction by the transfer of information between mobile application and the acquiring bank.
Below are the steps followed to integrate bank payment gateway with ionic3 application:-

Step1:- Install the Cordova and Ionic Native plugins
$ ionic cordova plugin add cordova-plugin-inappbrowser
$ npm install –save @ionic-native/in-app-browser

Step2:- Get the hash key (provides added security to the payment) from server
Step3:-Create html page in WWW folder(redirect.html). This html page should contain an empty form with an id. We use this html page to submit to the payment gateway.
Step4:-From form, load string to html tags, it should be in the format of how we submit to the payment gateway.
 Step5:-Import inappbrowser  to app.module.ts
import { InAppBrowser } from '@ionic-native/in-app-browser';

and include it in @NgModule’s providers array.
Step6:-Import inappbrowser in checkout page and add this in constructor.
constructor(public navCtrl: NavController,private iab: InAppBrowser)

Step7:-Create and show inappbrowser using create method
create(url, target,options);
this.browser = this.iab.create( "redirect.html", "_blank", "EnableViewPortScale=yes,closebuttoncaption=Done"  );
here we are using HTML page created in step3(redirect.html) as the url, which opens the URL in a new inappbrowser instance.
Step8:-Call executeScript with the string created as in Step4.This executeScript injects Javascript code into the inappbrowser window(this is available only when the target is set to ‘_blank’). executeScript() method injects JavaScript in childview.
Step9:- When the executeScript() is called then the events will be fired and inappbrowser gives response to its parent. The events which are fired are,
loadstart- this is fired when the inappbrowser starts to load a URL.
loadstop- this event gets fired when the inappbrowser finished loading a URL.
loaderror- fired when the inappbrowser encounters an error loading a URL.
exit-this event is fired when the inappbrowser window is closed.

Then check for the URL success or failure of loadstop event in the browser parent.

this.browser.on("loadstop").subscribe(
    (event) => {
        //this.close_event = true;
      
        console.log(event);
        if(event.url.includes(“Successful")){
 //write the code here
            this.browser.close();        
        }
        else if(event.url.includes("failure")){
            //your code here
            this.browser.close();
        }
    },
    (err) => {
        console.log("InAppBrowser Loadstop Event Error: " + err);
    }
);

 If the payment succeeds or fails close the browser with command close().
this.browser.close();
Step10:-Reading response from gateway should be handled at server, status can be stored in the localstorage of the application.

Step11:-Redirect the application as required.

Comments

  1. High Risk Gateways provide a best High Risk Merchant Account in India We offer a High Risk Merchant Account at affordable range. High Risk Gateways has been served many genuine business of Merchant Account in India in the past few years.

    ReplyDelete


  2. ePay Global Offers MLM Merchant Account with specialized business and requires the special merchant account . We support the high-risk industries by providing offshore payment solutions.

    ReplyDelete
  3. Helpful blog to learn about Payment integration in Ionic 3. It's working fine.

    Come with your suggestions or ideas in Ionic, A leading Mobile App Development Company in Calgary specially called as Devolve can definitly help you to build your next Ionic project.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. Great explanation about Ionic 3 Payment gateway integration.
    After reading this, I'm damn sure, anyone can do payment gateway integration easily in Ionic 3.

    Jeevitha from Way2Smile (Trusted Mobile App Development Company in Chennai).

    ReplyDelete
  6. Being a renowned and reliable ecommerce payment solution provider for merchants, we offer scalable and tailor-made ecommerce payment solutions with short settlement period and competitive rates. We are also proud of providing 24/7 customer service and technical support for years.

    PaymentAsia

    PaymentAsia

    ReplyDelete
  7. Will you please share the source code ?

    ReplyDelete
  8. Web customers locate the Online Payments framework profoundly useful. They can buy various types of products online to encourage their necessities and wants.

    ReplyDelete
  9. Very good article . wow, awesome post. Really thank you! Great


    photoshoot in andaman

    ReplyDelete

Post a Comment

Popular posts from this blog

Making Cross Enable for webAPI1

Hi All,       I was working on webAPI1 when ever i tried to access that API from other domain it was not working. To fix that issue we have created new class called CrossHandler.cs Below is the code which is present in the CrossHandler.cs  public class CorsHandler : DelegatingHandler     {         const string Origin = "Origin";         const string AccessControlRequestMethod = "Access-Control-Request-Method";         const string AccessControlRequestHeaders = "Access-Control-Request-Headers";         const string AccessControlAllowOrigin = "Access-Control-Allow-Origin";         const string AccessControlAllowMethods = "Access-Control-Allow-Methods";         const string AccessControlAllowHeaders = "Access-Control-Allow-Headers";         protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)         {             bool isCorsRequest =

Ionic 3 Sqllite connection setup

It is too simple thing to set up the local db connection for local storage in ionic. But why am i writing blog for simple thing? Because we make complex with the simple thing only! i myself made complex with this simple thing. To setup the environment for sqllite please fallow  here . Document which will be updated as and when the new version of the Ionic get published.  Document showed the following steps when i referred it. Install the Cordova and Ionic Native plugins: $ ionic cordova plugin add cordova-sqlite-storage $ npm install --save @ionic-native/sqlite Usage import { SQLite, SQLiteObject } from '@ionic-native/sqlite' ; constructor (private sqlite: SQLite) { } ... this .sqlite.create({ name: 'data.db' , location: 'default' }) .then((db: SQLiteObject) => { db.executeSql( 'create table danceMoves(name VARCHAR(32))' , {}) .then(() => console .log( 'Executed SQL' )) .catch(e => console .log(