Skip to content

Commit 566542b

Browse files
author
Ganeshram Chockalingam
committed
Added Samples
1 parent 148d350 commit 566542b

File tree

80 files changed

+3597
-65
lines changed

Some content is hidden

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

80 files changed

+3597
-65
lines changed

.vs/CheckoutNETSDK/xs/UserPrefs.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Properties StartupConfiguration="{1ABBF171-0333-4E55-949A-139CB6FAA33C}|Default">
2+
<MonoDevelop.Ide.Workbench ActiveDocument="Samples/AuthorizeIntentExamples/CaptureOrderSample.cs">
3+
<Files>
4+
<File FileName="Source/AccessToken.cs" Line="1" Column="1" />
5+
<File FileName="Samples/GetOrderSample.cs" Line="36" Column="17" />
6+
<File FileName="Samples/AuthorizeIntentExamples/CaptureOrderSample.cs" Line="15" Column="10" />
7+
<File FileName="Samples/AuthorizeIntentExamples/AuthorizeOrderSample.cs" Line="40" Column="30" />
8+
<File FileName="Source/Payments/AuthorizationsCaptureRequest.cs" Line="20" Column="18" />
9+
</Files>
10+
</MonoDevelop.Ide.Workbench>
11+
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
12+
<MonoDevelop.Ide.DebuggingService.Breakpoints>
13+
<BreakpointStore />
14+
</MonoDevelop.Ide.DebuggingService.Breakpoints>
15+
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
16+
<MonoDevelop.Ide.ItemProperties.Samples PreferredExecutionTarget="MonoDevelop.Default" />
17+
<MultiItemStartupConfigurations />
18+
<MonoDevelop.Ide.ItemProperties.Test PreferredExecutionTarget="MonoDevelop.Default" />
19+
</Properties>

.vs/CheckoutNETSDK/xs/sqlite3/db.lock

Whitespace-only changes.
2.4 MB
Binary file not shown.
32 KB
Binary file not shown.
3.95 MB
Binary file not shown.

