Skip to content

Commit 667861f

Browse files
committed
v0.0.1
0 parents  commit 667861f

File tree

79 files changed

+74515
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+74515
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin
2+
obj

Pages/Error.cshtml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@page
2+
@model ErrorModel
3+
@{
4+
ViewData["Title"] = "Error";
5+
}
6+
7+
<h1 class="text-danger">Error.</h1>
8+
<h2 class="text-danger">An error occurred while processing your request.</h2>
9+
10+
@if (Model.ShowRequestId)
11+
{
12+
<p>
13+
<strong>Request ID:</strong> <code>@Model.RequestId</code>
14+
</p>
15+
}
16+
17+
<h3>Development Mode</h3>
18+
<p>
19+
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
20+
</p>
21+
<p>
22+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
23+
It can result in displaying sensitive information from exceptions to end users.
24+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
25+
and restarting the app.
26+
</p>

Pages/Error.cshtml.cs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Diagnostics;
2+
using Microsoft.AspNetCore.Mvc;
3+
using Microsoft.AspNetCore.Mvc.RazorPages;
4+
5+
namespace aspnetcore_example.Pages;
6+
7+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8+
[IgnoreAntiforgeryToken]
9+
public class ErrorModel : PageModel
10+
{
11+
public string? RequestId { get; set; }
12+
13+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
14+
15+
private readonly ILogger<ErrorModel> _logger;
16+
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
21+
22+
public void OnGet()
23+
{
24+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
25+
}
26+
}
27+

Pages/Index.cshtml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@page
2+
@model IndexModel
3+
@{
4+
ViewData["Title"] = "Home page";
5+
}
6+
7+
<body>
8+
9+
<div class="container">
10+
<div class="row">
11+
<div class="col"></div>
12+
13+
<div class="col">
14+
<form method="post">
15+
<br><br><br>
16+
<div class="sm-3">
17+
<label for="amount" class="form-label">Enter amount (minimum 100)</label>
18+
<input type="number" id="amount" name="amount" class="form-control" min="100" max="500000" autofocus required/>
19+
</div>
20+
<br>
21+
<div class="sm-3">
22+
<input type="submit" value="Proceed to Payment" class="btn btn-primary" />
23+
</div>
24+
<br><br><br>
25+
</form>
26+
</div>
27+
28+
<div class="col"></div>
29+
</div>
30+
</div>
31+
32+
</body>

Pages/Index.cshtml.cs

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using System.Text.Json;
4+
5+
namespace aspnetcore_example.Pages;
6+
7+
public class IndexModel : PageModel
8+
{
9+
private readonly ILogger<IndexModel> _logger;
10+
11+
private string GatewayPageURL;
12+
13+
public IndexModel(ILogger<IndexModel> logger)
14+
{
15+
_logger = logger;
16+
}
17+
18+
public void OnGet()
19+
{
20+
21+
}
22+
23+
public RedirectResult OnPost()
24+
{
25+
var baseUrl = Request.Scheme + "://" + this.Request.Host;
26+
var PostData = new MultipartFormDataContent();
27+
28+
PostData.Add(new StringContent(Request.Form["amount"]), "total_amount");
29+
PostData.Add(new StringContent("BDT"), "currency");
30+
31+
// System Information
32+
PostData.Add(new StringContent("testbox"), "store_id");
33+
PostData.Add(new StringContent("qwerty"), "store_passwd");
34+
PostData.Add(new StringContent("test_tran_001"), "tran_id");
35+
PostData.Add(new StringContent(baseUrl + "/Success"), "success_url");
36+
PostData.Add(new StringContent(baseUrl + "/Fail"), "fail_url"); // "Fail.aspx" page needs to be created
37+
PostData.Add(new StringContent(baseUrl + "/Cancel"), "cancel_url"); // "Cancel.aspx" page needs to be created
38+
PostData.Add(new StringContent(baseUrl + "/Ipn"), "ipn_url"); // Backend IPN needs to be implemented
39+
40+
// Customer Information
41+
PostData.Add(new StringContent("Customer Name"), "cus_name");
42+
PostData.Add(new StringContent("[email protected]"), "cus_email");
43+
PostData.Add(new StringContent("Address"), "cus_add1");
44+
PostData.Add(new StringContent("Dhaka"), "cus_city");
45+
PostData.Add(new StringContent("1000"), "cus_postcode");
46+
PostData.Add(new StringContent("Bangladesh"), "cus_country");
47+
PostData.Add(new StringContent("0111111111"), "cus_phone");
48+
49+
// Misc Information
50+
PostData.Add(new StringContent("NO"), "shipping_method");
51+
PostData.Add(new StringContent("NO"), "num_of_item");
52+
PostData.Add(new StringContent("Shoes"), "product_category");
53+
PostData.Add(new StringContent("Red Shoe"), "product_name");
54+
PostData.Add(new StringContent("physical-goods"), "product_profile");
55+
PostData.Add(new StringContent("0"), "emi_option");
56+
57+
string ApiUrl = "https://sandbox.sslcommerz.com/gwprocess/v4/api.php";
58+
59+
var c = new HttpClient();
60+
var wr = new HttpRequestMessage(HttpMethod.Post, ApiUrl)
61+
{
62+
Content = PostData
63+
};
64+
65+
var r = c.Send(wr);
66+
var response = r.Content.ReadAsStream();
67+
68+
SSLCommerzInitRes? res =
69+
JsonSerializer.Deserialize<SSLCommerzInitRes>(response);
70+
71+
return Redirect(res?.GatewayPageURL);
72+
73+
}
74+
}
75+
76+
public class SSLCommerzInitRes
77+
{
78+
public string status { get; set; }
79+
public string failedreason { get; set; }
80+
public string sessionkey { get; set; }
81+
public Gw gw { get; set; }
82+
public string redirectGatewayURL { get; set; }
83+
public string redirectGatewayURLFailed { get; set; }
84+
public string GatewayPageURL { get; set; }
85+
public string storeBanner { get; set; }
86+
public string storeLogo { get; set; }
87+
public List<Desc> desc { get; set; }
88+
public string is_direct_pay_enable { get; set; }
89+
}
90+
91+
public class Gw
92+
{
93+
public string visa { get; set; }
94+
public string master { get; set; }
95+
public string amex { get; set; }
96+
public string othercards { get; set; }
97+
public string internetbanking { get; set; }
98+
public string mobilebanking { get; set; }
99+
}
100+
101+
public class Desc
102+
{
103+
public string name { get; set; }
104+
public string type { get; set; }
105+
public string logo { get; set; }
106+
public string gw { get; set; }
107+
}

