Requirements of the Stripe API
Learn about the requirements for a payment gateway service like Stripe.
Introduction to payment gateway
A payment gateway is a service through which customers transfer funds to the merchant's account by allowing a broad variety of payment methods, such as credit or debit cards. Payment gateways have made it possible to connect millions of customers and merchants where customers buy goods from online stores and pay via credit or debit cards. Contrary to what it seems, the payment gateway offers various complex services to customers and merchants. The customers and merchants interact with the payment gateway via the API provided by the service. In this lesson, we identify requirements to design the API for a payment gateway such as Stripe.
What could be the challenges of making a functional Stripe service?
Let's start with the following functional and non-functional requirements for Stripe.
Requirements
There are many services that a payment gateway provides; however, we will limit our scope to the following functional and non-functional requirements.
Functional requirements
Payment: The Stripe API should allow merchants to charge their customers for products the customer intends to purchase.
Customers' data: Stripe API should provide operations relevant to a customer, such as creating, updating, deleting, and storing a customer's information (credit/debit cards, personal details, etc.) securely.
Invoices: The API should provide an invoice to customers before charging them for a purchase.
Transaction details: Stripe API should provide all transaction details performed in a merchant's account, including purchases, refunds, payouts, and so on. It should also allow
andone-time One-time payment is where the customers are charged only once for a product or service. .recurring payments A recurring payment is where the customers are charged periodically. A periodic payment is where the customers are charged periodically. Balance: Stripe API should enable merchants to view the status of the account, such as current balance, statement, and so on.
Non-functional requirements
Strong consistency: The API should be strongly consistent and should update all the sources of truth (databases) even if it costs performance. For example, a transaction should trigger updates in the customer's and the merchant's account. It shouldn’t be the case that an amount is deducted from one account but not received in another.
Security: The API should incorporate state-of-the-art security mechanisms to protect customers' and merchants' data and their valued money in addition to authentication and authorization mechanisms. Our API should ensure the security of transactions, accounts, and debit and credit card details.
Reliability: The API should also be highly reliable and should continue to perform services despite errors in one or more components.
Availability: The API should be highly available to provide uninterrupted services to customers and merchants.
Scalability: The API should support any number of customers, merchants, and associated transactions.
Prerequisites
Before embarking on modeling the API for Stripe, we encourage our learners to go through the following concepts in the initial lessons thoroughly:
API security: This chapter helps us in making our API secure.
Different ways of client-server communication: This chapter assists us in determining which protocol to use for communication between client and server.
Data formats: Through this chapter, we decide on suitable data formats to exchange data between client and server.
Architecture styles: Here, we decide the architecture styles to acquire between clients, API gateway, and backend servers.
Latency budget: This chapter helps us to estimate the response time of our Stripe API.
How will we design the Stripe API?
This chapter is structured as follows:
Working of a Payment System: In this lesson, we will give a complete picture of the payment ecosystem and the entities involved in the payment process.
Stripe API Design Decisions: Here, we will make some important technical decisions based on their efficacy that govern the design of our API for Stripe.
API Model for Stripe Service: In this lesson, we will model the API for Stripe in light of the decisions we make in the previous lesson.
Stripe API Design Evaluation and Latency Budget: This lesson will focus on how we achieve the non-functional requirements and perform some optimizations. We will also discuss the latency budget of our proposed API in this lesson.
Let's start with how a payment system works in the next lesson.