Over the past couple of months, we have been working to build a few automation pieces for the Internet Freedom Foundation’s donation processing systems especially for the recurring giving program i.e. the IFF memberships. We are reaching towards the final few steps of this project and ready to tell the larger Internet Freedom community about this.
For some context, all our membership payments happen through Razorpay (Payment Gateway). Until recently we only had a provision to create recurring subscriptions for a limited number of Credit Cards, this changed when Razorpay started supporting e-Mandate. E-Mandate is a new payment service that allows anyone with a bank account/debit card to easily automate recurring payments. However, unlike the credit card based subscription, the recurring payment had to be deducted manually every month from the Razorpay dashboard, which is a time-consuming and quite likely a more error prone process. You can find more information on E-Mandate here.
Kickstarting The Project
In April, the IFF team started to look for ways to find a system for sending welcome emails, generating 80G certificates without much human intervention if at all any, the platform we found the best for this was ERPNext. It is a popular FOSS(Free and open-source software) product, built by Frappe Technologies in Mumbai. A conversation started with the Frappe team, and they agreed to volunteer for this project. ERPNext already had a Non Profit Module which we would use to keep track of our membership payments and more. Over the next few months, we migrated our members’ list to ERPNext, Shivam from the Frappe team wrote custom endpoints that were triggered by the Razorpay webhooks when any new subscription payment was made. This was a relatively painless process, with only a few hiccups coming our way. All the new features were added to the ERPNext codebase directly, ensuring that any other non-profit can take full benefit of this.
Time for an E-Mandate
The next piece was getting E-Mandate up and running. The team (@TheJoker, @farkhanda, @karthik, @shivam and @Shivani) started to carry this project forward. The next couple of months involved a lot of calls within the team, calls with the Razorpay integration team and quite a few experiments. The Razorpay documentation for this particular feature was a bit confusing to begin with, (which is unlike their other products), however a call with their integration team did solve all our doubts. We did quite a bit of sprinting between documentation pages to figure the exact flow of the payments, but once it all came together we were able to write the pieces for this code. We are extremely grateful to the RazorPay team for this product, it has the potential to be a boon for the nonprofit sector.
The following is the e-mandate flow marked E1, E2, E3 in the diagram
- Member details are sent to E Mandate Lambda
- The lambda calls Razorpay with the details, which generates a token and returns it back, which is sent to ERPNext and the IFF Website to trigger payment
- Once the token is received we pass it along with the generated customer ID to ERPNext which stores the details for future use
- The token has to be confirmed by the bank, which takes a while to process, when it is confirmed a web hook is triggered which ERPNext listens to, and updates the token status in it’s database
- Following this, every subsequent month, depending on the plan the member is on, the payment is triggered via Razorpay API from ERPNext
We put this system in place, after a few weeks of testing we finally are live with E-Mandate payments on our donate page, which essentially means that we have been able to fully automate the recurring payments through E-Mandate and will be able to sign-up members through NetBanking and Debit Cards.
We started working on this custom integration using e-mandate mainly because Razorpay does not natively support inbuilt-scheduling for e-mandate based recurring payments.
On July 23rd Razorpay announced UPI Autopay, which offers features like inbuilt scheduler among other things, at the convenience of UPI apps customers are already familiar with. But as of writing this post, Razorpay has confirmed that it will take a while until all the above said features are enabled on their end. We plan on integrating UPI subscriptions when it goes live and is stable enough for our purposes.
If you’re a non-profit like us, we highly recommend to keep looking out for this feature and make use of it whenever possible.
All the code we created during the course of this project has been published under a free license allowing anyone to use it for their non-profits. Following are the links to those project repositories: