DEV Community

Ovidio Pérez
Ovidio Pérez

Posted on • Edited on

How to send transactional emails for your Paypal Smart Button

TL;DR

  • Use automation tools like zapier, make, integrately.
  • Use Paypal IPN to send information to the automation tool that you choose.
  • Use and connect mailersend (or other transactional email platform) to the automation tool to send the emails.

Context

I have a client who needed his patients to be able to pay him using credit or debit cards. This client uses paypal in his daily life so it is practical for him that the payments made to him are made through this platform. That way he can pay for what he needs using paypal and at the same time " top up" his balance with patient payments.

The solution? Paypal Smart Button.

I added the Paypal Smart Button on a page of their site and configured it to be a flexible payment (like a donation) since not all patients always pay the same, I also edited the code to apply a validation that prevented entering an amount less than 25$, and also the amount entered is added the commission charged by paypal, that way my client always gets the full amount.

The darkest hours

Now, my crisis moment? That moment was when my client wanted those who paid using that Smart Button to receive a transactional email with some "Thank you for your payment" or "Your payment has been received" type message. My response? "Of course I can do that". Did I know how to do it? Nope, of course not.

But as a developer, it's not an option to just sit back and do nothing, that's when I started to do extensive research. There were many options, create a plugin, use a plugin with a paid extension, "borrow" the code from that paid plugin and make it work the way I needed it to.

Those options required me to know a bit of PHP (I hate php), plus I needed to know how to implement a plugin in wordpress. I also looked into webhooks, I could make it so that when a transaction was made on the Smart Button, it would be saved in the database, then notify the transactional email provider to send the email with the saved information. The last option sounds cool, right? Yes, I know... but it wasn't worth it, not for me at least.

Besides, as far as I know, developing a plugin means maintaining it (you can confirm me in the comments). And this guy over here doesn't want to do that.

So, what did I do?

The Holy Grail

Automation platforms.
theoffice-episode-12-the-office-tv

There are many of these, such as Zapier, Automate.io, Make, Appypie, Integrately, SyncSpider, LeadsBridge, and those are the ones I know about.

Zapier was the one recommended to me, so I started with that one. Result? None, I couldn't use it because the Paypal integration option is paid. But if you want to pay for it, it will probably work for you.

The solution, the salvation, came with Integrately, it's free and I could integrate it with paypal at no extra cost. A win-win situation.

I also found Make interesting, and it allows you to use filters (such as if and else statements) for free.

The road to glory was near.

Ok, I don't have to create a plugin anymore, but now what?

So, the scenario where I created a plugin is out of the question. I found an automation platform, but how does that help me to send the Paypal Smart Button transactional emails?

Simple, paypal has something called IPN (Instant Payment Notification), As the name suggests, it notifies you when you receive payments. How does that integrate with the automation platform? Well, here's where the beloved webhooks come in.

When integrating Integrately with paypal, it gives you a link that you must enter in paypal, so your paypal account when receiving a payment, will send an http request with the payment information to the integrately link.

Here you can see where Integrately gives you the link.
Integrately-page-to-connect-paypal-to-integrately
And here how to add that link to paypal.
Paypal-IPN-Settings

(I won't go into too much detail, but you have an idea how to do that part)

Once I achieved that, and tested it using the Paypal's IPN Simulator, I felt that there was a progress, the long and stressful investigation was bearing fruit.

erik-killmonger-its-beautiful-black-panther

Good, Good but what about the emails?

Welp, that was the easiest part. I used Mailersend. Integrately even gives you a step-by-step on how to connect your Mailersend account.
Integrately-instrucctions-to-connect-mailersend

How did I find Mailsersend? Well, Mailerlite had been recommended to me, while I was researching it I saw that it was practically like Mailchimp and that's not what I needed, but I found Mandrill which is Mailchimp's add-on for transactional emails. But I was not convinced and I found Mailersend (which is like Mandrill but by Mailerlite) while I was reading about Mailerlite.

Once Mailersend is connected to Integrately, you can choose to send a simple email (text only) or send a template. Mailersend offers several pre-made templates that you can edit, and you can use variables in the email so you can use the information that paypal sends you.

And that's all you need to know to send transational emails for your Paypal Smart Button. If you know a better way I would like to read it in the comments. Any feedback is appreciated.

Top comments (0)