Skip to content

Commit 21c1b97

Browse files
authored
Update custom-checkout.md
1 parent 9ea568a commit 21c1b97

File tree

1 file changed

+47
-35
lines changed

1 file changed

+47
-35
lines changed

15/umbraco-commerce/tutorials/build-a-store/custom-checkout.md

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ description: Learn how to build a custom checkout flow in Umbraco Commerce.
44

55
# Creating a Custom Checkout Flow
66

7-
If you need a more custom checkout experience, you can build your own checkout flow using the Umbraco Commerce API. This approach gives you full control over the checkout experience, allowing you to tailor it to your specific requirements.
7+
If you need a more custom checkout experience, you can build a custom checkout flow using the Umbraco Commerce API. This approach gives you full control over the checkout experience, allowing you to tailor it to your specific requirements.
88

99
## Create a Checkout Surface Controller
1010

11-
To create a custom checkout flow, you will need to create a custom Surface Controller to handle the checkout process.
11+
To create a custom checkout flow, add a custom Surface Controller to handle the checkout process.
1212

13-
1. Create a new class in your project and inherit from `Umbraco.Cms.Web.Website.Controllers.SurfaceController`.
13+
1. Create a new class and inherit from `Umbraco.Cms.Web.Website.Controllers.SurfaceController`.
1414
2. Name the class `CheckoutSurfaceController`.
1515
3. Add the following code to the class:
1616

@@ -46,25 +46,28 @@ public class CheckoutSurfaceController : SurfaceController
4646
// Add your checkout actions here
4747
}
4848
```
49+
4950
## Define the Checkout Steps
5051

51-
Before we can start building the checkout flow, we need to define the steps that the customer will go through. A typical checkout flow consists of the following steps:
52+
Before you can start building the checkout flow, you must define the steps the customer goes through. A typical checkout flow consists of the following steps:
53+
54+
* Collecting Customer Information.
55+
* Selecting a Shipping Method.
56+
* Selecting a Payment Method.
57+
* Reviewing Order Details.
58+
* Showing an Order Confirmation.
5259

53-
1. Collecting Customer Information
54-
2. Selecting a Shipping Method
55-
3. Selecting a Payment Method
56-
4. Reviewing Order Details
57-
5. Showing an Order Confirmation
60+
To accommodate these steps, you must create a few new Document Types for each step (or one with multiple templates, one per step). Each Document Type will represent a step in the checkout flow.
5861

59-
To accomodate these steps, we need to create a few new documents type for each step (or one with multiple templates, one per step). Each document type will represent a step in the checkout flow. These won't need to have any specific properties defined on them so we'll leave this to you to create, but you should end up with something like this.
62+
1. Create Document Types for each of the steps above, adding only properties that make sense for your setup.
6063

6164
![Checkout Steps](../images/blendid/checkout_structure.png)
6265

6366
## Collecting Customer Information
6467

65-
To collect customer information, we need to create an action method in our `CheckoutSurfaceController` that accepts these details and updates the order accordingly. We'll wrap these properties in a DTO class to pass it to the controller.
68+
To collect customer information, you need to create an action method in our `CheckoutSurfaceController`. This should accept the details and update the order accordingly. The properties will be wrapped in a DTO class to pass it to the controller.
6669

67-
1. Create a new class in your project and name it `UpdateOrderInformationDto` with the following properties.
70+
1. Create a new class and name it `UpdateOrderInformationDto` using the following properties.
6871

6972
```csharp
7073
namespace Umbraco.Commerce.DemoStore.Dtos;
@@ -92,6 +95,7 @@ public class OrderAddressDto
9295
}
9396

