For the complete documentation index, see llms.txt. This page is also available as Markdown.

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

Example add form
@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

Key
Value

UmbCheckout_Added_To_Basket

Key of the LineItem added to the Basket

UmbCheckout_Add_To_Basket_Failed

Key of the product that couldn't be added: it has no valid price, its currency isn't supported or differs from the page's, or a limit was reached

Increase

Increases the specified item quantity, the example below would typically be used on the Basket page

This method sets the following TempData

Key
Value

UmbCheckout_Added_To_Basket

Key of the LineItem increased in the Basket

Reduce

Reduces the specified item quantity, the example below would typically be used on the Basket page

This method sets the following TempData

Key
Value

UmbCheckout_Basket_Reduced

Key of the LineItem reduced in the Basket

Remove

Removes the specified item, the example below would typically be used on the Basket page

This method sets the following TempData

Key
Value

UmbCheckout_Basket_Removed

Key of the LineItem removed from the Basket

Checkout

Starts the Stripe Checkout process, the example below would typically be used on the Basket page

This method sets the following TempData

Key
Value

UmbCheckout_EmptyBasket

Returns true if there are 0 LineItems in the Basket

UmbCheckout_Basket_Repriced

The names of the products whose price changed or that were removed when the Basket was priced again; the customer is returned to the page instead of going to Stripe

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