You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 15/umbraco-commerce/tutorials/build-a-store/custom-checkout.md
+47-35Lines changed: 47 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@ description: Learn how to build a custom checkout flow in Umbraco Commerce.
4
4
5
5
# Creating a Custom Checkout Flow
6
6
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.
8
8
9
9
## Create a Checkout Surface Controller
10
10
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.
12
12
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`.
14
14
2. Name the class `CheckoutSurfaceController`.
15
15
3. Add the following code to the class:
16
16
@@ -46,25 +46,28 @@ public class CheckoutSurfaceController : SurfaceController
46
46
// Add your checkout actions here
47
47
}
48
48
```
49
+
49
50
## Define the Checkout Steps
50
51
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.
52
59
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.
58
61
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.
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.
66
69
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.
68
71
69
72
```csharp
70
73
namespaceUmbraco.Commerce.DemoStore.Dtos;
@@ -92,6 +95,7 @@ public class OrderAddressDto
92
95
}
93
96
94
97
```
98
+
95
99
2. Add the following action method to your `CheckoutSurfaceController`.
96
100
97
101
```csharp
@@ -145,7 +149,8 @@ public async Task<IActionResult> UpdateOrderInformation(UpdateOrderInformationDt
145
149
}
146
150
```
147
151
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.
149
154
150
155
```csharp
151
156
@injectIUmbracoCommerceApiUmbracoCommerceApi
@@ -221,13 +226,14 @@ public async Task<IActionResult> UpdateOrderInformation(UpdateOrderInformationDt
221
226
</div>
222
227
}
223
228
```
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.
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.
231
237
232
238
```csharp
233
239
namespaceUmbraco.Commerce.DemoStore.Dtos;
@@ -278,7 +284,8 @@ public async Task<IActionResult> UpdateOrderShippingMethod(UpdateOrderShippingMe
278
284
}
279
285
```
280
286
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.
282
289
283
290
```csharp
284
291
@injectIUmbracoCommerceApiUmbracoCommerceApi
@@ -342,13 +349,14 @@ public async Task<IActionResult> UpdateOrderShippingMethod(UpdateOrderShippingMe
342
349
</div>
343
350
}
344
351
```
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.
346
354
347
355

348
356
349
357
## Selecting a Payment Method
350
358
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.
352
360
353
361
```csharp
354
362
namespaceUmbraco.Commerce.DemoStore.Web.Dtos;
@@ -387,7 +395,8 @@ public async Task<IActionResult> UpdateOrderPaymentMethod(UpdateOrderPaymentMeth
387
395
}
388
396
```
389
397
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.
391
400
392
401
```csharp
393
402
@injectIUmbracoCommerceApiUmbracoCommerceApi
@@ -423,13 +432,14 @@ public async Task<IActionResult> UpdateOrderPaymentMethod(UpdateOrderPaymentMeth
423
432
424
433
```
425
434
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.
427
436
428
437

429
438
430
439
## Reviewing Order Details
431
440
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.
@@ -455,25 +465,26 @@ On the front end, the customer will be able to select a payment method and proce
455
465
}
456
466
```
457
467
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 methodspecific 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.
459
469
460
470
{% 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.
462
472
{% endhint %}
463
473
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.
465
475
466
476

467
477
468
478
## Capturing Payment
469
479
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.
471
481
472
482
For more information on how to implement a payment provider, see the [Payment Providers](../../key-concepts/payment-providers.md) documentation.
473
483
474
484
## Showing an Order Confirmation
475
485
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.
UmbracoCommercecomeswithadefaultorderconfirmationemailtemplateoutofthebox, butyoucancustomizethistosuityourstore's branding. See the [Customizing Templates](../../how-to-guides/customizing-templates.md) documentation for more information.
516
+
UmbracoCommercecomeswithadefaultorderconfirmationemailtemplate. Thiscanbecustomizedtosuityourstore's branding. See the [Customizing Templates](../../how-to-guides/customizing-templates.md) documentation for more information.
@@ -573,7 +584,8 @@ public async Task<IActionResult> RemoveDiscountOrGiftCardCode(DiscountOrGiftCard
573
584
}
574
585
```
575
586
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.
0 commit comments