Skip to content

Commit

Permalink
Add payment sample
Browse files Browse the repository at this point in the history
  • Loading branch information
msft-shahins committed May 10, 2017
1 parent 015faad commit 78af7ce
Show file tree
Hide file tree
Showing 40 changed files with 3,135 additions and 0 deletions.
239 changes: 239 additions & 0 deletions CSharp/sample-payments/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
build/
bld/
[Bb]in/
[Oo]bj/
ecf/
rcf/

# Visual Studio 2015 cache/options directory
.vs/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

# NUNIT
*.VisualState.xml
TestResult.xml

# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c

# DNX
*.lock.json
artifacts/

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc

# Chutzpah Test files
_Chutzpah*

# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opensdf
*.sdf
*.cachefile

# Visual Studio profiler
*.psess
*.vsp
*.vspx

# TFS 2012 Local Workspace
$tf/

# Guidance Automation Toolkit
*.gpState

# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user

# JustCode is a .NET coding add-in
.JustCode

# TeamCity is a build add-in
_TeamCity*

# DotCover is a Code Coverage Tool
*.dotCover

# NCrunch
_NCrunch_*
.*crunch*.local.xml

# MightyMoose
*.mm.*
AutoTest.Net/

# Web workbench (sass)
.sass-cache/

# Installshield output folder
[Ee]xpress/

# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html

# Click-Once directory
publish/

# Publish Web Output
*.[Pp]ublish.xml
## TODO: Comment the next line if you want to checkin your
## web deploy settings but do note that will include unencrypted
## passwords
#*.pubxml

## ignore imporeted publish xml files
*intercom-botdirectory-scratch\ -\ FTP.pubxml
*intercom-botdirectory-scratch\ -\ Web\ Deploy.pubxml

*.publishproj

# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config

# Windows Azure Build Output
csx/
*.build.csdef

# Windows Store app package directory
AppPackages/

# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/

# Others
ClientBin/
[Ss]tyle[Cc]op.*
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs

# RIA/Silverlight projects
Generated_Code/

# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm

# SQL Server files
*.mdf
*.ldf

# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings

# Microsoft Fakes
FakesAssemblies/

# Node.js Tools for Visual Studio
.ntvs_analysis.dat

# Visual Studio 6 build log
*.plg

# Visual Studio 6 workspace options file
*.opt

# LightSwitch generated files
GeneratedArtifacts/
_Pvt_Extensions/
ModelManifest.xml
/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll
/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.xml
/PublishScripts/Scripts/Deploy-AzureResourceGroup-5.ps1
/PublishScripts









# User-specific files
Documentation/Doxygen_warnings.txt

# Build results
Documentation/docs/

# Azure publish profiles
*.pubxml
PublishProfiles/
22 changes: 22 additions & 0 deletions CSharp/sample-payments/PaymentsBot.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PaymentsBot", "PaymentsBot\PaymentsBot.csproj", "{A8BA1066-5695-4D71-ABB4-65E5A5E0C3D4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A8BA1066-5695-4D71-ABB4-65E5A5E0C3D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8BA1066-5695-4D71-ABB4-65E5A5E0C3D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8BA1066-5695-4D71-ABB4-65E5A5E0C3D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8BA1066-5695-4D71-ABB4-65E5A5E0C3D4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
namespace PaymentsBot.Activities
{
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Web.Http;
using Microsoft.Bot.Builder.Internals.Fibers;
using Microsoft.Bot.Builder.Scorables;
using Microsoft.Bot.Connector;

public sealed class ActivityControllerDispatcher : Dispatcher
{
private readonly ApiController controller;
private readonly Activity activity;
private readonly HttpResponseMessage response;

public ActivityControllerDispatcher(ApiController controller, Activity activity, HttpResponseMessage response)
{
SetField.NotNull(out this.controller, nameof(controller), controller);
SetField.NotNull(out this.activity, nameof(activity), activity);
SetField.NotNull(out this.response, nameof(response), response);
}

protected override Type MakeType()
{
return this.controller.GetType();
}

protected override IReadOnlyList<object> MakeServices()
{
var credentials = new MicrosoftAppCredentials();
var connector = new ConnectorClient(new Uri(this.activity.ServiceUrl), credentials);

StateClient storage;
if (this.activity.ChannelId == "emulator")
{
storage = new StateClient(new Uri(this.activity.ServiceUrl), credentials);
}
else
{
storage = new StateClient(credentials);
}

return new object[] { this.controller, this.activity, this.response, connector, storage };
}
}
}
39 changes: 39 additions & 0 deletions CSharp/sample-payments/PaymentsBot/AppSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace PaymentsBot
{
using System;
using System.Configuration;

/// <summary>
/// App Settings
/// </summary>
public static class AppSettings
{
private static Lazy<string> invalidShippingCountry = new Lazy<string>(() => ConfigurationManager.AppSettings["InvalidShippingCountry"]);

private static Lazy<bool> liveMode = new Lazy<bool>(() => bool.TrueString.Equals(ConfigurationManager.AppSettings["LiveMode"], StringComparison.OrdinalIgnoreCase));

private static Lazy<string> merchantId = new Lazy<string>(() => ConfigurationManager.AppSettings["MerchantId"]);

private static Lazy<string> stripeApiKey = new Lazy<string>(() => ConfigurationManager.AppSettings["StripeApiKey"]);

/// <summary>
/// Invalid shipping country
/// </summary>
public static string InvalidShippingCountry => invalidShippingCountry.Value;

/// <summary>
/// Live Mode value
/// </summary>
public static bool LiveMode => liveMode.Value;

/// <summary>
/// Merchant Id
/// </summary>
public static string MerchantId => merchantId.Value;

/// <summary>
/// Stripe Api Key
/// </summary>
public static string StripeApiKey => stripeApiKey.Value;
}
}
33 changes: 33 additions & 0 deletions CSharp/sample-payments/PaymentsBot/App_Start/WebApiConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace PaymentsBot
{
using System.Web.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Json settings
config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;
JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
Formatting = Newtonsoft.Json.Formatting.Indented,
NullValueHandling = NullValueHandling.Ignore,
};

// Web API configuration and services

// Web API routes
config.MapHttpAttributeRoutes();

config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional });
}
}
}
Loading

0 comments on commit 78af7ce

Please sign in to comment.