Pages/Privacy.cshtml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page
2+
@model PrivacyModel
3+
@{
4+
ViewData["Title"] = "Privacy Policy";
5+
}
6+
<h1>@ViewData["Title"]</h1>
7+
8+
<p>Use this page to detail your site's privacy policy.</p>

Pages/Privacy.cshtml.cs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
4+
namespace aspnetcore_example.Pages;
5+
6+
7+
public class PrivacyModel : PageModel
8+
{
9+
private readonly ILogger<PrivacyModel> _logger;
10+
11+
public PrivacyModel(ILogger<PrivacyModel> logger)
12+
{
13+
_logger = logger;
14+
}
15+
16+
public void OnGet()
17+
{
18+
}
19+
}
20+

Pages/Shared/_Layout.cshtml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>@ViewData["Title"] - Example Project</title>
7+
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
8+
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
9+
<link rel="stylesheet" href="~/aspnetcore_example.styles.css" asp-append-version="true" />
10+
</head>
11+
<body>
12+
<header>
13+
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
14+
<div class="container">
15+
<a class="navbar-brand" asp-area="" asp-page="/Index">Example Porject</a>
16+
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
17+
aria-expanded="false" aria-label="Toggle navigation">
18+
<span class="navbar-toggler-icon"></span>
19+
</button>
20+
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
21+
<ul class="navbar-nav flex-grow-1">
22+
<li class="nav-item">
23+
<a class="nav-link text-dark" asp-area="" asp-page="/Index">Home</a>
24+
</li>
25+
<li class="nav-item">
26+
<a class="nav-link text-dark" asp-area="" asp-page="/Privacy">Privacy</a>
27+
</li>
28+
<li class="nav-item">
29+
<a class="nav-link text-dark" asp-area="" asp-page="/Success">Success</a>
30+
</li>
31+
</ul>
32+
</div>
33+
</div>
34+
</nav>
35+
</header>
36+
<div class="container">
37+
<main role="main" class="pb-3">
38+
@RenderBody()
39+
</main>
40+
</div>
41+
42+
<footer class="border-top footer text-muted">
43+
<div class="container">
44+
&copy; 2022 - Demonstration of SSLCommerz
45+
</div>
46+
</footer>
47+
48+
<script src="~/lib/jquery/dist/jquery.min.js"></script>
49+
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
50+
<script src="~/js/site.js" asp-append-version="true"></script>
51+
52+
@await RenderSectionAsync("Scripts", required: false)
53+
</body>
54+
</html>

Pages/Shared/_Layout.cshtml.css

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
2+
for details on configuring this project to bundle and minify static web assets. */
3+
4+
a.navbar-brand {
5+
white-space: normal;
6+
text-align: center;
7+
word-break: break-all;
8+
}
9+
10+
a {
11+
color: #0077cc;
12+
}
13+
14+
.btn-primary {
15+
color: #fff;
16+
background-color: #1b6ec2;
17+
border-color: #1861ac;
18+
}
19+
20+
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
21+
color: #fff;
22+
background-color: #1b6ec2;
23+
border-color: #1861ac;
24+
}
25+
26+
.border-top {
27+
border-top: 1px solid #e5e5e5;
28+
}
29+
.border-bottom {
30+
border-bottom: 1px solid #e5e5e5;
31+
}
32+
33+
.box-shadow {
34+
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
35+
}
36+
37+
button.accept-policy {
38+
font-size: 1rem;
39+
line-height: inherit;
40+
}
41+
42+
.footer {
43+
position: absolute;
44+
bottom: 0;
45+
width: 100%;
46+
white-space: nowrap;
47+
line-height: 60px;
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
2+
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

Pages/Success.cshtml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@page
2+
@model SuccessModel
3+
@{
4+
ViewData["Title"] = "Success Page";
5+
}
6+
<h1>@ViewData["Title"]</h1>
7+
8+
<p>@Model.Message</p>

Pages/Success.cshtml.cs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
4+
namespace aspnetcore_example.Pages;
5+
6+
[IgnoreAntiforgeryToken]
7+
public class SuccessModel : PageModel
8+
{
9+
private readonly ILogger<SuccessModel> _logger;
10+
public string Message
11+
{
12+
get;
13+
set;
14+
}
15+
16+
public SuccessModel(ILogger<SuccessModel> logger)
17+
{
18+
_logger = logger;
19+
}
20+
21+
public void OnGet()
22+
{
23+
Message = "This is a GET Request.";
24+
}
25+
26+
public void OnPost()
27+
{
28+
Message = "This is a POST Request.";
29+
}
30+
31+
}
32+

Pages/_ViewImports.cshtml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@using aspnetcore_example
2+
@namespace aspnetcore_example.Pages
3+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

Pages/_ViewStart.cshtml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
Layout = "_Layout";
3+
}

0 commit comments

Comments
 (0)