Using PayPal in Meteor

Same here. :slight_smile:
(need some more characters)

@aadams: Did you get it running in the end?

@marc2, indeed I did.

Waiting a guide too :smiley:

Hey I’ve posted my working solutions in my blog regarding using Paypal and its IPN in Meteor to take one-time payments and subscriptions:
http://lyt-tech.com/payments-with-paypal-ipn-and-meteor/

It’s not a comprehensive guide but it’s a good sample of code of my working solution. If anyone need extra help I’d be happy to lend a hand, email me at lytstephen@gmail.com

1 Like

Here’s a quick guide I just published:

2 Likes

Sounds great, thanks!

Thanks for the blog @lytstephen! Very useful!

After switching from Iron Router to Picker, my solution here no longer worked. But this post on SO has the answer if you’re using Picker & IR.

You can also use planefy:paypal-ipn-listener package which eliminates a lot of the boilerplate and makes it super easy to handle incoming ipns.

(Disclosure: I am the package author and the author of the SO answer you linked to above)

2 Likes

Reading your readme, I see you’re using ngrok! I was having issues all day yesterday with until I figured out independently that I could use ngrok (basically a proxy to localhost) to get past the paypal restrictions.

I’m using a PayPal buy button, so I had to modify the url to point to the proxy. Then I put meteor in debug mode – allowing me to debug the issue locally. The alternative is trying to debug remotely – which slows things down considerably.

I’m a little confused by your instructions, will you provide an example of using your package with a Picker.route?

Thank you!

This package uses Picker under the hood,so you do not need to explicitly define a Picker route.

To set up, all you need to do is (1) define your listener, (2) define your onVerified hooks, and (3) define your onError hooks.

// define your listener
const listener = new IpnListener({ 
   path: '/ipn',  // 
   allow_sandbox: true // optional, defaults to false
   host: 'http://<your_ngrok_tunnel>/' // optional, defaults to Meteor.absoluteUrl(). only necessary if you want the listener.url() to return your ngrok tunnell
});

// define your onVerified hooks
// this will only be run if the IPN has been verified.  So no need to do verification yourself.
// But you may wish to inspect other properties of IPN to to determine how to proceed (e.g. ipn.status)
listener.onVerified((err, ipn) => console.log(ipn));

// This will be triggered if the IPN couldn't be verified with PayPal
listener.onError((err, ipn) => console.log(err, ipn));

You can cal listener.onVerified and listener.onError multiple times to register multiple callbacks

Hope that is clear. let me know if you have any questions.

2 Likes

Thank you @mcb, I’ll give it a try.

Just curious, I’ve already got your other code (from SO) working last night; is there an advantage to using this new abstraction?

Also, thanks for abstracting this out for us, I’m sure this will help many.

Thanks for taking a look. I guess the main benefits are (1) more declarative way of defining your listener (2) handles IPN verification out of the box, (3) ability to define multiple hooks (4) helpers for testing your listener like listener.post() function

2 Likes