We all know that premature optimization is the root of all evil. But what I want to say is that when it comes to your company or side project, you should consider adding a payment gateway in a generic way to achieve scale and innovation to support your growing business.
When I joined Roblox 5 years ago, we were not yet a payment platform (as of December 31, 2020) that could power the annual booking economy of $1.9 billion, using 11 payment partners in 99 supported countries 59 different currencies are used in /regions. I will tell you how we got here and how to build a universal payment platform in advance so that we can grow as fast as our business. As a source of innovation and influence, payment is often overlooked. However, building your payment platform in the right way up front can open up new opportunities, allow for innovation and optimization, and create a competitive advantage for your company.
First of all, what is a “universal payment platform”? I use this phrase as a wrapper for any gateway or processor to facilitate receiving payments from customers. I will refer to the third party that performs payment orchestration as payment provider or gateway. The universal payment platform opens up centralized logging, fraud, indicators, security, and exchangeability of payment providers. The universal payment platform enables you to perform AB tests on providers with higher credit card completion rates in specific regions or higher fraud rates in certain regions. It also allows for automatic fallbacks in the event of a provider failure, which is more than any of us would have hoped to happen.
You will definitely change payment providers in the future, especially credit card providers. If you believe your company will be successful, the rates you get as a five-person garage store and the global e-commerce platform will be very different. In addition, as you grow, the providers you chose early may not be able to meet your needs-some of the most popular providers have limited international penetration. There are many reasons to switch suppliers, and bundling yourself to one supplier may mean that every purchase will hurt your bottom line.
Roblox uses a wide range of payment providers and has also stopped cooperating with many payment providers. We currently have desktop suppliers, prepaid card suppliers and app store suppliers. Since I joined Roblox, we have parted ways with at least 4 payment service providers.
I will draw what I call the high-level architecture of a plug-and-play payment provider. Roblox uses a microservice architecture, but if you are just starting out, you probably shouldn’t do it. The following logic can be a service, or it can just be separated at the application layer.
Please note that payment processing is only one step in the entire payment process. Starting with one provider is the right choice, but be sure to consider what will happen if you decide to add a second one. Will it be easy to update the routing logic, or will it be another project with a lot of refactoring? Early packaging also helps to consider security and PCI compliance.
I will not go into details on how we lay out our data because it may not be suitable for your use case, but at a high level, I want to emphasize that the payment processing step should be a step that can be easily replaced and changed. Don’t associate your data storage with the data layout of the payment processor. I even recommend looking at the different providers and how they handle the concepts of authentication, capture, and subscription, and decide to use all payment provider-specific logic encapsulated in a common data store in a completely separate table.
It will probably be the most difficult for you to update the data later. Think about what you need from persistent data or non-persistent data, and how long you need to store this data. I strongly recommend structuring the data to allow future integration with subscription products. Even if you may not consider subscribing now, if your business even has a chance to move along this path, plan your data storage to accommodate this. I won’t detail all the benefits of a subscription-based monetization strategy (there are many related resources online), but the predictable income allows you to make further plans for your company.
Subscription is another area that will benefit from staying away from the specific logic of payment providers. The subscription structure of payment providers is quite different. Most one-time purchases follow the same “charge the user immediately” model. However, there are several different models for subscriptions:
Make sure all your subscriptions go through a central data pipeline with universal renewal, cancellation, and (most importantly) grace periods. Some models (such as the pull model) will allow the subscription to remain active unless you receive a response from the provider. If your service fails or continues to time out, you will be trapped in providing products without actually charging users. This may be okay, depending on the subscription product you provide, but our virtual currency has inherent value, so we need to be extra careful when renewing and canceling subscriptions.
I hope I can persuade you to take the general route from the early implementation of payment gateways. I would not recommend which payment provider you should implement, but I hope you see that the payment provider you choose is not the most important decision. The most important decision is how to structure your system in the right way so that you can easily replace your payment provider in the future.
— — —
Dmitri Essiounine is Roblox’s senior engineering manager. His team is responsible for supporting Roblox Metaverse’s prosperous economy.
Neither Roblox Corporation nor this blog endorse or endorse any company or service. In addition, no guarantee or promise is made for the accuracy, reliability or completeness of the information contained in this blog.
©2021 Roblox Corporation. Roblox, the Roblox logo, and Powering Imagination are our registered and unregistered trademarks in the United States and other countries.