Stripe Basket Controller
The StripeBasketController is a preconfigured Umbraco Surface Controller which interacts with the BasketService.
It can be found within the namespace UmbCheckout.Stripe.Controllers.Surface
It has a number of methods available as a starting point to allow UmbCheckout to be consumed without the need to write C# code.
The POST actions need an antiforgery token: Html.BeginUmbracoForm adds it. The price and currency are always read from the product on the server.
Add
Adds an item to the Basket, the example below would typically be used on the Product page
@using (Html.BeginUmbracoForm<StripeBasketController>(nameof(StripeBasketController.Add), FormMethod.Post))
{
<label for="quantity">Quantity:</label>
<input type="number" name="quantity" value="1" min="1" /> <br />
<input type="hidden" name="key" value="@Model.Key" />
<button type="submit">Buy</button>
}This method sets the following TempData
Increase
Increases the specified item quantity, the example below would typically be used on the Basket page
This method sets the following TempData
Reduce
Reduces the specified item quantity, the example below would typically be used on the Basket page
This method sets the following TempData
Remove
Removes the specified item, the example below would typically be used on the Basket page
This method sets the following TempData
Checkout
Starts the Stripe Checkout process, the example below would typically be used on the Basket page
This method sets the following TempData
Before redirecting to Stripe, Checkout prices every line again from the published products (see Prices, Currencies and Baskets) and records the checkout session on the Basket.
EmptyBasket
Removes every item from the Basket. It is a GET action, so it can be used as a link, the example below would typically be used on the Basket page
When a change is refused
If a Saving notification handler cancels an add, reduce or remove, the Basket is left as it was and UmbCheckout_Basket_Change_Cancelled holds the handler's message.
Change return page
If you would like to change the page which the user is redirected to after carrying out one of the above actions you simply need to pass in the page Guid
The example below shows how to do this with the Add method
Last updated