PayTm integration with ionic3

Hi ,
I was integrate paytm to my ionic application . i have some error to redirect to the paytm server.

var headers = new Headers();

headers.append("Accept", 'application/json');

headers.append('Content-Type', 'application/json' );

let postData = {

"MID":"XXXXXXXXXX",

"ORDER_ID" :"ORDERVK002",

"CUST_ID":"10000988111",

"TXN_AMOUNT":"1",

"CHANNEL_ID":"WAP",

"INDUSTRY_TYPE_ID" :"Retail",

"WEBSITE":"APP_STAGING",

"CHECKSUMHASH":"EnUKKBreoyyh0fBcHo4FGk4iVJfDylyeJgo6W9LzHMFRuGDyl4+Pp6ZztOJK+6vwwymScNEyUd++V3IYtEvRouYWOA+Mp6bPbFG2YjEKU3k=",

"MOBILE_NO":"98655XXXX",

"EMAIL":"XXXXX@gmail.com"

}

this.http.post("https://securegw-stage.paytm.in/theia/processTransaction",
 postData, {headers:headers})
.subscribe( res =>
console.log(res));
}
``


i was run that code i am getting below error response 

Failed to load resource: the server responded with a status of 403 (Forbidden)
(index):1 Failed to load https://securegw-stage.paytm.in/theia/processTransaction: Response for preflight does not have HTTP ok status.

vendor.js:1823 ERROR Response

how to resolve this issue , 
                     Thankyou

for PayTm you have to send the exact same variables which was passed to create the checksum.
Are you getting lost in space issue?

Yes i’m getting lost in space issue . but the api will working fine in postman. but not working in integrate to app .

getting this type of error

Failed to load resource: the server responded with a status of 403 (Forbidden)
(index):1 Failed to load https://securegw-stage.paytm.in/theia/processTransaction: Response for preflight does not have HTTP ok status.

I can pay normally if I use it.

Thank you for Your Reply. i will check .

1 Like

Is that work or not ?

Hi,

I am also doing with inappbrowser, I am able to pay , but how to get the response from callback url to check whether the transaction is success or not.

@naveenkattimani
You give him a callback address for the parameter, then when you start the callback, you close the inappbrowser itself, and then you handle the rest.
image

Thanks yuhai, it’s working now

@naveenkattimani
Hi i am facing some issue while trying to integrate paytm to my app. can you share your code so that i can implement it same.
It would be very helpful to me.
Thanks and Best Regard

Hey,
I am unable to load html file into inAppBrowser.,It’s rendering only base64 form string.
Please suggest me how should i handle it.
I will appreciate your suggestion.
Thanks.

paytmpage(chcksum,ordertimeStamp)
{
chcksum=chcksum.replace(/+/g,"%2B");
var transferdata=“MID=xxxxxxxxxxxxxxx&”
transferdata=transferdata+“ORDER_ID=”+ordertimeStamp+"&"
transferdata=transferdata+“CUST_ID=88667677778788&”
transferdata=transferdata+“INDUSTRY_TYPE_ID=Retail&”
transferdata=transferdata+“CHANNEL_ID=WAP&”
transferdata=transferdata+“TXN_AMOUNT=“75”
transferdata=transferdata+“WEBSITE=APPSTAGING&”
transferdata=transferdata+“CALLBACK_URL=https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=”+ordertimeStamp+”&"
transferdata=transferdata+“CHECKSUMHASH=”+ chcksum;
const bb = this.iab.create(“https://securegw-stage.paytm.in/theia/processTransaction?"+transferdata,"_blank”,‘location=no’)
bb.on(“loadstart”)
.subscribe((ev: InAppBrowserEvent) => {
if(ev.url == “https://securegw-stage.paytm.in/theia/paytmCallback?ORDER_ID=”+ordertimeStamp){
console.log("----------------payment sucess");
loading.present();
bb.close();
var txnchecksum = ‘https://xxxxxxxxxxxxxxx/TxnStatus?’;
txnchecksum=txnchecksum+“ORDER_ID=”+ordertimeStamp+"&"
this.Http.post(txnchecksum, ‘’,’’)
.then(data => {
var respdata=data.data;
var myvar=setTimeout(() => {
loading.dismiss();
}, 4000);
if (respdata.indexOf(“STATUS=TXN_SUCCESS”)>-1)
{

               this.navCtrl.push(suucesspage);
             }
             if (respdata.indexOf("STATUS=TXN_FAILURE")>-1)
             {
               //do something
             }                
           })

           
         }
     }), error => {
               console.log(error);
             };

}

1 Like

Thanks for replying me.
But
let chcksum = checkSum.replace(/+/g, “%2B”);
not allowing me to run my app as i m getting .
Module parse failed: Error parsing regular expression: Invalid regular expression: /+/: Nothing to repeat (84:54)
You may need an appropriate loader to handle this file type.

above code is for typescript. you can check this link for this error https://stackoverflow.com/questions/6288181/javascript-regex-nothing-to-repeat-error

You turn your writing into demo and put it on git. Let me see.

Hi Naveen
Do you have any idea to integrate the paytm in ionic 3 or ionic 4, will please share the links or any documentation

can you please share you working code it will be really helpful for us to understand the process and what we doing wrong.

This helped me, thanks!

can you tell me how to generate CHECKSUMHASH key?