Error compiling template "Designs/Swift/Custom/StripeCheckout.cshtml"
Line 22: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Line 28: The type or namespace name 'Options' does not exist in the namespace 'Microsoft.Extensions' (are you missing an assembly reference?)
1 //------------------------------------------------------------------------------
2 // <auto-generated>
3 // This code was generated by a tool.
4 // Runtime Version:4.0.30319.42000
5 //
6 // Changes to this file may cause incorrect behavior and will be lost if
7 // the code is regenerated.
8 // </auto-generated>
9 //------------------------------------------------------------------------------
10
11 namespace CompiledRazorTemplates.Dynamic {
12 using System;
13
14 #line 4 "C:\inetpub\wwwroot\directions2023_dev\Files\Templates\Designs\Swift\Custom\StripeCheckout.cshtml"
15 using System.Collections.Generic;
16
17 #line default
18 #line hidden
19 using System.Linq;
20
21 #line 5 "C:\inetpub\wwwroot\directions2023_dev\Files\Templates\Designs\Swift\Custom\StripeCheckout.cshtml"
22 using Microsoft.AspNetCore.Mvc;
23
24 #line default
25 #line hidden
26
27 #line 6 "C:\inetpub\wwwroot\directions2023_dev\Files\Templates\Designs\Swift\Custom\StripeCheckout.cshtml"
28 using Microsoft.Extensions.Options;
29
30 #line default
31 #line hidden
32
33 #line 7 "C:\inetpub\wwwroot\directions2023_dev\Files\Templates\Designs\Swift\Custom\StripeCheckout.cshtml"
34 using Stripe;
35
36 #line default
37 #line hidden
38
39 #line 8 "C:\inetpub\wwwroot\directions2023_dev\Files\Templates\Designs\Swift\Custom\StripeCheckout.cshtml"
40 using Stripe.Checkout;
41
42 #line default
43 #line hidden
44
45
46 public class RazorEngine_832009125616464e9df324e01967fa5d : Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> {
47
48 #line hidden
49
50 public RazorEngine_832009125616464e9df324e01967fa5d() {
51 }
52
53 public override void Execute() {
54 WriteLiteral("// This example sets up an endpoint using the ASP.NET MVC framework.\r\n// To learn" +
55 " more about ASP.NET MVC, watch this video: https://youtu.be/2-mMOB8MhmE.\r\n\r\n");
56
57 WriteLiteral(@"
58 namespace server.Controllers
59 {
60 public class PaymentsController : Controller
61 {
62 public PaymentsController()
63 {
64 StripeConfiguration.ApiKey = ""sk_test_v0rQRqenSs7uso5uewLvjI7b00A9HmbCmN"";
65 }
66
67 [HttpPost(""create-checkout-session"")]
68 public ActionResult CreateCheckoutSession()
69 {
70 var options = new SessionCreateOptions
71 {
72 LineItems = new List<SessionLineItemOptions>
73 {
74 new SessionLineItemOptions
75 {
76 PriceData = new SessionLineItemPriceDataOptions
77 {
78 UnitAmount = 2000,
79 Currency = ""usd"",
80 ProductData = new SessionLineItemPriceDataProductDataOptions
81 {
82 Name = ""T-shirt"",
83 },
84 },
85 Quantity = 1,
86 },
87 },
88 Mode = ""payment"",
89 UiMode = ""embedded"",
90 ReturnUrl = ""https://example.com/return?session_id={CHECKOUT_SESSION_ID}"",
91 };
92
93 var service = new SessionService();
94 Session session = service.Create(options);
95
96 return Json(new {clientSecret = session.RawJObject[""client_secret""]});
97 }
98 }
99 }");
100
101 }
102 }
103 }
104
1 // This example sets up an endpoint using the ASP.NET MVC framework.
2 // To learn more about ASP.NET MVC, watch this video: https://youtu.be/2-mMOB8MhmE.
3
4 @using System.Collections.Generic;
5 @using Microsoft.AspNetCore.Mvc;
6 @using Microsoft.Extensions.Options;
7 @using Stripe;
8 @using Stripe.Checkout;
9
10 namespace server.Controllers
11 {
12 public class PaymentsController : Controller
13 {
14 public PaymentsController()
15 {
16 StripeConfiguration.ApiKey = "sk_test_v0rQRqenSs7uso5uewLvjI7b00A9HmbCmN";
17 }
18
19 [HttpPost("create-checkout-session")]
20 public ActionResult CreateCheckoutSession()
21 {
22 var options = new SessionCreateOptions
23 {
24 LineItems = new List<SessionLineItemOptions>
25 {
26 new SessionLineItemOptions
27 {
28 PriceData = new SessionLineItemPriceDataOptions
29 {
30 UnitAmount = 2000,
31 Currency = "usd",
32 ProductData = new SessionLineItemPriceDataProductDataOptions
33 {
34 Name = "T-shirt",
35 },
36 },
37 Quantity = 1,
38 },
39 },
40 Mode = "payment",
41 UiMode = "embedded",
42 ReturnUrl = "https://example.com/return?session_id={CHECKOUT_SESSION_ID}",
43 };
44
45 var service = new SessionService();
46 Session session = service.Create(options);
47
48 return Json(new {clientSecret = session.RawJObject["client_secret"]});
49 }
50 }
51 }