{"id":263637,"date":"2018-01-18T08:07:11","date_gmt":"2018-01-18T15:07:11","guid":{"rendered":"http:\/\/css-tricks.com\/?p=263637"},"modified":"2018-01-19T08:54:33","modified_gmt":"2018-01-19T15:54:33","slug":"creating-vue-js-serverless-checkout-part-three","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/creating-vue-js-serverless-checkout-part-three\/","title":{"rendered":"Creating a Vue.js Serverless Checkout Form: Application and Checkout Component"},"content":{"rendered":"

This is the third post in a four-part series. In part one, we set up a serverless Stripe function on Azure. Part two covered how we hosted the function on Github. This post will focus on wiring everything up as a Vue.js application.<\/p>\n

<\/p>\n

\n

Article Series:<\/h4>\n
    \n
  1. Setup and Testing<\/a><\/li>\n
  2. Stripe Function and Hosting<\/a><\/li>\n
  3. Application and Checkout Component<\/a> (This Post)<\/li>\n
  4. Configure the Checkout Component<\/a><\/li>\n<\/ol>\n<\/div>\n
    \n

    Stripe has a number of ways to build out a checkout form, the most basic being a single button on the page that you trigger to pull up their custom modal. There\u2019s a repo and component for this<\/a>, but as easy as that is to implement (it’s probably the most simple way to do it), I wanted a little more customization and wanted the checkout flow to be part of the page and application. This approach wouldn\u2019t work for my needs.<\/p>\n

    Stripe Elements<\/h3>\n

    Stripe also offers a thing called Elements<\/a>. Elements allow you to integrate Stripe’s payment system into your own checkout form and style it like your own site for a cohesive experience. It won’t feel like you’re using a third party plugin. They do have some pre-styled examples<\/a> if you prefer something you can use right out of the box.<\/p>\n

    Luckily for us, there’s a really nice repo with a Vue version of Stripe Elements called vue-stripe-elements<\/a>. The repo’s documentation is really nice, so you could check that out. Here’s how I put it to use:<\/p>\n

    npm i vue-stripe-elements-plus --save<\/code><\/pre>\n

    …or using Yarn:<\/p>\n

    yarn add vue-stripe-elements-plus<\/code><\/pre>\n

    Now let’s talk about our cart and integrate it.<\/p>\n

    The Cart<\/h3>\n

    Here’s what everything looks like as a birds eye view of the application. We’ve already addressed the function and stripe pieces, now let’s dig into the application itself.<\/p>\n

    \"birds<\/figure>\n

    We’re not going to go through setting up the entire application in these posts, rather just the Cart and Checkout. I’d suggest checking out the following links before continuing if you need to catch up on the basics of Vue, Vuex, and Nuxt:<\/p>\n