I think I'm going to do a series of posts here on Stripe, as we're in the middle of developing an e-commerce site from scratch. I know paths have been developed before me and I have found a few helpful ones, but I'm also hoping that it can be of help to others as well as attract any of those other path builders to weigh in with their own advice.
Our use case is that we're developing an online marketplace for sellers to post their products and buyers to come buy them. Stripe has a lot of offerings and features for marketplaces that make things easy to handle. Additionally, they have their own tax product that helps calculate and record tax transactions to make it easier to file and remit sales tax.
Apologies if this is starting to sound like a commercial for Stripe (it slices, it dices, and soo much more!). I am not a Stripe employee or paid by Stripe for posting this.
So sellers come to our site and register, but before they can post items for sale, they need to connect their Stripe account to our site. There are different account types: Standard, Express, and Custom. We are currently using Standard accounts, which means the seller has a longer on-boarding process, with providing their own financial information before being able to accept payouts. Express accounts are more streamlined, but we would have to pay $2/month for each account. I didn't really dive further into Custom accounts because Standard accounts seem to work just fine for our use case. And if in the process of connecting their Stripe account, they already have a Stripe account, then they just need to log in. After going through the on-boarding process or logging in, they return to our site along with their Stripe account ID, which we can use to transfer money back and forth.
On the flipside, buyers put their items in a cart, which breaks down into one or more orders based on the items' sellers. So if the buyer is buying 3 items from 2 sellers, then there are 2 orders. And then there are line items for each item. We also use the Stripe Tax API to calculate tax based on the shipping address and our own company's tax registrations (which are managed in our own Stripe account).
For the purchasing process, with Stripe, I'm using the Address and Payment Elements on a custom checkout page along with a SetupIntent, which will record the payment method. The user places the order and sees an "Order Placed" screen that says they'll receive confirmation via email for their order. When we receive the SetupIntent via webhooks, we generate a PaymentIntent per order for the amount with a manual capture. If that was successful, we notify the seller and send a receipt to the buyer. If it wasn't successful, we will send an email to the buyer to send them back to the cart to remit payment again.
When the seller receives their order notification, they can drop line items (i.e. the item is no longer available) or cancel orders altogether. They can also mark an order as shipped, which will then capture the authorized funds from the PaymentIntent. If they dropped any items from the order, we capture the partial amount, which "refunds" the difference. We will also record a tax transaction for future filing and remitting.
So that's the high-level overview. In future posts, I will be breaking it down into more details.
Top comments (0)