Skip to content

Commit

Permalink
update csharp_checkout checkout page.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiao Hu committed Sep 5, 2019
1 parent 613fbfa commit 7b5536c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
11 changes: 9 additions & 2 deletions connect-examples/v2/csharp_checkout/Pages/Checkout.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,25 @@ public CheckoutModel(IConfiguration configuration)
public IActionResult OnPost()
{
CheckoutApi checkoutApi = new CheckoutApi(configuration: this.configuration);
int amount = (int)float.Parse(Request.Form["amount"]) * 100;

try
{
// create line items for the order
// This example assumes the order information is retrieved and hard coded
// You can find different ways to retrieved order information and fill in the following lineItems object.
List<CreateOrderRequestLineItem> lineItems = new List<CreateOrderRequestLineItem>()
{
new CreateOrderRequestLineItem(
Name: "Test Payment",
Name: "Test Item A",
Quantity: "1",
BasePriceMoney: new Money(Amount: 500,
Currency: Money.CurrencyEnum.USD)
),
new CreateOrderRequestLineItem(
Name: "Test Item B",
Quantity: "3",
BasePriceMoney: new Money(Amount: 1000,
Currency: Money.CurrencyEnum.USD)
)
};

Expand Down
17 changes: 14 additions & 3 deletions connect-examples/v2/csharp_checkout/Pages/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@
<div id="square-logo"></div>
<h1 class="header">Simple Checkout</h1>
</header>
<div class="form-container">
<form method="post" action="Checkout">
<input name="amount" type="text" value="5.00" />
<div class="container">
<form class="form-container" method="post" action="Checkout">
<div class="item-line">
<div class="item-label">Test Item A x 1</div>
<div class="item-amount">$5.00</div>
</div>
<div class="item-line">
<div class="item-label">Test Item B x 3</div>
<div class="item-amount">$30.00</div>
</div>
<div class="item-line total-line">
<div class="item-label">Total</div>
<div class="item-amount">$35.00</div>
</div>
<button type="submit">Pay now!</button>
</form>
</div>
33 changes: 28 additions & 5 deletions connect-examples/v2/csharp_checkout/wwwroot/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,39 @@
padding-top: 25px;
}

body {
background-color: #ececec;
}

.header {
text-align: center;
margin-top: 0;
}

.form-container {
text-align: center;
margin: 0 auto;
width: 320px;
display: flex;
flex-direction: column;
}

.item-line {
display: flex;
}

.item-label {
flex-grow: 1;
}

.item-amount {
font-weight: bold;
}

.total-line {
font-weight: bold;
margin: 5px 0 5px 0;
padding-top: 5px;
border-top: 1px solid #c2c7cc;
}

body {
background-color: #ececec;
}

form {
Expand Down Expand Up @@ -55,3 +77,4 @@ button {
outline: none;
font-family: "HelveticaNeue-Bold", Helvetica, Arial, sans-serif;
}

0 comments on commit 7b5536c

Please sign in to comment.