Building Web Applications with Go - Intermediate Level
Learn how to build a secure ecommerce application with Go (Golang)
Learn how to build a secure ecommerce application with Go (Golang)
This course is the followup to Building Modern Web Applications in Go. In this course, we go further than we did the first time around. We will build a sample E-Commerce application that consists of multiple, separate applications: a front end (which services content to the end user as web pages); a back end API (which is called by the front end as necessary), and a microservice that performs only one task, but performs it extremely well (dynamically building PDF invoices and sending them to customers as an email attachment).
The application will sell individual items, as well as allow users to purchase a monthly subscription. All credit card transactions will be processed through Stripe, which is arguably one of the most popular payment processing systems available today, and for good reason: developers love it. Stripe offers a rich API (application programming interface), and it is available in more than 35 countries around the world, and works with more than 135 currencies. Literally millions of organizations and businesses use Stripe’s software and APIs to accept payments, send payouts, and manage their businesses online with the Stripe dashboard. However, in many cases, developers want to be able to build a more customized solution, and not require end users to log in to both a web application and the Stripe dashboard. That is precisely the kind of thing that we will be covering in this course.
We will start with a simple Virtual Terminal, which can be used to process so-called "card not present" transactions. This will be a fully functional web application, built from the ground up on Go (sometimes referred to as Golang). The front end will be rendered using Go's rich html/template package, and authenticated users will be able to process credit card payments from a secure form, integrated with the Stripe API. In this section of the course, we will cover the following:
How to build a secure, production ready web application in Go
How to capture the necessary information for a secure online credit card transaction
How to call the Stripe API from a Go back end to create a paymentIntent (Stripe's object for authorizing and making a transaction)
Once we have that out of the way, we'll build a second web application in the next section of the course, consisting of a simple web site that allows users to purchase a product, or purchase a monthly subscription. Again, this will be a web application built from the ground up in Go. In this section of the course, we'll cover the following:
How to allow users to purchase a single product
How to allow users to purchase a recurring monthly subscription (a Stripe Plan)
How to handle cancellations and refunds
How to save all transaction information to a database (for refunds, reporting, etc).
How to refund a transaction
How to cancel a subscription
How to secure access to the front end (via session authentication)
How to secure access to the back end API (using stateful tokens)
How to manage users (add/edit/delete)
How to allow users to reset their passwords safely and securely
How to log a user out and cancel their account instantly, over websockets
Once this is complete, we'll start work on the microservice. A microservice is a particular approach to software development that has the basic premise of building very small applications that do one thing, but do it very well. A microservice does not care in the slightest about what application calls it; it is completely separate, and completely agnostic. We'll build a microserivce that does the following:
Accepts a JSON payload describing an individual purchase
Produces a PDF invoice with information from the JSON payload
Creates an email to the customer, and attaches the PDF to it
Sends the email
All of these components (front end, back end, and microservice) will be built using a single code base that produces multiple binaries, using Gnu Make.
FAQ area empty
What we're going to build
136 Xem trướcSetting up a (trivial) web application
896 Xem trướcSetting up routes and building a render function
1239 Xem trướcDisplaying one page
536 Xem trướcA better extension for Go templates and VS Code
190 Xem trướcCreating the form
692 Xem trướcConnecting our form to stripe.js
643 Xem trướcClient side validation
468 Xem trướcGetting the paymentIntent - setting up the back end package
945 Xem trướcGetting the paymentIntent - starting work on the back end api
572 Xem trướcGetting the paymentIntent - setting up a route and handler, and using make
650 Xem trướcGetting the paymentIntent - finishing up our handler
527 Xem trướcUpdating the front end JavaScript to call our paymentIntent handler
541 Xem trướcGetting the payment intent, and completing the transaction
1054 Xem trướcGenerating a receipt
710 Xem trướcCleaning up the API url and Stripe Publishable Key on our form
247 Xem trướcTest your knowledge
What are we going to build?
95 Xem trướcCreate the database
93 Xem trướcConnecting to the database
498 Xem trướcCreating a product page
356 Xem trướcCreating the product form
259 Xem trướcMoving JavaScript to a reusable file
268 Xem trướcModifying the handler to take a struct
564 Xem trướcUpdate the Widget page to use data passed to the template
295 Xem trướcCreating a formatCurrency template function
206 Xem trướcTesting the transaction functionality
252 Xem trướcCreating a database table for items for sale
642 Xem trướcRunning database migrations
175 Xem trướcCreating database models
620 Xem trướcWorking on database functions
351 Xem trướcInserting a new transaction
238 Xem trướcInserting a new order
140 Xem trướcAn aside: fixing a problem with calculating the amount
320 Xem trướcGetting more information about a transaction
827 Xem trướcCustomers
619 Xem trướcGetting started saving customer and transaction information
609 Xem trướcCreate the save customer database method
138 Xem trướcSaving the customer, transaction, and order from the handler
987 Xem trướcRunning a test transaction
394 Xem trướcFixing a database error, and saving more details
501 Xem trướcRedirecting after post
395 Xem trướcSimplifying our PaymentSucceeded handler
958 Xem trướcRevising our Virtual Terminal
577 Xem trướcFixing a mistake in the formatCurrency template function
99 Xem trướcWhat are we going to build in this section?
121 Xem trướcCreating a Plan on the Stripe Dashboard
185 Xem trướcCreating stubs for the front end page and handler
279 Xem trướcSetting up the form
559 Xem trướcWorking on the JavaScript for plans
423 Xem trướcContinuing with the Javascript for subscribing to a plan
289 Xem trướcCreate a handler for the POST request after a user is subscribed
388 Xem trướcCreate methods to create a Stripe customer and subscribe to a plan
531 Xem trướcUpdating our handler to complete a subscription
371 Xem trướcSaving transaction & customer information to the database
599 Xem trướcSaving transaction & customer information II
869 Xem trướcDisplaying a receipt page for the Bronze Plan
436 Xem trướcIntroduction
225 Xem trướcCreating a login page
423 Xem trướcWriting the stub javascript to authenticate against the back end
204 Xem trướcCreate a route and handler for authentication
817 Xem trướcCreate a writeJSON helper function
253 Xem trướcStarting the authentication process
356 Xem trướcCreating an invalidCredentials helper function
187 Xem trướcCreating a passwordMatches helper function
379 Xem trướcMaking sure that everything works
105 Xem trướcCreate a function to generate a token
445 Xem trướcGenerating and sending back a token
235 Xem trướcSaving the token to the database
451 Xem trướcSaving the token to local storage
484 Xem trướcChanging the login link based on authentication status
563 Xem trướcChecking authentication on the back end
681 Xem trướcA bit of housekeeping
46 Xem trướcCreating stub functions to validate a token
289 Xem trướcExtracting the token from the authorization header
268 Xem trướcValidating the token on the back end
376 Xem trướcTesting out our token validation
322 Xem trướcChallenge: Checking for expiry
76 Xem trướcSolution to challenge
379 Xem trướcImplementing middleware to protect specfic routes
214 Xem trướcTrying out a protected route
146 Xem trướcConverting the Virtual Terminal post to use the back end
616 Xem trướcChanging the virtual terminal page to use fetch
788 Xem trướcVerifying the saved transaction
159 Xem trướcPassword resets
588 Xem trướcSending mail Part I
855 Xem trướcMailtrap.io
108 Xem trướcSending mail Part II
644 Xem trướcCreating our mail templates and sending a test email
612 Xem trướcImplementing signed links for our email message
764 Xem trướcUsing our urlsigner package
393 Xem trướcCreating the reset password route and handler
379 Xem trướcSetting up the reset password page
405 Xem trướcCreating a back end route to handle password resets
552 Xem trướcSetting an expiry for password reset emails
201 Xem trướcAdding an encryption package
739 Xem trướcUsing our encryption package to lock down password resets
327 Xem trướcImproving our front end and setting up an Admin menu
450 Xem trướcSetting up stub pages for sales and subscriptions
382 Xem trướcUpdating migrations and resetting the database
211 Xem trướcListing all sales: database query
297 Xem trướcListing all sales: database function
358 Xem trướcListing all sales: writing the API handler and route
122 Xem trướcListing all sales: front end javascript
386 Xem trướcDisplaying our results in a table
325 Xem trướcMaking our table prettier, and adding some checks in JavaScript
292 Xem trướcChallenge
100 Xem trướcSolution to challenge
128 Xem trướcDisplaying a sale: part 1
684 Xem trướcDisplaying a sale: part 2
300 Xem trướcDisplaying a subscription
284 Xem trướcRefunds from the Stripe Dashboard
61 Xem trướcAdding a refund function to our cards package
202 Xem trướcCreating an API handler to process refunds
415 Xem trướcUpdate the front end for refunds
850 Xem trướcImproving the front end
199 Xem trướcAdding UI components to the sales page
545 Xem trướcUpdating status to refunded in the database
240 Xem trướcCreating a database method to paginate all orders
406 Xem trướcModifying the AllSales handler to use paginated data
241 Xem trướcUpdating the all-sales.page.gohtml template
337 Xem trướcImproving pagination on the front end
572 Xem trướcAdding listeners to page navigation buttons
259 Xem trướcTaking user to correct page of data on click
197 Xem trướcHow I implemented pagination on the all subscriptions page
134 Xem trướcSetting up templates to manage users
359 Xem trướcAdding routes and handlers on the front end
149 Xem trướcWriting the database functions to manage users
628 Xem trướcCreating a handler and route for all users on the back end
118 Xem trướcUpdating the front end to call AllUsers
151 Xem trướcDisplaying the list of users
242 Xem trướcCreating a user add/edit form
423 Xem trướcCall the api back end to get one user
352 Xem trướcPopulating the user form, and a challenge
403 Xem trướcSolution to challenge
175 Xem trướcSaving an edited user - part one
344 Xem trướcSaving an edited user - part two
522 Xem trướcDeleting a user
462 Xem trướcRemoving the deleted users token from the database
208 Xem trướcSetting up websockets
1129 Xem trướcConnecting to WebSockets from the browser
384 Xem trướcLogging the deleted user out over websockets
359 Xem trướcWhat are microservices?
96 Xem trướcSetting up a simple microservice
847 Xem trướcReceiving data with our micrsoservice
403 Xem trướcGenerating an invoice as a PDF
1221 Xem trướcTesting our PDF
329 Xem trướcMailing the invoice
494 Xem trướcCall the microservice when a Widget is sold
580 Xem trướcChallenge
94 Xem trướcSolution
155 Xem trướcA basic understanding of the Go programming language
A basic understanding of HTML, CSS, and JavaScript
A basic understanding of SQL syntax
How to build a front end website using Go
How to build a back end API using Go
How to build multiple applications from a single code base
How to build microservices in Go
User authentication in Go
API authentication using stateful tokens
How to allow users to reset a password in a safe, secure manner
How to integrate Stripe credit card processing with a Go back end
Make one time or recurring payments with Stripe
Best practices for making secure credit card transactions