9497
```
98+
9599
2. Add the following action method to your `CheckoutSurfaceController`.
96100

97101
```csharp
@@ -145,7 +149,8 @@ public async Task<IActionResult> UpdateOrderInformation(UpdateOrderInformationDt
145149
}
146150
```
147151

148-
3. In the view for the `Collecting Customer Information` step, create a form that posts to the `UpdateOrderInformation` action method of the `CheckoutSurfaceController`, passing the customer information.
152+
3. Open the view for the `Collecting Customer Information` step.
153+
4. Create a form that posts to the `UpdateOrderInformation` action method of the `CheckoutSurfaceController`, passing the customer information.
149154

150155
```csharp
151156
@inject IUmbracoCommerceApi UmbracoCommerceApi
@@ -221,13 +226,14 @@ public async Task<IActionResult> UpdateOrderInformation(UpdateOrderInformationDt
221226
</div>
222227
}
223228
```
224-
On the front end, the customer will be able to fill out their details and proceed to the next step in the checkout flow.
229+
230+
The customer can fill out their details and proceed to the next step in the checkout flow.
225231

226232
![Collecting Customer Information](../images/blendid/checkout_information.png)
227233

228234
## Selecting a Shipping Method
229235

230-
1. Create a new class in your project and name it `UpdateShippingMethodDto` with the following properties.
236+
1. Create a new class and name it `UpdateShippingMethodDto` using the following properties.
231237

232238
```csharp
233239
namespace Umbraco.Commerce.DemoStore.Dtos;
@@ -278,7 +284,8 @@ public async Task<IActionResult> UpdateOrderShippingMethod(UpdateOrderShippingMe
278284
}
279285
```
280286

281-
3. In the view for the `Selecting a Shipping Method` step, create a form that posts to the `UpdateOrderShippingMethod` action method of the `CheckoutSurfaceController`, passing the selected shipping method.
287+
3. Open the view for the `Selecting a Shipping Method` step.
288+
4. Create a form that posts to the `UpdateOrderShippingMethod` action method of the `CheckoutSurfaceController`, passing the selected shipping method.
282289

283290
```csharp
284291
@inject IUmbracoCommerceApi UmbracoCommerceApi
@@ -342,13 +349,14 @@ public async Task<IActionResult> UpdateOrderShippingMethod(UpdateOrderShippingMe
342349
</div>
343350
}
344351
```
345-
On the front end, the customer will be able to select a shipping method and proceed to the next step in the checkout flow.
352+
353+
The customer can select a shipping method and proceed to the next step in the checkout flow.
346354

347355
![Selecting a Shipping Method](../images/blendid/checkout_shipping_method.png)
348356

349357
## Selecting a Payment Method
350358

351-
1. Create a new class in your project and name it `UpdatePaymentMethodDto` with the following properties.
359+
1. Create a new class and name it `UpdatePaymentMethodDto` using the following properties.
352360

353361
```csharp
354362
namespace Umbraco.Commerce.DemoStore.Web.Dtos;
@@ -387,7 +395,8 @@ public async Task<IActionResult> UpdateOrderPaymentMethod(UpdateOrderPaymentMeth
387395
}
388396
```
389397

390-
3. In the view for the `Selecting a Payment Method` step, create a form that posts to the `UpdateOrderPaymentMethod` action method of the `CheckoutSurfaceController`, passing the selected payment method.
398+
3. Open the view for the `Selecting a Payment Method` step
399+
4. Create a form that posts to the `UpdateOrderPaymentMethod` action method of the `CheckoutSurfaceController`, passing the selected payment method.
391400

392401
```csharp
393402
@inject IUmbracoCommerceApi UmbracoCommerceApi
@@ -423,13 +432,14 @@ public async Task<IActionResult> UpdateOrderPaymentMethod(UpdateOrderPaymentMeth
423432

424433
```
425434

426-
On the front end, the customer will be able to select a payment method and proceed to the next step in the checkout flow.
435+
The customer can select a payment method and proceed to the next step in the checkout flow.
427436

428437
![Selecting a Payment Method](../images/blendid/checkout_payment_method.png)
429438

430439
## Reviewing Order Details
431440

432-
1. In the view for the `Reviewing Order Details` step, display the order details and provide a button to trigger capturing payment.
441+
1. Open the view for the `Reviewing Order Details` step.
442+
2. Display the order details and provide a button to trigger capturing payment.
433443

434444
```csharp
435445
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Commerce.DemoStore.Models.CheckoutReviewPage>
@@ -455,25 +465,26 @@ On the front end, the customer will be able to select a payment method and proce
455465
}
456466
```
457467

458-
This is a unique step in the checkout flow as it doesn't post back to the `CheckoutSurfaceController`. Instead, it uses the `BeginPaymentFormAsync` method of the `Html` helper to render a payment method specific form that triggers the payment capturing process.
468+
This is a unique step in the checkout flow as it doesn't post back to the `CheckoutSurfaceController`. Instead, it uses the `BeginPaymentFormAsync` method of the `Html` helper to render a payment method-specific form that triggers the payment capturing process.
459469

460470
{% hint style="info" %}
461-
It is within the `BeginPaymentFormAsync` method that an order number is assigned and as such, it is important that no modifications are made to the order after this point as it may result in the order number getting reset and the payment failing.
471+
It is within the `BeginPaymentFormAsync` method that an order number is assigned. No modifications must be made to the order after this point as it may result in the order number getting reset and the payment failing.
462472
{% endhint %}
463473

464-
On the front end, the customer will be able to review their order details and proceed to the payment gateway.
474+
The customer can review their order details and proceed to the payment gateway.
465475

466476
![Reviewing Order Details](../images/blendid/checkout_review.png)
467477

468478
## Capturing Payment
469479

470-
The payment capture screen is entirely dependent on the payment method being used. It is the responsibility of the associated payment provider to redirect and handle the payment process. The payment provider will then redirect back to order confirmation page on success, or to the cart page with an error if there is a problem.
480+
The payment capture screen is entirely dependent on the payment method being used. It is the responsibility of the associated payment provider to redirect and handle the payment process. The payment provider will redirect back to the order confirmation page on success, or to the cart page with an error if there is a problem.
471481

472482
For more information on how to implement a payment provider, see the [Payment Providers](../../key-concepts/payment-providers.md) documentation.
473483

474484
## Showing an Order Confirmation
475485

476-
1. In the view for the `Showing an Order Confirmation` step, display the order confirmation details.
486+
1. Open the view for the `Showing an Order Confirmation` step.
487+
2. Display the order confirmation details.
477488

478489
```csharp
479490
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<Umbraco.Commerce.DemoStore.Models.CheckoutConfirmationPage>
@@ -492,25 +503,25 @@ For more information on how to implement a payment provider, see the [Payment Pr
492503
@await Html.PartialAsync("OrderInformationSummary")
493504
```
494505

495-
In the order confirmation it is important that you use `GetCurrentFinalizedOrderAsync` instead of the previously used `GetCurrentOrderAsync`. This is because the order will have been finalized during the payment processing step and the current cart order will be cleared.
506+
In the order confirmation, you must use `GetCurrentFinalizedOrderAsync` instead of the previously used `GetCurrentOrderAsync`. This is because the order will have been finalized during the payment processing step and the current cart order will be cleared.
496507

497-
On the front end, the customer will be able to view their order confirmation details.
508+
The customer can view their order confirmation details.
498509

499510
![Showing an Order Confirmation](../images/blendid/checkout_confirmation.png)
500511

501-
It is at this stage that the customer should also receive an email confirmation of their order.
512+
At this stage, the customer should receive an email confirmation of their order.
502513

503514
![Order Confirmation Email](../images/blendid/order_confirmation_email.png)
504515

505-
Umbraco Commerce comes with a default order confirmation email template out of the box, but you can customize this to suit your store's branding. See the [Customizing Templates](../../how-to-guides/customizing-templates.md) documentation for more information.
516+
Umbraco Commerce comes with a default order confirmation email template. This can be customized to suit your store's branding. See the [Customizing Templates](../../how-to-guides/customizing-templates.md) documentation for more information.
506517

507518
## Extras
508519

509520
### Redeeming a Coupon / Gift Card
510521

511-
The checkout flow is also a common place to allow customers to redeem a coupon or gift card. This can be done by adding an additional step to the checkout flow where the customer can enter the code and apply it to their order.
522+
The checkout flow is a common place to allow customers to redeem coupons or gift cards. This can be done by adding another step to the checkout flow where the customer can enter the code and apply it to their order.
512523

513-
1. Create a new class in your project and name it `DiscountOrGiftCardCodeDto` with the following properties.
524+
1. Create a new class and name it `DiscountOrGiftCardCodeDto` using the following properties.
514525

515526
```csharp
516527
namespace Umbraco.Commerce.DemoStore.Web.Dtos;
@@ -573,7 +584,8 @@ public async Task<IActionResult> RemoveDiscountOrGiftCardCode(DiscountOrGiftCard
573584
}
574585
```
575586

576-
2. In the base view for your checkout flow, create a form that posts to the `ApplyDiscountOrGiftCardCode` action method of the `CheckoutSurfaceController`, passing the code to redeem.
587+
2. Open the base view for your checkout flow.
588+
3. Create a form that posts to the `ApplyDiscountOrGiftCardCode` action method of the `CheckoutSurfaceController`, passing the code to redeem.
577589

578590
```csharp
579591
@using (Html.BeginUmbracoForm("ApplyDiscountOrGiftCardCode", "CheckoutSurface"))
@@ -583,7 +595,7 @@ public async Task<IActionResult> RemoveDiscountOrGiftCardCode(DiscountOrGiftCard
583595
}
584596
```
585597

586-
3. In the same view, show a list of applied discounts and gift cards with a link to remove them.
598+
4. Show a list of applied discounts and gift cards with a link to remove them.
587599

588600
```csharp
589601
@if (order.DiscountCodes.Count > 0 || order.GiftCards.Count > 0)
@@ -601,6 +613,6 @@ public async Task<IActionResult> RemoveDiscountOrGiftCardCode(DiscountOrGiftCard
601613
}
602614
```
603615

604-
On the front end, the customer will be able to enter a discount or gift card code and apply it to their order.
616+
The customers can enter a discount or gift card code and apply it to their order.
605617

606618
![Redeeming a Coupon / Gift Card](../images/blendid/discount.png)

0 commit comments

Comments
 (0)