{"id":1184,"date":"2020-02-21T11:28:28","date_gmt":"2020-02-21T10:28:28","guid":{"rendered":"https:\/\/blog.besharp.it\/?p=1184"},"modified":"2021-03-24T12:44:04","modified_gmt":"2021-03-24T11:44:04","slug":"how-to-create-a-serverless-payment-system-using-stripe-and-aws-lambda","status":"publish","type":"post","link":"https:\/\/blog.besharp.it\/how-to-create-a-serverless-payment-system-using-stripe-and-aws-lambda\/","title":{"rendered":"How to create a serverless payment system using Stripe and AWS Lambda"},"content":{"rendered":"
We are in the online shopping epoch and the implementation of the online payment methods into cloud-native apps<\/strong> is becoming an increasing need for the market.<\/span><\/p>\n As we can guess, managing payments into our business flow requires a secure and reliable infrastructure, that can guarantee the privacy<\/strong> and the consistency of data and transactions<\/strong>.<\/span><\/p>\n The integration to more and more numerous payment circuits involves a considerable effort in development and maintainability.<\/span><\/p>\n Today we are introducing to you a fully serverless solution based on the famous service Stripe<\/a>, a payment middleware<\/strong> that provides to its users a back office dashboard and a REST interface.<\/span><\/p>\n A fully-managed service – like Stripe is – can help, but each payment flow has its own features depending on different business requirements. <\/span>It is strongly recommended to write server-side code in order to keep this information secret so that it is possible to avoid any sensitive data spread.<\/span><\/p>\n As a scalable and fully-managed<\/strong> service, Stripe allows us to build high performing applications. Anyway, to get the most out of this service it is important to build an equally scalable and agile back-end able to adapt the best way possible. To do so, Serverless technologies<\/strong> come to help.\u00a0<\/span><\/p>\n In particular, in this article, we are focusing on the use of AWS Lambda<\/strong>, a serverless computing service provided by Amazon web services.<\/span><\/p>\n For the beginners, Lambdas are stateless serverless functions. The developer is able to work in an environment where he can write code without worry about host hardware and you pay only what you use.<\/span><\/p>\n Let\u2019s deep dive into Stripe. How to use it?\u00a0<\/span><\/p>\n First of all, sign up to Stripe.<\/a><\/span><\/p>\n Signing up is free and you\u2019ll pay only for what you use. For pricing details check this page<\/a>.\u00a0<\/span><\/p>\n <\/p>\n In this article, we are not going to explain every single feature of Stripe (form more details, see the official documentation<\/a><\/span>). Instead, we are going to integrate an AWS Lambda serverless application with the API of our just-created Stripe account.<\/span><\/p>\n One of the main components of Stripe is the dashboard<\/strong>: it offers users the possibility to create and manage resources like subscriptions and products.<\/span><\/p>\n <\/p>\n As you can see from the dashboard, we can choose between two different kinds of APIs:<\/strong><\/span><\/p>\n keypair test APIs<\/strong> through which you will be able to create test data (note: they will be visible only if the “Viewing test data” is checked) and live API key<\/strong>, used to create real transactions (usually for production environment).<\/span><\/p>\nGetting started with Stripe<\/h2>\n