CheckoutNETSDK.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Source", "Source\Source.csp
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{EB4A7FDB-ACFE-4E36-B9E7-C6CAAF483ADE}"
99
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples", "Samples\Samples.csproj", "{1ABBF171-0333-4E55-949A-139CB6FAA33C}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
@@ -44,5 +46,17 @@ Global
4446
{EB4A7FDB-ACFE-4E36-B9E7-C6CAAF483ADE}.Release|x64.Build.0 = Release|Any CPU
4547
{EB4A7FDB-ACFE-4E36-B9E7-C6CAAF483ADE}.Release|x86.ActiveCfg = Release|Any CPU
4648
{EB4A7FDB-ACFE-4E36-B9E7-C6CAAF483ADE}.Release|x86.Build.0 = Release|Any CPU
49+
{1ABBF171-0333-4E55-949A-139CB6FAA33C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50+
{1ABBF171-0333-4E55-949A-139CB6FAA33C}.Debug|Any CPU.Build.0 = Debug|Any CPU
51+
{1ABBF171-0333-4E55-949A-139CB6FAA33C}.Debug|x64.ActiveCfg = Debug|Any CPU
52+
{1ABBF171-0333-4E55-949A-139CB6FAA33C}.Debug|x64.Build.0 = Debug|Any CPU
53+
{1ABBF171-0333-4E55-949A-139CB6FAA33C}.Debug|x86.ActiveCfg = Debug|Any CPU
54+
{1ABBF171-0333-4E55-949A-139CB6FAA33C}.Debug|x86.Build.0 = Debug|Any CPU
55+
{1ABBF171-0333-4E55-949A-139CB6FAA33C}.Release|Any CPU.ActiveCfg = Release|Any CPU
56+
{1ABBF171-0333-4E55-949A-139CB6FAA33C}.Release|Any CPU.Build.0 = Release|Any CPU
57+
{1ABBF171-0333-4E55-949A-139CB6FAA33C}.Release|x64.ActiveCfg = Release|Any CPU
58+
{1ABBF171-0333-4E55-949A-139CB6FAA33C}.Release|x64.Build.0 = Release|Any CPU
59+
{1ABBF171-0333-4E55-949A-139CB6FAA33C}.Release|x86.ActiveCfg = Release|Any CPU
60+
{1ABBF171-0333-4E55-949A-139CB6FAA33C}.Release|x86.Build.0 = Release|Any CPU
4761
EndGlobalSection
4862
EndGlobal
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
5+
using CheckoutNetsdk.Orders;
6+
using BraintreeHttp;
7+
8+
namespace Samples.AuthorizeIntentExamples
9+
{
10+
public class AuthorizeOrderSample : SampleSkeleton
11+
{
12+
13+
public async static Task<HttpResponse> AuthorizeOrder(string OrderId, bool debug = false)
14+
{
15+
var request = new OrdersAuthorizeRequest(OrderId);
16+
request.Prefer("return=representation");
17+
request.RequestBody(new OrderActionRequest());
18+
var response = await SampleSkeleton.client().Execute(request);
19+
20+
if (debug)
21+
{
22+
var result = response.Result<Order>();
23+
Console.WriteLine("Status: {0}", result.Status);
24+
Console.WriteLine("Order Id: {0}", result.Id);
25+
Console.WriteLine("Authorization Id: {0}", result.PurchaseUnits[0].Payments.Authorizations[0].Id);
26+
Console.WriteLine("Intent: {0}", result.Intent);
27+
Console.WriteLine("Links:");
28+
foreach (LinkDescription link in result.Links)
29+
{
30+
Console.WriteLine("\t{0}: {1}\tCall Type: {2}", link.Rel, link.Href, link.Method);
31+
}
32+
AmountWithBreakdown amount = result.PurchaseUnits[0].Amount;
33+
Console.WriteLine("Buyer:");
34+
Console.WriteLine("\tEmail Address: {0}", result.Payer.EmailAddress);
35+
}
36+
37+
return response;
38+
}
39+
40+
//static void Main(string[] args)
41+
//{
42+
// string OrderId = "8D641494172581340";
43+
// AuthorizeOrder(OrderId, true).Wait();
44+
//}
45+
}
46+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
5+
using CheckoutNetsdk.Payments;
6+
using BraintreeHttp;
7+
8+
namespace Samples.AuthorizeIntentExamples
9+
{
10+
public class CaptureOrderSample : SampleSkeleton
11+
{
12+
13+
public async static Task<HttpResponse> CaptureOrder(string AuthorizationId, bool debug = false)
14+
{
15+
var request = new AuthorizationsCaptureRequest(AuthorizationId);
16+
request.Prefer("return=representation");
17+
request.RequestBody(new CaptureRequest());
18+
var response = await SampleSkeleton.client().Execute(request);
19+
20+
if (debug)
21+
{
22+
var result = response.Result<Capture>();
23+
Console.WriteLine("Status: {0}", result.Status);
24+
Console.WriteLine("Order Id: {0}", result.Id);
25+
Console.WriteLine("Links:");
26+
foreach (LinkDescription link in result.Links)
27+
{
28+
Console.WriteLine("\t{0}: {1}\tCall Type: {2}", link.Rel, link.Href, link.Method);
29+
}
30+
}
31+
32+
return response;
33+
}
34+
35+
static void Main(string[] args)
36+
{
37+
string OrderId = "1B753033X77480819";
38+
CaptureOrder(OrderId, true).Wait();
39+
}
40+
}
41+
}
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
5+
using CheckoutNetsdk.Orders;
6+
using BraintreeHttp;
7+
8+
namespace Samples.AuthorizeIntentExamples
9+
{
10+
public class CreateOrderSample : SampleSkeleton
11+
{
12+
private static OrderRequest BuildRequestBody()
13+
{
14+
OrderRequest orderRequest = new OrderRequest()
15+
{
16+
Intent = "AUTHORIZE",
17+
18+
ApplicationContext = new ApplicationContext
19+
{
20+
BrandName = "EXAMPLE INC",
21+
LandingPage = "BILLING",
22+
CancelUrl = "https://www.google.com",
23+
ReturnUrl = "https://www.google.com",
24+
UserAction = "CONTINUE",
25+
ShippingPreference = "SET_PROVIDED_ADDRESS"
26+
},
27+
PurchaseUnits = new List<PurchaseUnitRequest>
28+
{
29+
new PurchaseUnitRequest{
30+
ReferenceId = "PUHF",
31+
Description = "Sporting Goods",
32+
CustomId = "CUST-HighFashions",
33+
SoftDescriptor = "HighFashions",
34+
Amount = new AmountWithBreakdown
35+
{
36+
CurrencyCode = "USD",
37+
Value = "230.00",
38+
Breakdown = new AmountBreakdown
39+
{
40+
ItemTotal = new Money
41+
{
42+
CurrencyCode = "USD",
43+
Value = "180.00"
44+
},
45+
Shipping = new Money
46+
{
47+
CurrencyCode = "USD",
48+
Value = "30.00"
49+
},
50+
Handling = new Money
51+
{
52+
CurrencyCode = "USD",
53+
Value = "10.00"
54+
},
55+
TaxTotal = new Money
56+
{
57+
CurrencyCode = "USD",
58+
Value = "20.00"
59+
},
60+
ShippingDiscount = new Money
61+
{
62+
CurrencyCode = "USD",
63+
Value = "10.00"
64+
}
65+
}
66+
},
67+
Items = new List<Item>
68+
{
69+
new Item
70+
{
71+
Name = "T-shirt",
72+
Description = "Green XL",
73+
Sku = "sku01",
74+
UnitAmount = new Money
75+
{
76+
CurrencyCode = "USD",
77+
Value = "90.00"
78+
},
79+
Tax = new Money
80+
{
81+
CurrencyCode = "USD",
82+
Value = "10.00"
83+
},
84+
Quantity = "1",
85+
Category = "PHYSICAL_GOODS"
86+
},
87+
new Item
88+
{
89+
Name = "Shoes",
90+
Description = "Running, Size 10.5",
91+
Sku = "sku02",
92+
UnitAmount = new Money
93+
{
94+
CurrencyCode = "USD",
95+
Value = "45.00"
96+
},
97+
Tax = new Money
98+
{
99+
CurrencyCode = "USD",
100+
Value = "5.00"
101+
},
102+
Quantity = "2",
103+
Category = "PHYSICAL_GOODS"
104+
}
105+
},
106+
Shipping = new ShippingDetails
107+
{
108+
Name = new Name
109+
{
110+
FullName = "John Doe"
111+
},
112+
AddressPortable = new AddressPortable
113+
{
114+
AddressLine1 = "123 Townsend St",
115+
AddressLine2 = "Floor 6",
116+
AdminArea2 = "San Francisco",
117+
AdminArea1 = "CA",
118+
PostalCode = "94107",
119+
CountryCode = "US"
120+
}
121+
}
122+
}
123+
}
124+
};
125+
126+
return orderRequest;
127+
}
128+
129+
public async static Task<HttpResponse> CreateOrder(bool debug=false)
130+
{
131+
var request = new OrdersCreateRequest();
132+
request.Prefer("return=representation");
133+
request.RequestBody(BuildRequestBody());
134+
var response = await SampleSkeleton.client().Execute(request);
135+
136+
if (debug)
137+
{
138+
var result = response.Result<Order>();
139+
Console.WriteLine("Status: {0}", result.Status);
140+
Console.WriteLine("Order Id: {0}", result.Id);
141+
Console.WriteLine("Intent: {0}", result.Intent);
142+
Console.WriteLine("Links:");
143+
foreach(LinkDescription link in result.Links)
144+
{
145+
Console.WriteLine("\t{0}: {1}\tCall Type: {2}", link.Rel, link.Href, link.Method);
146+
}
147+
AmountWithBreakdown amount = result.PurchaseUnits[0].Amount;
148+
Console.WriteLine("Total Amount: {0} {1}", amount.CurrencyCode, amount.Value);
149+
}
150+
151+
return response;
152+
}
153+
154+
//static void Main(string[] args)
155+
//{
156+
// CreateOrder(true).Wait();
157+
//}
158+
}
159+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading.Tasks;
4+
5+
using CheckoutNetsdk.Orders;
6+
using BraintreeHttp;
7+
8+
namespace Samples.CaptureIntentExamples
9+
{
10+
public class CaptureOrderSample : SampleSkeleton
11+
{
12+
13+
public async static Task<HttpResponse> CaptureOrder(string OrderId, bool debug = false)
14+
{
15+
var request = new OrdersCaptureRequest(OrderId);
16+
request.Prefer("return=representation");
17+
request.RequestBody(new OrderActionRequest());
18+
var response = await SampleSkeleton.client().Execute(request);
19+
20+
if (debug)
21+
{
22+
var result = response.Result<Order>();
23+
Console.WriteLine("Status: {0}", result.Status);
24+
Console.WriteLine("Order Id: {0}", result.Id);
25+
Console.WriteLine("Intent: {0}", result.Intent);
26+
Console.WriteLine("Links:");
27+
foreach (LinkDescription link in result.Links)
28+
{
29+
Console.WriteLine("\t{0}: {1}\tCall Type: {2}", link.Rel, link.Href, link.Method);
30+
}
31+
AmountWithBreakdown amount = result.PurchaseUnits[0].Amount;
32+
Console.WriteLine("Buyer:");
33+
Console.WriteLine("\tEmail Address: {0}\n\tName: {1}\n\tPhone Number: {2}{3}", result.Payer.EmailAddress, result.Payer.Name.FullName, result.Payer.Phone.CountryCode, result.Payer.Phone.NationalNumber);
34+
}
35+
36+
return response;
37+
}
38+
39+
//static void Main(string[] args)
40+
//{
41+
// string OrderId = "0FG2496500642503G";
42+
// CaptureOrder(OrderId, true).Wait();
43+
//}
44+
}
45+
}

0 commit comments

Comments
 (0)