Reputation: 109
I'm currently working on e-commerce based website for our country.I need to integrate a local payment gateway solution. The architecture of that system is actually to based on REST. so I need to post
several data to a specific url
and they response
back with a content
of another url
where my app should be redirected. After the transaction either success/failed/canceled, the third party system redirects back to my app url.
now I'm having problem with redirecting to the third-party url
from my app.
var result = HTTP.post(url,{params:data_me});
console.log(result.content+' ....');
The post
method is synchronous and i recieve the url properly. how do I now redirect my app to their response url.
Note: these statements are written in a server method. And I'm using iron router for my app.
Upvotes: 0
Views: 230
Reputation: 6173
You can use location.href
in client side code, better put it under onRendered
location.href="http://example.com"
or use iron-router
's Router to write redirect header in server side
Router.route('/myurl', function () {
//do sth
var url = "http://example.com"
this.response.writeHead(302, {
'Location': url
});
this.response.end();
}, {
where: 'server'
});
Upvotes: 1
Reputation: 20227
Since you're doing the integration on the server, have the server method return the new url
to the client. Then on the client simply do:
window.location=url;
iron-router won't take you to an offsite url because it only manages internal routes.
Upvotes: 0