Keywords: RESTful API, PayPal, eCommerce, WooCommerce
We live in an international, interconnected world. We work for one another on all sorts of solutions. And we all want to get paid for our work, right? Right.
It’s not uncommon for people to use a CMS like WordPress to advertise, facilitate, and implement their business. And when doing so, an eCommerce platform handles all of the sales, taxes, and so on. But what if we’re not paying for a product, but rather providing payment to another person for a service rendered?
The client in this example is running a business in Australia, and connects those needing professional SEO services with qualified freelancers. The desired solution would not only ensure the proper flow of payment from the former to the latter, but also automate the process so that recurring contracts with a monthly or bi-weekly payout schedule would take place without requiring manual input.
The prevailing idea was to have a solution that was as seamless as possible with current WordPress and WooCommerce functionality. The modularity of WordPress and, by extension, WooCommerce means that new classes to handle a situation like this can be added onto the platform is relatively straightforward. With that in mind, I worked to craft a class that drew the information required from existing sources, work it through the PayPal API, and update all of the pertinent data without interfering with other processes.
In most instances, this is a process that is done manually. By automating things, we could make the work of the client more smooth, provided that we could ensure the success of these transactions should they run automatically as a CRON job based on whenever the appropriate payout should be made, as well as checking for the proper currencies on payout.
Thanks to the functionality of WooCommerce and PayPal, the incoming currency was the only type that requires a callout. Once the recipients information is entered and the transaction started, PayPal handles the rest. However, giving it the incoming currency is crucial, in that PayPal is informed that default currency values should not be used.
Then, it’s a matter of making sure the correct credentials are culled for both payer and recipient from the WordPress database. This information is entered by both parties as part of their registration for the site. The class consolidates this information and, along with the currency type and amount, facilitates the transaction.