Handle response data from a payment gateway

Running Meteor with Angular2.

I’m integrating Moneris Hosted Paypage (mandatory). On my checkout component html I perform a form post which flows to the Moneris Payment page. Once the transaction is complete or fails Moneris builds a response and sends it back in a POST.

Any suggestions on how I can handle response data?

@vigorwebsolutions Wow thanks! I’ll have a look at these. Are these two packages used together or separately? Have you had any experiences with these packages?


I’ve been using picker for over a year. I think it’s probably less complicated, especially if you’re used to flow router. Stable but not maintained.

I think most would recommend restivus, as it’s maintained and more robust.

1 Like

So if the Moneris gateway sends a response as a POST back to https://mysite.com/handleresponse, then Picker.router will process this and then I can do things with the response data returned in the POST?

For example:

Picker.route( '/handleresponse', function( params, request, response, next ) {
  // Handle our request and response here.

Where would this code reside? Do you have a particular directory structure/naming convention you follow?

It needs to be on the server side – I’d recommend either the /server folder, which is automatically loaded, or as an import in a server startup call.

I typically don’t have a ton of server-side routes, so I group them together in one file and just import/call the methods and functions as needed.

@vigorwebsolutions Would you happen to know how I can import the Picker package into my ts file? I’m getting a “Cannot find name ‘Picker’.” error.

Are you using the atmosphere package? If so, you wouldn’t need to import anything as the package makes Picker a global.

Yes I am. It shows up in my .meteor/packages file as well.


So despite the TS grumblings, I’m receiving responses.
Based on the link above (thanks @a.com), here’s the basic template I have:

var bodyParser = Npm.require('body-parser');
Picker.middleware(bodyParser.urlencoded({extended: false}));

// Define our routes.
Picker.route('/api/webhooks/:provider', function ({provider}, request, response) {
  // Now we have access to request.body!
  console.log("Request body " + request.body);
  console.log("Params " + provider.params);
  if (request.body.message) {
    console.log("request body message " + request.body.message);

Using Postman to send a POST to http://localhost:3000/api/webhooks/test I get the following console logs:

I20170131-14:05:48.780(-5)? Request body [object Object]
I20170131-14:05:48.780(-5)? Parmas undefined

And Postman receives a “Failed”.

In Postman I’ve tried adding data to the body of the message and makes no difference.

hmm… the example uses stripe subscriptions. I’d have to do a comparison of your api vs stripes to see where the difference is…

and you have a server running? did you try to the tool mentioned at the bottom of the article?

Shouldn’t the body parser have parsed out any of the data passed from Postman?
I was waiting to build out the webhooks until I’m able to confirm I’m retrieving the request body message.
Am I missing something?

So I’ve made some progress and I’m able to parse the data from the request body. Does anyone know how I might go about routing to a new view to render the information i.e. a receipt page or a denial page?