تماشای این درس نیاز به اشتراک حرفه‌ای دارد.

Clearing Cart After Checkout0:00

Now, whenever an order is placed and the checkup is successful, we want to make sure that we, of course, delete the actual card. Otherwise, it could be quite confusing when your user returns to your website and still notice that his or her card contains the exact same items he or she just ordered. So, if we head over to our CreateStripeCheckoutSession, let's add some additional metadata. Let's add cardId here as well. Now, let's go back to our HandleCheckoutSessionCompleted. And here we can say card is equal to cardBindAvailableSessionMetadata.cardId.

Testing Checkout Flow0:38

And here we can say card is equal to cardBindAvailableSessionMetadata.cardId. And now we can say cardItemsDelete, and delete our card as well. So, let's verify that everything is working. Let's add a few items to our card. Next, we'll head over to our checkout. We'll enter our dummy information and click Play. We have redirected back, and as you can see, our card is now set to zero. Now, if we take a look at our database, we should see our order.

Verifying Order in Database1:13

We have redirected back, and as you can see, our card is now set to zero. Now, if we take a look at our database, we should see our order. There we go. We have all the information about the total. We have our billing address, our shipping address. And if you look at our order items, we can see each of the individual items on our order. So, we have the name, description, and all the pricing information, quantity as well. So, that all seems to work.

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