diff --git a/.gitignore b/.gitignore index d5bb44b..7f0d9d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,352 +1,8 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. -## -## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore - -# 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/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015/2017 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# Visual Studio 2017 auto generated files -Generated\ Files/ - -# 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 - -# Benchmark Results -BenchmarkDotNet.Artifacts/ - -# .NET Core -project.lock.json -project.fragment.lock.json -artifacts/ -**/Properties/launchSettings.json - -# StyleCop -StyleCopReport.xml - -# Files built by Visual Studio -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.iobj -*.pch -*.pdb -*.ipdb -*.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 -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# Visual Studio Trace Files -*.e2e - -# 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 - -# AxoCover is a Code Coverage Tool -.axoCover/* -!.axoCover/settings.json - -# Visual Studio code coverage results -*.coverage -*.coveragexml - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# 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 -*.azurePubxml -# Note: Comment the next line if you want to checkin your web deploy settings, -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/[Pp]ackages/* -# except build/, which is used as an MSBuild target. -!**/[Pp]ackages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/[Pp]ackages/repositories.config -# NuGet v3's project.json files produces more ignorable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt -*.appx - -# 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/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.jfm -*.pfx -*.publishsettings -orleans.codegen.cs - -# Including strong name files can present a security risk -# (https://github.com/github/gitignore/pull/2483#issue-259490424) -#*.snk - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# 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 -ServiceFabricBackup/ -*.rptproj.bak - -# SQL Server files -*.mdf -*.ldf -*.ndf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings -*.rptproj.rsuser - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat -node_modules/ - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) -*.vbw - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider +obj +packages +bin +cybersource-rest-samples-netcore.csproj.user +.vs .idea/ -*.sln.iml - -# CodeRush -.cr/ - -# Python Tools for Visual Studio (PTVS) -__pycache__/ -*.pyc - -# Cake - Uncomment if you are using it -# tools/** -# !tools/packages.config - -# Tabs Studio -*.tss - -# Telerik's JustMock configuration file -*.jmconfig - -# BizTalk build output -*.btp.cs -*.btm.cs -*.odx.cs -*.xsd.cs - -# OpenCover UI analysis results -OpenCover/ - -# Azure Stream Analytics local run output -ASALocalRun/ - -# MSBuild Binary and Structured Log -*.binlog - -# NVidia Nsight GPU debugger configuration file -*.nvuser - -# MFractors (Xamarin productivity tool) working folder -.mfractor/ -/src/RestSharp.xml -/src/RestSharp.dll -/src/NLog.xml -/src/NLog.dll -/src/Newtonsoft.Json.xml -/src/Newtonsoft.Json.dll -/src/jose-jwt.dll -/src/FlexServerSDK.xml -/src/FlexServerSDK.dll -/src/CyberSource.dll -/src/cybersource-rest-samples-dotnet.vshost.exe.config -/src/cybersource-rest-samples-dotnet.vshost.exe -/src/cybersource-rest-samples-dotnet.exe.config -/src/cybersource-rest-samples-dotnet.exe -/src/AuthenticationSdk.dll -/src/cybersource-rest-samples-dotnet.vshost.exe.manifest -/src/SampleCode.exe -/src/SampleCode.vshost.exe -/src/SampleCode.vshost.exe.config -/src/SampleCode.vshost.exe.manifest -/src/SampleCode.exe.config -/src/cybersource-rest-client-dotnet.dll +*.log +.DS_Store diff --git a/.travis.yml b/.travis.yml index 8d4dad6..8c8d22c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,9 @@ os: windows - + language: cpp - + before_install: - powershell -c "Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine" - powershell -c "Import-Module PackageManagement; Install-PackageProvider Nuget" @@ -13,12 +13,13 @@ before_install: - export PATH="c:\tools\NuGet.CommandLine\tools":$PATH install: + - choco install dotnetcore-sdk - nuget restore cybersource-rest-samples-csharp.sln before_script: - MSBuild.exe cybersource-rest-samples-csharp.sln - - cd src - + script: - - dir - - ./SampleCode.exe RunAll + - ./bin/Debug/net461/SampleCode.exe RunAll + - dotnet build cybersource-rest-samples-netcore.sln + - dotnet bin/Debug/netcoreapp3.1/SampleCodeNetCore.dll RunAll diff --git a/Logging_Net461.md b/Logging_Net461.md new file mode 100644 index 0000000..9ae2c2c --- /dev/null +++ b/Logging_Net461.md @@ -0,0 +1,83 @@ +[![Generic badge](https://img.shields.io/badge/LOGGING-NEW-GREEN.svg)](https://shields.io/) + +# Logging in CyberSource REST Client SDK (.NET) + +Since v0.0.1.14, a new logging framework has been introduced in the SDK. This new logging framework makes use of NLog, and standardizes the logging so that it can be integrated with the logging in the client application. The decision to use NLog for building this logging framework has been taken based on benchmark studies that have been made on various logging platforms supported for C#/.NET. + +[One such study](https://www.loggly.com/blog/benchmarking-5-popular-net-logging-libraries/) performed benchmarking of five logging frameworks on the market — Log4Net, ELMAH, NLog, Microsoft Enterprise Library, and NSpring. In this study, + +> _For heavy-hitting applications that require file logging and speed, NLog was clearly the winner. NLog also has good support from the community with integrationsfor log management solutions._ + +## NLog Configuration + +NLog is a flexible and free logging platform for various .NET platforms, including .NET standard. NLog makes it easy to write to several targets (database, file, console) and change the logging configuration on-the-fly. + +Refer this [document of NLog Configuration](https://nlog-project.org/config/) for a complete and detailed description of all the configuration options. + +## Setup + +In order to leverage the new logging framework, it is required to install the **`NLog.Config`** package into the .NET project. This can be done using the Package Manager, steps for which can be found on the [NuGet page for the package](https://www.nuget.org/packages/NLog.Config/). + +When the **`NLog.Config`** package is installed, it will add two new files to the project — **`NLog.config`** and **`NLog.xsd`**. + +**Note that the package name is `NLog.Config` and the name of the newly added file is `NLog.config`.** + +The **`Copy To Output Directory`** property of this `NLog.config` file needs to be set to **`Copy Always`**. + +## Sample NLog.config File + +```xml + + + + + + + + + + + + + + + + +``` + +### Important Notes + +* The logger name in the rule must match the **'Logger name of the Logger object'**. It can include wildcard characters (`*`, `?`). +* The logger name can be the namespace from which logging statements should be honored. + * In case `name="*"` is used, all logging statements from all namespaces will be written to log. This will include logging statements from inside the SDK as well. + * If logging statements from inside the SDK should not be logged, provide specific namespaces in the rules. +* The `minlevel` field denotes the minimum level to log. In a production environment, this may be set to `Warn`. +* The variable `enableMasking` needs to be set to `true` if sensitive data in the request/response should be hidden/masked. + * Sensitive data fields are listed below: + * Card Security Code + * Card Number + * Any field with `number` in the name + * Card Expiration Month + * Card Expiration Year + * Account + * Routing Number + * Email + * First Name & Last Name + * Phone Number + * Type + * Token + * Signature diff --git a/Logging_NetCore.md b/Logging_NetCore.md new file mode 100644 index 0000000..f735fa0 --- /dev/null +++ b/Logging_NetCore.md @@ -0,0 +1,91 @@ +[![Generic badge](https://img.shields.io/badge/LOGGING-NEW-GREEN.svg)](https://shields.io/) + +# Logging in CyberSource REST Client SDK (.NET Standard) + +Since v0.0.1.7, a new logging framework has been introduced in the SDK. This new logging framework makes use of NLog, and standardizes the logging so that it can be integrated with the logging in the client application. The decision to use NLog for building this logging framework has been taken based on benchmark studies that have been made on various logging platforms supported for C#/.NET. + +[One such study](https://www.loggly.com/blog/benchmarking-5-popular-net-logging-libraries/) performed benchmarking of five logging frameworks on the market — Log4Net, ELMAH, NLog, Microsoft Enterprise Library, and NSpring. In this study, + +> _For heavy-hitting applications that require file logging and speed, NLog was clearly the winner. NLog also has good support from the community with integrationsfor log management solutions._ + +## NLog Configuration + +NLog is a flexible and free logging platform for various .NET platforms, including .NET standard. NLog makes it easy to write to several targets (database, file, console) and change the logging configuration on-the-fly. + +Refer this [document of NLog Configuration](https://nlog-project.org/config/) for a complete and detailed description of all the configuration options. + +## Setup + +In order to leverage the new logging framework, it is required to install the **`NLog.Schema`** package into the .NET project. This can be done using the Package Manager, steps for which can be found on the [NuGet page for the package](https://www.nuget.org/packages/NLog.Config/). + +When the **`NLog.Schema`** package is installed, it will add new file to the project — **`NLog.xsd`**. + +Create and add the **`NLog.config`** file to main directory of your source project and sample for **`NLog.config`** file is given below: + +## Sample NLog.config File + +```xml + + + + + + + + + + + + + + + + +``` + +The **`Copy To Output Directory`** property of this `NLog.config` file needs to be set to **`Copy Always`**. +Or this can be done by adding below lines to your **`Project.csproj`** file. +```xml + + + Always + + +``` + +### Important Notes + +* The logger name in the rule must match the **'Logger name of the Logger object'**. It can include wildcard characters (`*`, `?`). +* The logger name can be the namespace from which logging statements should be honored. + * In case `name="*"` is used, all logging statements from all namespaces will be written to log. This will include logging statements from inside the SDK as well. + * If logging statements from inside the SDK should not be logged, provide specific namespaces in the rules. +* The `minlevel` field denotes the minimum level to log. In a production environment, this may be set to `Warn`. +* The variable `enableMasking` needs to be set to `true` if sensitive data in the request/response should be hidden/masked. + * Sensitive data fields are listed below: + * Card Security Code + * Card Number + * Any field with `number` in the name + * Card Expiration Month + * Card Expiration Year + * Account + * Routing Number + * Email + * First Name & Last Name + * Phone Number + * Type + * Token + * Signature diff --git a/NLog.config b/NLog.config new file mode 100644 index 0000000..cfbca0f --- /dev/null +++ b/NLog.config @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/NLog.xsd b/NLog.xsd similarity index 55% rename from src/NLog.xsd rename to NLog.xsd index 075bb91..cf06a05 100644 --- a/src/NLog.xsd +++ b/NLog.xsd @@ -37,12 +37,12 @@ - Global log level threshold for application log messages. Messages below this level won't be logged.. + Global log level threshold for application log messages. Messages below this level won't be logged. - Throw an exception when there is an internal error. Default value is: false. + Throw an exception when there is an internal error. Default value is: false. Not recommend to set to true in production! @@ -72,7 +72,7 @@ - Perform mesage template parsing and formatting of LogEvent messages (true = Always, false = Never, empty = Auto Detect). Default value is: empty. + Perform message template parsing and formatting of LogEvent messages (true = Always, false = Never, empty = Auto Detect). Default value is: empty. @@ -123,7 +123,7 @@ - Name of the logger. May include '*' character which acts like a wildcard. Allowed forms are: *, Name, *Name, Name* and *Name* + Filter on the name of the logger. May include wildcard characters ('*' or '?'). @@ -158,7 +158,17 @@ - Enable or disable logging rule. Disabled rules are ignored. + Enable this rule. Note: disabled rules aren't available from the API. + + + + + Rule identifier to allow rule lookup with Configuration.FindRuleByName and Configuration.RemoveRuleByName. + + + + + Loggers matching will be restricted to specified minimum level for following rules. @@ -171,6 +181,11 @@ + + + Default action if none of the filters match. + + @@ -210,12 +225,19 @@ + + + + Variable value. Note, the 'value' attribute has precedence over this one. + + + Variable name. - + Variable value. @@ -274,47 +296,53 @@ - - - - - - - + + + + + + + + Name of the target. - + - Number of log events that should be processed in a batch by the lazy writer thread. + Action to be taken when the lazy writer thread request queue count exceeds the set limit. - + - Limit of full s to write before yielding into Performance is better when writing many small batches, than writing a single large batch + Limit on the number of requests in the lazy writer thread request queue. - + - Action to be taken when the lazy writer thread request queue count exceeds the set limit. + Number of log events that should be processed in a batch by the lazy writer thread. - + - Limit on the number of requests in the lazy writer thread request queue. + Whether to use the locking queue, instead of a lock-free concurrent queue The locking queue is less concurrent when many logger threads, but reduces memory allocation + + + + + Limit of full s to write before yielding into Performance is better when writing many small batches, than writing a single large batch - Time in milliseconds to sleep between batches. + Time in milliseconds to sleep between batches. (1 or less means trigger on new activity) - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -331,11 +359,17 @@ - - - - + + + + + + + + Name of the target. + + Delay the flush until the LogEvent has been confirmed as written @@ -346,14 +380,14 @@ Condition expression. Log events who meet this condition will cause a flush on the wrapped target. - + - Name of the target. + Only flush when LogEvent matches condition. Ignore explicit-flush, config-reload-flush and shutdown-flush - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -363,31 +397,31 @@ - - - - - - + + + + + + Name of the target. - + Number of log events to be buffered. - + - Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes. + Action to take if the buffer overflows. - + - Action to take if the buffer overflows. + Timeout (in milliseconds) after which the contents of buffer will be flushed if there's no write in the specified period of time. Use -1 to disable timed flushes. @@ -395,9 +429,9 @@ Indicates whether to use sliding timeout. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -413,162 +447,186 @@ - - - - - - - - - - - - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. - + - Encoding to be used. + Separator for operation-states-stack. - + - Instance of that is used to format log messages. + Stack separator for log4j:NDC in output from nested context. - + - End of line value if a newline is appended at the end of log message . + Renderer for log4j:event logger-xml-attribute (Default ${logger}) - + - Maximum message size in bytes. + Whether to include the contents of the properties-dictionary. - + - Indicates whether to append newline at the end of log message. + Whether to include log4j:NDC in output from nested context. - + - Action that should be taken if the will be more connections than . + Indicates whether to include source info (file name and line number) in the information sent over the network. - + - Maximum queue size. + Whether to include log4j:NDC in output from nested context. - + - Maximum current connections. 0 = no maximum. + Option to include all properties from the log events - + - Indicates whether to keep connection open whenever possible. + Indicates whether to include call site (class and method name) in the information sent over the network. - + - Size of the connection cache (number of connections which are kept alive). + AppInfo field. By default it's the friendly name of the current AppDomain. - + - Network address. + Instance of that is used to format log messages. + + + + + Indicates whether to include NLog-specific extensions to log4j schema. + + + + + Action that should be taken, when more connections than . + + + + + Get or set the SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. + + + + + Action that should be taken, when more pending messages than . - Action that should be taken if the message is larger than maxMessageSize. + Action that should be taken if the message is larger than - + - NDLC item separator. + Maximum queue size for a single connection. Requires = true - + - NDC item separator. + Size of the connection cache (number of connections which are kept alive). Requires = true - + - Indicates whether to include NLog-specific extensions to log4j schema. + Indicates whether to keep connection open whenever possible. - + - Indicates whether to include source info (file name and line number) in the information sent over the network. + The number of seconds a connection will remain idle before the first keep-alive probe is sent - + - Indicates whether to include contents of the stack. + Network address. - + - Indicates whether to include stack contents. + Maximum simultaneous connections. Requires = false - + - Indicates whether to include dictionary contents. + Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - + - Indicates whether to include dictionary contents. + Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - + - Indicates whether to include call site (class and method name) in the information sent over the network. + Indicates whether to append newline at the end of log message. - + - Option to include all properties from the log events + Encoding to be used. - + - AppInfo field. By default it's the friendly name of the current AppDomain. + End of line value if a newline is appended at the end of log message . - + - Renderer for log4j:event logger-xml-attribute (Default ${logger}) + Maximum message size in bytes. On limit breach then action is activated. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -576,11 +634,32 @@ + + + + + + + + + + + + + + + + + + + + + @@ -588,19 +667,32 @@ + + + + + + + - - + + + + + + Viewer parameter name. + + - Layout that should be use to calcuate the value for the parameter. + Layout that should be use to calculate the value for the parameter. - + - Viewer parameter name. + Whether an attribute with empty value should be included in the output @@ -608,17 +700,20 @@ - - - - - - - - + + + + + + + + + + + - + @@ -645,14 +740,29 @@ Indicates whether to auto-check if the console is available. - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) + + + Enables output using ANSI Color Codes + + The encoding for writing messages to the . - + - Indicates whether the error stream (stderr) should be used instead of the output stream (stdout). + Indicates whether to send the log messages to the standard error instead of the standard output. + + + + + Indicates whether to auto-flush after + + + + + Indicates whether to auto-check if the console has been redirected to file - Disables coloring logic when System.Console.IsOutputRedirected = true @@ -660,9 +770,9 @@ Indicates whether to use default row highlighting rules. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -691,18 +801,18 @@ - - - + + + - + - Condition that must be met in order to set the specified foreground and background color. + Background color. - + - Background color. + Condition that must be met in order to set the specified foreground and background color. @@ -713,19 +823,35 @@ - - - - - - - + + + + + + + + + + + Background color. + + Compile the ? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used. + + + Condition that must be met before scanning the row for highlight of words + + + + + Foreground color. + + Indicates whether to ignore case when comparing texts. @@ -746,29 +872,21 @@ Indicates whether to match whole words only. - - - Background color. - - - - - Foreground color. - - - - - - - - - - + + + + + + + + + + @@ -790,6 +908,11 @@ Footer. + + + Indicates whether to auto-flush after + + Indicates whether to auto-check if the console is available - Disables console writing if Environment.UserInteractive = False (Windows Service) - Disables console writing if Console Standard Input is not available (Non-Console-App) @@ -800,243 +923,121 @@ The encoding for writing messages to the . - + Indicates whether to send the log messages to the standard error instead of the standard output. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + Whether to activate internal buffering to allow batch writing, instead of using + + + + + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. - + - - - - - - - - - - - - - - - - - + + + + + Name of the target. - - - Obsolete - value will be ignored! The logging code always runs outside of transaction. Gets or sets a value indicating whether to use database transactions. Some data providers require this. - - - + - Database user name. If the ConnectionString is not provided this value will be used to construct the "User ID=" part of the connection string. + Text to be rendered. - + - Name of the database provider. + Header. - + - Database password. If the ConnectionString is not provided this value will be used to construct the "Password=" part of the connection string. + Footer. - + - Indicates whether to keep the database connection open between the log events. + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. - + + + + + + + + + + + + + + - Database name. If the ConnectionString is not provided this value will be used to construct the "Database=" part of the connection string. + Name of the target. - + - Name of the connection string (as specified in <connectionStrings> configuration section. + Text to be rendered. - + - Connection string. When provided, it overrides the values specified in DBHost, DBUserName, DBPassword, DBDatabase. + Header. - + - Database host name. If the ConnectionString is not provided this value will be used to construct the "Server=" part of the connection string. + Footer. - + - Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used. + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. - + + + + + + + + + + + + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + Name of the target. - + - Text of the SQL command to be run on each log level. + Layout used to format log messages. - + - Type of the SQL command to be run on each log level. - - - - - - - - - - - - - - - - - - - - - - - Type of the command. - - - - - Connection string to run the command against. If not provided, connection string from the target is used. - - - - - Indicates whether to ignore failures. - - - - - Command text. - - - - - - - - - - - - - - Layout that should be use to calcuate the value for the parameter. - - - - - Database parameter name. - - - - - Database parameter precision. - - - - - Database parameter scale. - - - - - Database parameter size. - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit - - - - - - - - - - - - - - - - Name of the target. - - - - - Layout used to format log messages. - - - - - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -1046,18 +1047,18 @@ - - - - - - - - - - - - + + + + + + + + + + + + @@ -1076,7 +1077,7 @@ - Optional entrytype. When not set, or when not convertable to then determined by + Optional entry type. When not set, or when not convertible to then determined by @@ -1096,7 +1097,7 @@ - Maximum Event log size in kilobytes. If null, the value won't be set. Default is 512 Kilobytes as specified by Eventlog API + Maximum Event log size in kilobytes. @@ -1114,9 +1115,9 @@ Action to take if the message is larger than the option. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -1133,9 +1134,10 @@ - - - + + + + @@ -1147,9 +1149,14 @@ Indicates whether to return to the first target after any successful write. - + + + Whether to enable batching, but fallback will be handled individually + + + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -1159,52 +1166,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. + + + Name of the file to write to. + + Text to be rendered. @@ -1220,24 +1233,34 @@ Footer. - + - File encoding. + Indicates whether the footer should be written only when the file is archived. - + - Line ending mode. + Maximum number of archive files that should be kept. - + - Indicates whether to compress archive files into the zip archive format. + Maximum days of archive files that should be kept. - + - Way file archives are numbered. + Value of the file size threshold to archive old log file on startup. + + + + + Indicates whether to archive old log file on startup. + + + + + Indicates whether to compress archive files into the zip archive format. @@ -1255,29 +1278,29 @@ Indicates whether to automatically archive log files every time the specified time passes. - + - Size in bytes above which log files will be automatically archived. Warning: combining this with isn't supported. We cannot create multiple archive files, if they should have the same name. Choose: + Value specifying the date format to use when archiving files. - + - Maximum number of archive files that should be kept. + Size in bytes above which log files will be automatically archived. - + - Indicates whether the footer should be written only when the file is archived. + Way file archives are numbered. - + - Maximum number of log filenames that should be stored as existing. + Indicates whether to create directories if they do not exist. - + - Is the an absolute or relative path? + Indicates whether file creation calls should be synchronized by a system global mutex. @@ -1285,19 +1308,24 @@ Gets or set a value indicating whether a managed file stream is forced, instead of using the native implementation. - + - Value indicationg whether file creation calls should be synchronized by a system global mutex. + Is the an absolute or relative path? - + - Indicates whether to replace file contents on each write instead of appending log message at the end. + File attributes (Windows only). + + + + + Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong. - Indicates whether to write BOM (byte order mark) in created files + Indicates whether to write BOM (byte order mark) in created files. Defaults to true for UTF-16 and UTF-32 @@ -1305,44 +1333,44 @@ Indicates whether to enable log file(s) to be deleted. - + - Name of the file to write to. + Indicates whether to delete old log file on startup. - + - Value specifying the date format to use when archiving files. + File encoding. - + - Indicates whether to archive old log file on startup. + Indicates whether to replace file contents on each write instead of appending log message at the end. - + - Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong. + Line ending mode. - + - Indicates whether to create directories if they do not exist. + Whether or not this target should just discard all data that its asked to write. Mostly used for when testing NLog Stack except final write - + - Indicates whether to delete old log file on startup. + Delay in milliseconds to wait before attempting to write to the file again. - + - File attributes (Windows only). + Maximum number of seconds before open files are flushed. Zero or negative means disabled. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + Maximum number of seconds that files are kept open. Zero or negative means disabled. @@ -1350,9 +1378,14 @@ Indicates whether concurrent writes to the log file by multiple processes on different network hosts. - + + + Log file buffer size in bytes. + + + - Maximum number of seconds that files are kept open. If this number is negative the files are not automatically closed after a period of inactivity. + Indicates whether to automatically flush the file buffers after each log message. @@ -1365,11 +1398,6 @@ Indicates whether to keep log file open instead of opening and closing it on each logging event. - - - Whether or not this target should just discard all data that its asked to write. Mostly used for when testing NLog Stack except final write - - Indicates whether concurrent writes to the log file by multiple processes on the same host. @@ -1380,37 +1408,14 @@ Number of times the write is appended on the file before NLog discards the log message. - - - Delay in milliseconds to wait before attempting to write to the file again. - - - - - Log file buffer size in bytes. - - - - - Maximum number of seconds before open files are flushed. If this number is negative or zero the files are not flushed by timer. - - - + - Indicates whether to automatically flush the file buffers after each log message. + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. - - - - - - - - @@ -1435,6 +1440,14 @@ + + + + + + + + @@ -1459,9 +1472,10 @@ - - - + + + + @@ -1473,285 +1487,141 @@ Condition expression. Log events who meet this condition will be forwarded to the wrapped target. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. - + - - - - - - - - - + + + Name of the target. - - - Windows domain name to change context to. - - - - - Required impersonation level. - - - - - Type of the logon provider. - - - - - Logon Type. - - - - - User account password. - - - + - Indicates whether to revert to the credentials of the process instead of impersonating another user. + Identifier to perform group-by - + - Username to change context to. - - - - - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + - Interval in which messages will be written up to the number of messages. + Name of the target. - + - Maximum allowed number of messages written per . + Interval in which messages will be written up to the number of messages. - + - Name of the target. + Maximum allowed number of messages written per . - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. - + - Endpoint address. + Text to be rendered. - + - Name of the endpoint configuration in WCF configuration file. + Header. - + - Indicates whether to use a WCF service contract that is one way (fire and forget) or two way (request-reply) + Footer. - + - Client ID. + Indicates whether NewLine characters in the body should be replaced with tags. - + - Indicates whether to include per-event properties in the payload sent to the server. + Priority used for sending mails. - + - Indicates whether to use binary message encoding. + Encoding to be used for sending e-mail. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit - - - - - - - - - - - - - - - Layout that should be use to calculate the value for the parameter. - - - - - Name of the parameter. - - - - - Type of the parameter. - - - - - Type of the parameter. Obsolete alias for - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Name of the target. - - - - - Text to be rendered. - - - - - Header. - - - - - Footer. - - - - - Indicates whether NewLine characters in the body should be replaced with tags. - - - - - Priority used for sending mails. - - - - - Encoding to be used for sending e-mail. - - - - - BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). + BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). @@ -1789,12 +1659,12 @@ Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com). - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. - + Indicates the SMTP client timeout. @@ -1824,7 +1694,7 @@ Indicates whether SSL (secure sockets layer) should be used when communicating with SMTP server. - + Port number that SMTP Server is listening on. @@ -1834,7 +1704,7 @@ Indicates whether the default Settings from System.Net.MailSettings should be used. - + Folder where applications save mail messages to be processed by the local SMTP server. @@ -1865,9 +1735,12 @@ - - - + + + + + + @@ -1876,12 +1749,27 @@ - Layout used to format log messages. + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Max number of items to have in memory - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -1891,11 +1779,11 @@ - - - + - + + + @@ -1912,32 +1800,65 @@ Method name. The method must be public and static. Use the AssemblyQualifiedName , https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx e.g. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. + + + + + + + + + + Name of the parameter. + + + + + Layout that should be use to calculate the value for the parameter. + + + + + Fallback value when result value is not available + + + + + Type of the parameter. + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -1949,64 +1870,89 @@ Layout used to format log messages. - + - Encoding to be used. + Get or set the SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - + - End of line value if a newline is appended at the end of log message . + Action that should be taken, when more pending messages than . - + - Maximum message size in bytes. + Action that should be taken, when more connections than . - + - Indicates whether to append newline at the end of log message. + Maximum queue size for a single connection. Requires = true - + - Network address. + Action that should be taken if the message is larger than + + + + + Indicates whether to keep connection open whenever possible. + + + + + The number of seconds a connection will remain idle before the first keep-alive probe is sent - Size of the connection cache (number of connections which are kept alive). + Size of the connection cache (number of connections which are kept alive). Requires = true - + - Indicates whether to keep connection open whenever possible. + Network address. - Maximum current connections. 0 = no maximum. + Maximum simultaneous connections. Requires = false - + - Maximum queue size. + Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - + - Action that should be taken if the will be more connections than . + Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - + + + Indicates whether to append newline at the end of log message. + + + + + Encoding to be used. + + + - Action that should be taken if the message is larger than maxMessageSize. + End of line value if a newline is appended at the end of log message . + + + + + Maximum message size in bytes. On limit breach then action is activated. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -2016,107 +1962,96 @@ - - - - - - - - - - - - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + Name of the target. - - - Encoding to be used. - - - - - Instance of that is used to format log messages. - - - - - End of line value if a newline is appended at the end of log message . - - - + - Maximum message size in bytes. + Separator for operation-states-stack. - + - Indicates whether to append newline at the end of log message. + Stack separator for log4j:NDC in output from nested context. - + - Action that should be taken if the will be more connections than . + Renderer for log4j:event logger-xml-attribute (Default ${logger}) - + - Maximum queue size. + Whether to include the contents of the properties-dictionary. - + - Maximum current connections. 0 = no maximum. + Whether to include log4j:NDC in output from nested context. - + - Indicates whether to keep connection open whenever possible. + Indicates whether to include source info (file name and line number) in the information sent over the network. - + - Size of the connection cache (number of connections which are kept alive). + Whether to include log4j:NDC in output from nested context. - + - Network address. + Option to include all properties from the log events - + - Action that should be taken if the message is larger than maxMessageSize. + Indicates whether to include call site (class and method name) in the information sent over the network. - + - NDLC item separator. + AppInfo field. By default it's the friendly name of the current AppDomain. - + - NDC item separator. + Instance of that is used to format log messages. @@ -2124,219 +2059,134 @@ Indicates whether to include NLog-specific extensions to log4j schema. - + - Indicates whether to include source info (file name and line number) in the information sent over the network. + Action that should be taken, when more connections than . - + - Indicates whether to include contents of the stack. + Get or set the SSL/TLS protocols. Default no SSL/TLS is used. Currently only implemented for TCP. - + - Indicates whether to include stack contents. + Action that should be taken, when more pending messages than . - + - Indicates whether to include dictionary contents. + Action that should be taken if the message is larger than - + - Indicates whether to include dictionary contents. + Maximum queue size for a single connection. Requires = true - + - Indicates whether to include call site (class and method name) in the information sent over the network. + Size of the connection cache (number of connections which are kept alive). Requires = true - + - Option to include all properties from the log events + Indicates whether to keep connection open whenever possible. - + - AppInfo field. By default it's the friendly name of the current AppDomain. + The number of seconds a connection will remain idle before the first keep-alive probe is sent - + - Renderer for log4j:event logger-xml-attribute (Default ${logger}) + Network address. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + Maximum simultaneous connections. Requires = false - - - - - - - - - - - - - + - Name of the target. + Type of compression for protocol payload. Useful for UDP where datagram max-size is 8192 bytes. - + - Layout used to format log messages. + Skip compression when protocol payload is below limit to reduce overhead in cpu-usage and additional headers - + - Indicates whether to perform layout calculation. + Indicates whether to append newline at the end of log message. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + Encoding to be used. - - - - - - - - - - - - + - Name of the target. + End of line value if a newline is appended at the end of log message . - + - Layout used to format log messages. + Maximum message size in bytes. On limit breach then action is activated. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. - + - - - - - - - - - + + + + Name of the target. - - - Indicates whether performance counter should be automatically created. - - - - - Name of the performance counter category. - - - - - Counter help text. - - - - - Name of the performance counter. - - - - - Performance counter type. - - - + - The value by which to increment the counter. + Layout used to format log messages. - + - Performance counter instance name. + Indicates whether to perform layout calculation. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + @@ -2348,9 +2198,9 @@ Default filter to be applied when no specific rule matches. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -2358,8 +2208,8 @@ - - + + @@ -2376,17 +2226,17 @@ - - + + Name of the target. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -2396,18 +2246,18 @@ - - - + + + Name of the target. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -2422,27 +2272,33 @@ - - - - + + + + + Name of the target. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. - + - Number of retries that should be attempted on the wrapped target in case of a failure. + Whether to enable batching, and only apply single delay when a whole batch fails - + + + Number of retries that should be attempted on the wrapped target in case of a failure. + + + Time to wait between retries in milliseconds. @@ -2454,17 +2310,17 @@ - - + + Name of the target. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -2474,17 +2330,17 @@ - - + + Name of the target. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -2494,10 +2350,13 @@ - - - - + + + + + + + @@ -2506,17 +2365,32 @@ - Layout used to format log messages. + Text to be rendered. + + + + + Header. + + + + + Footer. + + + + + Forward to (Instead of ) - Always use independent of + Force use independent of - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -2526,32 +2400,33 @@ - + - - - - - - - - - - - - - + - + + + + + + + + + + + + + + Name of the target. - + - Target supports reuse of internal buffers, and doesn't have to constantly allocate new buffers Required for legacy NLog-targets, that expects buffers to remain stable after Write-method exit + NLog Layout are by default threadsafe, so multiple threads can be rendering logevents at the same time. This ensure high concurrency with no lock-congestion for the application-threads, especially when using or AsyncTaskTarget. But if using custom or that are not threadsafe, then this option can enabled to protect against thread-concurrency-issues. Allowing one to update to NLog 5.0 without having to fix custom/external layout-dependencies. @@ -2574,21 +2449,26 @@ Protocol to be used when calling web service. - + - Custom proxy address, include port separated by a colon + (optional) root namespace of the XML document, if POST of XML document chosen. (see and ). - + - Encoding. + Proxy configuration when calling web service - + Web service URL. + + + Value of the User-agent HTTP header. + + Value whether escaping be done according to the old NLog style (Very non-standard) @@ -2609,14 +2489,14 @@ Name of the root XML element, if POST of XML document chosen. If so, this property must not be null. (see and ). - + - (optional) root namespace of the XML document, if POST of XML document chosen. (see and ). + Encoding. - + - Proxy configuration when calling web service + Custom proxy address, include port separated by a colon @@ -2656,39 +2536,39 @@ - - - - - - - - + + + + + + + + - + - Footer layout. + Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom'). - + - Header layout. + Column delimiter. - + - Body layout (can be repeated multiple times). + Footer layout. - + - Custom column delimiter value (valid when ColumnDelimiter is set to 'Custom'). + Header layout. - + - Column delimiter. + Body layout (can be repeated multiple times). @@ -2709,6 +2589,13 @@ + + + + + + + @@ -2720,70 +2607,92 @@ - - - - - - - - - + + + + + + Name of the column. + + Layout of the column. - + - Name of the column. + Override of Quoting mode - + - - - - - - - - + + + - + - List of property names to exclude when is true + Option to render the empty object value {} - + + + Option to suppress the extra spaces in the output json + + + + + + + + + + + + + + + + + + + + + Option to include all properties from the log event (as JSON) - + Indicates whether to include contents of the dictionary. - + - Indicates whether to include contents of the dictionary. + Whether to include the contents of the dictionary. - + - Option to render the empty object value {} + Should forward slashes be escaped? If true, / will be converted to \/ - + - Option to suppress the extra spaces in the output json + Option to exclude null/empty properties from the log event (as JSON) + + + + + List of property names to exclude when is true @@ -2791,30 +2700,53 @@ How far should the JSON serializer follow object references before backing off + + + Option to render the empty object value {} + + + + + Option to suppress the extra spaces in the output json + + - - - - - + + + + + + + + + + + Name of the attribute. + + Layout that will be rendered as the attribute's value. - + - Name of the attribute. + Fallback value when result value is not available - Determines wether or not this attribute will be Json encoded. + Determines whether or not this attribute will be Json encoded. + + + + + Should forward slashes be escaped? If true, / will be converted to \/ @@ -2827,14 +2759,19 @@ Whether an attribute with empty value should be included in the output + + + Result value type, for conversion of layout rendering output + + - - - + + + @@ -2858,35 +2795,60 @@ - - - - - + + + + + + + + + + - + Option to include all properties from the log events - + - Indicates whether to include contents of the dictionary. + Whether to include log4j:NDC in output from nested context. - + - Indicates whether to include contents of the dictionary. + Whether to include log4j:NDC in output from nested context. - + + + Whether to include the contents of the properties-dictionary. + + + - Indicates whether to include contents of the stack. + AppInfo field. By default it's the friendly name of the current AppDomain. - + - Indicates whether to include contents of the stack. + Indicates whether to include call site (class and method name) in the information sent over the network. + + + + + Indicates whether to include source info (file name and line number) in the information sent over the network. + + + + + Log4j:event logger-xml-attribute (Default ${logger}) + + + + + Whether the log4j:throwable xml-element should be written as CDATA @@ -2896,7 +2858,7 @@ - + @@ -2906,12 +2868,224 @@ + + + + + + + + + + + + + + + + + + + + + + + Name of the root XML element + + + + + Value inside the root XML element + + + + + Whether to include the contents of the dictionary. + + + + + Determines whether or not this attribute will be Xml encoded. + + + + + List of property names to exclude when is true + + + + + Whether a ElementValue with empty value should be included in the output + + + + + Auto indent and create new lines + + + + + How far should the XML serializer follow object references before backing off + + + + + XML element name to use for rendering IList-collections items + + + + + XML attribute name to use when rendering property-key When null (or empty) then key-attribute is not included + + + + + XML element name to use when rendering properties + + + + + XML attribute name to use when rendering property-value When null (or empty) then value-attribute is not included and value is formatted as XML-element-value + + + + + Option to include all properties from the log event (as XML) + + + + + + + + + + + + + + + + + Name of the attribute. + + + + + Layout that will be rendered as the attribute's value. + + + + + Fallback value when result value is not available + + + + + Determines whether or not this attribute will be Xml encoded. + + + + + Whether an attribute with empty value should be included in the output + + + + + Result value type, for conversion of layout rendering output + + + + + + + + + + + + + + + + + + + + + + + + Name of the element + + + + + Whether to include the contents of the dictionary. + + + + + Value inside the element + + + + + Determines whether or not this attribute will be Xml encoded. + + + + + List of property names to exclude when is true + + + + + Whether a ElementValue with empty value should be included in the output + + + + + Auto indent and create new lines + + + + + How far should the XML serializer follow object references before backing off + + + + + XML element name to use for rendering IList-collections items + + + + + XML attribute name to use when rendering property-key When null (or empty) then key-attribute is not included + + + + + XML element name to use when rendering properties + + + + + XML attribute name to use when rendering property-value When null (or empty) then value-attribute is not included and value is formatted as XML-element-value + + + + + Option to include all properties from the log event (as XML) + + + - - + + @@ -2939,10 +3113,10 @@ - - - - + + + + @@ -2971,10 +3145,10 @@ - - - - + + + + @@ -3003,10 +3177,10 @@ - - - - + + + + @@ -3035,10 +3209,10 @@ - - - - + + + + @@ -3067,26 +3241,30 @@ - - - - - - - - - - - + + + + + + + + + + Action to be taken when filter matches. - + - Default number of unique filter values to expect, will automatically increase if needed + Append FilterCount to the when an event is no longer filtered + + + + + Insert FilterCount value into when an event is no longer filtered @@ -3099,11 +3277,6 @@ Layout to be used to filter log messages. - - - Max number of unique filter values to expect simultaneously - - Max length of filter values, will truncate if above limit @@ -3114,24 +3287,19 @@ How long before a filter expires, and logging is accepted again - - - Default buffer size for the internal buffers - - - + - Reuse internal buffers, and doesn't have to constantly allocate new buffers + Default number of unique filter values to expect, will automatically increase if needed - + - Append FilterCount to the when an event is no longer filtered + Max number of unique filter values to expect simultaneously - + - Insert FilterCount value into when an event is no longer filtered + Default buffer size for the internal buffers diff --git a/README.md b/README.md index e38055f..488a1be 100644 --- a/README.md +++ b/README.md @@ -1,69 +1,53 @@ # C# Sample Code for the CyberSource SDK -[![Travis CI Status](https://travis-ci.org/CyberSource/cybersource-rest-samples-csharp.svg?branch=master)](https://travis-ci.org/CyberSource/cybersource-rest-samples-csharp) -This repository contains working code samples which demonstrate C#/.NET integration with the CyberSource REST APIs through the [CyberSource .NET SDK](https://github.com/CyberSource/cybersource-rest-client-dotnet). +[![Build Status](https://app.travis-ci.com/CyberSource/cybersource-rest-samples-csharp.svg?branch=master)](https://app.travis-ci.com/CyberSource/cybersource-rest-samples-csharp) +This repository contains two applications that demonstrate integration with the CyberSource REST APIs through our SDKs. -## Using the Sample Code +## .NET Framework -The samples are all completely independent and self-contained. You can analyze them to get an understanding of how a particular method works, or you can use the snippets as a starting point for your own project. +The application `cybersource-rest-samples-csharp.sln` contains working code samples in a .NET 4.6.1 application which uses the [CyberSource .NET SDK](https://github.com/CyberSource/cybersource-rest-client-dotnet). -### Requirements -* .NET Framework 4.6.1 -* [CyberSource Account](https://developer.cybersource.com/api/developer-guides/dita-gettingstarted/registration.html) -* [CyberSource API Keys](https://developer.cybersource.com/api/developer-guides/dita-gettingstarted/registration/createCertSharedKey.html) +For a more detailed explanation of how to use this application, please refer to [README_Net461.md](./README_Net461.md). -The samples are organized into categories and common usage examples. +## .NET Core +The application `cybersource-rest-samples-netcore.sln` contains working code samples in a .NET Core 3.1 application the [CyberSource .NET Standard SDK](https://github.com/CyberSource/cybersource-rest-client-dotnetstandard). -### Running the Samples -* Clone this repository: -``` - $ git clone https://github.com/CyberSource/cybersource-rest-samples-csharp.git -``` -* Open the solution in Visual Studio and build: - -* Run the console app and select a sample to execute. +For a more detailed explanation of how to use this application, please refer to [README_NetCore.md](./README_NetCore.md). -## Setting Your API Credentials +## Run Environments -To set your API credentials for an API request,Configure the following information in src/Configuration.cs file: - - * Http +The run environments that were supported in CyberSource .NET SDK and CyberSource .NET Standard SDK have been deprecated. +Moving forward, the SDKs will only support the direct hostname as the run environment. -``` - authenticationType = http_Signature - merchantID = your_merchant_id - merchantKeyId = your_key_serial_number - merchantsecretKey = your_key_shared_secret -``` - * Jwt +For the old run environments previously used, they should be replaced by the following hostnames: -``` - authenticationType = Jwt - merchantID = your_merchant_id - keyAlias = your_merchant_id - keyPassword = your_merchant_id - keyFileName = your_merchant_id - keysDirectory = Resource -``` +| Old Run Environment | New Hostname Value | +|-----------------------------------------------|------------------------------------------------| +|`cybersource.environment.sandbox` |`apitest.cybersource.com` | +|`cybersource.environment.production` |`api.cybersource.com` | +|`cybersource.environment.mutualauth.sandbox` |`api-matest.cybersource.com` | +|`cybersource.environment.mutualauth.production`|`api-ma.cybersource.com` | +|`cybersource.in.environment.sandbox` |`apitest.cybersource.com` | +|`cybesource.in.environment.production` |`api.in.cybersource.com` | -## Switching between the sandbox environment and the production environment -CyberSource maintains a complete sandbox environment for testing and development purposes. This sandbox environment is an exact -duplicate of our production environment with the transaction authorization and settlement process simulated. By default, this SDK is -configured to communicate with the sandbox environment. To switch to the production environment, set the appropriate environment -constant in src/App.json file. For example: +For example, replace the following code in the Configuration file: ```csharp // For TESTING use _configurationDictionary.Add("runEnvironment", "cybersource.environment.sandbox"); + // For PRODUCTION use // _configurationDictionary.Add("runEnvironment", "cybersource.environment.production"); ``` +with the following code: -The [API Reference Guide](https://developer.cybersource.com/api/reference/api-reference.html) provides examples of what information is needed for a particular request and how that information would be formatted. Using those examples, you can easily determine what methods would be necessary to include that information in a request -using this SDK. +```csharp +// For TESTING use +_configurationDictionary.Add("runEnvironment", "apitest.cybersource.com"); - ## License -This repository is distributed under a proprietary license. +// For PRODUCTION use +// _configurationDictionary.Add("runEnvironment", "api.cybersource.com"); +``` diff --git a/README_Net461.md b/README_Net461.md new file mode 100644 index 0000000..a723eca --- /dev/null +++ b/README_Net461.md @@ -0,0 +1,186 @@ +# C# Sample Code for the CyberSource SDK + +[![Travis CI Status](https://travis-ci.org/CyberSource/cybersource-rest-samples-csharp.svg?branch=master)](https://travis-ci.org/CyberSource/cybersource-rest-samples-csharp) + +This repository contains working code samples which demonstrate C#/.NET integration with the CyberSource REST APIs through the [CyberSource .NET SDK](https://github.com/CyberSource/cybersource-rest-client-dotnet). + +## Using the Sample Code + +The samples are all completely independent and self-contained. You can analyze them to get an understanding of how a particular method works, or you can use the snippets as a starting point for your own project. + +### Requirements + +* .NET Framework 4.6.1 +* [CyberSource Account](https://developer.cybersource.com/api/developer-guides/dita-gettingstarted/registration.html) +* [CyberSource API Keys](https://developer.cybersource.com/api/developer-guides/dita-gettingstarted/registration/createCertSharedKey.html) + +The samples are organized into categories and common usage examples. + +### Running the Samples + +* Clone this repository. + + ```bash + git clone https://github.com/CyberSource/cybersource-rest-samples-csharp.git + ``` + +* Open the solution `cybersource-rest-samples-csharp.sln` in Visual Studio and perform a clean build. + +* Run the console app and select a sample to execute. + + The console app can be executed from the `Debug` menu in Visual Studio. + + Alternatively, the console app can also be executed from `command prompt`, run the following command. + + ```bash + bin\Debug\net461\SampleCode.exe + ``` + +## Setting Your API Credentials + +To set your API credentials for an API request, configure the following information in `Source\Configuration.cs` file: + +* Http + + ```lang-none + authenticationType = http_Signature + merchantID = your_merchant_id + merchantKeyId = your_key_serial_number + merchantsecretKey = your_key_shared_secret + useMetaKey = false + enableClientCert = false + ``` + +* Jwt + + ```lang-none + authenticationType = Jwt + merchantID = your_merchant_id + keyAlias = your_merchant_id + keyPassword = your_merchant_id + keyFileName = your_merchant_id + keysDirectory = Resource + useMetaKey = false + enableClientCert = false + ``` + +* MetaKey Http + + ```lang-none + authenticationType = http_Signature + merchantID = your_child_merchant_id + merchantKeyId = your_metakey_serial_number + merchantsecretKey = your_metakey_shared_secret + portfolioId = your_portfolio_id + useMetaKey = true + enableClientCert = false + ``` + +* MetaKey JWT + + ```lang-none + authenticationType = Jwt + merchantID = your_child_merchant_id + keyAlias = your_child_merchant_id + keyPassword = your_portfolio_id + keyFileName = your_portfolio_id + keysDirectory = Resource + useMetaKey = true + enableClientCert = false + ``` + + * OAuth + + CyberSource OAuth uses mutual authentication. A Client Certificate is required to authenticate against the OAuth API. + + Refer to [Supporting Mutual Authentication](https://developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro/Supporting-Mutual-Authentication.html) to get information on how to generate Client certificate. + + If the certificate (Public Key) and Private Key are in 2 different files, merge them into a single .p12 file using `openssl`. + + ```bash + openssl pkcs12 -export -out certificate.p12 -inkey privateKey.key -in certificate.crt + ``` + + Set the run environment to OAuth enabled URLs. OAuth only works in these run environments. + + ```csharp + // For TESTING use + _configurationDictionary.Add("runEnvironment", "api-matest.cybersource.com") + // For PRODUCTION use + // _configurationDictionary.Add("runEnvironment", "api-ma.cybersource.com") + ``` + + To generate tokens, an Auth Code is required. The Auth Code can be generated by following the instructions given in [Integrating OAuth](https://developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro/integrating_OAuth.html). + + This generated Auth Code can then be used to create the Access Token and Refresh Token. + + In `Source/Configuration.cs` file, set the following properties. + + Note that `authenticationType` is set to `MutualAuth` only to generate the Access Token and the Refresh Token. + + ```lang-none + authenticationType = MutualAuth + enableClientCert = true + clientCertDirectory = resources + clientCertFile = your_client_cert in .p12 format + clientCertPassword = password_for_client_cert + clientId = your_client_id + clientSecret = your_client_secret + ``` + + Once the tokens are obtained, the `authenticationType` can then be set to `OAuth` to use the generated Access Token to send requests to other APIs. + + ```lang-none + authenticationType = OAuth + enableClientCert = true + clientCertDirectory = resources + clientCertFile = your_client_cert - .p12 format + clientCertPassword = password_for_client_cert + clientId = your_client_id + clientSecret = your_client_secret + accessToken = generated_access_token + refreshToken = generated_refresh_token + ``` + + The Access Token is valid for 15 mins, whereas the Refresh Token is valid for 1 year. + + Once the Access Token expires, use the Refresh Token to generate another Access Token. + + Refer to [StandAloneOAuth.cs](https://github.com/CyberSource/cybersource-rest-samples-csharp/tree/master/Source/Samples/Authentication/StandaloneOAuth.cs) to understand how to consume OAuth. + + For further information, refer to the documentation at [Cybersource OAuth 2.0](https://developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro.html). + +## Switching between the sandbox environment and the production environment + +CyberSource maintains a complete sandbox environment for testing and development purposes. This sandbox environment is an exact duplicate of our production environment with the transaction authorization and settlement process simulated. By default, this SDK is configured to communicate with the sandbox environment. To switch to the production environment, set the appropriate environment constant in `Source\Configuration.cs` file. For example: + +```csharp + // For TESTING use + _configurationDictionary.Add("runEnvironment", "apitest.cybersource.com"); + + // For PRODUCTION use + // _configurationDictionary.Add("runEnvironment", "api.cybersource.com"); +``` + +To use OAuth, switch to OAuth enabled URLs + +```csharp + // For TESTING use + _configurationDictionary.Add("runEnvironment", "api-matest.cybersource.com") + // For PRODUCTION use + // _configurationDictionary.Add("runEnvironment", "api-ma.cybersource.com") +``` + +The [API Reference Guide](https://developer.cybersource.com/api/reference/api-reference.html) provides examples of what information is needed for a particular request and how that information would be formatted. Using those examples, you can easily determine what methods would be necessary to include that information in a request using this SDK. + +### Logging + +[![Generic badge](https://img.shields.io/badge/LOGGING-NEW-GREEN.svg)](https://shields.io/) + +Since v0.0.1.14, a new logging framework has been introduced in the SDK. This new logging framework makes use of NLog, and standardizes the logging so that it can be integrated with the logging in the client application. + +More information about this new logging framework can be found in this file : [Logging_Net461.md](Logging_Net461.md) + +## License + +This repository is distributed under a proprietary license. diff --git a/README_NetCore.md b/README_NetCore.md new file mode 100644 index 0000000..79a9836 --- /dev/null +++ b/README_NetCore.md @@ -0,0 +1,252 @@ +# .NET Core Sample Code for the CyberSource SDK + + + +This repository contains working code samples which demonstrate .NET Core integration with the CyberSource REST APIs through the [CyberSource .NET Standard SDK](https://github.com/CyberSource/cybersource-rest-client-dotnetstandard). + +## Using the Sample Code + +The samples are all completely independent and self-contained. You can analyze them to get an understanding of how a particular method works, or you can use the snippets as a starting point for your own project. + +### Requirements + +* .NET Core 3.1 / .NET Standard 2.1 +* Visual Studio 2019 +* [CyberSource Account](https://developer.cybersource.com/api/developer-guides/dita-gettingstarted/registration.html) +* [CyberSource API Keys](https://developer.cybersource.com/api/developer-guides/dita-gettingstarted/registration/createCertSharedKey.html) + +The samples are organized into categories and common usage examples. + +#### Caveats + +* Remember to add the installation path for the .NET Core/.NET Standard to the PATH environment variable. + +### Running the Samples + +#### Windows OS + +* Clone this repository + + ```bash + git clone https://github.com/CyberSource/cybersource-rest-samples-csharp.git + ``` + +* Open the solution `cybersource-rest-samples-netcore.sln` in Visual Studio 2019 and perform a clean build. + +* Run the console app and select a sample to execute. + + The console app can be executed from the `Debug` menu in Visual Studio 2019. + + Alternatively, the console app can also be executed from `command prompt`, run the following command. + + ```bash + dotnet bin\Debug\netcoreapp3.1\SampleCodeNetCore.dll + ``` + +#### Linux / Mac OS + +* Clone this repository. + + ```bash + git clone https://github.com/CyberSource/cybersource-rest-samples-csharp.git + ``` + +* Change directory to `cybersource-rest-samples-netcore` folder. + + ```bash + cd cybersource-rest-samples-netcore + ``` + +* Clean the `bin` folder to remove any previous build (if applicable). + + ```bash + rm -r -f bin/* + ``` + +* From the root directory of the repository, run the following command: + + ```bash + dotnet publish -c -r --self-contained + ``` + +* In this command, + + * For ``, accepted values are `Debug` and `Release`. + + * For ``, refer to [.NET Core RID Catalog](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog) to find the proper **Runtime Identifier (RID)**. + + * This determines the location of the output files ( `bin//netcoreapp3.1//publish` ). + +* Move the output files from `bin//netcoreapp3.1//publish` to `bin//netcoreapp3.1`. + + ```bash + mv bin//netcoreapp3.1//publish/* bin//netcoreapp3.1 + ``` + +* Linux : Provide execute permissions for the DLL. + + ```bash + chmod 777 bin//netcoreapp3.1/SampleCodeNetCore.dll + ``` + +* Execute the console app and select a sample to execute. + + * Linux + + ```bash + ./bin//netcoreapp3.1/SampleCodeNetCore.dll + ``` + + * Mac OS + + ```bash + dotnet bin//netcoreapp3.1/SampleCodeNetCore.dll + ``` + +## Setting Your API Credentials + +To set your API credentials for an API request, configure the following information in `Source\Configuration.cs` file: + +* Http + + ```lang-none + authenticationType = http_Signature + merchantID = your_merchant_id + merchantKeyId = your_key_serial_number + merchantsecretKey = your_key_shared_secret + useMetaKey = false + enableClientCert = false + ``` + +* Jwt + + ```lang-none + authenticationType = Jwt + merchantID = your_merchant_id + keyAlias = your_merchant_id + keyPassword = your_merchant_id + keyFileName = your_merchant_id + keysDirectory = Resource + useMetaKey = false + enableClientCert = false + ``` + +* MetaKey Http + + ```lang-none + authenticationType = http_Signature + merchantID = your_child_merchant_id + merchantKeyId = your_metakey_serial_number + merchantsecretKey = your_metakey_shared_secret + portfolioId = your_portfolio_id + useMetaKey = true + enableClientCert = false + ``` + +* MetaKey JWT + + ```lang-none + authenticationType = Jwt + merchantID = your_child_merchant_id + keyAlias = your_child_merchant_id + keyPassword = your_portfolio_id + keyFileName = your_portfolio_id + keysDirectory = Resource + useMetaKey = true + enableClientCert = false + ``` + + * OAuth + + CyberSource OAuth uses mutual authentication. A Client Certificate is required to authenticate against the OAuth API. + + Refer to [Supporting Mutual Authentication](https://developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro/Supporting-Mutual-Authentication.html) to get information on how to generate Client certificate. + + If the certificate (Public Key) and Private Key are in 2 different files, merge them into a single .p12 file using `openssl`. + + ```bash + openssl pkcs12 -export -out certificate.p12 -inkey privateKey.key -in certificate.crt + ``` + + Set the run environment to OAuth enabled URLs. OAuth only works in these run environments. + + ```csharp + // For TESTING use + _configurationDictionary.Add("runEnvironment", "api-matest.cybersource.com") + // For PRODUCTION use + // _configurationDictionary.Add("runEnvironment", "api-ma.cybersource.com") + ``` + + To generate tokens, an Auth Code is required. The Auth Code can be generated by following the instructions given in [Integrating OAuth](https://developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro/integrating_OAuth.html). + + This generated Auth Code can then be used to create the Access Token and Refresh Token. + + In `Source/Configuration.cs` file, set the following properties. + + Note that `authenticationType` is set to `MutualAuth` only to generate the Access Token and the Refresh Token. + + ```lang-none + authenticationType = MutualAuth + enableClientCert = true + clientCertDirectory = resources + clientCertFile = your_client_cert in .p12 format + clientCertPassword = password_for_client_cert + clientId = your_client_id + clientSecret = your_client_secret + ``` + + Once the tokens are obtained, the `authenticationType` can then be set to `OAuth` to use the generated Access Token to send requests to other APIs. + + ```lang-none + authenticationType = OAuth + enableClientCert = true + clientCertDirectory = resources + clientCertFile = your_client_cert - .p12 format + clientCertPassword = password_for_client_cert + clientId = your_client_id + clientSecret = your_client_secret + accessToken = generated_access_token + refreshToken = generated_refresh_token + ``` + + The Access Token is valid for 15 mins, whereas the Refresh Token is valid for 1 year. + + Once the Access Token expires, use the Refresh Token to generate another Access Token. + + Refer to [StandAloneOAuth.cs](https://github.com/CyberSource/cybersource-rest-samples-csharp/tree/master/Source/Samples/Authentication/StandaloneOAuth.cs) to understand how to consume OAuth. + + For further information, refer to the documentation at [Cybersource OAuth 2.0](https://developer.cybersource.com/api/developer-guides/OAuth/cybs_extend_intro.html). + +## Switching between the sandbox environment and the production environment + +CyberSource maintains a complete sandbox environment for testing and development purposes. This sandbox environment is an exact duplicate of our production environment with the transaction authorization and settlement process simulated. By default, this SDK is configured to communicate with the sandbox environment. To switch to the production environment, set the appropriate environment constant in `Source\Configuration.cs` file. For example: + +```csharp + // For TESTING use + _configurationDictionary.Add("runEnvironment", "apitest.cybersource.com"); + // For PRODUCTION use + // _configurationDictionary.Add("runEnvironment", "api.cybersource.com"); +``` + +To use OAuth, switch to OAuth enabled URLs + +```csharp + // For TESTING use + _configurationDictionary.Add("runEnvironment", "api-matest.cybersource.com") + // For PRODUCTION use + // _configurationDictionary.Add("runEnvironment", "api-ma.cybersource.com") +``` + +The [API Reference Guide](https://developer.cybersource.com/api/reference/api-reference.html) provides examples of what information is needed for a particular request and how that information would be formatted. Using those examples, you can easily determine what methods would be necessary to include that information in a request using this SDK. + +### Logging + +[![Generic badge](https://img.shields.io/badge/LOGGING-NEW-GREEN.svg)](https://shields.io/) + +Since v0.0.1.7, a new logging framework has been introduced in the SDK. This new logging framework makes use of NLog, and standardizes the logging so that it can be integrated with the logging in the client application. + +More information about this new logging framework can be found in this file : [Logging_NetCore.md](Logging_NetCore.md) + +## License + +This repository is distributed under a proprietary license. diff --git a/src/Api.cs b/Source/Api.cs similarity index 100% rename from src/Api.cs rename to Source/Api.cs diff --git a/Source/App.config b/Source/App.config new file mode 100644 index 0000000..9065e05 --- /dev/null +++ b/Source/App.config @@ -0,0 +1,46 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AuthenticationData/Configuration.cs b/Source/AuthenticationData/Configuration.cs similarity index 100% rename from src/AuthenticationData/Configuration.cs rename to Source/AuthenticationData/Configuration.cs diff --git a/src/AuthenticationData/RequestData.cs b/Source/AuthenticationData/RequestData.cs similarity index 100% rename from src/AuthenticationData/RequestData.cs rename to Source/AuthenticationData/RequestData.cs diff --git a/Source/Configuration.cs b/Source/Configuration.cs new file mode 100644 index 0000000..f8820f4 --- /dev/null +++ b/Source/Configuration.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.IO; + +namespace Cybersource_rest_samples_dotnet +{ + public class Configuration + { + // initialize dictionary object + private readonly Dictionary _configurationDictionary = new Dictionary(); + + public Dictionary GetConfiguration() + { + _configurationDictionary.Add("authenticationType", "HTTP_SIGNATURE"); + _configurationDictionary.Add("merchantID", "testrest"); + _configurationDictionary.Add("merchantsecretKey", "yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE="); + _configurationDictionary.Add("merchantKeyId", "08c94330-f618-42a3-b09d-e1e43be5efda"); + _configurationDictionary.Add("keysDirectory", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\Source\\Resource")); + _configurationDictionary.Add("keyFilename", "testrest"); + _configurationDictionary.Add("runEnvironment", "apitest.cybersource.com"); + _configurationDictionary.Add("keyAlias", "testrest"); + _configurationDictionary.Add("keyPass", "testrest"); + _configurationDictionary.Add("timeout", "300000"); + + // Configs related to meta key + _configurationDictionary.Add("portfolioID", string.Empty); + _configurationDictionary.Add("useMetaKey", "false"); + + // Configs related to OAuth + _configurationDictionary.Add("enableClientCert", "false"); + _configurationDictionary.Add("clientCertDirectory", "Resource"); + _configurationDictionary.Add("clientCertFile", ""); + _configurationDictionary.Add("clientCertPassword", ""); + _configurationDictionary.Add("clientId", ""); + _configurationDictionary.Add("clientSecret", ""); + + /* + * PEM Key file path for decoding JWE Response Enter the folder path where the .pem file is located. + * It is optional property, require adding only during JWE decryption. + */ + _configurationDictionary.Add("pemFileDirectory", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\Source\\Resource\\NetworkTokenCert.pem")); + + // _configurationDictionary.Add("proxyAddress", string.Empty); + // _configurationDictionary.Add("proxyPort", string.Empty); + // _configurationDictionary.Add("proxyUsername", string.Empty); + // _configurationDictionary.Add("proxyPassword", string.Empty); + return _configurationDictionary; + } + + public Dictionary GetAlternativeConfiguration() + { + _configurationDictionary.Add("authenticationType", "HTTP_SIGNATURE"); + _configurationDictionary.Add("merchantID", "testrest_cpctv"); + _configurationDictionary.Add("merchantsecretKey", "zXKpCqMQPmOR/JRldSlkQUtvvIzOewUVqsUP0sBHpxQ="); + _configurationDictionary.Add("merchantKeyId", "964f2ecc-96f0-4432-a742-db0b44e6a73a"); + _configurationDictionary.Add("keysDirectory", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\Source\\Resource")); + _configurationDictionary.Add("keyFilename", "testrest_cpctv"); + _configurationDictionary.Add("runEnvironment", "apitest.cybersource.com"); + _configurationDictionary.Add("keyAlias", "testrest_cpctv"); + _configurationDictionary.Add("keyPass", "testrest_cpctv"); + _configurationDictionary.Add("timeout", "300000"); + // _configurationDictionary.Add("proxyAddress", string.Empty); + // _configurationDictionary.Add("proxyPort", string.Empty); + // _configurationDictionary.Add("proxyUsername", string.Empty); + // _configurationDictionary.Add("proxyPassword", string.Empty); + + // Configs related to meta key + _configurationDictionary.Add("portfolioID", string.Empty); + _configurationDictionary.Add("useMetaKey", "false"); + + // Configs related to OAuth + _configurationDictionary.Add("enableClientCert", "false"); + _configurationDictionary.Add("clientCertDirectory", "Resource"); + _configurationDictionary.Add("clientCertFile", ""); + _configurationDictionary.Add("clientCertPassword", ""); + _configurationDictionary.Add("clientId", ""); + _configurationDictionary.Add("clientSecret", ""); + + + return _configurationDictionary; + } + + public Dictionary GetIntermediateConfiguration() + { + _configurationDictionary.Add("authenticationType", "HTTP_SIGNATURE"); + _configurationDictionary.Add("merchantID", "testrest"); + _configurationDictionary.Add("merchantsecretKey", "yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE="); + _configurationDictionary.Add("merchantKeyId", "08c94330-f618-42a3-b09d-e1e43be5efda"); + _configurationDictionary.Add("keysDirectory", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\Source\\Resource")); + _configurationDictionary.Add("keyFilename", "testrest"); + _configurationDictionary.Add("runEnvironment", "apitest.cybersource.com"); + //new property has been added for user to configure the base path so that request can route the API calls via Azure Management URL. + //Example: If intermediate url is https://manage.windowsazure.com then in property input can be same url or manage.windowsazure.com. + _configurationDictionary.Add("intermediateHost", "https://manage.windowsazure.com"); + _configurationDictionary.Add("keyAlias", "testrest"); + _configurationDictionary.Add("keyPass", "testrest"); + _configurationDictionary.Add("timeout", "300000"); + + // Configs related to meta key + _configurationDictionary.Add("portfolioID", string.Empty); + _configurationDictionary.Add("useMetaKey", "false"); + + // Configs related to OAuth + _configurationDictionary.Add("enableClientCert", "false"); + _configurationDictionary.Add("clientCertDirectory", "Resource"); + _configurationDictionary.Add("clientCertFile", ""); + _configurationDictionary.Add("clientCertPassword", ""); + _configurationDictionary.Add("clientId", ""); + _configurationDictionary.Add("clientSecret", ""); + + // _configurationDictionary.Add("proxyAddress", string.Empty); + // _configurationDictionary.Add("proxyPort", string.Empty); + // _configurationDictionary.Add("proxyUsername", string.Empty); + // _configurationDictionary.Add("proxyPassword", string.Empty); + return _configurationDictionary; + } + } +} diff --git a/Source/MerchantBoardingConfiguration.cs b/Source/MerchantBoardingConfiguration.cs new file mode 100644 index 0000000..65a88a5 --- /dev/null +++ b/Source/MerchantBoardingConfiguration.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet +{ + internal class MerchantBoardingConfiguration + { + + private readonly Dictionary _configurationDictionary = new Dictionary(); + + public Dictionary GetMerchantBoardingConfiguration() + { + _configurationDictionary.Add("authenticationType", "jwt"); + _configurationDictionary.Add("merchantID", ""); + _configurationDictionary.Add("merchantsecretKey", ""); + _configurationDictionary.Add("merchantKeyId", ""); + _configurationDictionary.Add("keysDirectory", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\Source\\Resource")); + _configurationDictionary.Add("keyFilename", ""); + _configurationDictionary.Add("runEnvironment", "apitest.cybersource.com"); + _configurationDictionary.Add("keyAlias", ""); + _configurationDictionary.Add("keyPass", ""); + _configurationDictionary.Add("timeout", "300000"); + + // Configs related to meta key + _configurationDictionary.Add("portfolioID", string.Empty); + _configurationDictionary.Add("useMetaKey", "false"); + + + return _configurationDictionary; + } + + + } +} diff --git a/src/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs similarity index 72% rename from src/Properties/AssemblyInfo.cs rename to Source/Properties/AssemblyInfo.cs index 0374fb4..440512d 100644 --- a/src/Properties/AssemblyInfo.cs +++ b/Source/Properties/AssemblyInfo.cs @@ -1,34 +1,35 @@ using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following +// General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("CybsPayments")] +[assembly: AssemblyTitle("cybersource-rest-samples-csharp")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("CybsPayments")] -[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyCompany("Visa Inc")] +[assembly: AssemblyProduct("cybersource-rest-samples-csharp")] +[assembly: AssemblyCopyright("Copyright © Visa Inc 2020")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("4cf837ff-237d-4b5b-b922-71ccc654d718")] +[assembly: Guid("97ff11a4-924d-4c87-a028-2aaf64655954")] // Version information for an assembly consists of the following four values: // // Major Version -// Minor Version +// Minor Version // Build Number // Revision // -// You can specify all the values or you can default the Build and Revision Numbers +// You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] diff --git a/src/Resource/AuthTRRReport.json b/Source/Resource/AuthTRRReport.json similarity index 100% rename from src/Resource/AuthTRRReport.json rename to Source/Resource/AuthTRRReport.json diff --git a/src/Resource/DownloadReport.csv b/Source/Resource/DownloadReport.csv similarity index 100% rename from src/Resource/DownloadReport.csv rename to Source/Resource/DownloadReport.csv diff --git a/Source/Resource/DownloadedFileWithFileID.csv b/Source/Resource/DownloadedFileWithFileID.csv new file mode 100644 index 0000000..0da03d6 --- /dev/null +++ b/Source/Resource/DownloadedFileWithFileID.csv @@ -0,0 +1,2 @@ +Batch Files Detail Report,1.0,2020-01-30 to 2020-01-30,,,,,,, +merchant_id,txn_batch_id,payment_processor,request_id,trans_ref_no,merchant_ref_number,ics_rflag,amount,currency,action diff --git a/Source/Resource/NetworkTokenCert.pem b/Source/Resource/NetworkTokenCert.pem new file mode 100644 index 0000000..98f6e3f --- /dev/null +++ b/Source/Resource/NetworkTokenCert.pem @@ -0,0 +1,3 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA2tNGgpyJKgviPHjuNmcF+5tPjFsxBKebsto9swyebVcJVYu5Mp4Yz8VnhPbEdkyzckTtAulXQYA82iPYG/BHEbChR/PHwO3yCsbTDDNQlkB0R5c5Py/Ts4BSLvIwkbJEvd/SQxTPaPOOYjqbqSfzJ4oKsCGzW+K94UnZic8b5II8CrKlLZLZSO2RoURFg+4htjXhikBJXqJdDhneZCgnMxbWU8MKbdXXJUIDZq0jMkNUNOi1xdzLHhZQl464kD+VocTUS06Ky8h/FBU6xRJciLQW7/VieqzVxG5MGxwcSNfbiozG7aHw+Nt4Awkt6N2VpcxL6AmOXoKRH5om1yCNhwIDAQABAoIBAQCky1WfiVl288ol9oCXMdD8ogMvVYG92qfT8q1iiQ9KkrBx3y7SouNWnXiPVvOvj6XYWXYQqj/PEU9CjJn0uGgdN2LOeBWoAso0OXW5C3AWJ2YqgAVZw5/v36SEvFm9b357a/LCGAr3I+zHpxGRO4fP8BKKgGa9vS14W5BbS0DbPZ9/QvzRfinw6l+/l2mnPihB8KyvABtsiBv0ylh525JY3SFp7bx9qLePjYXMR9u8P+LhD4CPvps5htj1E/JSV3nysNYUP7qc3m4OPhrT46ly2vIMVYDWrHw7i9CGf4XVtZuJ0jRSaG/FaS/ggvy4wzeBkjWkfx+PROG1RYLBWuBJAoGBAP/GwOWn4UgDFqc6W3qhZU4j1uHzsYuFCaagof151dV3YdTBOSVx40zq3sWxNkgFhAAJLF7RywYslWW8UEEsLjjdjMjofJBEYIS3I3wUGpU85x//SUwlf1cO5rIg+hehU+m/dgSPFwh/jaBxBb1u9wX5B18N/3kGbwBcchs9mJxtAoGBANsEQHGLf3RYUZ/HMB3QpVNwYbE904CVhU+foRuiog0o9jBJEgnQeuMcDd4sEenhDobuI5+W8VdFSD4h9n2fwoUStqx5uLAenWH/zquuaH+q1/Nz/IO78GoUoaerPV32HZWv5oPafYO6sMPt2TDVhcWmpnDMQkx/54iuKfLigfFDAoGBAOVNyC2bniozKqHtfYmpG+s70i9rjCZqtMY/iDp4ea4QgxJ7z8G0InUYs3NEdkeHOlnV34N6TatRWPaGJuTmuOGeLdMIKnQj+OvCS/u3AkX8/a//7DRqAYmJAGV9jviUV2hdj25y4dFqmQvXh6/WxXsDUQp0wC4+CFGoj1vAkwrZAoGANBtG2by+jgeVI9ZX9D/3lWpfU7PJ5gWsuczYn6KJu2fLaqF30S3wjqfWBM2nVWVd92wgvY9Dy+eH0IB0DF8+ADr7iv1Km1wtRWt+2AmegwE6b4lgwlasVBCkhSeQahJr53j59tS8l+KKu5KS4bNrKCMF5kAyZdDoXPRStp59G9ECgYB2lLPPN/OsecBnl5ye9vuBpw6VUlsxUk3UGlDIKZTx46UJm1RCVCis0O434s49nHATzylyaT2ED77HdvOQSx9eqh3+goS+xs3DPBry477TwiP1Cvo/+7neIrS7uO7B6fHBWze7jk59JD7Rs5wANMfErmv8bX1LPoXq43i2ZQGBNA== +-----END RSA PRIVATE KEY----- diff --git a/Source/Resource/NumericUtility.cs b/Source/Resource/NumericUtility.cs new file mode 100644 index 0000000..145e2ab --- /dev/null +++ b/Source/Resource/NumericUtility.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Resource +{ + public class NumericUtility + { + public static string LongRandom(int min, int max) + { + Random generator = new Random(); + string r = generator.Next(min, max).ToString("D8"); + return r; + } + } +} diff --git a/src/Resource/TRRReport.json b/Source/Resource/TRRReport.json similarity index 100% rename from src/Resource/TRRReport.json rename to Source/Resource/TRRReport.json diff --git a/Source/Resource/jwsToken.txt b/Source/Resource/jwsToken.txt new file mode 100644 index 0000000..9d53fa6 --- /dev/null +++ b/Source/Resource/jwsToken.txt @@ -0,0 +1 @@ +eyJhbGciOiJSUzI1NiIsInYtYy1tZXJjaGFudC1pZCI6InRlc3RyZXN0IiwieDVjIjpbIk1JSUNYekNDQWNpZ0F3SUJBZ0lXTlRjME5qWTBNalF6TURZNU1ERTNOekV3TnpBME5qQU5CZ2txaGtpRzl3MEJBUXNGQURBZU1Sd3dHZ1lEVlFRRERCTkRlV0psY2xOdmRYSmpaVU5sY25SQmRYUm9NQjRYRFRFNU1URXlOVEEyTkRRd00xb1hEVEl4TVRFeU5UQTJORFF3TTFvd05ERVJNQThHQTFVRUF3d0lkR1Z6ZEhKbGMzUXhIekFkQmdOVkJBVVRGalUzTkRZMk5ESTBNekEyT1RBeE56Y3hNRGN3TkRZd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUJEd0F3Z2dFS0FvSUJBUUMrQnRkTWNva2FLd1RlczlPK3NucWpXc2VoTzAvWTRDSnJ3bzRjZEdDYWZSTzZvd3MzbUMxeG1wU1l0dFRLSWRlR1IxcU9ZcFRTZVk5dUpoMmNDZmF5TUtYbWhRZjRkNXY4cE5Ebm1ZQk1HQndVMXdXamxZc01MRmJjUEZXamRQdEtsb3UyUklXWjU2NllXSWJXQ0JmK0c0ZEhrQTBEN0NzcDNGVDNsblVOMm1lNGxKa2x5c2ZxcDFYOHEzSkRxVklRRlZBZHVhbWhXQ1lNUlM1S2c4c0t3TWpsZEdRVWJ5ODhTK01Pd2NDQTNIT0hUNjRiYXJ2UElkMkV4cUFxdmZ5QkNQQVI0OVY2L3l3RFZzSDlTeUhld2cxMjFja01jQTlnNTV0SXFkc3lIR1JaTjlmczIwa015cUVQNzhMNGN4ZmlzdVZRQzhrbmxmWnRkY3FWQVk3RkFnTUJBQUV3RFFZSktvWklodmNOQVFFTEJRQURnWUVBdHBDL0VocS8yUDdWYXp6WTgxZ1ZucFBnRWpIWFB5S2t0emJSU1ZkUkcvTUdiVko1OVFWSmVMbnpnbXpIbXlxMGNKK1FTUVBWTzQ2YmxvTkYrMjlJWVErelZZWGFOZ3ZqcVlRU2hYUEM2bllJbkZDZk9uMXByUklJY0l0KzViWkpZRmtRR1R6OGprRUF2QlpsYjBsdm02S3REVWI5T0xPMzhIMDV5U0xpbDY4PSJdfQ.eyJpYXQiOiJXZWQsIDAyIE1hciAyMDIyIDA3OjU0OjM3IEdNVCJ9.Mxko9nrb6kja6JH5zOna0SzEShZFgrsMxBNpl5bhA9loJNuEZ9IIR6Ij25uJoN6yFQ2IphlKaZKEwvuHkoQWPS_9SUu7Nq9Q4jhrJebNXfhyEew_NFs24LSwgrZvmfq7UOvNmIQX6gsNzNeSSmUgS1IB676mHeFpBIEN6GjuDu44SA-G1_J4MCYj3I-qFoijqOCLPbbZFTqI6De33oV8o5sLDjZ-LJg0xrwgJ4wlQCe5FwXIg9n9yvHswlAhYTq_EDYP_5r9fX7bGDy7KCMfJsADYgLE_SM5jV9ArRNHErXws3cvJop1dnH55V2Gjl3Lz2Lkk07HBiEFakJMGcF5Jg \ No newline at end of file diff --git a/src/Resource/mcb_test_merch.p12 b/Source/Resource/mcb_test_merch.p12 similarity index 100% rename from src/Resource/mcb_test_merch.p12 rename to Source/Resource/mcb_test_merch.p12 diff --git a/src/Resource/request_captures.json b/Source/Resource/request_captures.json similarity index 100% rename from src/Resource/request_captures.json rename to Source/Resource/request_captures.json diff --git a/src/Resource/request_payments.json b/Source/Resource/request_payments.json similarity index 100% rename from src/Resource/request_payments.json rename to Source/Resource/request_payments.json diff --git a/src/Resource/request_refund.json b/Source/Resource/request_refund.json similarity index 100% rename from src/Resource/request_refund.json rename to Source/Resource/request_refund.json diff --git a/src/Resource/request_reversals.json b/Source/Resource/request_reversals.json similarity index 100% rename from src/Resource/request_reversals.json rename to Source/Resource/request_reversals.json diff --git a/src/Resource/request_void.json b/Source/Resource/request_void.json similarity index 100% rename from src/Resource/request_void.json rename to Source/Resource/request_void.json diff --git a/Source/Resource/signatureHeaderValue.txt b/Source/Resource/signatureHeaderValue.txt new file mode 100644 index 0000000..8848bcd --- /dev/null +++ b/Source/Resource/signatureHeaderValue.txt @@ -0,0 +1 @@ +keyid="08c94330-f618-42a3-b09d-e1e43be5efda", algorithm="HmacSHA256", headers="host date request-target digest v-c-merchant-id", signature="I/3BC76nsQmZGOlnsrvslZk/VLVaXA2Jb0iVtce++JE=" \ No newline at end of file diff --git a/src/Resource/testrest.p12 b/Source/Resource/testrest.p12 similarity index 100% rename from src/Resource/testrest.p12 rename to Source/Resource/testrest.p12 diff --git a/Source/Resource/testrest_cpctv.p12 b/Source/Resource/testrest_cpctv.p12 new file mode 100644 index 0000000..9bb718b Binary files /dev/null and b/Source/Resource/testrest_cpctv.p12 differ diff --git a/src/SampleCode.cs b/Source/SampleCode.cs similarity index 92% rename from src/SampleCode.cs rename to Source/SampleCode.cs index ee4afd4..38bb89c 100644 --- a/src/SampleCode.cs +++ b/Source/SampleCode.cs @@ -9,7 +9,7 @@ namespace Cybersource_rest_samples_dotnet { public class SampleCode { - private static readonly string PathOfSamplesFolder = Path.Combine($"{AppDomain.CurrentDomain.BaseDirectory}", $"Samples"); + private static readonly string PathOfSamplesFolder = Path.Combine($"{AppDomain.CurrentDomain.BaseDirectory}", $"../../../Source/Samples"); private static readonly string ProjectNamespace = "Cybersource_rest_samples_dotnet"; @@ -29,6 +29,10 @@ public class SampleCode // NLog Logger object private static Logger logger; + public static string TimeoutVoidTransactionId { get; set; } + + public static string TimeoutReversalTransactionId { get; set; } + public static void Main(string[] args) { // initializing logger object @@ -72,12 +76,16 @@ public static void RunSample(string cmdLineArg = null) if (_sampleToRun.ToUpper().Contains("RUNALL")) { + int sampleCount = 1; foreach (var apiMethod in ApiList) { - Console.WriteLine("\n#### START RUNNING SAMPLE CODE FOR " + apiMethod.ApiFunctionCall + " ####"); + Console.WriteLine("\n" + sampleCount + ".\t#### START RUNNING SAMPLE CODE FOR " + apiMethod.ApiFunctionCall + " ####"); RunSample(apiMethod.ApiFunctionCall); Console.WriteLine("\n#### END RUNNING SAMPLE CODE FOR " + apiMethod.ApiFunctionCall + " ####"); + sampleCount++; } + + Console.WriteLine("\n\nTotal number of Sample run : " + sampleCount); } else { @@ -190,7 +198,7 @@ private static void ShowMethods() lineCharsCount = 0; } - lineCharsCount = lineCharsCount + api.ApiFunctionCall.Length; + lineCharsCount += api.ApiFunctionCall.Length; } Console.WriteLine(apirow); @@ -223,7 +231,13 @@ 4. Add the Api Object to the ApiList List. foreach (var dir in dirList) { - var dirModified = dir.Replace(' ', '_'); + var dirModified = dir; + + if (!dir.Contains("Risk Management")) + { + dirModified = dir.Replace(' ', '_'); + } + dirModified = dirModified.Substring(PathOfSamplesFolder.Length + 1); dirModified = dirModified.Replace(@"/", "."); dirModified = dirModified.Replace(@"\", "."); @@ -241,11 +255,12 @@ 4. Add the Api Object to the ApiList List. foreach (var file in allfiles) { - var lastBackSlashIndex = file.LastIndexOf(@"/", StringComparison.Ordinal); + var lastForwardSlashIndex = file.LastIndexOf(@"/", StringComparison.Ordinal); + var lastBackSlashIndex = file.LastIndexOf(@"\", StringComparison.Ordinal); - if (lastBackSlashIndex == -1) + if (lastBackSlashIndex < lastForwardSlashIndex) { - lastBackSlashIndex = file.LastIndexOf(@"\", StringComparison.Ordinal); + lastBackSlashIndex = lastForwardSlashIndex; } var firstPart = file.Remove(lastBackSlashIndex); diff --git a/Source/Samples/AccountUpdater/AmexRegistrationCustomerTokenBatch.cs b/Source/Samples/AccountUpdater/AmexRegistrationCustomerTokenBatch.cs new file mode 100644 index 0000000..6b4b07a --- /dev/null +++ b/Source/Samples/AccountUpdater/AmexRegistrationCustomerTokenBatch.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.AccountUpdater +{ + public class AmexRegistrationCustomerTokenBatch + { + public static InlineResponse202 Run() + { + string type = "amexRegistration"; + + List includedTokens = new List (); + string includedTokensId1 = "C06977C0EDC0E985E053AF598E0A3326"; + includedTokens.Add(new Accountupdaterv1batchesIncludedTokens( + Id: includedTokensId1 + )); + + string includedTokensId2 = "C069A534044F6140E053AF598E0AD492"; + includedTokens.Add(new Accountupdaterv1batchesIncludedTokens( + Id: includedTokensId2 + )); + + Accountupdaterv1batchesIncluded included = new Accountupdaterv1batchesIncluded( + Tokens: includedTokens + ); + + string merchantReference = "TC50171_3"; + string notificationEmail = "test@cybs.com"; + var requestObj = new Body( + Type: type, + Included: included, + MerchantReference: merchantReference, + NotificationEmail: notificationEmail + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BatchesApi(clientConfig); + InlineResponse202 result = apiInstance.PostBatch(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/AccountUpdater/AmexRegistrationInstrumentIdentifierTokenBatch.cs b/Source/Samples/AccountUpdater/AmexRegistrationInstrumentIdentifierTokenBatch.cs new file mode 100644 index 0000000..5a46178 --- /dev/null +++ b/Source/Samples/AccountUpdater/AmexRegistrationInstrumentIdentifierTokenBatch.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.AccountUpdater +{ + public class AmexRegistrationInstrumentIdentifierTokenBatch + { + public static InlineResponse202 Run() + { + string type = "amexRegistration"; + + List includedTokens = new List (); + string includedTokensId1 = "7030000000000260224"; + string includedTokensExpirationMonth1 = "12"; + string includedTokensExpirationYear1 = "2020"; + includedTokens.Add(new Accountupdaterv1batchesIncludedTokens( + Id: includedTokensId1, + ExpirationMonth: includedTokensExpirationMonth1, + ExpirationYear: includedTokensExpirationYear1 + )); + + string includedTokensId2 = "7030000000000231118"; + string includedTokensExpirationMonth2 = "12"; + string includedTokensExpirationYear2 = "2020"; + includedTokens.Add(new Accountupdaterv1batchesIncludedTokens( + Id: includedTokensId2, + ExpirationMonth: includedTokensExpirationMonth2, + ExpirationYear: includedTokensExpirationYear2 + )); + + Accountupdaterv1batchesIncluded included = new Accountupdaterv1batchesIncluded( + Tokens: includedTokens + ); + + string merchantReference = "TC50171_3"; + string notificationEmail = "test@cybs.com"; + var requestObj = new Body( + Type: type, + Included: included, + MerchantReference: merchantReference, + NotificationEmail: notificationEmail + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BatchesApi(clientConfig); + InlineResponse202 result = apiInstance.PostBatch(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/AccountUpdater/ListBatches.cs b/Source/Samples/AccountUpdater/ListBatches.cs new file mode 100644 index 0000000..2e47e83 --- /dev/null +++ b/Source/Samples/AccountUpdater/ListBatches.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.AccountUpdater +{ + public class ListBatches + { + public static void Run() + { + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BatchesApi(clientConfig); + string fromDate = "20230101T123000Z"; + string toDate = "20230410T123000Z"; + InlineResponse2005 result = apiInstance.GetBatchesList(0, 10, fromDate, toDate); + Console.WriteLine(result); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} diff --git a/Source/Samples/AccountUpdater/OneOffVisaMasterCardCustomerTokenBatch.cs b/Source/Samples/AccountUpdater/OneOffVisaMasterCardCustomerTokenBatch.cs new file mode 100644 index 0000000..d3de147 --- /dev/null +++ b/Source/Samples/AccountUpdater/OneOffVisaMasterCardCustomerTokenBatch.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.AccountUpdater +{ + public class OneOffVisaMasterCardCustomerTokenBatch + { + public static InlineResponse202 Run() + { + string type = "oneOff"; + + List includedTokens = new List (); + string includedTokensId1 = "C064DE56200B0DB0E053AF598E0A52AA"; + includedTokens.Add(new Accountupdaterv1batchesIncludedTokens( + Id: includedTokensId1 + )); + + string includedTokensId2 = "C064DE56213D0DB0E053AF598E0A52AA"; + includedTokens.Add(new Accountupdaterv1batchesIncludedTokens( + Id: includedTokensId2 + )); + + Accountupdaterv1batchesIncluded included = new Accountupdaterv1batchesIncluded( + Tokens: includedTokens + ); + + string merchantReference = "TC50171_3"; + string notificationEmail = "test@cybs.com"; + var requestObj = new Body( + Type: type, + Included: included, + MerchantReference: merchantReference, + NotificationEmail: notificationEmail + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BatchesApi(clientConfig); + InlineResponse202 result = apiInstance.PostBatch(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/AccountUpdater/OneOffVisaMasterCardInstrumentIdentifierTokenBatch.cs b/Source/Samples/AccountUpdater/OneOffVisaMasterCardInstrumentIdentifierTokenBatch.cs new file mode 100644 index 0000000..234e9e4 --- /dev/null +++ b/Source/Samples/AccountUpdater/OneOffVisaMasterCardInstrumentIdentifierTokenBatch.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.AccountUpdater +{ + public class OneOffVisaMasterCardInstrumentIdentifierTokenBatch + { + public static InlineResponse202 Run() + { + string type = "oneOff"; + + List includedTokens = new List(); + string includedTokensId1 = "7030000000000116236"; + string includedTokensExpirationMonth1 = "12"; + string includedTokensExpirationYear1 = "2020"; + includedTokens.Add(new Accountupdaterv1batchesIncludedTokens( + Id: includedTokensId1, + ExpirationMonth: includedTokensExpirationMonth1, + ExpirationYear: includedTokensExpirationYear1 + )); + + string includedTokensId2 = "7030000000000178855"; + string includedTokensExpirationMonth2 = "12"; + string includedTokensExpirationYear2 = "2020"; + includedTokens.Add(new Accountupdaterv1batchesIncludedTokens( + Id: includedTokensId2, + ExpirationMonth: includedTokensExpirationMonth2, + ExpirationYear: includedTokensExpirationYear2 + )); + + Accountupdaterv1batchesIncluded included = new Accountupdaterv1batchesIncluded( + Tokens: includedTokens + ); + + string merchantReference = "TC50171_3"; + string notificationEmail = "test@cybs.com"; + var requestObj = new Body( + Type: type, + Included: included, + MerchantReference: merchantReference, + NotificationEmail: notificationEmail + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BatchesApi(clientConfig); + InlineResponse202 result = apiInstance.PostBatch(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/AccountUpdater/RetrieveBatchReport.cs b/Source/Samples/AccountUpdater/RetrieveBatchReport.cs new file mode 100644 index 0000000..ad99eb8 --- /dev/null +++ b/Source/Samples/AccountUpdater/RetrieveBatchReport.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.AccountUpdater +{ + public class RetrieveBatchReport + { + public static void Run() + { + try + { + string batchId = "16188390061150001062041064"; + + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BatchesApi(clientConfig); + InlineResponse2007 result = apiInstance.GetBatchReport(batchId); + Console.WriteLine(result); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} diff --git a/Source/Samples/AccountUpdater/RetrieveBatchStatus.cs b/Source/Samples/AccountUpdater/RetrieveBatchStatus.cs new file mode 100644 index 0000000..6c74497 --- /dev/null +++ b/Source/Samples/AccountUpdater/RetrieveBatchStatus.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.AccountUpdater +{ + public class RetrieveBatchStatus + { + public static void Run() + { + try + { + string batchId = "16188390061150001062041064"; + + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BatchesApi(clientConfig); + InlineResponse2006 result = apiInstance.GetBatchStatus(batchId); + Console.WriteLine(result); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} diff --git a/src/Samples/Authentication/CallHttpMethods/DeleteMethod.cs b/Source/Samples/Authentication/CallHttpMethods/DeleteMethod.cs similarity index 68% rename from src/Samples/Authentication/CallHttpMethods/DeleteMethod.cs rename to Source/Samples/Authentication/CallHttpMethods/DeleteMethod.cs index 81a7e0a..4fc3bf8 100644 --- a/src/Samples/Authentication/CallHttpMethods/DeleteMethod.cs +++ b/Source/Samples/Authentication/CallHttpMethods/DeleteMethod.cs @@ -11,6 +11,13 @@ public class DeleteMethod // Below request unsubscribes 'TRR Report' Subscription for Organization ID: testrest private const string RequestTarget = "/reporting/v2/reportSubscriptions/TRRReport?organizationId=testrest"; + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static void Run() { try @@ -32,11 +39,20 @@ public static void Run() Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); Console.WriteLine("\n Response Code:{0}", response.StatusCode); Console.WriteLine("\n Response Message:{0}", response.Data); + if (response.StatusCode == 200 || response.StatusCode == 404) + { + WriteLogAudit(200); + } + else + { + WriteLogAudit(response.StatusCode); + } } } catch (Exception e) { - ExceptionUtility.Exception(e.Message, e.StackTrace); + Console.WriteLine(e.Message); + Console.WriteLine(e.StackTrace); } } } diff --git a/src/Samples/Authentication/CallHttpMethods/GetMethod.cs b/Source/Samples/Authentication/CallHttpMethods/GetMethod.cs similarity index 76% rename from src/Samples/Authentication/CallHttpMethods/GetMethod.cs rename to Source/Samples/Authentication/CallHttpMethods/GetMethod.cs index 4a7c2bb..0443fb6 100644 --- a/src/Samples/Authentication/CallHttpMethods/GetMethod.cs +++ b/Source/Samples/Authentication/CallHttpMethods/GetMethod.cs @@ -11,6 +11,13 @@ public class GetMethod // Below Request fetches the payment details of payment ID: 5319754772076048103525 private const string RequestTarget = "/pts/v2/payments/5526383152166546003003"; + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static void Run() { try @@ -32,11 +39,13 @@ public static void Run() Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); Console.WriteLine("\n Response Code:{0}", response.StatusCode); Console.WriteLine("\n Response Message:{0}", response.Data); + WriteLogAudit(response.StatusCode); } } catch (Exception e) { - ExceptionUtility.Exception(e.Message, e.StackTrace); + Console.WriteLine(e.Message); + Console.WriteLine(e.StackTrace); } } } diff --git a/src/Samples/Authentication/CallHttpMethods/GetObjectMethod.cs b/Source/Samples/Authentication/CallHttpMethods/GetObjectMethod.cs similarity index 79% rename from src/Samples/Authentication/CallHttpMethods/GetObjectMethod.cs rename to Source/Samples/Authentication/CallHttpMethods/GetObjectMethod.cs index 080f5ed..64b3847 100644 --- a/src/Samples/Authentication/CallHttpMethods/GetObjectMethod.cs +++ b/Source/Samples/Authentication/CallHttpMethods/GetObjectMethod.cs @@ -12,6 +12,13 @@ public class GetObjectMethod // Below Request fetches the payment details of payment ID: 5319754772076048103525 private const string RequestTarget = "/pts/v2/payments/5526478103126428303006"; + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static void Run() { try @@ -36,11 +43,13 @@ public static void Run() Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); Console.WriteLine("\n Response Code:{0}", response.StatusCode); Console.WriteLine("\n Response Message:{0}", response.Data); + WriteLogAudit(response.StatusCode); } } catch (Exception e) { - ExceptionUtility.Exception(e.Message, e.StackTrace); + Console.WriteLine(e.Message); + Console.WriteLine(e.StackTrace); } } } diff --git a/src/Samples/Authentication/CallHttpMethods/PostMethod.cs b/Source/Samples/Authentication/CallHttpMethods/PostMethod.cs similarity index 71% rename from src/Samples/Authentication/CallHttpMethods/PostMethod.cs rename to Source/Samples/Authentication/CallHttpMethods/PostMethod.cs index 7af0841..70e2b68 100644 --- a/src/Samples/Authentication/CallHttpMethods/PostMethod.cs +++ b/Source/Samples/Authentication/CallHttpMethods/PostMethod.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using ApiSdk.controller; using AuthenticationSdk.core; using AuthenticationSdk.util; @@ -11,7 +12,14 @@ public class PostMethod // POST Request to Authorize the payment for a transaction. // Transaction details provided in the JSON File are sent along with the Request as Request Body private const string RequestTarget = "/pts/v2/payments/"; - private const string RequestJsonFilePath = "Resource\\request_payments.json"; + private static string RequestJsonFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Source/Resource/request_payments.json").ToString(); + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } public static void Run() { @@ -37,11 +45,13 @@ public static void Run() Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); Console.WriteLine("\n Response Code:{0}", response.StatusCode); Console.WriteLine("\n Response Message:{0}", response.Data); + WriteLogAudit(response.StatusCode); } } catch (Exception e) { - ExceptionUtility.Exception(e.Message, e.StackTrace); + Console.WriteLine(e.Message); + Console.WriteLine(e.StackTrace); } } } diff --git a/src/Samples/Authentication/CallHttpMethods/PostObjectMethod.cs b/Source/Samples/Authentication/CallHttpMethods/PostObjectMethod.cs similarity index 79% rename from src/Samples/Authentication/CallHttpMethods/PostObjectMethod.cs rename to Source/Samples/Authentication/CallHttpMethods/PostObjectMethod.cs index 71d7af1..d84389a 100644 --- a/src/Samples/Authentication/CallHttpMethods/PostObjectMethod.cs +++ b/Source/Samples/Authentication/CallHttpMethods/PostObjectMethod.cs @@ -12,6 +12,13 @@ public class PostObjectMethod // Transaction details are sent along with the Request as Request Body private const string RequestTarget = "/pts/v2/payments/"; + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static void Run() { try @@ -39,11 +46,13 @@ public static void Run() Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); Console.WriteLine("\n Response Code:{0}", response.StatusCode); Console.WriteLine("\n Response Message:{0}", response.Data); + WriteLogAudit(response.StatusCode); } } catch (Exception e) { - ExceptionUtility.Exception(e.Message, e.StackTrace); + Console.WriteLine(e.Message); + Console.WriteLine(e.StackTrace); } } } diff --git a/src/Samples/Authentication/CallHttpMethods/PutMethod.cs b/Source/Samples/Authentication/CallHttpMethods/PutMethod.cs similarity index 73% rename from src/Samples/Authentication/CallHttpMethods/PutMethod.cs rename to Source/Samples/Authentication/CallHttpMethods/PutMethod.cs index 4eeefe0..7d8f64d 100644 --- a/src/Samples/Authentication/CallHttpMethods/PutMethod.cs +++ b/Source/Samples/Authentication/CallHttpMethods/PutMethod.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using ApiSdk.controller; using AuthenticationSdk.core; using AuthenticationSdk.util; @@ -12,7 +13,14 @@ public class PutMethod // Report Details provided in the JSON File are sent along with the Request as Request Body // Below request subscribes 'TRR Report' for Organization ID: testrest private const string RequestTarget = "/reporting/v2/reportSubscriptions/TRRReport?organizationId=testrest"; - private const string RequestJsonFilePath = "Resource\\TRRReport.json"; + private static string RequestJsonFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Source/Resource/TRRReport.json"); + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } public static void Run() { @@ -38,11 +46,13 @@ public static void Run() Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); Console.WriteLine("\n Response Code:{0}", response.StatusCode); Console.WriteLine("\n Response Message:{0}", response.Data); + WriteLogAudit(response.StatusCode); } } catch (Exception e) { - ExceptionUtility.Exception(e.Message, e.StackTrace); + Console.WriteLine(e.Message); + Console.WriteLine(e.StackTrace); } } } diff --git a/src/Samples/Authentication/GenerateHttpRequestHeaders/DeleteGenerateHeaders.cs b/Source/Samples/Authentication/GenerateHttpRequestHeaders/DeleteGenerateHeaders.cs similarity index 79% rename from src/Samples/Authentication/GenerateHttpRequestHeaders/DeleteGenerateHeaders.cs rename to Source/Samples/Authentication/GenerateHttpRequestHeaders/DeleteGenerateHeaders.cs index 4ef0864..3accef8 100644 --- a/src/Samples/Authentication/GenerateHttpRequestHeaders/DeleteGenerateHeaders.cs +++ b/Source/Samples/Authentication/GenerateHttpRequestHeaders/DeleteGenerateHeaders.cs @@ -10,6 +10,13 @@ public class DeleteGenerateHeaders // Below request unsubscribes 'TRR Report' Subscription for Organization ID: testrest private const string RequestTarget = "/reporting/v2/reportSubscriptions/TRRReport?organizationId=testrest"; + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static void Run() { try @@ -21,7 +28,7 @@ public static void Run() RequestType = Enumerations.RequestType.DELETE.ToString(), }; - // Call to the Authorize class of AuthSDK to get the signature and token objects + // Call to the Authorize class of AuthSDK to get the signature and token objects var authorizeObj = new Authorize(merchantConfig); if (string.Equals(merchantConfig.AuthenticationType, Enumerations.AuthenticationType.HTTP_SIGNATURE.ToString(), StringComparison.OrdinalIgnoreCase)) @@ -33,6 +40,7 @@ public static void Run() Console.WriteLine("{0} {1}", "Date:", requestHeaders.GmtDateTime); Console.WriteLine("{0} {1}", "Host:", requestHeaders.HostName); Console.WriteLine("{0} {1}", "signature:", requestHeaders.SignatureParam); + WriteLogAudit(200); } else if (string.Equals(merchantConfig.AuthenticationType, Enumerations.AuthenticationType.JWT.ToString(), StringComparison.OrdinalIgnoreCase)) { @@ -40,11 +48,14 @@ public static void Run() Console.WriteLine("{0} {1}", "Accept:", "application/hal+json"); Console.WriteLine("{0} {1}", "Authorization:", requestHeaders.BearerToken); + WriteLogAudit(200); } } catch (Exception e) { - ExceptionUtility.Exception(e.Message, e.StackTrace); + Console.WriteLine(e.Message); + Console.WriteLine(e.StackTrace); + WriteLogAudit(400); } } } diff --git a/src/Samples/Authentication/GenerateHttpRequestHeaders/GetGenerateHeaders.cs b/Source/Samples/Authentication/GenerateHttpRequestHeaders/GetGenerateHeaders.cs similarity index 80% rename from src/Samples/Authentication/GenerateHttpRequestHeaders/GetGenerateHeaders.cs rename to Source/Samples/Authentication/GenerateHttpRequestHeaders/GetGenerateHeaders.cs index 358cff6..fbb2a4b 100644 --- a/src/Samples/Authentication/GenerateHttpRequestHeaders/GetGenerateHeaders.cs +++ b/Source/Samples/Authentication/GenerateHttpRequestHeaders/GetGenerateHeaders.cs @@ -10,6 +10,13 @@ public class GetGenerateHeaders // Below Request fetches the payment details of payment ID: 5289697403596987704107 private const string RequestTarget = "/pts/v2/payments/5289697403596987704107"; + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static void Run() { try @@ -33,6 +40,7 @@ public static void Run() Console.WriteLine("{0} {1}", "Date:", requestHeaders.GmtDateTime); Console.WriteLine("{0} {1}", "Host:", requestHeaders.HostName); Console.WriteLine("{0} {1}", "signature:", requestHeaders.SignatureParam); + WriteLogAudit(200); } else if (string.Equals(merchantConfig.AuthenticationType, Enumerations.AuthenticationType.JWT.ToString(), StringComparison.OrdinalIgnoreCase)) { @@ -40,11 +48,14 @@ public static void Run() Console.WriteLine("{0} {1}", "Accept:", "application/hal+json"); Console.WriteLine("{0} {1}", "Authorization:", requestHeaders.BearerToken); + WriteLogAudit(200); } } catch (Exception e) { - ExceptionUtility.Exception(e.Message, e.StackTrace); + Console.WriteLine(e.Message); + Console.WriteLine(e.StackTrace); + WriteLogAudit(400); } } } diff --git a/src/Samples/Authentication/GenerateHttpRequestHeaders/PostGenerateHeaders.cs b/Source/Samples/Authentication/GenerateHttpRequestHeaders/PostGenerateHeaders.cs similarity index 77% rename from src/Samples/Authentication/GenerateHttpRequestHeaders/PostGenerateHeaders.cs rename to Source/Samples/Authentication/GenerateHttpRequestHeaders/PostGenerateHeaders.cs index 0a9f9d7..df4d1c9 100644 --- a/src/Samples/Authentication/GenerateHttpRequestHeaders/PostGenerateHeaders.cs +++ b/Source/Samples/Authentication/GenerateHttpRequestHeaders/PostGenerateHeaders.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using AuthenticationSdk.core; using AuthenticationSdk.util; using SampleCode.data; @@ -10,7 +11,14 @@ public class PostGenerateHeaders // POST Request to Authorize the payment for a transaction. // Transaction details provided in the JSON File are sent along with the Request as Request Body private const string RequestTarget = "/pts/v2/payments"; - private const string RequestJsonFilePath = "Resource\\request_payments.json"; + private static string RequestJsonFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Source/Resource/request_payments.json"); + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } public static void Run() { @@ -39,6 +47,7 @@ public static void Run() Console.WriteLine("{0} {1}", "Host:", requestHeaders.HostName); Console.WriteLine("{0} {1}", "digest:", requestHeaders.Digest); Console.WriteLine("{0} {1}", "signature:", requestHeaders.SignatureParam); + WriteLogAudit(200); } else if (string.Equals(merchantConfig.AuthenticationType, Enumerations.AuthenticationType.JWT.ToString(), StringComparison.OrdinalIgnoreCase)) { @@ -46,11 +55,14 @@ public static void Run() Console.WriteLine("{0} {1}", "Content-Type:", "application/json"); Console.WriteLine("{0} {1}", "Authorization:", requestHeaders.BearerToken); + WriteLogAudit(200); } } catch (Exception e) { - ExceptionUtility.Exception(e.Message, e.StackTrace); + Console.WriteLine(e.Message); + Console.WriteLine(e.StackTrace); + WriteLogAudit(400); } } } diff --git a/src/Samples/Authentication/GenerateHttpRequestHeaders/PutGenerateHeaders.cs b/Source/Samples/Authentication/GenerateHttpRequestHeaders/PutGenerateHeaders.cs similarity index 79% rename from src/Samples/Authentication/GenerateHttpRequestHeaders/PutGenerateHeaders.cs rename to Source/Samples/Authentication/GenerateHttpRequestHeaders/PutGenerateHeaders.cs index d664d54..832bf31 100644 --- a/src/Samples/Authentication/GenerateHttpRequestHeaders/PutGenerateHeaders.cs +++ b/Source/Samples/Authentication/GenerateHttpRequestHeaders/PutGenerateHeaders.cs @@ -11,10 +11,16 @@ public class PutGenerateHeaders // Report Details provided in the JSON File are sent along with the Request as Request Body // Below request subscribes 'TRR Report' for Organization ID: testrest private const string RequestTarget = "/reporting/v2/reportSubscriptions/TRRReport?organizationId=testrest"; - private const string RequestJsonFilePath = "Resource\\TRRReport.json"; + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } public static void Run() { + string RequestJsonFilePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../", "Source/Resource/TRRReport.json"); try { // Setting up Merchant Config @@ -40,6 +46,7 @@ public static void Run() Console.WriteLine("{0} {1}", "Host:", requestHeaders.HostName); Console.WriteLine("{0} {1}", "digest:", requestHeaders.Digest); Console.WriteLine("{0} {1}", "signature:", requestHeaders.SignatureParam); + WriteLogAudit(200); } else if (string.Equals(merchantConfig.AuthenticationType, Enumerations.AuthenticationType.JWT.ToString(), StringComparison.OrdinalIgnoreCase)) { @@ -47,11 +54,14 @@ public static void Run() Console.WriteLine("{0} {1}", "Content-Type:", "application/json"); Console.WriteLine("{0} {1}", "Authorization:", requestHeaders.BearerToken); + WriteLogAudit(200); } } catch (Exception e) { - ExceptionUtility.Exception(e.Message, e.StackTrace); + Console.WriteLine(e.Message); + Console.WriteLine(e.StackTrace); + WriteLogAudit(400); } } } diff --git a/src/Samples/Authentication/StandAloneHttpSignature.cs b/Source/Samples/Authentication/StandAloneHttpSignature.cs similarity index 89% rename from src/Samples/Authentication/StandAloneHttpSignature.cs rename to Source/Samples/Authentication/StandAloneHttpSignature.cs index d005aed..89cc058 100644 --- a/src/Samples/Authentication/StandAloneHttpSignature.cs +++ b/Source/Samples/Authentication/StandAloneHttpSignature.cs @@ -12,11 +12,19 @@ public class StandAloneHttpSignature { // Try with your own credentaials // Get Key ID, Secret Key and Merchant Id from EBC portal + //private static string merchantID request-target= "testrest"; private static string merchantID = "testrest"; private static string merchantKeyId = "08c94330-f618-42a3-b09d-e1e43be5efda"; private static string merchantsecretKey = "yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE="; private static string requestHost = "apitest.cybersource.com"; + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + /// /// This Example illustrate two tests - HTTP get and post method with Cybersource Payments API. /// Each test will caluate HTTP Signature Digest and Authenticate Cybersource Payments API using HTTP Client @@ -72,14 +80,16 @@ public static async Task RunAsync() var statusCode = await CallCyberSourceAPI(body); - if ((int)statusCode >= 200 && (int)statusCode <= 299) + if (statusCode >= 200 && statusCode <= 299) { - Console.WriteLine(string.Format("STATUS : SUCCESS (HTTP Status = {0})", (int)statusCode)); + Console.WriteLine(string.Format("STATUS : SUCCESS (HTTP Status = {0})", statusCode)); } else { - Console.WriteLine(string.Format("STATUS : ERROR (HTTP Status = {0})", (int)statusCode)); + Console.WriteLine(string.Format("STATUS : ERROR (HTTP Status = {0})", statusCode)); } + + WriteLogAudit(statusCode); } catch (Exception e) { @@ -92,14 +102,14 @@ public static async Task RunAsync() /// /// Request to send to API endpoint /// Task - public static async Task CallCyberSourceAPI(string request) + public static async Task CallCyberSourceAPI(string request) { - TaskStatus responseCode; + TaskStatus responseCodeGet, responseCodePost; // HTTP GET request using (var client = new HttpClient()) { - string resource = "/reporting/v3/reports?startTime=2018-10-01T00:00:00.0Z&endTime=2018-10-30T23:59:59.0Z&timeQueryType=executedTime&reportMimeType=application/xml"; + string resource = "/reporting/v3/reports?startTime=2021-01-01T00:00:00.0Z&endTime=2021-01-02T23:59:59.0Z&timeQueryType=executedTime&reportMimeType=application/xml"; /* Add Request Header :: "v-c-merchant-id" set value to Cybersource Merchant ID or v-c-merchant-id * This ID can be found on EBC portal. @@ -140,7 +150,7 @@ public static async Task CallCyberSourceAPI(string request) { string result = await r.Content.ReadAsStringAsync(); Console.WriteLine(result); - responseCode = (TaskStatus)r.StatusCode; + responseCodeGet = (TaskStatus)r.StatusCode; } } @@ -196,12 +206,19 @@ public static async Task CallCyberSourceAPI(string request) Console.WriteLine("\n -- Response Message --\n"); var response = await client.PostAsync("https://" + requestHost + resource, content); - responseCode = (TaskStatus)response.StatusCode; + responseCodePost = (TaskStatus)response.StatusCode; string responsecontent = await response.Content.ReadAsStringAsync(); Console.WriteLine(responsecontent); } - return responseCode; + if (((int)responseCodePost >= 200 && (int)responseCodePost <= 299) && ((int)responseCodePost >= 200 && (int)responseCodePost <= 299)) + { + return 200; + } + else + { + return 400; + } } /// @@ -235,7 +252,7 @@ public static string GenerateDigest(string request) // paramter 'Signature' is calucated based on below key values and then signed with SECRET KEY - // host: Sandbox (apitest.cybersource.com) or Production (api.cybersource.com) hostname // date: "HTTP-date" format as defined by RFC7231. - // (request-target): Should be in format of httpMethod: path + // request-target: Should be in format of httpMethod: path // Example: "post /pts/v2/payments" // Digest: Only needed for POST calls. // digestString = BASE64( HMAC-SHA256 ( Payload )); @@ -246,8 +263,8 @@ public static StringBuilder GenerateSignature(string request, string digest, str { StringBuilder signatureHeaderValue = new StringBuilder(); string algorithm = "HmacSHA256"; - string postHeaders = "host date (request-target) digest v-c-merchant-id"; - string getHeaders = "host date (request-target) v-c-merchant-id"; + string postHeaders = "host date request-target digest v-c-merchant-id"; + string getHeaders = "host date request-target v-c-merchant-id"; string url = "https://" + requestHost + resource; string getRequestTarget = method + " " + resource; string postRequestTarget = method + " " + resource; @@ -265,7 +282,7 @@ public static StringBuilder GenerateSignature(string request, string digest, str signatureString.Append(": "); signatureString.Append(gmtDateTime); signatureString.Append('\n'); - signatureString.Append("(request-target)"); + signatureString.Append("request-target"); signatureString.Append(": "); if (method.Equals("post")) @@ -311,7 +328,7 @@ public static StringBuilder GenerateSignature(string request, string digest, str signatureHeaderValue.Append(", signature=\"" + base64EncodedSignature + "\""); // Writing Generated Token to file. - File.WriteAllText(@".\Resource\" + "signatureHeaderValue.txt", signatureHeaderValue.ToString()); + File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + @"../../../Source/Resource/" + "signatureHeaderValue.txt", signatureHeaderValue.ToString()); } catch (Exception ex) { diff --git a/src/Samples/Authentication/StandAloneJWT.cs b/Source/Samples/Authentication/StandAloneJWT.cs similarity index 87% rename from src/Samples/Authentication/StandAloneJWT.cs rename to Source/Samples/Authentication/StandAloneJWT.cs index ca43e18..25fdb24 100644 --- a/src/Samples/Authentication/StandAloneJWT.cs +++ b/Source/Samples/Authentication/StandAloneJWT.cs @@ -15,6 +15,13 @@ public class StandAloneJWT private static string merchantID = "testrest"; private static string requestHost = "apitest.cybersource.com"; + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + /// /// This is standalone code that show cases how to generate headers for CyberSource REST API - POST and GET calls. /// This sample code has sample Mercahnt credentails (testrest) with .p12(At same dir level) that you can also use for testing. @@ -73,14 +80,16 @@ public static async Task RunAsync() "}"; var statusCode = await CallCyberSourceAPI(request); - if ((int)statusCode >= 200 && (int)statusCode <= 299) + if (statusCode >= 200 && statusCode <= 299) { - Console.WriteLine(string.Format("STATUS : SUCCESS (HTTP Status = {0})", (int)statusCode)); + Console.WriteLine(string.Format("STATUS : SUCCESS (HTTP Status = {0})", statusCode)); } else { - Console.WriteLine(string.Format("STATUS : ERROR (HTTP Status = {0})", (int)statusCode)); + Console.WriteLine(string.Format("STATUS : ERROR (HTTP Status = {0})", statusCode)); } + + WriteLogAudit(statusCode); } catch (Exception e) { @@ -93,14 +102,14 @@ public static async Task RunAsync() /// /// Request to send to API endpoint< /// Task - public static async Task CallCyberSourceAPI(string request) + public static async Task CallCyberSourceAPI(string request) { - TaskStatus responseCode; + TaskStatus responseCodeGet, responseCodePost; // HTTP GET request using (var client = new HttpClient()) { - string resource = "/reporting/v3/reports?startTime=2018-10-01T00:00:00.0Z&endTime=2018-10-30T23:59:59.0Z&timeQueryType=executedTime&reportMimeType=application/xml"; + string resource = "/reporting/v3/reports?startTime=2021-02-01T00:00:00.0Z&endTime=2021-02-02T23:59:59.0Z&timeQueryType=executedTime&reportMimeType=application/xml"; Console.WriteLine("\nSample 1: GET call - CyberSource Reporting API"); Console.WriteLine(" -- RequestURL -- "); @@ -116,6 +125,7 @@ public static async Task CallCyberSourceAPI(string request) { string result = await r.Content.ReadAsStringAsync(); Console.WriteLine("\n -- Response Message --\n\n" + result); + responseCodeGet = (TaskStatus)r.StatusCode; } } @@ -135,12 +145,19 @@ public static async Task CallCyberSourceAPI(string request) client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", jwtToken); var response = await client.PostAsync("https://" + requestHost + resource, content); - responseCode = (TaskStatus)response.StatusCode; + responseCodePost = (TaskStatus)response.StatusCode; string responseContent = await response.Content.ReadAsStringAsync(); Console.WriteLine("\n -- Response Message --\n\n" + responseContent + "\n"); } - return responseCode; + if (((int)responseCodePost >= 200 && (int)responseCodePost <= 299) && ((int)responseCodePost >= 200 && (int)responseCodePost <= 299)) + { + return 200; + } + else + { + return 400; + } } /// @@ -181,7 +198,7 @@ public static string GenerateJWT(string request, string method) Console.WriteLine("\tJWT BODY : " + jwtBody); // P12 certificate public key is sent in the header and the private key is used to sign the token - X509Certificate2 x5Cert = new X509Certificate2(Path.Combine($"Resource", $"testrest.p12"), merchantID, X509KeyStorageFlags.MachineKeySet); + X509Certificate2 x5Cert = new X509Certificate2(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"../../../Source/Resource", $"testrest.p12"), merchantID, X509KeyStorageFlags.MachineKeySet); // Extracting Public Key from .p12 file string x5cPublicKey = Convert.ToBase64String(x5Cert.RawData); @@ -223,7 +240,7 @@ public static string GenerateJWT(string request, string method) token = Jose.JWT.Encode(jwtBody, privateKey, Jose.JwsAlgorithm.RS256, cybsHeaders); // Writing Generated Token to file. - File.WriteAllText(Path.Combine($"Resource", $"jwsToken.txt"), token); + File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"../../../Source/Resource", $"jwsToken.txt"), token); } catch (Exception ex) { diff --git a/Source/Samples/Authentication/StandAloneMetaKey.cs b/Source/Samples/Authentication/StandAloneMetaKey.cs new file mode 100644 index 0000000..1bf124a --- /dev/null +++ b/Source/Samples/Authentication/StandAloneMetaKey.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using CyberSource.Model; +using CyberSource.Client; +using CyberSource.Api; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Samples.Authentication +{ + + public class StandAloneMetaKey + { + // initialize dictionary object + private static readonly Dictionary _configurationDictionary = new Dictionary(); + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + private static Dictionary GetConfiguration() + { + _configurationDictionary.Add("authenticationType", "HTTP_SIGNATURE"); + _configurationDictionary.Add("merchantID", ""); + _configurationDictionary.Add("merchantsecretKey", ""); + _configurationDictionary.Add("merchantKeyId", ""); + _configurationDictionary.Add("runEnvironment", "apitest.cybersource.com"); + + // Configs related to meta key + _configurationDictionary.Add("portfolioID", ""); + _configurationDictionary.Add("useMetaKey", "true"); + return _configurationDictionary; + } + + public static void Run() + { + SimplePaymentUsingMetaKey(); + } + + public static PtsV2PaymentsPost201Response SimplePaymentUsingMetaKey() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Authentication/StandAloneOAuth.cs b/Source/Samples/Authentication/StandAloneOAuth.cs new file mode 100644 index 0000000..0da48d2 --- /dev/null +++ b/Source/Samples/Authentication/StandAloneOAuth.cs @@ -0,0 +1,223 @@ +using System; +using System.Collections.Generic; +using CyberSource.Model; +using CyberSource.Api; +using CyberSource.Client; +using System.IO; + +namespace Cybersource_rest_samples_dotnet.Samples.Authentication +{ + + public class StandAloneOAuth + { + + private static Dictionary GetConfiguration() + { + Dictionary _configDictionary = new Dictionary(); + _configDictionary.Add("runEnvironment", "api-matest.cybersource.com"); + + // Configs related to OAuth + _configDictionary.Add("enableClientCert", "true"); + _configDictionary.Add("clientCertDirectory", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Source\\Resource")); + _configDictionary.Add("clientCertFile", ""); + _configDictionary.Add("clientCertPassword", ""); + _configDictionary.Add("clientId", ""); + _configDictionary.Add("clientSecret", ""); + return _configDictionary; + } + + private static string code; + private static string grantType; + private static string refreshToken; + private static string accessToken; + private static Dictionary configDictionary; + public static bool createUsingAuthCode = false; + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + CallOAuthAPI(null); + } + + public static void CallOAuthAPI(string[] args) + { + AccessTokenResponse result ; + if(createUsingAuthCode) + { + // Create Access Token using Auth Code + code = ""; + grantType = "authorization_code"; + result = postAccessTokenFromAuthCode(); + } + else { + // Create Access Token using Refresh Token + grantType = "refresh_token"; + refreshToken = ""; + result = postAccessTokenFromRefreshToken(); + } + + if(result != null) { + refreshToken = result.RefreshToken; + accessToken = result.AccessToken; + + // Save accessToken and refreshToken before making API calls + configDictionary["accessToken"] = accessToken; + configDictionary["refreshToken"] = refreshToken; + + // Set Authentication to OAuth + configDictionary["authenticationType"] = "OAuth"; + + //Call Payments SampleCode using OAuth, Set Authentication to OAuth in Sample Code Configuration + var resultCode = SimpleAuthorizationInternet(); + WriteLogAudit(resultCode); + } + + } + + public static AccessTokenResponse postAccessTokenFromAuthCode() + { + AccessTokenResponse result = null; + try + { + configDictionary = GetConfiguration(); + configDictionary["authenticationType"] = "Mutual_Auth"; + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var requestObj = new CreateAccessTokenRequest( + Code: code, + GrantType: grantType, + ClientId: configDictionary["clientId"], + ClientSecret: configDictionary["clientSecret"] + ); + + var apiInstance = new OAuthApi(clientConfig); + result = apiInstance.PostAccessTokenRequest(requestObj); + Console.WriteLine(result); + return result; + + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + + public static AccessTokenResponse postAccessTokenFromRefreshToken() + { + AccessTokenResponse result = null; + try + { + configDictionary = GetConfiguration(); + configDictionary["authenticationType"] = "Mutual_Auth"; + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var requestObj = new CreateAccessTokenRequest( + RefreshToken: refreshToken, + GrantType: grantType, + ClientId: configDictionary["clientId"], + ClientSecret: configDictionary["clientSecret"] + ); + + var apiInstance = new OAuthApi(clientConfig); + result = apiInstance.PostAccessTokenRequest(requestObj); + Console.WriteLine(result); + return result; + + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + + public static int SimpleAuthorizationInternet() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return apiInstance.GetStatusCode(); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return e.ErrorCode; + } + } + } +} diff --git a/Source/Samples/AzureIntermediateTesting/SampleTestingForAzureIntermediateHost.cs b/Source/Samples/AzureIntermediateTesting/SampleTestingForAzureIntermediateHost.cs new file mode 100644 index 0000000..b782b04 --- /dev/null +++ b/Source/Samples/AzureIntermediateTesting/SampleTestingForAzureIntermediateHost.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.AzureIntermediateTesting +{ + public class AzureIntermediateTesting + { + public static PtsV2CreditsPost201Response Run() + { + string clientReferenceInformationCode = "12345678"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "03"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardType = "001"; + Ptsv2paymentsidrefundsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsidrefundsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Type: paymentInformationCardType + ); + + Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "200"; + string orderInformationAmountDetailsCurrency = "usd"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Deo"; + string orderInformationBillToAddress1 = "900 Metro Center Blvd"; + string orderInformationBillToLocality = "Foster City"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "48104-2201"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "9321499232"; + Ptsv2paymentsidcapturesOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsidcapturesOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreateCreditRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + //adding additional headers for azure host + Dictionary additionalHeaders = new Dictionary(); + additionalHeaders.Add("Ocp-Apim-Subscription-Key", "=fchgfchgvjhvjh5536hg"); + additionalHeaders.Add("Ocp-Apim-Trace", "dfgcjgvjkhbkjkjhnkjvjgchdxh"); + additionalHeaders.Add("Host", "manage.windowsazure.com"); + + var configDictionary = new Configuration().GetIntermediateConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(defaultHeader: additionalHeaders, merchConfigDictObj: configDictionary); + + var apiInstance = new CreditApi(clientConfig); + PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); + Console.WriteLine(result); + return result; + } + + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/BinLookup/BINLookupWithCard.cs b/Source/Samples/BinLookup/BINLookupWithCard.cs new file mode 100644 index 0000000..37a9e97 --- /dev/null +++ b/Source/Samples/BinLookup/BINLookupWithCard.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.BinLookup +{ + public class BINLookupWithCard + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static InlineResponse2011 Run() + { + Binv1binlookupClientReferenceInformation clientReferenceInformation = new Binv1binlookupClientReferenceInformation( + ); + + string paymentInformationCardNumber = "4111111111111111"; + Binv1binlookupPaymentInformationCard paymentInformationCard = new Binv1binlookupPaymentInformationCard( + Number: paymentInformationCardNumber + ); + + Binv1binlookupPaymentInformation paymentInformation = new Binv1binlookupPaymentInformation( + Card: paymentInformationCard + ); + + var requestObj = new CreateBinLookupRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BinLookupApi(clientConfig); + InlineResponse2011 result = apiInstance.GetAccountInfo(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(999); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/BinLookup/BINLookupWithHealthcareCard.cs b/Source/Samples/BinLookup/BINLookupWithHealthcareCard.cs new file mode 100644 index 0000000..7804edc --- /dev/null +++ b/Source/Samples/BinLookup/BINLookupWithHealthcareCard.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.BinLookup +{ + public class BINLookupWithHealthcareCard + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static InlineResponse2011 Run() + { + string paymentInformationCardNumber = "4288900100000"; + Binv1binlookupPaymentInformationCard paymentInformationCard = new Binv1binlookupPaymentInformationCard( + Number: paymentInformationCardNumber + ); + + Binv1binlookupPaymentInformation paymentInformation = new Binv1binlookupPaymentInformation( + Card: paymentInformationCard + ); + + var requestObj = new CreateBinLookupRequest( + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BinLookupApi(clientConfig); + InlineResponse2011 result= apiInstance.GetAccountInfo(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(999); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/BinLookup/BINLookupWithNetworkToken.cs b/Source/Samples/BinLookup/BINLookupWithNetworkToken.cs new file mode 100644 index 0000000..064e112 --- /dev/null +++ b/Source/Samples/BinLookup/BINLookupWithNetworkToken.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.BinLookup +{ + public class BINLookupWithNetworkToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static InlineResponse2011 Run() + { + string paymentInformationCardNumber = "4895370016313691"; + Binv1binlookupPaymentInformationCard paymentInformationCard = new Binv1binlookupPaymentInformationCard( + Number: paymentInformationCardNumber + ); + + Binv1binlookupPaymentInformation paymentInformation = new Binv1binlookupPaymentInformation( + Card: paymentInformationCard + ); + + var requestObj = new CreateBinLookupRequest( + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BinLookupApi(clientConfig); + InlineResponse2011 result= apiInstance.GetAccountInfo(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(999); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/BinLookup/BINLookupWithTMSCustomerID.cs b/Source/Samples/BinLookup/BINLookupWithTMSCustomerID.cs new file mode 100644 index 0000000..43fe7fc --- /dev/null +++ b/Source/Samples/BinLookup/BINLookupWithTMSCustomerID.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.BinLookup +{ + public class BINLookupWithTMSCustomerID + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static InlineResponse2011 Run() + { + string paymentInformationCustomerId = "E5426CFDE77F7390E053A2598D0A925D"; + GetAllSubscriptionsResponsePaymentInformationCustomer paymentInformationCustomer = new GetAllSubscriptionsResponsePaymentInformationCustomer( + Id: paymentInformationCustomerId + ); + + Binv1binlookupPaymentInformation paymentInformation = new Binv1binlookupPaymentInformation( + Customer: paymentInformationCustomer + ); + + var requestObj = new CreateBinLookupRequest( + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BinLookupApi(clientConfig); + InlineResponse2011 result= apiInstance.GetAccountInfo(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(999); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/BinLookup/BINLookupWithTMSInstrumentIdentifier.cs b/Source/Samples/BinLookup/BINLookupWithTMSInstrumentIdentifier.cs new file mode 100644 index 0000000..7922f46 --- /dev/null +++ b/Source/Samples/BinLookup/BINLookupWithTMSInstrumentIdentifier.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.BinLookup +{ + public class BINLookupWithTMSInstrumentIdentifier + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static InlineResponse2011 Run() + { + string paymentInformationInstrumentIdentifierId = "7010000000016241111"; + Ptsv2paymentsPaymentInformationInstrumentIdentifier paymentInformationInstrumentIdentifier = new Ptsv2paymentsPaymentInformationInstrumentIdentifier( + Id: paymentInformationInstrumentIdentifierId + ); + + Binv1binlookupPaymentInformation paymentInformation = new Binv1binlookupPaymentInformation( + InstrumentIdentifier: paymentInformationInstrumentIdentifier + ); + + var requestObj = new CreateBinLookupRequest( + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BinLookupApi(clientConfig); + InlineResponse2011 result = apiInstance.GetAccountInfo(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(999); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/BinLookup/BINLookupWithTMSJWTTransientToken.cs b/Source/Samples/BinLookup/BINLookupWithTMSJWTTransientToken.cs new file mode 100644 index 0000000..2388451 --- /dev/null +++ b/Source/Samples/BinLookup/BINLookupWithTMSJWTTransientToken.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.BinLookup +{ + public class BINLookupWithTMSJWTTransientToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static InlineResponse2011 Run() + { + string tokenInformationTransientTokenJwt = "eyJraWQiOiIwODd0bk1DNU04bXJHR3JHMVJQTkwzZ2VyRUh5VWV1ciIsImFsZyI6IlJTMjU2In0.eyJpc3MiOiJGbGV4LzA4IiwiZXhwIjoxNjYwMTk1ODcwLCJ0eXBlIjoiYXBpLTAuMS4wIiwiaWF0IjoxNjYwMTk0OTcwLCJqdGkiOiIxRTBXQzFHTzg3SkcxQkRQMENROFNDUjFUVEs4NlU5Tjk4SDNXSDhJRk05TVZFV1RJWUZJNjJGNDk0MUU3QTkyIiwiY29udGVudCI6eyJwYXltZW50SW5mb3JtYXRpb24iOnsiY2FyZCI6eyJudW1iZXIiOnsibWFza2VkVmFsdWUiOiJYWFhYWFhYWFhYWFgxMTExIiwiYmluIjoiNDExMTExIn0sInR5cGUiOnsidmFsdWUiOiIwMDEifX19fX0.MkCLbyvufN4prGRvHJcqCu1WceDVlgubZVpShNWQVjpuFQUuqwrKg284sC7ucVKuIsOU0DTN8_OoxDLduvZhS7X_5TnO0QjyA_aFxbRBvU_bEz1l9V99VPADG89T-fox_L6sLUaoTJ8T4PyD7rkPHEA0nmXbqQCVqw4Czc5TqlKCwmL-Fe0NBR2HlOFI1PrSXT-7_wI-JTgXI0dQzb8Ub20erHwOLwu3oni4_ZmS3rGI_gxq2MHi8pO-ZOgA597be4WfVFAx1wnMbareqR72a0QM4DefeoltrpNqXSaASVyb5G0zuqg-BOjWJbawmg2QgcZ_vE3rJ6PDgWROvp9Tbw"; + Binv1binlookupTokenInformation tokenInformation = new Binv1binlookupTokenInformation( + TransientTokenJwt: tokenInformationTransientTokenJwt + ); + + var requestObj = new CreateBinLookupRequest( + TokenInformation: tokenInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BinLookupApi(clientConfig); + InlineResponse2011 result = apiInstance.GetAccountInfo(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(999); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/BinLookup/BINLookupWithTMSJtiTransientToken.cs b/Source/Samples/BinLookup/BINLookupWithTMSJtiTransientToken.cs new file mode 100644 index 0000000..17e0f08 --- /dev/null +++ b/Source/Samples/BinLookup/BINLookupWithTMSJtiTransientToken.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.BinLookup +{ + public class BINLookupWithTMSJtiTransientToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static InlineResponse2011 Run() + { + string tokenInformationJti = "1E0WC1GO87JG1BDP0CQ8SCR1TTK86U9N98H3WH8IFM9MVEWTIYFI62F4941E7A92"; + Binv1binlookupTokenInformation tokenInformation = new Binv1binlookupTokenInformation( + Jti: tokenInformationJti + ); + + var requestObj = new CreateBinLookupRequest( + TokenInformation: tokenInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BinLookupApi(clientConfig); + InlineResponse2011 result = apiInstance.GetAccountInfo(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(999); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/BinLookup/BINLookupWithTMSPaymentInstrument.cs b/Source/Samples/BinLookup/BINLookupWithTMSPaymentInstrument.cs new file mode 100644 index 0000000..970ccbb --- /dev/null +++ b/Source/Samples/BinLookup/BINLookupWithTMSPaymentInstrument.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.BinLookup +{ + public class BINLookupWithTMSPaymentInstrument + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static InlineResponse2011 Run() + { + string paymentInformationPaymentInstrumentId = "E5427539180789D0E053A2598D0AF053"; + Ptsv2paymentsPaymentInformationPaymentInstrument paymentInformationPaymentInstrument = new Ptsv2paymentsPaymentInformationPaymentInstrument( + Id: paymentInformationPaymentInstrumentId + ); + + Binv1binlookupPaymentInformation paymentInformation = new Binv1binlookupPaymentInformation( + PaymentInstrument: paymentInformationPaymentInstrument + ); + + var requestObj = new CreateBinLookupRequest( + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BinLookupApi(clientConfig); + InlineResponse2011 result = apiInstance.GetAccountInfo(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(999); + return null; + } + } + } +} \ No newline at end of file diff --git a/src/Samples/Flex/CoreServices/TokenizeCard.cs b/Source/Samples/FlexMicroform/FlexTokenizeCard.cs similarity index 57% rename from src/Samples/Flex/CoreServices/TokenizeCard.cs rename to Source/Samples/FlexMicroform/FlexTokenizeCard.cs index 23a25a8..317b9b9 100644 --- a/src/Samples/Flex/CoreServices/TokenizeCard.cs +++ b/Source/Samples/FlexMicroform/FlexTokenizeCard.cs @@ -1,44 +1,55 @@ -using System; +using System; using System.Collections.Generic; -using System.IO; -using System.Security.Cryptography; -using System.Text; +using System.Globalization; + using CyberSource.Api; +using CyberSource.Client; using CyberSource.Model; using CyberSource.Utilities.Flex.Model; using CyberSource.Utilities.Flex.TokenVerification; -namespace Cybersource_rest_samples_dotnet.Samples.Flex.CoreServices +namespace Cybersource_rest_samples_dotnet.Samples.FlexMicroform { - public class TokenizeCard + public class FlexTokenizeCard { - public static void Run() + /*public static void WriteLogAudit(int status) { - var generateKeyResult = GenerateKey.Run(); - var keyId = generateKeyResult.KeyId; + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static FlexV1TokensPost200Response Run() + { + var generateKeyResult = GenerateKeyLegacyTokenFormat.Run(); + string keyId = generateKeyResult.KeyId; var derFormat = generateKeyResult.Der.Format; var derAlgo = generateKeyResult.Der.Algorithm; var derPublicKey = generateKeyResult.Der.PublicKey; - var requestObj = new TokenizeRequest - ( + string cardInfoCardNumber = "4111111111111111"; + string cardInfoCardExpirationMonth = "12"; + string cardInfoCardExpirationYear = "2031"; + string cardInfoCardType = "001"; + Flexv1tokensCardInfo cardInfo = new Flexv1tokensCardInfo( + CardNumber: cardInfoCardNumber, + CardExpirationMonth: cardInfoCardExpirationMonth, + CardExpirationYear: cardInfoCardExpirationYear, + CardType: cardInfoCardType + ); + + var requestObj = new TokenizeRequest( KeyId: keyId, - CardInfo: new Flexv1tokensCardInfo - ( - CardExpirationYear: "2031", - CardNumber: "5555555555554444", - CardType: "002", - CardExpirationMonth: "03" - ) - ); + CardInfo: cardInfo + ); try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new TokenizationApi(clientConfig); - var result = apiInstance.Tokenize(requestObj); + var apiInstance = new TokenizationApi(clientConfig); + FlexV1TokensPost200Response result = apiInstance.Tokenize(requestObj); Console.WriteLine(result); TokenVerificationUtility tokenVerifier = new TokenVerificationUtility(); @@ -67,11 +78,16 @@ public static void Run() var tokenVerificationResult = tokenVerifier.Verify(flexPublicKey, postParameters); Console.WriteLine("TOKEN VERIFICATION : " + tokenVerificationResult); + + WriteLogAudit(apiInstance.GetStatusCode()); + return result; } - catch (Exception e) + catch (ApiException e) { - Console.WriteLine("Exception on calling the API: " + e.Message); + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; } - } + } */ } } diff --git a/Source/Samples/FlexMicroform/GenerateCaptureContext.cs b/Source/Samples/FlexMicroform/GenerateCaptureContext.cs new file mode 100644 index 0000000..a06904d --- /dev/null +++ b/Source/Samples/FlexMicroform/GenerateCaptureContext.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.FlexMicroform +{ + class GenerateCaptureContext + { + public static String Run() + { + List targetOrigins = new List() + { + "https://www.test.com" + }; + + List allowedCardNetworks = new List() + { + "VISA", + "MAESTRO", + "MASTERCARD", + "AMEX", + "DISCOVER", + "DINERSCLUB", + "JCB", + "CUP", + "CARTESBANCAIRES" + }; + + string clientVerison = "v2.0"; + + var requestObj = new GenerateCaptureContextRequest( + TargetOrigins: targetOrigins, + AllowedCardNetworks: allowedCardNetworks, + ClientVersion: clientVerison + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new MicroformIntegrationApi(clientConfig); + String result = apiInstance.GenerateCaptureContext(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/FlexMicroform/GenerateKey.cs b/Source/Samples/FlexMicroform/GenerateKey.cs new file mode 100644 index 0000000..ac47c59 --- /dev/null +++ b/Source/Samples/FlexMicroform/GenerateKey.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.FlexMicroform +{ + public class GenerateKey + { + /*public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static FlexV1KeysPost200Response Run() + { + string encryptionType = "RsaOaep"; + string targetOrigin = "https://www.test.com"; + var requestObj = new GeneratePublicKeyRequest( + EncryptionType: encryptionType, + TargetOrigin: targetOrigin + ); + + string format = "JWT"; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new KeyGenerationApi(clientConfig); + FlexV1KeysPost200Response result = apiInstance.GeneratePublicKey(format, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + }*/ + } +} diff --git a/Source/Samples/FlexMicroform/GenerateKeyLegacyTokenFormat.cs b/Source/Samples/FlexMicroform/GenerateKeyLegacyTokenFormat.cs new file mode 100644 index 0000000..ca76756 --- /dev/null +++ b/Source/Samples/FlexMicroform/GenerateKeyLegacyTokenFormat.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.FlexMicroform +{ + /*public class GenerateKeyLegacyTokenFormat + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static FlexV1KeysPost200Response Run() + { + string encryptionType = "None"; + string targetOrigin = "https://www.test.com"; + var requestObj = new GeneratePublicKeyRequest( + EncryptionType: encryptionType, + TargetOrigin: targetOrigin + ); + + string format = "legacy"; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new KeyGenerationApi(clientConfig); + FlexV1KeysPost200Response result = apiInstance.GeneratePublicKey(format, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + }*/ + +} diff --git a/Source/Samples/Invoicing/InvoiceSettings/GetInvoiceSettings.cs b/Source/Samples/Invoicing/InvoiceSettings/GetInvoiceSettings.cs new file mode 100644 index 0000000..34036d7 --- /dev/null +++ b/Source/Samples/Invoicing/InvoiceSettings/GetInvoiceSettings.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Invoicing +{ + public class GetInvoiceSettings + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InvoicingV2InvoiceSettingsGet200Response Run() + { + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InvoiceSettingsApi(clientConfig); + InvoicingV2InvoiceSettingsGet200Response result = apiInstance.GetInvoiceSettings(); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Invoicing/InvoiceSettings/UpdateInvoiceSettings.cs b/Source/Samples/Invoicing/InvoiceSettings/UpdateInvoiceSettings.cs new file mode 100644 index 0000000..71998fb --- /dev/null +++ b/Source/Samples/Invoicing/InvoiceSettings/UpdateInvoiceSettings.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Invoicing +{ + public class UpdateInvoiceSettings + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InvoicingV2InvoiceSettingsGet200Response Run() + { + string invoiceSettingsInformationMerchantLogo = "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAQCAwMDAgQDAwMEBAQEBQkGBQUFBQsICAYJDQsNDQ0LDAwOEBQRDg8TDwwMEhgSExUWFxcXDhEZGxkWGhQWFxb/2wBDAQQEBAUFBQoGBgoWDwwPFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhb/wAARCADHAM0DASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwDlPBvhzU77xaYFVhHnIIPf3rp/il4d1+w0lFWRwi4PBPWvQtG0+LSv+Jj5e1gM9OteP/tCfFjUJPEUOl29q0kEOPMYD9K8aMYVpc0Y3kehgOIcfGrDC4jSLeunTubXwa0i4F95+s3DttwQGbPFeqa1rNnJY/ZUnIyMKoavEdD8R6nq+mK9hbMJFXCgHkmtjwB4P8Y6zqzahqly1uMYjXooFY+wrzbex9X7SjKvGFBuSv8Ah6m1d648OqtbeeyjHB3GuV1bTrrUdUkuGuHwx+XntXWeM/AesabD9uX/AEjbye9cm9/NCu1wc5wR6V14TCUormqfEfF8XZtmWGxCp01aO6Y7T9DkhufNW4kD/wC8ea6jwrosk10Lue4c+UOBmsXR5TOwfdxXRWOo2lvGyyyFePWtMRQwk99z8+jDEV63tK0bnX2+sSRxi1DOY8YIBrzn4w+ENO1q1e8hH+kAEqe+fers3iu1s5NoYSBugBq5Z6ot7A0giPTI+lcFOp9WqXjZo9SjhqsJRqRlb9D508UeHNQtLGRzDJujHYdaytHmm+yeTNCyseNx4r7A8F+HNM8QWckVxbrv52r6mq83wu0LT42k1ezijkJLRkjOeeK9hYnnjdo9+WZRp+9TnzL+up4D8OfDzuyzybhu5xmvQF0KytolkUfMeTz3rrp/DlrbttswqxgZOBTU0tJVVSQMnFcsqkXJts8jMcTiq0ISk7R6HP2pji27m2qPer9jr8aSeRFub1wTS+LfB995kAtH/dvjcPWgaNBp0KoXXzcc/WsKbbTaR5kK86CfVl+3mS9uIxc5K56Z7V07LHbRwy6Wm0DBYiuWsbaNrYmR8GrMl9PZRqI3O0HOetc/PTcrXO/D8U4jDrllBNHdate3F1o2+V3Qkd2rjtTvIbMFWuHY/wC8aNR8SG/0c20jkFRwcVx3iOW5it/PKs6qOWFb16kIWUNUYyzN4qXO46nQaTDZXF488srYPcsa7jQ9Bjn0Geeyuf3mOPnPpXjukX7v9wt83tXW6Tf6zp9kXt5ZI43HP0q6VXnjY0jUcp/DdeW5xvi+XxQNYmtbUXLMr/OyseOa7T4SXeuWS5nuLqJz1IkINVtO1K7juJJfKjmd85Zu5q9YXlyu+WYRruz8oFcdfFTo3cYo6f8AZlR5m2pdrfqdTDqb/wBoOzM8nPzMWJJrivFUl9LrUr2s7pGeg3GtSyvlKlvvNzXG+KLu6OrN5SSFdo6VjgMTXV3Ld9z5ydduNm9D1n48ar4V0v4dn+zdYt2vfKxFEjBmY++OnNeEeDfBHiHx9eb0sAEJz5hHHSqfi34fS7vtlrePJHjdnf0FXPhz8VNU8A3P2WL/AEiJPvR5yfzr0LVJx/cpep+sfWstlJc03fax1F54S8R+BbyHbYpNbqw3YHOK7v8A4Sm3/wCEbSSS2NvKV71wl/8AFTxF4zt55obKO3Vc7VJyWrk/EfiDxJNpLWjw4Kn7y1tSoYqfuOy+Z6FDM8Jhdb6PyPV7HxvPc2strs8whSBn0rgtQsxPeTNdoU3SE4/wryqx+JOp+G9YIuhuw2MkYrdl+K9rdyebdIDuHyqi55960+qVU7X1PNznE4TMaa3TV7HYXkT2kG60iZh61j6vaa/c2rXEVvJtxnFa2heMo59DV4rTeHwcba2tP8USvZeQ1gwD8A7KzVOMZ6q7PgpVnhq3u62PG9H1a7PjGO0uonyrcqT717DpPiTQrScQX1xHbybRhXOPaovCvh7Tzr8uv3NsqiFeXPCrn1PQV5r8V7zSNS8f+fEhaONvL3oOGPt69auVKhVrxTjsj0YTp5g3CcbWPZdK8W20OoL/AGVcKWJ4dTkVu6t4pvNcYNqMgkaNNqYGABXnfwz8PDT9JW7CCVJOUYNuC9OpHFaHijWIdIt3cjLAZCr3NYVJwU7Q1PnMRR9nN0sO3bqX/E3iGLSbFpJ7hYQ428ntUvw1lj1mN7iC+QxqeRur5t8YTeJfGnif/S7hre3jYiGFDwo9TVjwzf654VvxZRao4jY9AfwraWET66nr0MtpyoRVSTc157eR9SeLNbgtNGf7LL5kkakde9cF4VvbzUL6W5vmPLHH0qh4O1E3Vuq3ETkMOp7mt2Aqtwfl2rjoPSuGXLCLhfVnNi/Y0sOrL3+36mzMvnR/uXxjtWbPqaw3SwS7Xz2BqSbWrKwtT5zCJepZj2riNSMt9r39oafLmPHHvWdLAUvaKVN6+Zx4PD1Kt6k42Xc7aPyp3/fN5KNmtOW/0e30c21wu7APOO2K5yxkgms40vZv3/REXqasap4F17W7UzRTrBFt4UHkj1/Wuvka0irnp08Mov3VcTwrcaJdaxN5EirGnPPSoPjF8QovD2kpp+n2/wBoluMIrL0XPf8AlXP6b4NuIbiS2kunVh1YHrVLV9AtbGQ3GrztLHH90k1m5U6lXlvouhrRdLm5YO12aWg+JL6awjYrhzyQavnXLgzbZmx9K43XvGXhfT7BY7C58ycYG1OceuTVBdbnuYVurWBnyO9Kjh9HJQ+86c0yKra0aqb8noeq6XeTM2IZMKetXpHgJBldN2Oc15xofiy5XT3imtDDKVwpJ/lVR7/XpmLxFmXPXrW0qNSrpy2PDo5Go+9OdzrPg/40tNd06SwLKzlCoVjz0rlvFGljw9rrSTxZWdy3P1ryDwbrV74f8SR31o7FVYeYM8YzXs/jMS+OvCNvqGlMXuIAHkRDzjHNXSTw1W32X+DPsK+GdOoklftY0PB91HK/lQR7VkPQe9d5pEdhbws86K2ASSw6cVgfA/wyDo41TUQV2HADd6zvjtr40LSbmLTH3TXa7E4+5ngmvAzH63jMZDD0Z2jfWxhUyXGfVo42tor7dbPqed/EHT9P8ReJLqW2gxbmQhCDnOD1p3hjwVYHbDLgKOpIrmfCd5rNvtkCNNhsn3r23wr4P8a3ujpqsnhu4NrIu4MF6ivrKkvYRSUrerPOqLG1JNUNV6X0LOhaDa6Tp8cjXMflPhVGK0Nblt9Ps98AM8mVwqA4AJxuY9gOP88iO40O+ubqCI2ssENvjzVcdPWuyutH06XRYktIvLntZmQuUz5qsqkZ9FAJ+teLicdQoSVSu7ruj69cJ0KsIuEf3jSvro31Z47rEOp60iPrEs8sTNn7KvEYHXaqZwOACWPPNYM9h9lkUr5UXkhki/dhtiH2PVj6nmvZ49CtXkuFnmKpG5wpQKCgHJ78VheLNH0GDR3uJ7t4Y1YYbZvL+wVecnGMdfx4rD/WLL5TUIt39D0IcN4ylD4UkvM8Xe7uNOvVOnPcWcik4kjmZZHPqSpGee1WI/E+qyXKjWLprqLO3e/3l/x/GtaG48O+JINcu/DVvqkcmhywLdRXdt5TtHLkJMFySF3rjBwfmU96zZNKkvGzHbCRsfxYBP0B6V7EIxqLmcdV33R4GIoU+fVJ+a1/Ez/F2r29ncxyWkgLSdwa5t5b+XVUuIyZMc59/Sui1rwuJ7RcKDLDn2OPeq2h6bfLex21tbPIpP3guRXVF3drHLXoqFJOG5uaT4t1i2sxGtrllGFzUcnjfxIkzF4l57e1dtoXgbUbl4WkgG3gHiuouPh1o6Sxi7wzMcMqda86tXo0p25fuPElKnCTdVad+h4jq+tajrepRyanKfJhORGrYH/166XQfE0MIEYJRAccmvR/GnwP+3rDqHh5RFAynzRj2ritK8FPa+JBa2FsdQmhbEwI6H0HpWdPF0aq/du9uh6kaLrvVpL+tu52/wAN9e8GXWoxWsyO144+/gjmvTVv/C8kx0q01f8A0lVzJCH5Ue9cv4O+H1wL3N9py206puUqOTXLn4f3mlfEC+1bS/PdpARPI5+6e9EsY4xbS6fK53YTJ54lpVElC9n3+7/Mwv2kfHll4eW3m8Pzx3EivtkAbknP/wBauE8OfF7S9dQWWrw+WzjByO9R+LPAq3es3N3dXqxnzHOxz15PNcPrnhN9KuxNDaNcbuVC966aMMNOGmr7nAsppVnLk6M9Kg+H8eoXEmo6UiPHJyAK057L+w9HYzMsckK52Eda898C+LfF+jagreXKltCP9U3Tiu1j8a2viyykkubfy54/4SO9ctP6/SrNVPep91uvUqnh/Z1OX4ku+hTk8TNNC0n2XKqBnaK6bwv4u0FtJTzIm3AkHK15PrV5NHrE0cLFVzgjFdz4EvdJj0BUkRS/mHdx34r0cRU9lT5oxuejhsow+KqeznP2a3udNJ8H7C80+RtOnjdgv4k1v/CTwhqXhG6VfszPBcHZIg+b8am/aCE/hD46S+HtLZ7WwjgjkjjDfeB5zXeeGfiNZ6T4diM9lH5zfIrvzk/1rx8bjqnO8PUVl5K59ZRyejThTxrnZrbXS/z18jQn8PSSW62kSm3ibk8dc1y3ij4d6TfYhn3TMfx5rcvvGV826+uIiYx82FHQdeBWA3xv0CTVlt7RY/tQ42unOe/avPo0587lSv8AI9LF1KMoqNZRt0Urfqd78G/g34M8PwJruvQRvNvzBFKcqOnbua7Xxh8T9D8P25gGl3UkcK8CKIBQPauV8I6nHqGmw6rd+ZKznG1x07jA9KreNV/thGks4zJ5kfl4fgL15xVYitarGnUerW7PhqmOVHGulRprlTSsuvocj8RvilJrGjXr+AfDUNxrMgCRLqEZ8lf7zkD7xAPAOBnr6HwXw1pPxr13UtS1GWDWbl7GRDcva3UMbWTH7uxNyhQQBnaOmBX2t8LfBFjovhcS3UULyFPMk8teTgZ4z3qbw1pEcVvNIIFj+2ymWVcDn0B9cDArjlm8sLQcORO+10fV1KNOpUvGTSj5nzx4f0fxHcSLFrF7JDc3IBRHtB8uMkq2HCkkA8j8jUniD4ft4nsZtGu7t7OO8hGZo5fLlQA5BjPIDKVU89TxXuPjTRIlZWES/Kx2nA49P51yP2WUR+TchXiydrZ2lRXxsswq063PD3Wn0/Q+mopYihyt3TVtTxjwH8IbTwFpuqxRazd6xfalHGl3d3kWzckbbljVAW4BwSSxzgDgDlkegO0mPMV3Xk5XBA9vUV65NYW0nCXk0Mf/AC0z8w/Xmue8SW9nbK0Uf2Jo2OwyzR7sgg5GARzwa+oynOMVicR7z5pSt0PDzPKcNQw3uqyR5u2lhlEiFtzEjDDPrwc981c8I3MmgXc2+3S4s5uJEAy8J/vpnH4j+taWszWChY4iknGdwATntz2rHlm88N5aLhSCgc5YHPU//rr7mu4S90+C+r+0ptTWjPQdH13SnjBhufkfGGBqaLybW8mnkfzI5VOwk56148zOmpSCK58h93KsPkc57+n4Yp9l4p1aG7/s5ndPMxsWX7r5/ut0P0615dTB1ISUlK68zxcRlKk1FbHuHh3Xru2W6s2lZUdCIcng8VZ+EN5pWmXd9qU9hmZXbBI/1j/WuFtI7y505I1kLXD8q684PcCqd/eeNYLeOzsbOWRJOC6rjafcmt5YGNC1Wkt9dD3KeErUHyULXWmqvbs0ei+JPFGonUGvDerbbcui7vujrWXpPxO0uHS7yTEc0sisHkznnnmuCs/Cvim+uvN1plUzcAzS44/zmr+n/Dbw7pgYeIPiLoOkpIclGmBbHfA5/lWPLiKs2orT0PSyvB08thOvWquUpb301+Z4f45TWtX8WT6ilyfs7SblRW4UZ4qWCbUnjw0y/IPlyemK9UvfCfwG0iO4e9+Ld9evnKR2NkzD6A4ArOsdV/Zx0GA3Z0TxV4hlVvl8+ZYY2+uT/Svcp0VGCp209Dx6dbEczmmrt9H/AJXPMFv9RubgWzeW7M2CcdqxNWtdX8O6s64ZVlG88djXttt8YPCUrGLwl8LdH0qNT/x8XkrTSe3oK5/xRHqPibVE1G8tIpjJjiNMKB6AVTcY+6kayqvkcpv3vn+v+R5K89/qUu2GIl8/eA71c0ttVtIGhdG3ByTlfpXqWn2kVnJmPSfLZB6VIdLnuGaU2iruOcZrneIglZrQ462OpU0nKorvzPZPjdo0Pjr4oW2t2Lx7pIliuZmboB0qxqXin4T+BtGjttSt21nVLZD8sS7tp9fQV5+3iPS7VEtTfSGe4G6GFWOXGfQf1rgfjUz2d5HPFYzIlzGGMir97sQa8WlD22MXO9036nvVs3WIUJUYtQ6N7J+XmdtN8V5/EHipbTR9Ejgs5jtCSvzzXp3w18NaJp2uG91LSNPMj4JZzkgn0zXzT4BEl/J5aQSWgjG4zPwWxzxXbN4j1O2bzbe/mupI0KqCchTXRiMPClJKlZN9NTlxWcVZTjD2l7eVz6R8QeJtLns4rKzW3idJAdpAXIHoRU/g2SDxJ4iCyytHBDjcoP38Y4r5Yt/F2strdrFqYlZZm/d7R9456DjrX0j4BSTw/Z2esahprQRTxb40Y4L+9eTjsuVapCpVbSj9x3RqYOso4mUveW/+fkeyanHaWujqivt3Dy413fe9f0rNju7e3jUyuFAOBnvXG6Xqx13xpJqPnLJHHbbIUVspGDycD1+X9a1dQi+WRyc7Tx78f/Xr53OK8HUjGnqkj28t5MTR57uzb/yE8X6vYNC2ZlDKpwB3GDz+YrzbWtek8x0igYxc/OPwA4/OtzxFbBGXzCVJAI3NgZ7E+39awIdMillnLh5C8OMJIMjHceuOuD7YIr1Mg4boY6m8TX1XRX/MnM85qZfJYbD79W/0OH1PVdWu5jL5zW8RBU+Q/t09cZH86x7madpFlUvuiXudwA65zWvqdu8MjIiZVX+Yng4/pWVqimFkkJPqOK+ko4ahhbxowUTx6+Kr4qzrTbM0IdpJGC2dzKoIyevHaoLxTFJ8qhgDkgHhxT5JSDJtQ/NhlXd0wTkA1DcEYxv3Ryev8B7fj2rov2OXl7jpntpI23RKQ33WyeT2z9P6VkPaS/aB5F08YkwxRhuCOD0I6Ee/UVoKTHu6sDztYc4zms43DRagksb4bBB7b/8A64qoSsJwRcuvHfjWxFtpOj2lnE6OcbIwWYnuCTyKbrnjTxrDp7xeI9QutNaX7jxkRhjjpkVn3x8vUY54mba5G1u6t2bPY5rqv+E9vodOW7v/AA9p2t6eq+VdWc65YP3ZT75z+NdMK0E0mtGL2k0/Jeen9en3Hmei67pCTX1zrV7e6hqW0mzd7hnUN2JyelczrWoTa5q32q5dd68AqvQZr17wz4O+EfxKkmg0W8v/AA14gZyVtZUJt+/H0H4V6r8KP2U9I0zw+brxRfNqN27HY1qf3YHY1ljK+HwadatJ/m/uJljIxgoRimt9LWv59b+qPlu2st9n8xDYORnqeKoyW095q0MQfy4IT8yk8da+rtX+CXhnTdaEjTShVJKRk/4fSq114E8NQWNzF9igfzAcPt+bPbmvNocTZdWaVOb+45aGIw0p8krRfqfNOrR6jPiHTbLzRnkoOeO9em/BvVb64t47K/01lSFcBmXBzWvZ+ALfS1nu0l8qSbIQxk/KKgs/D93p1ldXWnaxcNPtLLFKc7sDOAK1ea4erNwjZr5nPisVhq1R00m5LtZ/g7Gv4mtEtw+pNIvlY+5j5uKwJdYt9w2eaRjshOK2/hNqHiLxPpd7catbx2+nae+2UzxYZz6L6966CTWdLjwtjoaNHj7zR43HpnFZ4iWHo1OWe/rc8upluUVHzzm438n/AJs5Y6Dp22LxW9/YW9rKqrbxLKDIFUY5HbvUusa94butOSO81aCSINgA/McegriZvD3hY3ULypLtC7mQzEAnPpXW+GtN8PR2s11/ZdpEIIzKMLubA6ZJ+lRUnSilNNrtoepSw+FrVbc7s+l3b8v1NCbwpp2s2ebW6m+woAUCpsb3BP8AnrVfTfCekabdJc2xeJIm4DNu3H3rX8O+K7CPTbiKGZpN6Z8p13BPxFea614n8T6j4hWx0yK3jWR+5wNufelSp4urUlryxXmYzwmL9uowjGMH13f6s9f8Ajw/ceLBdatBADb5e3BUbd30rR8ZfGrw1q8lvpd9dxrNYkqIYxk9ec49sVV8M+D9Mk8Jx6Tq99DdXbKWmmiYqCSM4HOa838ReCPB3w98SLeXmoRyJdK0iQyHLRgHqO55FL2eHqz5asm7fieo8pqYTDupWle+/wDXX5Hq/wALfEmn2GsXdxHqhls79oYbW1jXLQuzEMzHsAMfSvaZozGuJTtVl2sp7EZr4l1L4lQWcb/8Iv4fnuZgS8bLFgOw5HB/CvsmHXo9c8O6b4ih3NDqFlDdZ/2pFG9T6MjblPoRXgcQYOm19Yp03FaK3y/4HU97IsZzwVDlaS2v1MbV/Kub4q2ZVVtpU9Dx1rm9Wu4kYRND9lnt3z5iL+7IHHIHQdOe3NdRqMaS6dcS7CPnEaMDjJ6kjFcX4he4W43qSXQEHHU4r7Hh6Hscsgr6dDx83lz4yTOX8RXoXU5fPgaSO45jZF5UH7y4/i6Z9cEGssXGn3BJjYTKOGXPKfUHn/PNaN7cWSTL9pikZHYKywg8H146H3x65qp4y8F3Kaf/AMJNoN/Ff28P37m24kgJ/guI+qE/3vut2x0p1oJzbNqFWLppPcz7y00+eBtj7WUgg+nsf8ayZNJ4mjV1O5vmibg1c0WSKe233aTW0nzAhFDBjjoORgH8RUS+J7CzvhYN4f8AtcrQsu+4uCpH+5gHlcZyfX0rmk5JtJXsdHs4vd2uZ15p03kiaVtiiU85wSf6Vm3FpKJVLdFJ3ZHQGu7h18X+krpz2lqscZDTZgAnBwB8wOcqcDkZHvUN1Y2r26rEhhZQShRQQw9/UUU6nN0syJ0XHqcRrWnD7Ostu7vAeWCDJT8PSneGdT+wa00jRrNDIvlXMZYFSR91weh9/UH6Vqa5ps0TGbSZVs9RxwhOYrge2f5Vwsl48eqN9ttBaXDOfPjjY7C3qq4+Ud8cit6lJVKbT2ODEUY1YSg+p7j4XvNAsNSj1W206OO524dkAzivV/BXxK0m1VFjaaF2P3W5T8a+e/CyXeqaOJIZI1AUhyVO7I/yPzpbpdb0KwF815avDIdvlzEIxPtn6V8vLLa3trupr2u/1PiYVsfh6nLzxb7a/nY+hfHM3gr4gWb2T68/hvUXIEN9Ef3Mjddrdq+f/Hln448M6pqOnPrNtdTQSeXam3cOJRjhs/Qiud0nxnpevLqdvc3T28sdpIohz9zHVgfX39q2Phnpp1q4jt4rlp5GXPmvJkt7mu+caOHoWq0lzR3dj3HjowoP2tD3vTS/e5L4V1bxk2lsuuQ2q3BbAzwCPXFbl5rWgaDo0t34iu4vtQjzBBEeWPsPSnfG3RtQ8LeH7PUBNGUuX8lpGG7ymIOOOh6GvFNqxfbbvxFaf2h5qZiujKQWPbiuzC0FXp+3UVyvsc2Fw8azVZR/r8TvPEvxI1DVfDcNt4a0lpmRfmAbALepHeuej8T+LWiX7baSedjkINoHtiq3hBYreDzbORolHOFf7td5o/iVTYIJDp9wy8GQuOa0lShTk7QTfd7l4nEVJy5oqP3f5nNeHZ9O1C+mmu7IzEnKoW2iQ9h7Cu70mLT77Tprf7PDHJdEYjiZmWNR/DzWTd+HbaQAi3W3nAyjwnn8u9bPwusddj1Ce01KC3Syt9rb2U758nt9Mc/Wj2tKrHmXTozPD4yNaP7mXL01Wv6mv4U8K6VZaSJI7B1Z2JMqgjPPqawfGGgD7RnTLLzpnGVJj+YdeteleKobabS7m7sLvdJboii2UZVB0ypH1rzzWtZ1K1vjpmh6Tc6prGMSCMfJbg9DI3Yc9Kwq4qUWla7+5fNmuIlGhJQhNvzW33dPQ4RbXWtHZ5b61u1knYqoRmD5PGQO1Ub/AEtX1yOwv9RSS/uPlihuJvMYLjP+P617BpvhS+t4Tf8Aiy4RZ5kWVlkbaqDsQT0X3rh/G8nw30LUpPEOn3ovdQjj8sQ2Z85iT/dI4z1Gc11UMTGo23v5I9F51RppUqF5O27V9fIqWng67uIYvMns4DEMfu4yWA9c9K9p/ZS11bae9+H19qy3STXK3Omic7RGzKVmgX03Da6j+8rf3q8btfFkly1r9n0q/t47hSSLtNuAOvAzjjpTPDusSjxBPP4WsYWhiuInMk7kyRybuWUjoc8jmuyjhVXjOnVXuk4LG42rUdStPZ/jbyPrXxBoNxpeneUMNbSzFjKRkowHT2BH8q5HW9LkS/e52BlwPNj454HNdl8N/ES+O/CshLbL4R+TdQsOBMoOJU/2XGcjsVIqvqmgzRzqnmbGZeGKkAMB0P8ASu6OHjRoqNP4TpqTnKo/abnmGqaNCkDyGISxzZ3MB831xWJf6SJVkWIzR+bEI1mglMchX0bHJHHQ16LrmlSG1ljdlRlUlQh4fj9K4uSwuHgGYpF2ZJy3ysOenuK8isnGTfQ66VpLzOD8Q6fe6au+3TzfLAEkeAFf3U9FY+nQ84x0PFalqdvceILN4/MjuEuFDxyjBPOMEYJz9AfpXutxE01v5M8as3GYyMbh6+hrjvFHg2ZGN/YoNzKR5ToGV07owPDKfQ8fSs6VaKlqjq5nKKuU7iwQTBwhIX54/mwy9tyMDkemQfbr8tSQzS2tv++fzYef3ypjBzyHUfd+oGPUAc1jWWry2M3k3VtcFI2yIyWaSHjBKnrIoA9fMAGP3q8Vu77e4tEvLS4WTfys0YBUjn72DjrgZ6Z4+Q/LXHNuErSR6EeWavEi1CKOe3aJgWhYBiFb54iejKe49Ox7E9K4jx3FFDH9m1vahfiw1iMfKW7LJ/d9+30rsJom2MsYS3n3MBCpC89SUJHGe6kYPcd6x9Zkgms57G8RSssZ8yCTIjlbH8GfuuPT8iw5rqoV2nZnJXo3Whk/DPX7jSrG8JjeZ1JhntVcZWVe6n3BH1GKwfFFvr3jC88/WNQMNrFL/o9pGuFjXoST61F4fd9E1ZbMEG3mO62lJ/1ij+E+69MV1q6NJqeoRudUitYJEwGlUmPJ6DjkV1OUY1NN+54GKwTm/a04+9+Ji+GNDi0q6uokkh/f2roAw+Zxjkn9a7P4PWs+g+KLe9tLQNtUq6RnC4YDJOe9V9D8B6v9quG07W/D+pwwPtmZdTUMhIHy/OBg89M8VB468P8AxCght49Ok1K20tZCb3+ywsxfA6CRM5rnxOGnVcqbd1JanB9Xrqpyzi2uu9vvPRP2pB/wlngnR9Js5DHbLMbm6kHqvAXjvyf0rkPAPhnwpd/DfxHbeLDeM1jamTTnWFlKOMAE5xlCT1rnvBt9qnhrTrnUv7SmN1Fj7DFMSW+bjcyt6enrXo+j/F/VNU0u7g8RQWbRW1oSzvGMz/7G3HGeK8/CxxuBp+xguaC63s/u6/eaYaTp+5DZp/l6+XY8Y0HSILGzuYLW9t7gXQKhpUPyJnPHvx1q1HpRC4tiqRjoANo/Kuk+JGu+E9R1CxvNJ0RtIjb5b2ONsrI3UFQOg61zeuDw/pF99lg1T7cGUStJbFmRS3OzkA5HANehTqVaqVRppvy/yOapGUt3dI37jx1oN1p8ssAvIRbtiaX7OP3WT6H6VV0X4paF4YvI5JdX1TUI23M1rdoBvz0w689hXnfxO8DeKtD8RLpXiHQ9W03T2YD7VLbNErM2MK7DKsAeATjkmorrTbPTbW001NRdpAzmFJFEj79vy7cD5s9OCa9F4SEo8sndfL/I76eXwg4vmene2/oe3eFfjBDrGk3+mpcwWr30mBGM7o4gdww2MkjFVZfEXibVINWit7NdDsTMv2MWEjGe5A6mSQdC2OfTNcx8JfCGkeGbxtQ+JOm6pZ3GpQM2hHUA1qs0gA3EIw+cAMM5wBmuguNYsbO4uFgurBfLbY0UbABSRn6E9+PWuCeGoRbSTdtuy9DjzCM8Jy1FSUlK/wDTS27o4XXrtJtTmOp6Tqcl2YgJF1C4klLY6KNxOF9ulV18WzWHkW8ejWltngRn5QMehxXZ6hd2+oeJreS/eSxtBCsUOoKw23EwblcZ+ZRkZP5V2UPheKxuYrLWbG2mkj5e7tQsoVCN24sM7Tj+Hr7VtCpD4Zxd/VmUcPOcISVG7l01Vr9+3keX2vjq8+1GDULBFgkB8428nmSBfUA4qjHrdtpt3LdWGmXiOkuU+z/Kpzzkn+gr1S+g0uG8CS6RbvDKWFvI6CNiASPmyMg8dD7Vl65oaXOLWR9R0iFl4YBfJbPT1B/A1tzU46JtN+Z2KNPDO1Sm15rX9TS+GvxS8YJrh1U3mn6Hb6asbtBPCD/aYI/1QRcEkgcnjHDZyOPpT4TfEnw18Q9Kk1HSLpg6N5dza3cLLJayY4GGA3o3JSQcMAeh4HxLa+DdDtPF9n4smu7jVLayulknCSb8kH7hyflU479q7+6+Jo1bxpBquleNbrRDYylYYn0rzo5YSMiHy42yOQOvHAPFaQqTo1ORK8H+H53PXjGniaCmnaXrfm+/Y+kfFljeJeyTWMEe0A+bsl/1TDuARkD2rBuoJpLVYrgC3bqXIDAH+tSaH4mn1jSYbiS78m5kiBL+WFLr0DbG/IZ54x2rQh1HTr+2NrdskV7FJzvXCsPfsOv40VqXN8LMoT5dJIxLzTmh08ZAfzDhTs5T6DqawtSt7sR7oGhkVOjMcHcOo/KvSb6zgttNwGW4t9uVOM4+jCuA1S8sxdMhVoFDYBU5DfWvJrpR0vqdlJt+hz9zpNnq9rNaXCxKsi9Tg5NeVeMNMvPDusNdWTyq6g/6TCfn9/MHSQe5+b3r2i4VDGZCVMOcAYOTXG/EDTlVWnUmQMP4XPA9DWUak+xvG0djjNH8TQ6hCsF7aQMwbGYmwG75UdR344I7betSaklvfadJHchisinbNIpyAOz4+8M4Iccjqf71YN54cmfVA9rLbwtIeN8yoCRz3IFac9xFpultdaxrWi7EXIjN/G0knuioTk8cnj8+a6Y0o3XKrF+2clq9DzzXDdxeIItGkgkmnkkDWcifeZgOc44Py5ye4GeDXV6PdsjtaXij90SpBPBPp+NHibTF1K1t9X0C4jme3dbiBV+8hB3Aoe4PdemCce9A6xo1zrEU94/9lvelhukI8ssCAyE9DgkZB5wQe9dU1zRTtqcvtPZz8mbOtaNc6hpLWmn3Ez2MsgkmtUkI3t2LD+L0z14rlk1i90d20vw9e6no3kvk+XK0bscZwCD0zXoT+G9S0+3W+06SG7jODtjk3YHqPT8fzouodK8SbHuhFb6pbtuSaWEOrsP4ZVP3h+tTSxCulU27/wCZp7NSTlS/r0MTSfHPxE1bT2n1hNIvtPZRa+frEaTnpj5XX51bnPGTSXL2OoXcaPJZ2ETIHd4i+W28DhsnaT3PPtXOeLbO80HxVbaj4htppoYZ/NYIf9GlTpkKmMD/AHfxrtfAY8Oazo5vLTQbqSEqTK7zKqdThVUncOBmu1UHON47eRzfu6k2qq1Oba+0+73TvZSXKqCIx9qwwPY4Uf1qKLUrpV2weFLeQd3dXYk+5zXU+M9N0/w/4YfxF4cmFtdR3CqLGVBJ5iHqQe59sVztpr+r6nEbm11e6to92PKYlcNgZOO3NQsO4bK69TmVOdNtafcv1PWP2YPB/wARIdD1DXNQ+K0unaFp6nbptvcNeM7Kh5EU/wAgAbGB174wKy/Cfxz8ZwzW+l694Y0vxlrFxOv9mXJsYbZYguDKIjHHlpAvUnHOPxvfDzwR4r8HWc2n6lpc1prGtP8AZVinaKTy0MbMzoy7lzkqACT91jivLdc+GviDQ7+SLWfEBeXTpWfNvI+EViMnd2b3AH6V59Ct9YqVVJWirJeb67fd8jeOK5HzRUtOrWifU92+O3xW8Q63DoNz4N8J6Zf2vkXEmtQeINAS+fTWBXavzZCtgPnbxjBPavBfEfxF1G6njtIPDuhQ2rWrxQnTtNW2AbORKyryxBJGeuCB2rYsY7dLq0uBf/Z5CQGnQtJL838TAsSACR19aj8aeAtT0+zlkg1uymsGuY2mVI2DrDnqsmME9TjAA9eMnpwvsqdH2beidterepHtPrLnVcbaa27W6dTiHlW6upLNPNuIPNw0xhSL5go3gRgnGGLd+RjgZrq/CPi7W/CH2aHRLtpPslybpoZUGztyO+SAAVPHArR+D/gPSI/FKa1Ho7axbXV6YYrzz2aJn/jiUoxQlQN7A844NXvi5p8HiLxBbW/g+w0vRtPsX8q5u7mCeOR23EFj8h+QDoBuLE8ECvRji8HKk4NX9RYaNad6tJ6beZr+OPitoWt+GLF79rdtSu/N+1vMwiZHAGwj+8Of5isPT79r/S2s4p5WhuIS8sKMSkiY5yBwQB3rhby1uY7ORc295Es5gDIqyxu6nIOD8ykcHnGMit618bQ+HrXQzo1ppGpW0Max6tayWHlJFcgMuPlcmQbcEvkZbFYVsKlC9LWx1fWoO/t0ZFxc6PoWuXaaNqN3p8ckW2axnKzpcMR8rQso3Bef4hwQRmnaTF5dutw0lmdvzK0L7GbnkL0zx1HtxWrdeIdQuby2n8K6ToNlcgSsIYNNG0RFOry/fIX0zj29WWMF5dW8MVzb2t1dTPlVFrljJjO1MEYAPIzwO/SueVSa0a/E4JfV5PmjOzfSz/S/5Fy1+36ZeRaxpOo21ncX5MUMrgfNhd2CzN90A5yeMnHWtmw+J3xA8qB7ltOmubD5Zbpov3NxCp5MyhgVBwQrKc5OCCMY5e5sfEk0LLqOh+WI2kiNtNE6mNhyZODhlwfXsfWprhrafTW0k6KttbyY3mCaRDJgDJZueOCenoPeuqjVpRio1It+lv8AMmTs7e0SfmpL/wBtPefhX8XdO8Q+HxcQXsWnTNKsctnLN5kW8naAr9VLEfKMZx1NbWrXFnqJYh44pVfDyRsJY0b/AGiucV8z+H/C+neGLX/hMU0+/wBN1CQSR6XDeXSzNBFjDXWAo2MVJVDk4BLcEqaxvDdxqMPiu7hi8Q2tukame1ZpdvmycYiTjlyC3XjjrWMqMK0mktPPodSkoRXva+XXz2R9T3FoI4G8xCr7Cyk8Dpycnt/nNcXqWspJpsqXbHgkCeJgWH1HGR+tedeNvjV8U49ChhuNUkEZbELrborIFGADjnnGSrdzk+lZHwH8a6v4l+NWk6bq00bRXyyqVeNVUuELbwigfMMcCsp4RuD5NLG1GvDnUZu9+xd1jUbBry8tNYtLi6tVG3zYxvdO25ARwa1PDfgubU7P+1NC8Kva6f8AZ90Y1gou/qCFGd2CMHJA5z9Tg+Jr3WG+IFy50fT2S2u5Io7m4uHRp9shCu7A9cYGAMcfjWX4+8f+NbKOfQ2axW3mjPmpZNv3J/dD8k8V1W0iqauKKo8zVe9lt/w52fhvQmgsJdW1GQado9ncLbu8UvmSXMzZURW4QMSysRxwCSOaszeG00lrnVNa0CHxH4XupPL1HyG3G1kxtWWZF+46hx8w7cZ4FcX8O/it4m8P6T/Y9/e29tDb2slzpttbWqs4uN3CyYHy7gTyRwcGpvA/xLmv9J1ePXbr915dpm1trryfPdZGRpZN3DOEPpyoA7UO8E3a8gp0qDt72nZ9LF3xlZ6Lo93AnhPUryYjaYbiMqI5I8AZBYhmxjHI5q1p3iJ7y8it721M0CkrFqCwrDNnsHOdrDI68dx6Vzln4r0HxDqx0zR9F+23Dv5dijK6s7dTtAP3e5Jxx6VstoGs+FraYa5a20c19K0ltaW1ys/lIy52Er1Iw30GATms6snOPvRt8jphRhGblFppdmzsmlM9iNO1mzSe2uI96bzztORv4yVPB5Hp3rm9a0V9FVrvSWa4stuWTADxj0YA9MjqP0o8Ite6tqkF1Jdx2sEMeyGPzt5ZQcFymeTwQT2247Gu91u1ttL097w3UVuwAMrSFRBMD3YZ4z+dclOu8PNKPX7jxcbnGE+sOk4veyf+Z5vPB4m1yO1s9MtCDMRsljnO3aAzEEkYB4PGe1XtP+H1hJE0jeLNPkLOTmAuEX1ALY3YPfGM1ZuxqeiXklz4euLi3kfElxZI5USL94FfXsfWotN8XaRdxtNqC2S3DMS/2iJRJ16HjnHrXZXxlaylH8DDEYqNNJqDlfsd54israz0WPwA3hPxbqTaZAIUvILe5tUvF2KxdJRt8yORmkbcpIwO4riPiFZ2+l/2HL4E8MTxrKHS9EMZkaP5Uk3eax3McSL7Aqce/qHhG+TT0heHQtU0+7S8mubS4k8STQXjkSBdzKCbfkyAECL7pGeKl8Y+KfD1z4rt38Ryatot7bwMEsr3U1EcnmFtzCSO3QbGy2WbI4GOmK86hGNKMFG7te/nf/g6nuQoVowhCMkkuunT5nnvg/4j6/cXgs/GuieE4LedTa7PEFn9oUuoJQKSGkAIByQwAx68VzurfEDwPqF1BZan8KNPljbCyPofiKezgILYY4kWRD97oAM96sy3mm6d4ok07w5qNzrVrC7y3up3Yubgx/LuWCO8kjUun3UUBUPA5PU1fGmmeJV8uOPVPDGichYdN1DUmgmuYmRXEgQRFFT5gANwOQ2AcE16iope90OZ1Oa3LG8l1sv8j1v4OeLPAt78CYZrPSNetfDWkTyW6w311aXAhk2BGL4EAkXZIcp/FuPGea5L9or4keBp7iODwb4fl8yW2jcz3KC0dTjO14o33BQAuMnr9K47QYPE2mxSTxv4WSSG2ZTJDeeejsSyL1QrHkFvrhecmurvvD/h34lXF1r/AImtl0nVLmGD/iY6dbJawXUW4os0cG3hMDHKt7FjWMacYyftNj0PaSnTSpp81tf+AeUXEF4dWj18Wlxd2DLtt7tLN4LdsqFeMKeMg5Ulvvbcgmr664reGbjQb2zs7ix+0iZgI1ilZ9uzO4AMw2jbznA6Y613Pjzwv4i+Hfi618MeEvG2raXb3Fsk99pniy2D6aJGbACXESNCylB5gdcLtOPlIIqHxF4cg1bwnNdS/wDCE2GqOFaK+0vUJvImy2G3RFdxJ6Dhe55ArZ1Ka0uZRpVWuaOve6/pfeYXh+7h1Rb6GygWGQ754bKIssaRd41bBKqMjGcnt3qDQ/EGu3WoXFvJpq20McywySGT5S2eNu4ZHTt6++Krt4XsfB/iqZD8QIZryM7XWGFuFznGwsMg4yD6fWnalqFmt212ZxP5jGR1UkEsV65wQB2x1rnlyOVkr/ecuJw/LTVVQV/kaa65LcTW0E3mXMm+UBDd7duDnLKFHUnqe34VqaLp9prmrXc/iKwl0/S9GiEt9JHfM25jjy4M7RlpBkkDoASeozm+D7DXNWmaxsbmwS5edEmvU2Dliu93TfuO1chQB85UrkZBpfjh4t0ew0ldB8FfNZ6Y8by3RgIed3zmSRclSzsvOF4yB6Y1jQcUn1ZzU4zrLnrL3V5LXyJ/EWo2Wr60t/qNjqVzazIIJYLTUI4YY0ByqbDE2QOB1x8vbgVkySeCLLdJPZ6opQmRYbe5gTavRQziMkDpzt59q5ptR8by6CGuvDNzp1lJGGnupreUSTqTwApxlcjIyvGM56VNrl1aTw2d9c6KyXULbLRApV5ZeMbx02gckHjpnrSjT5dyK8v3mtpX62t/VjQ1Wa0g1JbWKxmDSQtNColEpgJJwGYoN/Q5wAenpz2Hwu1HQdP+J2haNaztLdvdQsjLY/Z3cNneCpycg5HXPTpXJ6Sl1e6fDcvsD7z/AK6UMVGehA+6p5yeAOTmuz+HngrWv7Y0TxrF4Furm1fUreRNcSEqtsiTbZSF3DkEEMcHH61UnBp6amVGdOWIjaNtSv4tu7QaxPpUjadp6Q6pdM9zdkJEoDEAO2Gyxw5wPvHAAzXPQ/EPwro2sR3mp2N3ckShhpcebN7yJQwTMgU7FJCk9wCeM1Z+IdrPf3GopJeXEcV7dySzpBCVE6LK3lMxZcEA7sN6nryaxYdK8I29jHLr0t/crM8iWmlaPPEJG2dfMnYcZx0QccfMTxUUfZWTd7r8f6/plckZVGr+8nu9EvIofEbx5D4v1L+0IvC1ppc+xUxbT4DhQAQxCgHpxx+dc9JqN3czeaNF0KGTADNFFtZwB/Fjqa9Gs9K8LC3mkf4ZFFjiBgXUPEdxMZ5CQFTEZHXJyxAAwevWtNbPwokjzW3w28CW88CJ5zXEcsvlDB+baXIYggA9TkjtkjWWKhGOkHb1X+Z1SVG/NOsvkpf/ACJ554T8WaroFvcLpP8AZunyzgLd3UMAWSQdADL1VRnpjmtmLwH4v8RXUd02t3T7oWkR5EbYwP8ACGHXccjp74rs4PEVxEIbCxuvDtmbe48/ZpmkWsKR4GCTkcnA45OTjiresePvEtto7XFjrd3qr3DOha8vBDGrAfMwMe1egwqZJJ7VhLEOUlaCv5/8N+pFXEU1Dkp1JfKOn/pSMXwr4U1nRdbV4dB1rUZrV40L/ZJY4JAc5CEDlecnrjHvXV694VurjULaK90oKED+ZeyX1uv2Z84V/Lc/MDngdfauUtfEj3ektcancXkl3O7BIo8vGFLEqB5jAKVX5ScNuPOahh1C8uNWSFf7Q0yCABSbp7V4fOkA2hkUrJ26/OAT0IrWVSs+y/r5HMlRkkrSv5SS/wDbX+ZqX17pllotva32rTWmqLKS6MjTAnAAO6MsijABwrY+mMVg6xF4QjulbUtT0triZBIxe5+bnnnaePoeaLixi1q3S31O+KxNKBNMl03k5V/mf5cRgEgg9BhiK7HwvaMNGW4eSz1lbiV3S6uobaQ4zjYrGPOFxjBJxzSjZ7u3oiKVKpG9r2v11/yNPxH4i8Yw/De/1fwb44uNcvodet4nvZruK3kRZwV/fo3yQ7XSMbwxRg+Q3BA4P4vTfFUR295488P6xp+n2zKj61qcaur5OFCSKMKmUbDZAbB5raXSPC+g3X9g6xqttEupWyy/YbmaSX7QPNV4pXYZcfPHxxtbBrrPF2t67c2+tX8fihdNF3c/apdjrFHfOqoyRwBw7FgST1+XLAAda4KVTkWkU1320foe9Ro1pRlztr8TivC/jD4gJ8O9RuPBHibQdUs9K2vJpFlN9jm08FgFk2KwWdchtxjLEDBHXI6bw/deH774eNruuRprlxZ3yadPNFFJcxKrGOTEHm5dVVSeBjcPMxzg07SdQ0zWoWfxH4F8JXniK1UNNaRRtps0aOztCUubfywGIOSZFbkHODyen8My6OfhnFr2lSx+HdLh1U280V3fRzyK7EysrsAhRCInjLEFgVA+YcjlzKpOnQdShHWLV7WWnW/fT59ip4qrTpcy95NeqW2qv9zXmW7f4F+CfEV5Ipj1uK1eTAurMRxxzozbVlTdHvUYJI3dQM4rkviFovw9+F/iWz03UdQ8SWsCTF9MlaGG5liKNn5SzqSCzAhQMd+ua7H+19a0XXdY8SaffXtxazW1u2RdfaLeCDyvMDGFQGgG5nTL4B2jDEMK4i61zQ/EeoW/jjxRDNq+oaY6pDZW5JgiZznKxNhmbaDliMcYAya48txOYVZx57uNr+t108k+uh1UcRg6uFdRwfPotU7X73WjXbqMsvFtong8/D/S/ih4i1HUpppJbFNU8EedcpDKXM8JUXDpLG+5WVvl8sglGUMQavgvSNPs4f8AhX1/8R9Yu5LK4W7Jm8EtJe+Hy8gYCBhKwhWXcQyysYgP4QTuHpdnpdrr3wwsvGOnXM8X9pWn9oR6bcWu1k80hljRRkMDGFIwMYIA5zm7+z9oz/C+71LU1SPVta8RIq6raIjLHO8eCSE3t+8dNwyTt5JI617MqkKMvfnZPyv+hX1dVIaR5n6tf8A828Z+EbfU5be48T+ObLzNPtTbJdT+HLtGKKTtJ8oyKAe+4krj5eCRXO6d4Gs9c1Q6Lo/xI0nUZwGcW0OkaluEa4BfP2cjCkjr69q7T4mfGHQ9Q8VXNnY6NdWSwaYEu55TFPJNvkcgsgOESMAAv1APyqO/jvjDUtP1W8tkg/tLSJHthtM92sCEdAGyNp4OQCy5HXrW/tZ8zV7rvYx+r0klbS/S57l8Kfhlfm6W007XvCV/ZJl5biz1MXV2fl4YQyiI8NnAXoR3JxXJ/Fjw54j8CXCm08KTxT3E8sYurrQpPMhUZzLlWkhIYZIOcjqQK8vTwzr2sX1vbWksUemMipaXxg823lJZkjIaMlljZwu9s/KGJAIXA6vx58RtU8MQnxD4Ya80e8is4bT+z4ryW3t9JuUdIpRJChPnSDytuGYY84udxK1jOVRyjyvmb6baeupjOcFzQjpy67floZeg+JrrxdZrctqsN8I2+03omxMEZWCkHBLYG8dOm4kdDjtvF3hbw/pmj6jq2i2d/p+oaFaxzE2Ya9W6gl8pZQY5WJKqGMhJOAAR6YxpPiprc99oOt+IvAPhDxVcatCt9FJe2C2upWrEkBPtEZjkYksdrMWyOSM4z2d94x+GcvhLV4tQuPE/g241Wzh069trpoL2O1kyokWJS0czLiNVJJG3GcA4FClLRqNovfr/AJk0VRrUZOT5pdOlvy/A8stRpsmkahbveXCswlVJ47ZVaZVwULk/d3Et0ORge+ex+DPi/wAR6Lav4Hmmjk0/XrmJvs14wZrUsU3SRDcvzMuCdw2kL69VsfCWh6nYJb+DvijoeoaisG2eS3s7mNmcsxUmxmQg/KUUmORiMFsHNc38NfB0i/EhtUudYtmm0eSdpbqzDuJZYwwa4dzykYOAu4ZJQ9ARnojHnlbp/kc0MHCn+8jJp9v+CWfHcWvWXxYnu9EuF0+GSwicypI3mRYbCyOeBsZmCFRx8vYVia9YTX+qKHgjWZZREryOZGEpbBaGNTnJYjr19a6jxLFZ+O9W8zRr4q1vbrClvJMIZJlBLF0LDB5YkKe2Kg1DQ9es7W7vbLSQ1np433sk8hhjZQrZXzVyyucEgYyc8A94c3pyf16nPjaNSck1d/j+RlxaDcXVw8qXMl4q5KOco7FCyhSpPyAYH1OemMFbMwPqa3VxpWrzzb2zI7bg0bMOZSpUMxGflUn096j8MnV31q30tZW2lFaSLT5ftDICpdBGV5Y7yFxxgk5xXTaxoOr6peNC3g7UnRGVWey2+bFMxOUucMygrjOXAYjgnIzRKUlO0jh+rzfexzen6fDI0htrBGtMv/oxt2SZiOAq7uikjuCQORnNZF5uuPs8c0m+OzixFasVSG3PzBljVjy3Xk/MSTnNeqWvw1/4lSzajE0H25R5S7lIGGG7zFQnoOOoK9R70PEnwb8PHT5tbm8cXrXPnQrLoq2awrcEBQJVlcOqZx353fNk5IpU6l5a7HVTwNe13on95x9hDaR+Hba/MevRaoGaKGMW6PG78ZKyZHy4z91XOT61iaw/2y1VhqMl35as1xczRlWViSyqqHlwMqM8ZyemK6uT4V3Nxr0I0/xVdMsjbrd5YUixxuBYptG7gEDHp65GX8SvC+ueGb2ytbvxB+8ktGkaV51HzI7BiFUsQchTtbDc5xjBOylHm0ev9eRtUw9TlVoJef8ATI9H07WLvSZpba1N9pb5AhkO2G4IBGdu4BiuSf8AZyBzS33gqeSfEehyyiNQpdXVQT9M+9ex/CXw3oWmeA9P0Nr5beWGz33zSAkvIw3SNyScs5bpwc9K53xZdaLp+uS2vhtrvULVVXzLl7kfvJNozgADpwPwrnrYj2dtTto5R7ZJt7fI2NL8BWMWmyTm7lvrBpjEk+r6SZAUAbYZZrSQMDlcBlTP0xVfxN4R13QY7HW9Pm0XVvCVup81rDxNLuhYrgMjXiggjpsIbJPOScDPbwd4dv4bf+2PFt3PHHu823ijZryWR2JLP0jC/KOgAChsYzzBd/DO/sfDSrDbabHBNcZhjvf3mwNyTEV3oJMZGSAfcHmkp3evp1RXLVUbpfl/w5qW+uXsulxapoEF/cWU8WI5tf06CNZmOCQoCqX4wMx4BOTk1Pa2/hy600Q618KtA1LcskzxaZPLpscjhfupEsm3cFB3SYJwx565paZH458GwPYN4g1SCG4tCxtBdLMbkAn9yIWIjyAQgYnA6j0qlJ4C8XIkl/4h8X2lveBpLiy0eEm4s52eMrIZWO0A7TtKqCBhjn7tKvFQm48yTFGjOrT5oxsd342n0hL6GSy8P3+h6taqSHtddyqWpiZHRTFGsgjA2cMWTr8uK5K60qw8faV5mpXfiCDVNLlKpevqcsiJI4ChlR2dBIudu5QuByQetc3rUq6JqunadoWn3Gual9gii1hnv5EW31AIHkkaRAhKmMgDDhVLDBAG2p/DPxKk07xtfWesQreafZ2kqwNAArXF1ztRpAfmXJYbgD/CeStYYOi40uWkrLsv8isJyU4qTdkr6bW/E9eW9Twz8NbHwxHDctFp9gtpdSW6h1eGKNstEoBYFgsYOBuOD0Brzbxn8bLOHw7YQ6b4evrM7UD3t26wrcW5+6qCQZzuxyBgbe+SBpaN8X9N17UpNPOjrpseobrbzDqBlVXKnYjHyxtDt8pbnGSTwM1prNqdtp9vFP4N0ucxv5TrLDDLBE4QuoDqWyNoY7V64GT3EV6LjK9ZP7+h69Ct7SF6TX/BPDpNWtNfvrIPZWNjILjbFKZizkn5V+cgKOSOg4wPWuttdFtltTYXv+rt70/2lMwSREdeRGHYlVO3ac9QTjcMYrd0Lw5ZWc15A+kWcT3UouHUSeXCHaMOigLxjlfmGAOepFGvy6r4ft9E0l9J0NdT1a5F7MljqSS2trGDtCyqE3Bjjjjkg59a2jO8UoK1u7PKxlKak5t69WtEc5q+tapF4Zj0jxG8LWkVuwjTT43Xyownyh2AYIOD04JJJNX/ABc1p4g8K2evaZZ3k1xaqNOvtFELOxmSJVju2dzgySxAozfKcwDIOc10lnptxqmvW+nWUyiSBvNvr1UhV51DH93CpYYcgYVivAywwQAeem0vV7e11DQL/Trzw9DPpM1y7tp8sixGAGczjJ+ZysDqcNnDn6FJqo1Ubs1+XU5J4hqC1u1+RhaLaWt7eJqd/wCHpIb7TQJIJmcxC3lX51dkYNu74xkVrWI164vr3UdNvbu7t7iDzJJrgoxWc4zgDJIGT6dhzziHQbTU38YSeG7rWruPUNLgSZJTZvJBJFgOsgkI2tEVZT2JBI4INdjqDaw+uhW8GW+lW8tx5NvFZooEkW7BleQthhydojz0Peun94naD07ip0uaHOp6/mchLH4zOqW8XhprILbwiMpHfSCW7Lc+Y4A4yTkqCSAByelct/Zviu08J3mlJDctZb1VWtljK6r+8Ls7gncxBIBDEA4yRxXqiwNNeTAF7NomCJJb3SpLGWXGBt+YEgDnPOcgCtuPTrS1037UbjTnRFMZIdkmRht4OOOd2FJPJJ6HbWXtppe9ubqjUcNWeLWPh6/nS6tP+EfWy3zxteXTXAmaVchZHijyQGxuIGAv5V7D4it/htH4fn8LeCZPFWn6dqaxJdlNk0l7CrgJE5bLKNzRnnkBeoA4rmOy09pbi7h1OR9LZXtbS0RnycFg0igjzVUEEqTzlfQ4wfCOvaBrWkxx6lDq+lzTRyebp8Vk2YGU/PsjCqzB3kKjJPTk1pySnBN21FRpyjJ2nb0KfxQ+H0OleVpemWN1ofyyxtJc3UTyzPjodkm4L6BjyeK7KG7t/B8K+Gpp/wCxdMs4FMupfapLl5BkhiGyjmR03EoQMYABOK5uxmuE8N32sah4etYrSWFLixXUrpttwpUYQui8SAj0bhlwRzVnxlqWiN8IltNV0aG/v9bupLW1jhJZp52YlpGLPu4wp8zdhcKOehqMpte+9f69ToVL2adnp/XyL+g/E2PX/Hj6d4T0HSNYKLPcltRXb5tsqlTcTbGxGqBN7c5GBljnmtqPipNb8J2/hzQLmxhuLH7R/aWpSXAnW5gz8qwAgBXIz2wRtPB4rG0m6m8JaFfaDoHlR6l4gkeGRQqSRTRH955JfBdoVWIM4z1yD1rKbUbfXNPuYoooYfL1AtPcQWrQxTiQLwrtliq88dcEZpqEZap3uL2rte+hueH9RvpdPVZpILeZYBIpnY446Ngncy5z0Han+EdOi1hpbrxZqFjrZsi6u8C7y0ucomN23aOeDzgjFXPh74D0TWNQ1Mya1qWmrZ2kk1lLbW4uFu33cbmkOEHpkbRn1xVfwUbDQvBNsbOGy8tLhwLaCYedK4bGCcfMxIOX6ciuiKpqXoZclWaV3oaSeIrHUrq6sLeG4nmZRDOU/diJXzysgGGHGCD3NeaXWm3Ed9cR22oTeUkzKvlEFcZ9e9dtYeOb6ZDAdHWS6MkoIXHlxNtJUSEdduByPXNeY3WuaxfXEk63ViFMjYEc4jXrzgH3PWuWvFSnojtjUUafxanostrL4W0S51C1Ms8lq4xIdoPVQSfUkn9aZ4i8Sa5bfDmHxJrUki2+q6nIIYTsBKqY93lJGNqKOBljuO48YGaKKxpSc+VSd02b4iKpX5NNDs/CNp/wsXS7bVV0WzhtX1m4trK5A/0+8ZGJaInISJfMcJ3ztLZFFv8Aa5tJmv8AwxMsd3aTfZzBej7VGpLFWjXzc4yQCWBH3RzjIJRWlWnGT18wptqm2ux53b+HTqviW+1+602zjk1Nla90uK5ljtWCOgSQhT97KkjAOCTnNbGpfDfwZafEa3utOmv9XszCJrxWH2ezjudxLR28ZYyBVULy5OWBK4BxRRVYeUo2SZ5/s4ypty11/Ux9DsfCmr+PtDvH8DX1zY2NtM+qPcX6wq8x4jmCxyEu3ylgpGBvIPAzXrWpeI/h/o3hRb6LSPEa2oQC4t11CNBGNxQYKpuA5PAYnpn1oorDGc1avG7t6HTg+WjRdlf1v+jRxcPxc+GmnqYNJ+H+pXD2dv5J+0avIBGgJRFj+bHCHvjGawPB3xP8J3jXt7P4DkPmXA3ytqk0sik8biWYEZB6AnFFFbRwkZQs5St6s5q2NktVBfdf8z0HwrrVtqcbJpPg/TJPJYsscssqCMbgDvPmHcW9gcZre1e9i8GaOuqv4H0e2t5I5YIWW9uHaSR0ZHXZ5m1FKu2T2B46UUVxfVacnZ3+9/5nVTrNwV4rXyRjal4iu7l7fXG8F6cBLGqeS8pMZLr94/vDwAcAYyM/jTLLxheXlnOYvB+hwJDE4n8+MyDAPQZZuD9PrRRU1qEYWUW0vV9PmebicwrUZKMFH/wFf5FPxP4x8Qatomn2lr4Y0TT4Uc3KyW8UcatncqswVQxOVbuevT0yPCOtg332jUtE03X7JVaW5t72zja2jmUERzGIn5ipPAwecZoorqpUoxp6fm/1KjiqlWqr2XorCy6hb3V1d+HmY2k2o2itOIYgkHlyJlf3YyAApjwOgyeK6Hwb8PHma1nW7uPJeBQ0ksolbk/MG3ckEnO3px3oorOcmoHbQipSfkbPx++DWsaz4fW7tJWt9BsbeISW8MqplYUIyMknPPcHIHrg15H4k8O+GtK0WKTQvCT6vrezyrdrgRJBCmwDJBkG75iTyOwoorPC1pyvc1qU4yV/OxH4ZnXw7cQLfwXT3a25MrQzKJrYhQJEjbhcMGGc5+7xiuw1HwtcavfwJatHpFjZuubSKFDBcBl5kG0gqQMLgjsfXNFFehTqS9mpExw8HJ0+hj+dqSLfWOkLNcC8Xyot1yIV24IbIAzgkDj2rl/Ffi2XwvrVstrYxveWMH2WV7tAV8w8kDYc4Gcg/nRRWdGtOa1FiqMaekTz/wAaala3EUU9lrFxfapeQtPqcywGBRKW+4P7w298CuUW8JGRa+d6uzYJP50UV0RVonFJv2trn//Z"; + string invoiceSettingsInformationMerchantDisplayName = "Custom Merchant Display Name"; + string invoiceSettingsInformationCustomEmailMessage = "Custom merchant email message"; + bool invoiceSettingsInformationEnableReminders = true; + string invoiceSettingsInformationHeaderStyleFontColor = "#000001"; + string invoiceSettingsInformationHeaderStyleBackgroundColor = "#FFFFFF"; + InvoicingV2InvoiceSettingsGet200ResponseInvoiceSettingsInformationHeaderStyle invoiceSettingsInformationHeaderStyle = new InvoicingV2InvoiceSettingsGet200ResponseInvoiceSettingsInformationHeaderStyle( + FontColor: invoiceSettingsInformationHeaderStyleFontColor, + BackgroundColor: invoiceSettingsInformationHeaderStyleBackgroundColor + ); + + string invoiceSettingsInformationDeliveryLanguage = "en-US"; + string invoiceSettingsInformationDefaultCurrencyCode = "USD"; + string invoiceSettingsInformationPayerAuthenticationInInvoicing = "enable"; + Invoicingv2invoiceSettingsInvoiceSettingsInformation invoiceSettingsInformation = new Invoicingv2invoiceSettingsInvoiceSettingsInformation( + MerchantLogo: invoiceSettingsInformationMerchantLogo, + MerchantDisplayName: invoiceSettingsInformationMerchantDisplayName, + CustomEmailMessage: invoiceSettingsInformationCustomEmailMessage, + EnableReminders: invoiceSettingsInformationEnableReminders, + HeaderStyle: invoiceSettingsInformationHeaderStyle, + DeliveryLanguage: invoiceSettingsInformationDeliveryLanguage, + DefaultCurrencyCode: invoiceSettingsInformationDefaultCurrencyCode, + PayerAuthenticationInInvoicing: invoiceSettingsInformationPayerAuthenticationInInvoicing + ); + + var requestObj = new InvoiceSettingsRequest( + InvoiceSettingsInformation: invoiceSettingsInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InvoiceSettingsApi(clientConfig); + InvoicingV2InvoiceSettingsGet200Response result = apiInstance.UpdateInvoiceSettings(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Invoicing/Invoices/CancelInvoice.cs b/Source/Samples/Invoicing/Invoices/CancelInvoice.cs new file mode 100644 index 0000000..5fe9416 --- /dev/null +++ b/Source/Samples/Invoicing/Invoices/CancelInvoice.cs @@ -0,0 +1,33 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Samples.Invoicing +{ + public class CancelInvoice + { + public static InvoicingV2InvoicesPost201Response Run() + { + try + { + var invoiceId = CreateDraftInvoice.Run().Id; + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InvoicesApi(clientConfig); + InvoicingV2InvoicesPost201Response result = apiInstance.PerformCancelAction(invoiceId); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/Invoicing/Invoices/CreateAndSendInvoiceImmediately.cs b/Source/Samples/Invoicing/Invoices/CreateAndSendInvoiceImmediately.cs new file mode 100644 index 0000000..acbd140 --- /dev/null +++ b/Source/Samples/Invoicing/Invoices/CreateAndSendInvoiceImmediately.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Invoicing +{ + public class CreateAndSendInvoiceImmediately + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InvoicingV2InvoicesPost201Response Run() + { + string customerInformationName = "Tanya Lee"; + string customerInformationEmail = "tanya.lee@my-email.world"; + Invoicingv2invoicesCustomerInformation customerInformation = new Invoicingv2invoicesCustomerInformation( + Name: customerInformationName, + Email: customerInformationEmail + ); + + string invoiceInformationDescription = "This is a test invoice"; + DateTime invoiceInformationDueDate = DateTime.Parse("2019-07-11"); + bool invoiceInformationSendImmediately = true; + bool invoiceInformationAllowPartialPayments = true; + string invoiceInformationDeliveryMode = "email"; + Invoicingv2invoicesInvoiceInformation invoiceInformation = new Invoicingv2invoicesInvoiceInformation( + Description: invoiceInformationDescription, + DueDate: invoiceInformationDueDate, + SendImmediately: invoiceInformationSendImmediately, + AllowPartialPayments: invoiceInformationAllowPartialPayments, + DeliveryMode: invoiceInformationDeliveryMode + ); + + string orderInformationAmountDetailsTotalAmount = "2623.64"; + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsDiscountAmount = "126.08"; + decimal orderInformationAmountDetailsDiscountPercent = 5.00M; + decimal orderInformationAmountDetailsSubAmount = 2749.72M; + decimal orderInformationAmountDetailsMinimumPartialAmount = 20.00M; + string orderInformationAmountDetailsTaxDetailsType = "State Tax"; + string orderInformationAmountDetailsTaxDetailsAmount = "208.04"; + string orderInformationAmountDetailsTaxDetailsRate = "8.25"; + Invoicingv2invoicesOrderInformationAmountDetailsTaxDetails orderInformationAmountDetailsTaxDetails = new Invoicingv2invoicesOrderInformationAmountDetailsTaxDetails( + Type: orderInformationAmountDetailsTaxDetailsType, + Amount: orderInformationAmountDetailsTaxDetailsAmount, + Rate: orderInformationAmountDetailsTaxDetailsRate + ); + + string orderInformationAmountDetailsFreightAmount = "20.00"; + bool orderInformationAmountDetailsFreightTaxable = true; + Invoicingv2invoicesOrderInformationAmountDetailsFreight orderInformationAmountDetailsFreight = new Invoicingv2invoicesOrderInformationAmountDetailsFreight( + Amount: orderInformationAmountDetailsFreightAmount, + Taxable: orderInformationAmountDetailsFreightTaxable + ); + + Invoicingv2invoicesOrderInformationAmountDetails orderInformationAmountDetails = new Invoicingv2invoicesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency, + DiscountAmount: orderInformationAmountDetailsDiscountAmount, + DiscountPercent: orderInformationAmountDetailsDiscountPercent, + SubAmount: orderInformationAmountDetailsSubAmount, + MinimumPartialAmount: orderInformationAmountDetailsMinimumPartialAmount, + TaxDetails: orderInformationAmountDetailsTaxDetails, + Freight: orderInformationAmountDetailsFreight + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsProductSku1 = "P653727383"; + string orderInformationLineItemsProductName1 = "First line item's name"; + int orderInformationLineItemsQuantity1 = 21; + string orderInformationLineItemsUnitPrice1 = "120.08"; + orderInformationLineItems.Add(new Invoicingv2invoicesOrderInformationLineItems( + ProductSku: orderInformationLineItemsProductSku1, + ProductName: orderInformationLineItemsProductName1, + Quantity: orderInformationLineItemsQuantity1, + UnitPrice: orderInformationLineItemsUnitPrice1 + )); + + Invoicingv2invoicesOrderInformation orderInformation = new Invoicingv2invoicesOrderInformation( + AmountDetails: orderInformationAmountDetails, + LineItems: orderInformationLineItems + ); + + var requestObj = new CreateInvoiceRequest( + CustomerInformation: customerInformation, + InvoiceInformation: invoiceInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InvoicesApi(clientConfig); + InvoicingV2InvoicesPost201Response result = apiInstance.CreateInvoice(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Invoicing/Invoices/CreateDraftInvoice.cs b/Source/Samples/Invoicing/Invoices/CreateDraftInvoice.cs new file mode 100644 index 0000000..d965d96 --- /dev/null +++ b/Source/Samples/Invoicing/Invoices/CreateDraftInvoice.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Invoicing +{ + public class CreateDraftInvoice + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InvoicingV2InvoicesPost201Response Run() + { + string customerInformationName = "Tanya Lee"; + string customerInformationEmail = "tanya.lee@my-email.world"; + Invoicingv2invoicesCustomerInformation customerInformation = new Invoicingv2invoicesCustomerInformation( + Name: customerInformationName, + Email: customerInformationEmail + ); + + string invoiceInformationDescription = "This is a test invoice"; + DateTime invoiceInformationDueDate = DateTime.Parse("2019-07-11"); + bool invoiceInformationSendImmediately = false; + bool invoiceInformationAllowPartialPayments = true; + string invoiceInformationDeliveryMode = "none"; + Invoicingv2invoicesInvoiceInformation invoiceInformation = new Invoicingv2invoicesInvoiceInformation( + Description: invoiceInformationDescription, + DueDate: invoiceInformationDueDate, + SendImmediately: invoiceInformationSendImmediately, + AllowPartialPayments: invoiceInformationAllowPartialPayments, + DeliveryMode: invoiceInformationDeliveryMode + ); + + string orderInformationAmountDetailsTotalAmount = "2623.64"; + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsDiscountAmount = "126.08"; + decimal orderInformationAmountDetailsDiscountPercent = 5.00M; + decimal orderInformationAmountDetailsSubAmount = 2749.72M; + decimal orderInformationAmountDetailsMinimumPartialAmount = 20.00M; + string orderInformationAmountDetailsTaxDetailsType = "State Tax"; + string orderInformationAmountDetailsTaxDetailsAmount = "208.00"; + string orderInformationAmountDetailsTaxDetailsRate = "8.25"; + Invoicingv2invoicesOrderInformationAmountDetailsTaxDetails orderInformationAmountDetailsTaxDetails = new Invoicingv2invoicesOrderInformationAmountDetailsTaxDetails( + Type: orderInformationAmountDetailsTaxDetailsType, + Amount: orderInformationAmountDetailsTaxDetailsAmount, + Rate: orderInformationAmountDetailsTaxDetailsRate + ); + + string orderInformationAmountDetailsFreightAmount = "20.00"; + bool orderInformationAmountDetailsFreightTaxable = true; + Invoicingv2invoicesOrderInformationAmountDetailsFreight orderInformationAmountDetailsFreight = new Invoicingv2invoicesOrderInformationAmountDetailsFreight( + Amount: orderInformationAmountDetailsFreightAmount, + Taxable: orderInformationAmountDetailsFreightTaxable + ); + + Invoicingv2invoicesOrderInformationAmountDetails orderInformationAmountDetails = new Invoicingv2invoicesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency, + DiscountAmount: orderInformationAmountDetailsDiscountAmount, + DiscountPercent: orderInformationAmountDetailsDiscountPercent, + SubAmount: orderInformationAmountDetailsSubAmount, + MinimumPartialAmount: orderInformationAmountDetailsMinimumPartialAmount, + TaxDetails: orderInformationAmountDetailsTaxDetails, + Freight: orderInformationAmountDetailsFreight + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsProductSku1 = "P653727383"; + string orderInformationLineItemsProductName1 = "First line item's name"; + int orderInformationLineItemsQuantity1 = 21; + string orderInformationLineItemsUnitPrice1 = "120.08"; + orderInformationLineItems.Add(new Invoicingv2invoicesOrderInformationLineItems( + ProductSku: orderInformationLineItemsProductSku1, + ProductName: orderInformationLineItemsProductName1, + Quantity: orderInformationLineItemsQuantity1, + UnitPrice: orderInformationLineItemsUnitPrice1 + )); + + Invoicingv2invoicesOrderInformation orderInformation = new Invoicingv2invoicesOrderInformation( + AmountDetails: orderInformationAmountDetails, + LineItems: orderInformationLineItems + ); + + var requestObj = new CreateInvoiceRequest( + CustomerInformation: customerInformation, + InvoiceInformation: invoiceInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InvoicesApi(clientConfig); + InvoicingV2InvoicesPost201Response result = apiInstance.CreateInvoice(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Invoicing/Invoices/CreateInvoiceAndAssignItSpecificInvoiceNumber.cs b/Source/Samples/Invoicing/Invoices/CreateInvoiceAndAssignItSpecificInvoiceNumber.cs new file mode 100644 index 0000000..331e0df --- /dev/null +++ b/Source/Samples/Invoicing/Invoices/CreateInvoiceAndAssignItSpecificInvoiceNumber.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Invoicing +{ + public class CreateInvoiceAndAssignItSpecificInvoiceNumber + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InvoicingV2InvoicesPost201Response Run() + { + string customerInformationName = "Tanya Lee"; + string customerInformationEmail = "tanya.lee@my-email.world"; + Invoicingv2invoicesCustomerInformation customerInformation = new Invoicingv2invoicesCustomerInformation( + Name: customerInformationName, + Email: customerInformationEmail + ); + + string invoiceInformationInvoiceNumber = "A123"; + string invoiceInformationDescription = "This is a test invoice"; + DateTime invoiceInformationDueDate = DateTime.Parse("2019-07-11"); + bool invoiceInformationSendImmediately = true; + bool invoiceInformationAllowPartialPayments = true; + string invoiceInformationDeliveryMode = "email"; + Invoicingv2invoicesInvoiceInformation invoiceInformation = new Invoicingv2invoicesInvoiceInformation( + InvoiceNumber: invoiceInformationInvoiceNumber, + Description: invoiceInformationDescription, + DueDate: invoiceInformationDueDate, + SendImmediately: invoiceInformationSendImmediately, + AllowPartialPayments: invoiceInformationAllowPartialPayments, + DeliveryMode: invoiceInformationDeliveryMode + ); + + string orderInformationAmountDetailsTotalAmount = "2623.64"; + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsDiscountAmount = "126.08"; + decimal orderInformationAmountDetailsDiscountPercent = 5.00M; + decimal orderInformationAmountDetailsSubAmount = 2749.72M; + decimal orderInformationAmountDetailsMinimumPartialAmount = 20.00M; + string orderInformationAmountDetailsTaxDetailsType = "State Tax"; + string orderInformationAmountDetailsTaxDetailsAmount = "208.04"; + string orderInformationAmountDetailsTaxDetailsRate = "8.25"; + Invoicingv2invoicesOrderInformationAmountDetailsTaxDetails orderInformationAmountDetailsTaxDetails = new Invoicingv2invoicesOrderInformationAmountDetailsTaxDetails( + Type: orderInformationAmountDetailsTaxDetailsType, + Amount: orderInformationAmountDetailsTaxDetailsAmount, + Rate: orderInformationAmountDetailsTaxDetailsRate + ); + + string orderInformationAmountDetailsFreightAmount = "20.00"; + bool orderInformationAmountDetailsFreightTaxable = true; + Invoicingv2invoicesOrderInformationAmountDetailsFreight orderInformationAmountDetailsFreight = new Invoicingv2invoicesOrderInformationAmountDetailsFreight( + Amount: orderInformationAmountDetailsFreightAmount, + Taxable: orderInformationAmountDetailsFreightTaxable + ); + + Invoicingv2invoicesOrderInformationAmountDetails orderInformationAmountDetails = new Invoicingv2invoicesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency, + DiscountAmount: orderInformationAmountDetailsDiscountAmount, + DiscountPercent: orderInformationAmountDetailsDiscountPercent, + SubAmount: orderInformationAmountDetailsSubAmount, + MinimumPartialAmount: orderInformationAmountDetailsMinimumPartialAmount, + TaxDetails: orderInformationAmountDetailsTaxDetails, + Freight: orderInformationAmountDetailsFreight + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsProductSku1 = "P653727383"; + string orderInformationLineItemsProductName1 = "First line item's name"; + int orderInformationLineItemsQuantity1 = 21; + string orderInformationLineItemsUnitPrice1 = "120.08"; + orderInformationLineItems.Add(new Invoicingv2invoicesOrderInformationLineItems( + ProductSku: orderInformationLineItemsProductSku1, + ProductName: orderInformationLineItemsProductName1, + Quantity: orderInformationLineItemsQuantity1, + UnitPrice: orderInformationLineItemsUnitPrice1 + )); + + Invoicingv2invoicesOrderInformation orderInformation = new Invoicingv2invoicesOrderInformation( + AmountDetails: orderInformationAmountDetails, + LineItems: orderInformationLineItems + ); + + var requestObj = new CreateInvoiceRequest( + CustomerInformation: customerInformation, + InvoiceInformation: invoiceInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InvoicesApi(clientConfig); + InvoicingV2InvoicesPost201Response result = apiInstance.CreateInvoice(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Invoicing/Invoices/CreateInvoiceWithoutSendingIt.cs b/Source/Samples/Invoicing/Invoices/CreateInvoiceWithoutSendingIt.cs new file mode 100644 index 0000000..1fe7900 --- /dev/null +++ b/Source/Samples/Invoicing/Invoices/CreateInvoiceWithoutSendingIt.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Invoicing +{ + public class CreateInvoiceWithoutSendingIt + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InvoicingV2InvoicesPost201Response Run() + { + string customerInformationName = "Tanya Lee"; + string customerInformationEmail = "tanya.lee@my-email.world"; + Invoicingv2invoicesCustomerInformation customerInformation = new Invoicingv2invoicesCustomerInformation( + Name: customerInformationName, + Email: customerInformationEmail + ); + + string invoiceInformationInvoiceNumber = "A123"; + string invoiceInformationDescription = "This is a test invoice"; + DateTime invoiceInformationDueDate = DateTime.Parse("2019-07-11"); + bool invoiceInformationSendImmediately = true; + bool invoiceInformationAllowPartialPayments = true; + string invoiceInformationDeliveryMode = "none"; + Invoicingv2invoicesInvoiceInformation invoiceInformation = new Invoicingv2invoicesInvoiceInformation( + InvoiceNumber: invoiceInformationInvoiceNumber, + Description: invoiceInformationDescription, + DueDate: invoiceInformationDueDate, + SendImmediately: invoiceInformationSendImmediately, + AllowPartialPayments: invoiceInformationAllowPartialPayments, + DeliveryMode: invoiceInformationDeliveryMode + ); + + string orderInformationAmountDetailsTotalAmount = "2623.64"; + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsDiscountAmount = "126.08"; + decimal orderInformationAmountDetailsDiscountPercent = 5.00M; + decimal orderInformationAmountDetailsSubAmount = 2749.72M; + decimal orderInformationAmountDetailsMinimumPartialAmount = 20.00M; + string orderInformationAmountDetailsTaxDetailsType = "State Tax"; + string orderInformationAmountDetailsTaxDetailsAmount = "208.04"; + string orderInformationAmountDetailsTaxDetailsRate = "8.25"; + Invoicingv2invoicesOrderInformationAmountDetailsTaxDetails orderInformationAmountDetailsTaxDetails = new Invoicingv2invoicesOrderInformationAmountDetailsTaxDetails( + Type: orderInformationAmountDetailsTaxDetailsType, + Amount: orderInformationAmountDetailsTaxDetailsAmount, + Rate: orderInformationAmountDetailsTaxDetailsRate + ); + + string orderInformationAmountDetailsFreightAmount = "20.00"; + bool orderInformationAmountDetailsFreightTaxable = true; + Invoicingv2invoicesOrderInformationAmountDetailsFreight orderInformationAmountDetailsFreight = new Invoicingv2invoicesOrderInformationAmountDetailsFreight( + Amount: orderInformationAmountDetailsFreightAmount, + Taxable: orderInformationAmountDetailsFreightTaxable + ); + + Invoicingv2invoicesOrderInformationAmountDetails orderInformationAmountDetails = new Invoicingv2invoicesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency, + DiscountAmount: orderInformationAmountDetailsDiscountAmount, + DiscountPercent: orderInformationAmountDetailsDiscountPercent, + SubAmount: orderInformationAmountDetailsSubAmount, + MinimumPartialAmount: orderInformationAmountDetailsMinimumPartialAmount, + TaxDetails: orderInformationAmountDetailsTaxDetails, + Freight: orderInformationAmountDetailsFreight + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsProductSku1 = "P653727383"; + string orderInformationLineItemsProductName1 = "First line item's name"; + int orderInformationLineItemsQuantity1 = 21; + string orderInformationLineItemsUnitPrice1 = "120.08"; + orderInformationLineItems.Add(new Invoicingv2invoicesOrderInformationLineItems( + ProductSku: orderInformationLineItemsProductSku1, + ProductName: orderInformationLineItemsProductName1, + Quantity: orderInformationLineItemsQuantity1, + UnitPrice: orderInformationLineItemsUnitPrice1 + )); + + Invoicingv2invoicesOrderInformation orderInformation = new Invoicingv2invoicesOrderInformation( + AmountDetails: orderInformationAmountDetails, + LineItems: orderInformationLineItems + ); + + var requestObj = new CreateInvoiceRequest( + CustomerInformation: customerInformation, + InvoiceInformation: invoiceInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InvoicesApi(clientConfig); + InvoicingV2InvoicesPost201Response result = apiInstance.CreateInvoice(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Invoicing/Invoices/GetInvoiceDetails.cs b/Source/Samples/Invoicing/Invoices/GetInvoiceDetails.cs new file mode 100644 index 0000000..23f9fa0 --- /dev/null +++ b/Source/Samples/Invoicing/Invoices/GetInvoiceDetails.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Invoicing +{ + public class GetInvoiceDetails + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InvoicingV2InvoicesGet200Response Run() + { + string id = CreateDraftInvoice.Run().Id; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InvoicesApi(clientConfig); + InvoicingV2InvoicesGet200Response result = apiInstance.GetInvoice(id); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Invoicing/Invoices/GetListOfInvoices.cs b/Source/Samples/Invoicing/Invoices/GetListOfInvoices.cs new file mode 100644 index 0000000..10fa01b --- /dev/null +++ b/Source/Samples/Invoicing/Invoices/GetListOfInvoices.cs @@ -0,0 +1,36 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Samples.Invoicing +{ + public class GetListOfInvoices + { + public static InvoicingV2InvoicesAllGet200Response Run() + { + int offset = 0; + int limit = 10; + string query = null; + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InvoicesApi(clientConfig); + InvoicingV2InvoicesAllGet200Response result = apiInstance.GetAllInvoices(offset, limit, query); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/Invoicing/Invoices/SendInvoice.cs b/Source/Samples/Invoicing/Invoices/SendInvoice.cs new file mode 100644 index 0000000..8458a1f --- /dev/null +++ b/Source/Samples/Invoicing/Invoices/SendInvoice.cs @@ -0,0 +1,33 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Samples.Invoicing +{ + public class SendInvoice + { + public static InvoicingV2InvoicesPost201Response Run() + { + try + { + var invoiceId = CreateDraftInvoice.Run().Id; + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InvoicesApi(clientConfig); + InvoicingV2InvoicesPost201Response result = apiInstance.PerformSendAction(invoiceId); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/Invoicing/Invoices/UpdateInvoice.cs b/Source/Samples/Invoicing/Invoices/UpdateInvoice.cs new file mode 100644 index 0000000..ed1ad1f --- /dev/null +++ b/Source/Samples/Invoicing/Invoices/UpdateInvoice.cs @@ -0,0 +1,108 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Samples.Invoicing +{ + public class UpdateInvoice + { + public static InvoicingV2InvoicesPost201Response Run() + { + var invoiceId = CreateDraftInvoice.Run().Id; + + string customerInformationName = "New Customer Name"; + string customerInformationEmail = "new_email@my-email.world"; + Invoicingv2invoicesCustomerInformation customerInformation = new Invoicingv2invoicesCustomerInformation( + Name: customerInformationName, + Email: customerInformationEmail + ); + + string invoiceInformationDescription = "This is after updating invoice"; + DateTime invoiceInformationDueDate = DateTime.Parse("2019-07-11"); + bool invoiceInformationAllowPartialPayments = true; + string invoiceInformationDeliveryMode = "none"; + Invoicingv2invoicesidInvoiceInformation invoiceInformation = new Invoicingv2invoicesidInvoiceInformation( + Description: invoiceInformationDescription, + DueDate: invoiceInformationDueDate, + AllowPartialPayments: invoiceInformationAllowPartialPayments, + DeliveryMode: invoiceInformationDeliveryMode + ); + + string orderInformationAmountDetailsTotalAmount = "2623.64"; + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsDiscountAmount = "126.08"; + decimal orderInformationAmountDetailsDiscountPercent = 5.00M; + decimal orderInformationAmountDetailsSubAmount = 2749.72M; + decimal orderInformationAmountDetailsMinimumPartialAmount = 20.00M; + string orderInformationAmountDetailsTaxDetailsType = "State Tax"; + string orderInformationAmountDetailsTaxDetailsAmount = "208.00"; + string orderInformationAmountDetailsTaxDetailsRate = "8.25"; + Invoicingv2invoicesOrderInformationAmountDetailsTaxDetails orderInformationAmountDetailsTaxDetails = new Invoicingv2invoicesOrderInformationAmountDetailsTaxDetails( + Type: orderInformationAmountDetailsTaxDetailsType, + Amount: orderInformationAmountDetailsTaxDetailsAmount, + Rate: orderInformationAmountDetailsTaxDetailsRate + ); + + string orderInformationAmountDetailsFreightAmount = "20.00"; + bool orderInformationAmountDetailsFreightTaxable = true; + Invoicingv2invoicesOrderInformationAmountDetailsFreight orderInformationAmountDetailsFreight = new Invoicingv2invoicesOrderInformationAmountDetailsFreight( + Amount: orderInformationAmountDetailsFreightAmount, + Taxable: orderInformationAmountDetailsFreightTaxable + ); + + Invoicingv2invoicesOrderInformationAmountDetails orderInformationAmountDetails = new Invoicingv2invoicesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency, + DiscountAmount: orderInformationAmountDetailsDiscountAmount, + DiscountPercent: orderInformationAmountDetailsDiscountPercent, + SubAmount: orderInformationAmountDetailsSubAmount, + MinimumPartialAmount: orderInformationAmountDetailsMinimumPartialAmount, + TaxDetails: orderInformationAmountDetailsTaxDetails, + Freight: orderInformationAmountDetailsFreight + ); + + List orderInformationLineItems = new List(); + string orderInformationLineItemsProductSku1 = "P653727383"; + string orderInformationLineItemsProductName1 = "First line item's name"; + int orderInformationLineItemsQuantity1 = 21; + string orderInformationLineItemsUnitPrice1 = "120.08"; + orderInformationLineItems.Add(new Invoicingv2invoicesOrderInformationLineItems( + ProductSku: orderInformationLineItemsProductSku1, + ProductName: orderInformationLineItemsProductName1, + Quantity: orderInformationLineItemsQuantity1, + UnitPrice: orderInformationLineItemsUnitPrice1 + )); + + Invoicingv2invoicesOrderInformation orderInformation = new Invoicingv2invoicesOrderInformation( + AmountDetails: orderInformationAmountDetails, + LineItems: orderInformationLineItems + ); + + var requestObj = new UpdateInvoiceRequest( + CustomerInformation: customerInformation, + InvoiceInformation: invoiceInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InvoicesApi(clientConfig); + InvoicingV2InvoicesPost201Response result = apiInstance.UpdateInvoice(invoiceId, requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/MerchantBoarding/CreateRegistration.cs b/Source/Samples/MerchantBoarding/CreateRegistration.cs new file mode 100644 index 0000000..afbd52c --- /dev/null +++ b/Source/Samples/MerchantBoarding/CreateRegistration.cs @@ -0,0 +1,229 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.MerchantBoarding +{ + internal class CreateRegistration + { + + + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InlineResponse2012 Run() + { + + PostRegistrationBody reqObj = new PostRegistrationBody(); + + Boardingv1registrationsOrganizationInformation organizationInformation = new Boardingv1registrationsOrganizationInformation + { + ParentOrganizationId = "apitester00", + Type = Boardingv1registrationsOrganizationInformation.TypeEnum.MERCHANT, + Configurable = true + }; + + Boardingv1registrationsOrganizationInformationBusinessInformation businessInformation = new Boardingv1registrationsOrganizationInformationBusinessInformation + { + Name = "StuartWickedFastEatz" + }; + + Boardingv1registrationsOrganizationInformationBusinessInformationAddress address = new Boardingv1registrationsOrganizationInformationBusinessInformationAddress + { + Country = "US", + Address1 = "123456 SandMarket", + Locality = "ORMOND BEACH", + AdministrativeArea = "FL", + PostalCode = "32176" + }; + + businessInformation.Address = address; + businessInformation.WebsiteUrl = "https://www.StuartWickedEats.com"; + businessInformation.PhoneNumber = "6574567813"; + + Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact businessContact = new Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact + { + FirstName = "Stuart", + LastName = "Stuart", + PhoneNumber = "6574567813", + Email = "svc_email_bt@corpdev.visa.com" + }; + + businessInformation.BusinessContact = businessContact; + businessInformation.MerchantCategoryCode = "5999"; + organizationInformation.BusinessInformation = businessInformation; + + reqObj.OrganizationInformation = organizationInformation; + + Boardingv1registrationsProductInformation productInformation = new Boardingv1registrationsProductInformation(); + Boardingv1registrationsProductInformationSelectedProducts selectedProducts = new Boardingv1registrationsProductInformationSelectedProducts(); + + PaymentsProducts payments = new PaymentsProducts(); + PaymentsProductsPayerAuthentication payerAuthentication = new PaymentsProductsPayerAuthentication(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + payerAuthentication.SubscriptionInformation = subscriptionInformation; + + PaymentsProductsPayerAuthenticationConfigurationInformation configurationInformation = new PaymentsProductsPayerAuthenticationConfigurationInformation(); + PayerAuthConfig configurations = new PayerAuthConfig(); + PayerAuthConfigCardTypes cardTypes = new PayerAuthConfigCardTypes(); + PayerAuthConfigCardTypesVerifiedByVisa verifiedByVisa = new PayerAuthConfigCardTypesVerifiedByVisa(); + List currencies = new List(); + PayerAuthConfigCardTypesVerifiedByVisaCurrencies currency1 = new PayerAuthConfigCardTypesVerifiedByVisaCurrencies + { + CurrencyCodes = new List { "ALL" }, + AcquirerId = "469216", + ProcessorMerchantId = "678855" + }; + + currencies.Add(currency1); + verifiedByVisa.Currencies = currencies; + cardTypes.VerifiedByVisa = verifiedByVisa; + configurations.CardTypes = cardTypes; + configurationInformation.Configurations = configurations; + payerAuthentication.ConfigurationInformation = configurationInformation; + payments.PayerAuthentication = payerAuthentication; + + PaymentsProductsCardProcessing cardProcessing = new PaymentsProductsCardProcessing(); + PaymentsProductsCardProcessingSubscriptionInformation subscriptionInformation2 = new PaymentsProductsCardProcessingSubscriptionInformation + { + Enabled = true, + Features = new Dictionary + { + { + "cardNotPresent", new PaymentsProductsCardProcessingSubscriptionInformationFeatures + { Enabled = true } } + } + }; + + cardProcessing.SubscriptionInformation = subscriptionInformation2; + + PaymentsProductsCardProcessingConfigurationInformation configurationInformation2 = new PaymentsProductsCardProcessingConfigurationInformation(); + CardProcessingConfig configurations2 = new CardProcessingConfig(); + CardProcessingConfigCommon common = new CardProcessingConfigCommon + { + MerchantCategoryCode = "1234", + MerchantDescriptorInformation = new CardProcessingConfigCommonMerchantDescriptorInformation + { + Name = "r4ef", + City = "Bellevue", + Country = "US", + Phone = "4255547845", + State = "WA", + Street = "StreetName", + Zip = "98007" + }, + Processors = new Dictionary + { + { + "tsys", new CardProcessingConfigCommonProcessors + { + MerchantId = "123456789101", + TerminalId = "1231", + IndustryCode = CardProcessingConfigCommonProcessors.IndustryCodeEnum.D, + VitalNumber = "71234567", + MerchantBinNumber = "123456", + MerchantLocationNumber = "00001", + StoreID = "1234", + SettlementCurrency = "USD" + } + } + } + }; + + configurations2.Common = common; + CardProcessingConfigFeatures features2 = new CardProcessingConfigFeatures(); + CardProcessingConfigFeaturesCardNotPresent cardNotPresent = new CardProcessingConfigFeaturesCardNotPresent + { + VisaStraightThroughProcessingOnly = true + }; + + features2.CardNotPresent = cardNotPresent; + configurations2.Features = features2; + configurationInformation2.Configurations = configurations2; + cardProcessing.ConfigurationInformation = configurationInformation2; + payments.CardProcessing = cardProcessing; + + PaymentsProductsVirtualTerminal virtualTerminal = new PaymentsProductsVirtualTerminal + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true } + }; + + payments.VirtualTerminal = virtualTerminal; + + PaymentsProductsTax customerInvoicing = new PaymentsProductsTax + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true } + }; + + payments.CustomerInvoicing = customerInvoicing; + + PaymentsProductsPayouts payouts = new PaymentsProductsPayouts + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true } + }; + + payments.Payouts = payouts; + + selectedProducts.Payments = payments; + + CommerceSolutionsProducts commerceSolutions = new CommerceSolutionsProducts(); + CommerceSolutionsProductsTokenManagement tokenManagement = new CommerceSolutionsProductsTokenManagement + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true } + }; + + commerceSolutions.TokenManagement = tokenManagement; + selectedProducts.CommerceSolutions = commerceSolutions; + + RiskProducts risk = new RiskProducts(); + RiskProductsFraudManagementEssentials fraudManagementEssentials = new RiskProductsFraudManagementEssentials + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true }, + ConfigurationInformation = new RiskProductsFraudManagementEssentialsConfigurationInformation + { + TemplateId = Guid.Parse("E4EDB280-9DAC-4698-9EB9-9434D40FF60C") + } + }; + + risk.FraudManagementEssentials = fraudManagementEssentials; + selectedProducts.Risk = risk; + + productInformation.SelectedProducts = selectedProducts; + reqObj.ProductInformation = productInformation; + + + + try + { + var configDictionary = new MerchantBoardingConfiguration().GetMerchantBoardingConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new MerchantBoardingApi(clientConfig); + InlineResponse2012 result = apiInstance.PostRegistration(reqObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/MerchantBoarding/MerchantBoardingAmexDirect.cs b/Source/Samples/MerchantBoarding/MerchantBoardingAmexDirect.cs new file mode 100644 index 0000000..2faf3b6 --- /dev/null +++ b/Source/Samples/MerchantBoarding/MerchantBoardingAmexDirect.cs @@ -0,0 +1,250 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.MerchantBoarding +{ + internal class MerchantBoardingAmexDirect + { + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + + public static InlineResponse2012 Run() + { + + + PostRegistrationBody reqObj = new PostRegistrationBody(); + + Boardingv1registrationsOrganizationInformation organizationInformation = new Boardingv1registrationsOrganizationInformation + { + ParentOrganizationId = "apitester00", + Type = Boardingv1registrationsOrganizationInformation.TypeEnum.MERCHANT, + Configurable = true + }; + + Boardingv1registrationsOrganizationInformationBusinessInformation businessInformation = new Boardingv1registrationsOrganizationInformationBusinessInformation + { + Name = "StuartWickedFastEatz" + }; + + Boardingv1registrationsOrganizationInformationBusinessInformationAddress address = new Boardingv1registrationsOrganizationInformationBusinessInformationAddress + { + Country = "US", + Address1 = "123456 SandMarket", + Locality = "ORMOND BEACH", + AdministrativeArea = "FL", + PostalCode = "32176" + }; + + businessInformation.Address = address; + businessInformation.WebsiteUrl = "https://www.StuartWickedEats.com"; + businessInformation.PhoneNumber = "6574567813"; + + Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact businessContact = new Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact + { + FirstName = "Stuart", + LastName = "Stuart", + PhoneNumber = "6574567813", + Email = "svc_email_bt@corpdev.visa.com" + }; + + businessInformation.BusinessContact = businessContact; + businessInformation.MerchantCategoryCode = "5999"; + organizationInformation.BusinessInformation = businessInformation; + + reqObj.OrganizationInformation = organizationInformation; + + Boardingv1registrationsProductInformation productInformation = new Boardingv1registrationsProductInformation(); + Boardingv1registrationsProductInformationSelectedProducts selectedProducts = new Boardingv1registrationsProductInformationSelectedProducts(); + + PaymentsProducts payments = new PaymentsProducts(); + PaymentsProductsCardProcessing cardProcessing = new PaymentsProductsCardProcessing(); + PaymentsProductsCardProcessingSubscriptionInformation subscriptionInformation = new PaymentsProductsCardProcessingSubscriptionInformation(); + + subscriptionInformation.Enabled = true; + var features = new Dictionary(); + + PaymentsProductsCardProcessingSubscriptionInformationFeatures obj1 = new PaymentsProductsCardProcessingSubscriptionInformationFeatures + { + Enabled = true + }; + features.Add("cardNotPresent", obj1); + features.Add("cardPresent", obj1); + subscriptionInformation.Features = features; + cardProcessing.SubscriptionInformation = subscriptionInformation; + + PaymentsProductsCardProcessingConfigurationInformation configurationInformation = new PaymentsProductsCardProcessingConfigurationInformation(); + + CardProcessingConfig configurations = new CardProcessingConfig(); + CardProcessingConfigCommon common = new CardProcessingConfigCommon + { + MerchantCategoryCode = "1799" + }; + CardProcessingConfigCommonMerchantDescriptorInformation merchantDescriptorInformation = new CardProcessingConfigCommonMerchantDescriptorInformation + { + City = "Cupertino", + Country = "USA", + Name = "Mer name", + Phone = "8885554444", + Zip = "94043", + State = "CA", + Street = "mer street", + Url = "www.test.com" + }; + + common.MerchantDescriptorInformation = merchantDescriptorInformation; + common.SubMerchantId = "123457"; + common.SubMerchantBusinessName = "bus name"; + + var processors = new Dictionary(); + CardProcessingConfigCommonProcessors obj2 = new CardProcessingConfigCommonProcessors(); + CardProcessingConfigCommonAcquirer acquirer = new CardProcessingConfigCommonAcquirer(); + + obj2.Acquirer = acquirer; + var currencies = new Dictionary(); + CardProcessingConfigCommonCurrencies1 obj3 = new CardProcessingConfigCommonCurrencies1 + { + Enabled = true, + EnabledCardPresent = true, + TerminalId = "", + ServiceEnablementNumber = "1234567890" + }; + currencies.Add("AED", obj3); + currencies.Add("FJD", obj3); + currencies.Add("USD", obj3); + + obj2.Currencies = currencies; + + var paymentTypes = new Dictionary(); + CardProcessingConfigCommonPaymentTypes obj4 = new CardProcessingConfigCommonPaymentTypes + { + Enabled = true + }; + paymentTypes.Add("AMERICAN_EXPRESS", obj4); + + obj2.PaymentTypes = paymentTypes; + obj2.AllowMultipleBills = false; + obj2.AvsFormat = "basic"; + obj2.BatchGroup = "amexdirect_vme_default"; + obj2.EnableAutoAuthReversalAfterVoid = false; + obj2.EnhancedData = "disabled"; + obj2.EnableLevel2 = false; + obj2.AmexTransactionAdviceAddendum1 = "amex123"; + processors.Add("acquirer", obj2); + + common.Processors = processors; + configurations.Common = common; + + CardProcessingConfigFeatures features2 = new CardProcessingConfigFeatures(); + CardProcessingConfigFeaturesCardNotPresent cardNotPresent = new CardProcessingConfigFeaturesCardNotPresent(); + + var processors3 = new Dictionary(); + CardProcessingConfigFeaturesCardNotPresentProcessors obj5 = new CardProcessingConfigFeaturesCardNotPresentProcessors + { + RelaxAddressVerificationSystem = true, + RelaxAddressVerificationSystemAllowExpiredCard = true, + RelaxAddressVerificationSystemAllowZipWithoutCountry = false + }; + processors3.Add("amexdirect", obj5); + + cardNotPresent.Processors = processors3; + features2.CardNotPresent = cardNotPresent; + configurations.Features = features2; + configurationInformation.Configurations = configurations; + Guid templateId = Guid.Parse("2B80A3C7-5A39-4CC3-9882-AC4A828D3646"); + configurationInformation.TemplateId = templateId; + cardProcessing.ConfigurationInformation = configurationInformation; + payments.CardProcessing = cardProcessing; + + PaymentsProductsVirtualTerminal virtualTerminal = new PaymentsProductsVirtualTerminal(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation2 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + virtualTerminal.SubscriptionInformation = subscriptionInformation2; + + PaymentsProductsVirtualTerminalConfigurationInformation configurationInformation3 = new PaymentsProductsVirtualTerminalConfigurationInformation(); + Guid templateId2 = Guid.Parse("9FA1BB94-5119-48D3-B2E5-A81FD3C657B5"); + configurationInformation3.TemplateId = templateId2; + virtualTerminal.ConfigurationInformation = configurationInformation3; + payments.VirtualTerminal = virtualTerminal; + + PaymentsProductsTax customerInvoicing = new PaymentsProductsTax(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation6 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + customerInvoicing.SubscriptionInformation = subscriptionInformation6; + payments.CustomerInvoicing = customerInvoicing; + selectedProducts.Payments = payments; + + RiskProducts risk = new RiskProducts(); + selectedProducts.Risk = risk; + + CommerceSolutionsProducts commerceSolutions = new CommerceSolutionsProducts(); + CommerceSolutionsProductsTokenManagement tokenManagement = new CommerceSolutionsProductsTokenManagement(); + + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation7 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + tokenManagement.SubscriptionInformation = subscriptionInformation7; + CommerceSolutionsProductsTokenManagementConfigurationInformation configurationInformation4 = new CommerceSolutionsProductsTokenManagementConfigurationInformation(); + Guid templateId3 = Guid.Parse("D62BEE20-DCFD-4AA2-8723-BA3725958ABA"); + configurationInformation4.TemplateId = templateId3; + tokenManagement.ConfigurationInformation = configurationInformation4; + commerceSolutions.TokenManagement = tokenManagement; + selectedProducts.CommerceSolutions = commerceSolutions; + + ValueAddedServicesProducts valueAddedServices = new ValueAddedServicesProducts(); + PaymentsProductsTax transactionSearch = new PaymentsProductsTax(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation8 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + transactionSearch.SubscriptionInformation = subscriptionInformation8; + + valueAddedServices.TransactionSearch = transactionSearch; + PaymentsProductsTax reporting = new PaymentsProductsTax(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation9 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + reporting.SubscriptionInformation = subscriptionInformation9; + valueAddedServices.Reporting = reporting; + + selectedProducts.ValueAddedServices = valueAddedServices; + productInformation.SelectedProducts = selectedProducts; + reqObj.ProductInformation = productInformation; + + try + { + var configDictionary = new MerchantBoardingConfiguration().GetMerchantBoardingConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new MerchantBoardingApi(clientConfig); + InlineResponse2012 result = apiInstance.PostRegistration(reqObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/MerchantBoarding/MerchantBoardingBarclays.cs b/Source/Samples/MerchantBoarding/MerchantBoardingBarclays.cs new file mode 100644 index 0000000..df36660 --- /dev/null +++ b/Source/Samples/MerchantBoarding/MerchantBoardingBarclays.cs @@ -0,0 +1,276 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.MerchantBoarding +{ + internal class MerchantBoardingBarclays + { + + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InlineResponse2012 Run() + { + + + PostRegistrationBody reqObj = new PostRegistrationBody(); + + Boardingv1registrationsOrganizationInformation organizationInformation = new Boardingv1registrationsOrganizationInformation + { + ParentOrganizationId = "apitester00", + Type = Boardingv1registrationsOrganizationInformation.TypeEnum.MERCHANT, + Configurable = true + }; + + Boardingv1registrationsOrganizationInformationBusinessInformation businessInformation = new Boardingv1registrationsOrganizationInformationBusinessInformation + { + Name = "StuartWickedFastEatz" + }; + + Boardingv1registrationsOrganizationInformationBusinessInformationAddress address = new Boardingv1registrationsOrganizationInformationBusinessInformationAddress + { + Country = "US", + Address1 = "123456 SandMarket", + Locality = "ORMOND BEACH", + AdministrativeArea = "FL", + PostalCode = "32176" + }; + + businessInformation.Address = address; + businessInformation.WebsiteUrl = "https://www.StuartWickedEats.com"; + businessInformation.PhoneNumber = "6574567813"; + + Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact businessContact = new Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact + { + FirstName = "Stuart", + LastName = "Stuart", + PhoneNumber = "6574567813", + Email = "svc_email_bt@corpdev.visa.com" + }; + + businessInformation.BusinessContact = businessContact; + businessInformation.MerchantCategoryCode = "5999"; + organizationInformation.BusinessInformation = businessInformation; + + reqObj.OrganizationInformation = organizationInformation; + + Boardingv1registrationsProductInformation productInformation = new Boardingv1registrationsProductInformation(); + Boardingv1registrationsProductInformationSelectedProducts selectedProducts = new Boardingv1registrationsProductInformationSelectedProducts(); + + PaymentsProducts payments = new PaymentsProducts(); + PaymentsProductsCardProcessing cardProcessing = new PaymentsProductsCardProcessing(); + PaymentsProductsCardProcessingSubscriptionInformation subscriptionInformation = new PaymentsProductsCardProcessingSubscriptionInformation + { + Enabled = true + }; + + var features = new Dictionary + { + { "cardNotPresent", new PaymentsProductsCardProcessingSubscriptionInformationFeatures { Enabled = true } }, + { "cardPresent", new PaymentsProductsCardProcessingSubscriptionInformationFeatures { Enabled = true } } + }; + + subscriptionInformation.Features = features; + cardProcessing.SubscriptionInformation = subscriptionInformation; + + PaymentsProductsCardProcessingConfigurationInformation configurationInformation = new PaymentsProductsCardProcessingConfigurationInformation(); + + CardProcessingConfig configurations = new CardProcessingConfig(); + + CardProcessingConfigCommon common = new CardProcessingConfigCommon + { + MerchantCategoryCode = "5999", + DefaultAuthTypeCode = CardProcessingConfigCommon.DefaultAuthTypeCodeEnum.FINAL + }; + + var processors = new Dictionary(); + + CardProcessingConfigCommonProcessors obj2 = new CardProcessingConfigCommonProcessors + { + Acquirer = new CardProcessingConfigCommonAcquirer() + }; + + var currencies = new Dictionary + { + { "AED", new CardProcessingConfigCommonCurrencies1 + { + Enabled = true, + EnabledCardPresent = false, + EnabledCardNotPresent = true, + MerchantId = "1234", + ServiceEnablementNumber = "", + TerminalIds = new List { "12351245" } + } + }, + { "USD", new CardProcessingConfigCommonCurrencies1 + { + Enabled = true, + EnabledCardPresent = false, + EnabledCardNotPresent = true, + MerchantId = "1234", + ServiceEnablementNumber = "", + TerminalIds = new List { "12351245" } + } + } + }; + + obj2.Currencies = currencies; + + var paymentTypes = new Dictionary + { + { "MASTERCARD", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "VISA", new CardProcessingConfigCommonPaymentTypes { Enabled = true } } + }; + + obj2.PaymentTypes = paymentTypes; + obj2.BatchGroup = "barclays2_16"; + obj2.QuasiCash = false; + obj2.EnhancedData = "disabled"; + obj2.MerchantId = "124555"; + obj2.EnableMultiCurrencyProcessing = "false"; + + processors["barclays2"] = obj2; + + common.Processors = processors; + configurations.Common = common; + + CardProcessingConfigFeatures features3 = new CardProcessingConfigFeatures(); + + CardProcessingConfigFeaturesCardNotPresent cardNotPresent = new CardProcessingConfigFeaturesCardNotPresent(); + + var processors4 = new Dictionary + { + { "barclays2", new CardProcessingConfigFeaturesCardNotPresentProcessors + { + Payouts = new CardProcessingConfigFeaturesCardNotPresentPayouts + { + MerchantId = "1233", + TerminalId = "1244" + } + } + } + }; + + cardNotPresent.Processors = processors4; + features3.CardNotPresent = cardNotPresent; + + configurations.Features = features3; + + configurationInformation.Configurations = configurations; + + var templateId = Guid.Parse("0A413572-1995-483C-9F48-FCBE4D0B2E86"); + configurationInformation.TemplateId = templateId; + cardProcessing.ConfigurationInformation = configurationInformation; + + payments.CardProcessing = cardProcessing; + + PaymentsProductsVirtualTerminal virtualTerminal = new PaymentsProductsVirtualTerminal(); + + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation2 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + virtualTerminal.SubscriptionInformation = subscriptionInformation2; + + PaymentsProductsVirtualTerminalConfigurationInformation configurationInformation2 = new PaymentsProductsVirtualTerminalConfigurationInformation + { + TemplateId = Guid.Parse("E4EDB280-9DAC-4698-9EB9-9434D40FF60C") + }; + + virtualTerminal.ConfigurationInformation = configurationInformation2; + payments.VirtualTerminal = virtualTerminal; + + PaymentsProductsTax customerInvoicing = new PaymentsProductsTax(); + + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation3 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + customerInvoicing.SubscriptionInformation = subscriptionInformation3; + payments.CustomerInvoicing = customerInvoicing; + + selectedProducts.Payments = payments; + + RiskProducts risk2 = new RiskProducts(); + selectedProducts.Risk = risk2; + + CommerceSolutionsProducts commerceSolutions = new CommerceSolutionsProducts(); + CommerceSolutionsProductsTokenManagement tokenManagement = new CommerceSolutionsProductsTokenManagement(); + + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation5 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + tokenManagement.SubscriptionInformation = subscriptionInformation5; + + CommerceSolutionsProductsTokenManagementConfigurationInformation configurationInformation5 = new CommerceSolutionsProductsTokenManagementConfigurationInformation + { + TemplateId = Guid.Parse("D62BEE20-DCFD-4AA2-8723-BA3725958ABA") + }; + + tokenManagement.ConfigurationInformation = configurationInformation5; + commerceSolutions.TokenManagement = tokenManagement; + selectedProducts.CommerceSolutions = commerceSolutions; + + ValueAddedServicesProducts valueAddedServices = new ValueAddedServicesProducts(); + + PaymentsProductsTax transactionSearch = new PaymentsProductsTax(); + + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation6 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + transactionSearch.SubscriptionInformation = subscriptionInformation6; + valueAddedServices.TransactionSearch = transactionSearch; + + PaymentsProductsTax reporting = new PaymentsProductsTax(); + + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation7 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + reporting.SubscriptionInformation = subscriptionInformation7; + valueAddedServices.Reporting = reporting; + selectedProducts.ValueAddedServices = valueAddedServices; + + productInformation.SelectedProducts = selectedProducts; + reqObj.ProductInformation = productInformation; + + + + try + { + var configDictionary = new MerchantBoardingConfiguration().GetMerchantBoardingConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new MerchantBoardingApi(clientConfig); + InlineResponse2012 result = apiInstance.PostRegistration(reqObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/MerchantBoarding/MerchantBoardingBinLookUp.cs b/Source/Samples/MerchantBoarding/MerchantBoardingBinLookUp.cs new file mode 100644 index 0000000..e9f7dfe --- /dev/null +++ b/Source/Samples/MerchantBoarding/MerchantBoardingBinLookUp.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.MerchantBoarding +{ + internal class MerchantBoardingBinLookUp + { + + + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InlineResponse2012 Run() + { + + PostRegistrationBody reqObj = new PostRegistrationBody(); + + Boardingv1registrationsOrganizationInformation organizationInformation = new Boardingv1registrationsOrganizationInformation + { + ParentOrganizationId = "apitester00", + Type = Boardingv1registrationsOrganizationInformation.TypeEnum.MERCHANT, + Configurable = true + }; + + Boardingv1registrationsOrganizationInformationBusinessInformation businessInformation = new Boardingv1registrationsOrganizationInformationBusinessInformation + { + Name = "StuartWickedFastEatz" + }; + + Boardingv1registrationsOrganizationInformationBusinessInformationAddress address = new Boardingv1registrationsOrganizationInformationBusinessInformationAddress + { + Country = "US", + Address1 = "123456 SandMarket", + Locality = "ORMOND BEACH", + AdministrativeArea = "FL", + PostalCode = "32176" + }; + + businessInformation.Address = address; + businessInformation.WebsiteUrl = "https://www.StuartWickedEats.com"; + businessInformation.PhoneNumber = "6574567813"; + + Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact businessContact = new Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact + { + FirstName = "Stuart", + LastName = "Stuart", + PhoneNumber = "6574567813", + Email = "svc_email_bt@corpdev.visa.com" + }; + + businessInformation.BusinessContact = businessContact; + businessInformation.MerchantCategoryCode = "5999"; + organizationInformation.BusinessInformation = businessInformation; + + reqObj.OrganizationInformation = organizationInformation; + + Boardingv1registrationsProductInformation productInformation = new Boardingv1registrationsProductInformation(); + Boardingv1registrationsProductInformationSelectedProducts selectedProducts = new Boardingv1registrationsProductInformationSelectedProducts(); + + PaymentsProducts payments = new PaymentsProducts(); + selectedProducts.Payments = payments; + + RiskProducts risk = new RiskProducts(); + selectedProducts.Risk = risk; + + CommerceSolutionsProducts commerceSolutions = new CommerceSolutionsProducts(); + CommerceSolutionsProductsBinLookup binLookup = new CommerceSolutionsProductsBinLookup(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + binLookup.SubscriptionInformation = subscriptionInformation; + + CommerceSolutionsProductsBinLookupConfigurationInformation configurationInformation = new CommerceSolutionsProductsBinLookupConfigurationInformation(); + CommerceSolutionsProductsBinLookupConfigurationInformationConfigurations configurations = new CommerceSolutionsProductsBinLookupConfigurationInformationConfigurations + { + IsPayoutOptionsEnabled = false, + IsAccountPrefixEnabled = true + }; + + configurationInformation.Configurations = configurations; + binLookup.ConfigurationInformation = configurationInformation; + commerceSolutions.BinLookup = binLookup; + + selectedProducts.CommerceSolutions = commerceSolutions; + + ValueAddedServicesProducts valueAddedServices = new ValueAddedServicesProducts(); + selectedProducts.ValueAddedServices = valueAddedServices; + + productInformation.SelectedProducts = selectedProducts; + reqObj.ProductInformation = productInformation; + + + + try + { + var configDictionary = new MerchantBoardingConfiguration().GetMerchantBoardingConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new MerchantBoardingApi(clientConfig); + InlineResponse2012 result = apiInstance.PostRegistration(reqObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/MerchantBoarding/MerchantBoardingCUP.cs b/Source/Samples/MerchantBoarding/MerchantBoardingCUP.cs new file mode 100644 index 0000000..371be12 --- /dev/null +++ b/Source/Samples/MerchantBoarding/MerchantBoardingCUP.cs @@ -0,0 +1,239 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.MerchantBoarding +{ + internal class MerchantBoardingCUP + { + + + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InlineResponse2012 Run() + { + + PostRegistrationBody reqObj = new PostRegistrationBody(); + + Boardingv1registrationsOrganizationInformation organizationInformation = new Boardingv1registrationsOrganizationInformation + { + ParentOrganizationId = "apitester00", + Type = Boardingv1registrationsOrganizationInformation.TypeEnum.MERCHANT, + Configurable = true + }; + + Boardingv1registrationsOrganizationInformationBusinessInformation businessInformation = new Boardingv1registrationsOrganizationInformationBusinessInformation + { + Name = "StuartWickedFastEatz" + }; + + Boardingv1registrationsOrganizationInformationBusinessInformationAddress address = new Boardingv1registrationsOrganizationInformationBusinessInformationAddress + { + Country = "US", + Address1 = "123456 SandMarket", + Locality = "ORMOND BEACH", + AdministrativeArea = "FL", + PostalCode = "32176" + }; + + businessInformation.Address = address; + businessInformation.WebsiteUrl = "https://www.StuartWickedEats.com"; + businessInformation.PhoneNumber = "6574567813"; + + Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact businessContact = new Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact + { + FirstName = "Stuart", + LastName = "Stuart", + PhoneNumber = "6574567813", + Email = "svc_email_bt@corpdev.visa.com" + }; + + businessInformation.BusinessContact = businessContact; + businessInformation.MerchantCategoryCode = "5999"; + organizationInformation.BusinessInformation = businessInformation; + + reqObj.OrganizationInformation = organizationInformation; + + Boardingv1registrationsProductInformation productInformation = new Boardingv1registrationsProductInformation(); + + Boardingv1registrationsProductInformationSelectedProducts selectedProducts = new Boardingv1registrationsProductInformationSelectedProducts(); + + PaymentsProducts payments = new PaymentsProducts(); + PaymentsProductsCardProcessing cardProcessing = new PaymentsProductsCardProcessing(); + PaymentsProductsCardProcessingSubscriptionInformation subscriptionInformation = new PaymentsProductsCardProcessingSubscriptionInformation + { + Enabled = true + }; + + Dictionary features = new Dictionary(); + + PaymentsProductsCardProcessingSubscriptionInformationFeatures obj1 = new PaymentsProductsCardProcessingSubscriptionInformationFeatures + { + Enabled = true + }; + + features.Add("cardNotPresent", obj1); + features.Add("cardPresent", obj1); + + subscriptionInformation.Features = features; + cardProcessing.SubscriptionInformation = subscriptionInformation; + + PaymentsProductsCardProcessingConfigurationInformation configurationInformation = new PaymentsProductsCardProcessingConfigurationInformation(); + + CardProcessingConfig configurations = new CardProcessingConfig(); + CardProcessingConfigCommon common = new CardProcessingConfigCommon + { + MerchantCategoryCode = "1799" + }; + + Dictionary processors = new Dictionary(); + + CardProcessingConfigCommonProcessors obj2 = new CardProcessingConfigCommonProcessors(); + CardProcessingConfigCommonAcquirer acquirer = new CardProcessingConfigCommonAcquirer + { + CountryCode = "344_hongkong", + InstitutionId = "22344" + }; + + obj2.Acquirer = acquirer; + + Dictionary currencies = new Dictionary(); + + CardProcessingConfigCommonCurrencies1 obj3 = new CardProcessingConfigCommonCurrencies1 + { + Enabled = true, + EnabledCardPresent = false, + EnabledCardNotPresent = true, + MerchantId = "112233", + TerminalId = "11224455", + ServiceEnablementNumber = "" + }; + + currencies.Add("HKD", obj3); + currencies.Add("AUD", obj3); + currencies.Add("USD", obj3); + + obj2.Currencies = currencies; + + Dictionary paymentTypes = new Dictionary(); + + CardProcessingConfigCommonPaymentTypes obj4 = new CardProcessingConfigCommonPaymentTypes + { + Enabled = true + }; + + paymentTypes.Add("CUP", obj4); + obj2.PaymentTypes = paymentTypes; + + processors.Add("CUP", obj2); + common.Processors = processors; + configurations.Common = common; + configurationInformation.Configurations = configurations; + + Guid templateId = Guid.Parse("1D8BC41A-F04E-4133-87C8-D89D1806106F"); + configurationInformation.TemplateId = templateId; + cardProcessing.ConfigurationInformation = configurationInformation; + payments.CardProcessing = cardProcessing; + + PaymentsProductsVirtualTerminal virtualTerminal = new PaymentsProductsVirtualTerminal(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation2 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + virtualTerminal.SubscriptionInformation = subscriptionInformation2; + + PaymentsProductsVirtualTerminalConfigurationInformation configurationInformation2 = new PaymentsProductsVirtualTerminalConfigurationInformation + { + TemplateId = Guid.Parse("9FA1BB94-5119-48D3-B2E5-A81FD3C657B5") + }; + + virtualTerminal.ConfigurationInformation = configurationInformation2; + payments.VirtualTerminal = virtualTerminal; + + PaymentsProductsTax customerInvoicing = new PaymentsProductsTax(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation3 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + customerInvoicing.SubscriptionInformation = subscriptionInformation3; + payments.CustomerInvoicing = customerInvoicing; + selectedProducts.Payments = payments; + + RiskProducts risk = new RiskProducts(); + selectedProducts.Risk = risk; + CommerceSolutionsProducts commerceSolutions = new CommerceSolutionsProducts(); + + CommerceSolutionsProductsTokenManagement tokenManagement = new CommerceSolutionsProductsTokenManagement(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation4 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + tokenManagement.SubscriptionInformation = subscriptionInformation4; + + CommerceSolutionsProductsTokenManagementConfigurationInformation configurationInformation3 = new CommerceSolutionsProductsTokenManagementConfigurationInformation + { + TemplateId = Guid.Parse("9FA1BB94-5119-48D3-B2E5-A81FD3C657B5") + }; + + tokenManagement.ConfigurationInformation = configurationInformation3; + commerceSolutions.TokenManagement = tokenManagement; + + selectedProducts.CommerceSolutions = commerceSolutions; + + ValueAddedServicesProducts valueAddedServices = new ValueAddedServicesProducts(); + + PaymentsProductsTax transactionSearch = new PaymentsProductsTax(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation5 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + transactionSearch.SubscriptionInformation = subscriptionInformation5; + valueAddedServices.TransactionSearch = transactionSearch; + + PaymentsProductsTax reporting = new PaymentsProductsTax + { + SubscriptionInformation = subscriptionInformation5 + }; + + valueAddedServices.Reporting = reporting; + selectedProducts.ValueAddedServices = valueAddedServices; + productInformation.SelectedProducts = selectedProducts; + reqObj.ProductInformation = productInformation; + + + + try + { + var configDictionary = new MerchantBoardingConfiguration().GetMerchantBoardingConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new MerchantBoardingApi(clientConfig); + InlineResponse2012 result = apiInstance.PostRegistration(reqObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/MerchantBoarding/MerchantBoardingEFTPOS.cs b/Source/Samples/MerchantBoarding/MerchantBoardingEFTPOS.cs new file mode 100644 index 0000000..df4d76c --- /dev/null +++ b/Source/Samples/MerchantBoarding/MerchantBoardingEFTPOS.cs @@ -0,0 +1,154 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.MerchantBoarding +{ + internal class MerchantBoardingEFTPOS + { + + + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InlineResponse2012 Run() + { + + + + PostRegistrationBody reqObj = new PostRegistrationBody(); + + Boardingv1registrationsOrganizationInformation organizationInformation = new Boardingv1registrationsOrganizationInformation + { + ParentOrganizationId = "apitester00", + Type = Boardingv1registrationsOrganizationInformation.TypeEnum.MERCHANT, + Configurable = true + }; + + Boardingv1registrationsOrganizationInformationBusinessInformation businessInformation = new Boardingv1registrationsOrganizationInformationBusinessInformation + { + Name = "StuartWickedFastEatz" + }; + + Boardingv1registrationsOrganizationInformationBusinessInformationAddress address = new Boardingv1registrationsOrganizationInformationBusinessInformationAddress + { + Country = "US", + Address1 = "123456 SandMarket", + Locality = "ORMOND BEACH", + AdministrativeArea = "FL", + PostalCode = "32176" + }; + + businessInformation.Address = address; + businessInformation.WebsiteUrl = "https://www.StuartWickedEats.com"; + businessInformation.PhoneNumber = "6574567813"; + + Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact businessContact = new Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact + { + FirstName = "Stuart", + LastName = "Stuart", + PhoneNumber = "6574567813", + Email = "svc_email_bt@corpdev.visa.com" + }; + + businessInformation.BusinessContact = businessContact; + businessInformation.MerchantCategoryCode = "5999"; + organizationInformation.BusinessInformation = businessInformation; + + reqObj.OrganizationInformation = organizationInformation; + + Boardingv1registrationsProductInformation productInformation = new Boardingv1registrationsProductInformation(); + Boardingv1registrationsProductInformationSelectedProducts selectedProducts = new Boardingv1registrationsProductInformationSelectedProducts(); + + PaymentsProducts payments = new PaymentsProducts(); + PaymentsProductsCardProcessing cardProcessing = new PaymentsProductsCardProcessing(); + PaymentsProductsCardProcessingSubscriptionInformation subscriptionInformation = new PaymentsProductsCardProcessingSubscriptionInformation + { + Enabled = true, + Features = new Dictionary + { + { "cardNotPresent", new PaymentsProductsCardProcessingSubscriptionInformationFeatures { Enabled = true } }, + { "cardPresent", new PaymentsProductsCardProcessingSubscriptionInformationFeatures { Enabled = false } } + } + }; + + cardProcessing.SubscriptionInformation = subscriptionInformation; + + PaymentsProductsCardProcessingConfigurationInformation configurationInformation = new PaymentsProductsCardProcessingConfigurationInformation(); + + CardProcessingConfig configurations = new CardProcessingConfig(); + CardProcessingConfigCommon common = new CardProcessingConfigCommon + { + MerchantCategoryCode = "5999", + PreferCobadgedSecondaryBrand = true, + Processors = new Dictionary + { + { + "EFTPOS", + new CardProcessingConfigCommonProcessors + { + Acquirer = new CardProcessingConfigCommonAcquirer + { + CountryCode = "344_hongkong", + InstitutionId = "22344" + }, + Currencies = new Dictionary + { + { "AUD", new CardProcessingConfigCommonCurrencies1 { Enabled = true, MerchantId = "12345612344", TerminalId = "12121212" } } + }, + PaymentTypes = new Dictionary + { + { "EFTPOS", new CardProcessingConfigCommonPaymentTypes { Enabled = true } } + }, + EnableCVVResponseIndicator = true, + EnableLeastCostRouting = true, + MerchantTier = "000" + } + } + } + }; + + configurations.Common = common; + configurations.Features = new CardProcessingConfigFeatures(); + configurationInformation.Configurations = configurations; + configurationInformation.TemplateId = Guid.Parse("1F9B7F6E-F0DB-44C8-BF8E-5013E34C0F87"); + Console.WriteLine("Template id........" + Guid.Parse("1F9B7F6E-F0DB-44C8-BF8E-5013E34C0F87")); + cardProcessing.ConfigurationInformation = configurationInformation; + payments.CardProcessing = cardProcessing; + selectedProducts.Payments = payments; + + productInformation.SelectedProducts = selectedProducts; + reqObj.ProductInformation = productInformation; + + + + try + { + var configDictionary = new MerchantBoardingConfiguration().GetMerchantBoardingConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new MerchantBoardingApi(clientConfig); + InlineResponse2012 result = apiInstance.PostRegistration(reqObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/MerchantBoarding/MerchantBoardingFDIGlobal.cs b/Source/Samples/MerchantBoarding/MerchantBoardingFDIGlobal.cs new file mode 100644 index 0000000..1798683 --- /dev/null +++ b/Source/Samples/MerchantBoarding/MerchantBoardingFDIGlobal.cs @@ -0,0 +1,198 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.MerchantBoarding +{ + internal class MerchantBoardingFDIGlobal + { + + + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InlineResponse2012 Run() + { + + PostRegistrationBody reqObj = new PostRegistrationBody(); + + Boardingv1registrationsOrganizationInformation organizationInformation = new Boardingv1registrationsOrganizationInformation + { + ParentOrganizationId = "apitester00", + Type = Boardingv1registrationsOrganizationInformation.TypeEnum.MERCHANT, + Configurable = true + }; + + Boardingv1registrationsOrganizationInformationBusinessInformation businessInformation = new Boardingv1registrationsOrganizationInformationBusinessInformation + { + Name = "StuartWickedFastEatz" + }; + + Boardingv1registrationsOrganizationInformationBusinessInformationAddress address = new Boardingv1registrationsOrganizationInformationBusinessInformationAddress + { + Country = "US", + Address1 = "123456 SandMarket", + Locality = "ORMOND BEACH", + AdministrativeArea = "FL", + PostalCode = "32176" + }; + + businessInformation.Address = address; + businessInformation.WebsiteUrl = "https://www.StuartWickedEats.com"; + businessInformation.PhoneNumber = "6574567813"; + + Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact businessContact = new Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact + { + FirstName = "Stuart", + LastName = "Stuart", + PhoneNumber = "6574567813", + Email = "svc_email_bt@corpdev.visa.com" + }; + + businessInformation.BusinessContact = businessContact; + businessInformation.MerchantCategoryCode = "5999"; + organizationInformation.BusinessInformation = businessInformation; + + reqObj.OrganizationInformation = organizationInformation; + + Boardingv1registrationsProductInformation productInformation = new Boardingv1registrationsProductInformation(); + Boardingv1registrationsProductInformationSelectedProducts selectedProducts = new Boardingv1registrationsProductInformationSelectedProducts(); + + PaymentsProducts payments = new PaymentsProducts(); + PaymentsProductsCardProcessing cardProcessing = new PaymentsProductsCardProcessing(); + PaymentsProductsCardProcessingSubscriptionInformation subscriptionInformation = new PaymentsProductsCardProcessingSubscriptionInformation + { + Enabled = true + }; + + var features = new Dictionary + { + { "cardNotPresent", new PaymentsProductsCardProcessingSubscriptionInformationFeatures { Enabled = true } }, + { "cardPresent", new PaymentsProductsCardProcessingSubscriptionInformationFeatures { Enabled = true } } + }; + + subscriptionInformation.Features = features; + cardProcessing.SubscriptionInformation = subscriptionInformation; + + PaymentsProductsCardProcessingConfigurationInformation configurationInformation = new PaymentsProductsCardProcessingConfigurationInformation(); + + CardProcessingConfig configurations = new CardProcessingConfig(); + CardProcessingConfigCommon common = new CardProcessingConfigCommon + { + MerchantCategoryCode = "0742", + DefaultAuthTypeCode = CardProcessingConfigCommon.DefaultAuthTypeCodeEnum.PRE, + ProcessLevel3Data = "ignored", + MasterCardAssignedId = "123456789", + EnablePartialAuth = true + }; + + var processors = new Dictionary(); + CardProcessingConfigCommonProcessors obj5 = new CardProcessingConfigCommonProcessors + { + Acquirer = new CardProcessingConfigCommonAcquirer() + }; + + var currencies = new Dictionary + { + { "CHF", new CardProcessingConfigCommonCurrencies1 { Enabled = true, EnabledCardPresent = false, EnabledCardNotPresent = true, MerchantId = "123456789mer", TerminalId = "12345ter", ServiceEnablementNumber = "" } }, + { "HRK", new CardProcessingConfigCommonCurrencies1 { Enabled = true, EnabledCardPresent = false, EnabledCardNotPresent = true, MerchantId = "123456789mer", TerminalId = "12345ter", ServiceEnablementNumber = "" } }, + { "ERN", new CardProcessingConfigCommonCurrencies1 { Enabled = true, EnabledCardPresent = false, EnabledCardNotPresent = true, MerchantId = "123456789mer", TerminalId = "12345ter", ServiceEnablementNumber = "" } }, + { "USD", new CardProcessingConfigCommonCurrencies1 { Enabled = true, EnabledCardPresent = false, EnabledCardNotPresent = true, MerchantId = "123456789mer", TerminalId = "12345ter", ServiceEnablementNumber = "" } } + }; + + obj5.Currencies = currencies; + + var paymentTypes = new Dictionary + { + { "MASTERCARD", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "DISCOVER", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "JCB", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "VISA", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "AMERICAN_EXPRESS", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "DINERS_CLUB", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "CUP", new CardProcessingConfigCommonPaymentTypes { Enabled = true } } + }; + + var currencies2 = new Dictionary + { + { "USD", new CardProcessingConfigCommonCurrencies { Enabled = true, TerminalId = "pint123", MerchantId = "pinm123", ServiceEnablementNumber = null } } + }; + + paymentTypes.Add("PIN_DEBIT", new CardProcessingConfigCommonPaymentTypes { Enabled = true, Currencies = currencies2 }); + + obj5.PaymentTypes = paymentTypes; + obj5.BatchGroup = "fdiglobal_vme_default"; + obj5.EnhancedData = "disabled"; + obj5.EnablePosNetworkSwitching = true; + obj5.EnableTransactionReferenceNumber = true; + + processors["fdiglobal"] = obj5; + + common.Processors = processors; + configurations.Common = common; + + CardProcessingConfigFeatures features2 = new CardProcessingConfigFeatures(); + CardProcessingConfigFeaturesCardNotPresent cardNotPresent = new CardProcessingConfigFeaturesCardNotPresent(); + + var processors3 = new Dictionary + { + { "fdiglobal", new CardProcessingConfigFeaturesCardNotPresentProcessors + { + RelaxAddressVerificationSystem = true, + RelaxAddressVerificationSystemAllowExpiredCard = true, + RelaxAddressVerificationSystemAllowZipWithoutCountry = true + } + } + }; + + cardNotPresent.Processors = processors3; + cardNotPresent.VisaStraightThroughProcessingOnly = true; + cardNotPresent.AmexTransactionAdviceAddendum1 = "amex12345"; + cardNotPresent.IgnoreAddressVerificationSystem = true; + + features2.CardNotPresent = cardNotPresent; + configurations.Features = features2; + configurationInformation.Configurations = configurations; + + Guid templateId = Guid.Parse("685A1FC9-3CEC-454C-9D8A-19205529CE45"); + configurationInformation.TemplateId = templateId; + + cardProcessing.ConfigurationInformation = configurationInformation; + payments.CardProcessing = cardProcessing; + selectedProducts.Payments = payments; + + productInformation.SelectedProducts = selectedProducts; + reqObj.ProductInformation = productInformation; + + + + try + { + var configDictionary = new MerchantBoardingConfiguration().GetMerchantBoardingConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new MerchantBoardingApi(clientConfig); + InlineResponse2012 result = apiInstance.PostRegistration(reqObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/MerchantBoarding/MerchantBoardingGPX.cs b/Source/Samples/MerchantBoarding/MerchantBoardingGPX.cs new file mode 100644 index 0000000..a8b132f --- /dev/null +++ b/Source/Samples/MerchantBoarding/MerchantBoardingGPX.cs @@ -0,0 +1,261 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.MerchantBoarding +{ + internal class MerchantBoardingGPX + { + + + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InlineResponse2012 Run() + { + + PostRegistrationBody reqObj = new PostRegistrationBody(); + + Boardingv1registrationsOrganizationInformation organizationInformation = new Boardingv1registrationsOrganizationInformation + { + ParentOrganizationId = "apitester00", + Type = Boardingv1registrationsOrganizationInformation.TypeEnum.MERCHANT, + Configurable = true + }; + + Boardingv1registrationsOrganizationInformationBusinessInformation businessInformation = new Boardingv1registrationsOrganizationInformationBusinessInformation + { + Name = "StuartWickedFastEatz" + }; + + Boardingv1registrationsOrganizationInformationBusinessInformationAddress address = new Boardingv1registrationsOrganizationInformationBusinessInformationAddress + { + Country = "US", + Address1 = "123456 SandMarket", + Locality = "ORMOND BEACH", + AdministrativeArea = "FL", + PostalCode = "32176" + }; + + businessInformation.Address = address; + businessInformation.WebsiteUrl = "https://www.StuartWickedEats.com"; + businessInformation.PhoneNumber = "6574567813"; + + Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact businessContact = new Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact + { + FirstName = "Stuart", + LastName = "Stuart", + PhoneNumber = "6574567813", + Email = "svc_email_bt@corpdev.visa.com" + }; + + businessInformation.BusinessContact = businessContact; + businessInformation.MerchantCategoryCode = "5999"; + organizationInformation.BusinessInformation = businessInformation; + + reqObj.OrganizationInformation = organizationInformation; + + Boardingv1registrationsProductInformation productInformation = new Boardingv1registrationsProductInformation(); + Boardingv1registrationsProductInformationSelectedProducts selectedProducts = new Boardingv1registrationsProductInformationSelectedProducts(); + + PaymentsProducts payments = new PaymentsProducts(); + PaymentsProductsCardProcessing cardProcessing = new PaymentsProductsCardProcessing(); + PaymentsProductsCardProcessingSubscriptionInformation subscriptionInformation = new PaymentsProductsCardProcessingSubscriptionInformation + { + Enabled = true, + Features = new Dictionary + { + { "cardNotPresent", new PaymentsProductsCardProcessingSubscriptionInformationFeatures { Enabled = true } }, + { "cardPresent", new PaymentsProductsCardProcessingSubscriptionInformationFeatures { Enabled = true } } + } + }; + + cardProcessing.SubscriptionInformation = subscriptionInformation; + + PaymentsProductsCardProcessingConfigurationInformation configurationInformation = new PaymentsProductsCardProcessingConfigurationInformation(); + CardProcessingConfig configurations = new CardProcessingConfig(); + CardProcessingConfigCommon common = new CardProcessingConfigCommon + { + MerchantCategoryCode = "1799", + DefaultAuthTypeCode = CardProcessingConfigCommon.DefaultAuthTypeCodeEnum.FINAL, + FoodAndConsumerServiceId = "1456", + MasterCardAssignedId = "4567", + SicCode = "1345", + EnablePartialAuth = false, + AllowCapturesGreaterThanAuthorizations = false, + EnableDuplicateMerchantReferenceNumberBlocking = false, + CreditCardRefundLimitPercent = "2", + BusinessCenterCreditCardRefundLimitPercent = "3", + Processors = new Dictionary + { + { "gpx", new CardProcessingConfigCommonProcessors + { + Acquirer = new CardProcessingConfigCommonAcquirer + { + CountryCode = "840_usa", + FileDestinationBin = "123456", + InterbankCardAssociationId = "1256", + InstitutionId = "113366", + DiscoverInstitutionId = "1567" + }, + Currencies = new Dictionary + { + { "AED", new CardProcessingConfigCommonCurrencies1 + { + Enabled = true, + EnabledCardPresent = false, + EnabledCardNotPresent = true, + TerminalId = "", + ServiceEnablementNumber = "" + } + } + }, + PaymentTypes = new Dictionary + { + { "MASTERCARD", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "DISCOVER", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "JCB", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "VISA", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "DINERS_CLUB", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "PIN_DEBIT", new CardProcessingConfigCommonPaymentTypes { Enabled = true } } + }, + AllowMultipleBills = true, + BatchGroup = "gpx", + BusinessApplicationId = "AA", + EnhancedData = "disabled", + FireSafetyIndicator = false, + AbaNumber = "1122445566778", + MerchantVerificationValue = "234", + QuasiCash = false, + MerchantId = "112233", + TerminalId = "112244" + } + } + } + }; + + configurations.Common = common; + + CardProcessingConfigFeatures features2 = new CardProcessingConfigFeatures + { + CardNotPresent = new CardProcessingConfigFeaturesCardNotPresent + { + Processors = new Dictionary + { + { "gpx", new CardProcessingConfigFeaturesCardNotPresentProcessors + { + EnableEmsTransactionRiskScore = true, + RelaxAddressVerificationSystem = true, + RelaxAddressVerificationSystemAllowExpiredCard = true, + RelaxAddressVerificationSystemAllowZipWithoutCountry = true + } + } + }, + VisaStraightThroughProcessingOnly = false, + IgnoreAddressVerificationSystem = false + }, + CardPresent = new CardProcessingConfigFeaturesCardPresent + { + Processors = new Dictionary + { + { "gpx", new CardProcessingConfigFeaturesCardPresentProcessors + { + FinancialInstitutionId = "1347", + PinDebitNetworkOrder = "23456", + PinDebitReimbursementCode = "43567", + DefaultPointOfSaleTerminalId = "5432" + } + } + }, + EnableTerminalIdLookup = false + } + }; + + configurations.Features = features2; + configurationInformation.Configurations = configurations; + configurationInformation.TemplateId = Guid.Parse("D2A7C000-5FCA-493A-AD21-469744A19EEA"); + + cardProcessing.ConfigurationInformation = configurationInformation; + payments.CardProcessing = cardProcessing; + + PaymentsProductsVirtualTerminal virtualTerminal = new PaymentsProductsVirtualTerminal + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true }, + ConfigurationInformation = new PaymentsProductsVirtualTerminalConfigurationInformation { TemplateId = Guid.Parse("9FA1BB94-5119-48D3-B2E5-A81FD3C657B5") } + }; + + payments.VirtualTerminal = virtualTerminal; + + PaymentsProductsTax customerInvoicing = new PaymentsProductsTax + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true } + }; + + payments.CustomerInvoicing = customerInvoicing; + selectedProducts.Payments = payments; + + RiskProducts risk = new RiskProducts(); + selectedProducts.Risk = risk; + + CommerceSolutionsProducts commerceSolutions = new CommerceSolutionsProducts(); + CommerceSolutionsProductsTokenManagement tokenManagement = new CommerceSolutionsProductsTokenManagement + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true }, + ConfigurationInformation = new CommerceSolutionsProductsTokenManagementConfigurationInformation { TemplateId = Guid.Parse("D62BEE20-DCFD-4AA2-8723-BA3725958ABA") } + }; + + commerceSolutions.TokenManagement = tokenManagement; + selectedProducts.CommerceSolutions = commerceSolutions; + + ValueAddedServicesProducts valueAddedServices = new ValueAddedServicesProducts(); + + PaymentsProductsTax transactionSearch = new PaymentsProductsTax + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true } + }; + + valueAddedServices.TransactionSearch = transactionSearch; + + PaymentsProductsTax reporting = new PaymentsProductsTax + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true } + }; + + valueAddedServices.Reporting = reporting; + + selectedProducts.ValueAddedServices = valueAddedServices; + productInformation.SelectedProducts = selectedProducts; + reqObj.ProductInformation = productInformation; + + + + try + { + var configDictionary = new MerchantBoardingConfiguration().GetMerchantBoardingConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new MerchantBoardingApi(clientConfig); + InlineResponse2012 result = apiInstance.PostRegistration(reqObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/MerchantBoarding/MerchantBoardingSmartFDC.cs b/Source/Samples/MerchantBoarding/MerchantBoardingSmartFDC.cs new file mode 100644 index 0000000..e6ce488 --- /dev/null +++ b/Source/Samples/MerchantBoarding/MerchantBoardingSmartFDC.cs @@ -0,0 +1,198 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.MerchantBoarding +{ + internal class MerchantBoardingSmartFDC + { + + + + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InlineResponse2012 Run() + { + + PostRegistrationBody reqObj = new PostRegistrationBody(); + + Boardingv1registrationsOrganizationInformation organizationInformation = new Boardingv1registrationsOrganizationInformation + { + ParentOrganizationId = "apitester00", + Type = Boardingv1registrationsOrganizationInformation.TypeEnum.MERCHANT, + Configurable = true + }; + + Boardingv1registrationsOrganizationInformationBusinessInformation businessInformation = new Boardingv1registrationsOrganizationInformationBusinessInformation + { + Name = "StuartWickedFastEatz" + }; + + Boardingv1registrationsOrganizationInformationBusinessInformationAddress address = new Boardingv1registrationsOrganizationInformationBusinessInformationAddress + { + Country = "US", + Address1 = "123456 SandMarket", + Locality = "ORMOND BEACH", + AdministrativeArea = "FL", + PostalCode = "32176" + }; + + businessInformation.Address = address; + businessInformation.WebsiteUrl = "https://www.StuartWickedEats.com"; + businessInformation.PhoneNumber = "6574567813"; + + Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact businessContact = new Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact + { + FirstName = "Stuart", + LastName = "Stuart", + PhoneNumber = "6574567813", + Email = "svc_email_bt@corpdev.visa.com" + }; + + businessInformation.BusinessContact = businessContact; + businessInformation.MerchantCategoryCode = "5999"; + organizationInformation.BusinessInformation = businessInformation; + + reqObj.OrganizationInformation = organizationInformation; + + Boardingv1registrationsProductInformation productInformation = new Boardingv1registrationsProductInformation(); + Boardingv1registrationsProductInformationSelectedProducts selectedProducts = new Boardingv1registrationsProductInformationSelectedProducts(); + + PaymentsProducts payments = new PaymentsProducts(); + PaymentsProductsCardProcessing cardProcessing = new PaymentsProductsCardProcessing(); + PaymentsProductsCardProcessingSubscriptionInformation subscriptionInformation = new PaymentsProductsCardProcessingSubscriptionInformation + { + Enabled = true + }; + + var features = new Dictionary + { + { "cardNotPresent", new PaymentsProductsCardProcessingSubscriptionInformationFeatures { Enabled = true } }, + { "cardPresent", new PaymentsProductsCardProcessingSubscriptionInformationFeatures { Enabled = true } } + }; + + subscriptionInformation.Features = features; + cardProcessing.SubscriptionInformation = subscriptionInformation; + + PaymentsProductsCardProcessingConfigurationInformation configurationInformation = new PaymentsProductsCardProcessingConfigurationInformation(); + CardProcessingConfig configurations = new CardProcessingConfig(); + CardProcessingConfigCommon common = new CardProcessingConfigCommon + { + MerchantCategoryCode = "1799", + DefaultAuthTypeCode = CardProcessingConfigCommon.DefaultAuthTypeCodeEnum.FINAL, + EnablePartialAuth = true + }; + + var processors = new Dictionary + { + { + "smartfdc", new CardProcessingConfigCommonProcessors + { + Acquirer = new CardProcessingConfigCommonAcquirer(), + PaymentTypes = new Dictionary + { + { "MASTERCARD", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "DISCOVER", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "JCB", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "VISA", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "DINERS_CLUB", new CardProcessingConfigCommonPaymentTypes { Enabled = true } }, + { "AMERICAN_EXPRESS", new CardProcessingConfigCommonPaymentTypes { Enabled = true } } + }, + BatchGroup = "smartfdc_00", + MerchantId = "00001234567", + TerminalId = "00007654321" + } + } + }; + + common.Processors = processors; + configurations.Common = common; + configurationInformation.Configurations = configurations; + + configurationInformation.TemplateId = Guid.Parse("3173DA78-A71E-405B-B79C-928C1A9C6AB2"); + cardProcessing.ConfigurationInformation = configurationInformation; + payments.CardProcessing = cardProcessing; + + PaymentsProductsVirtualTerminal virtualTerminal = new PaymentsProductsVirtualTerminal + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true }, + ConfigurationInformation = new PaymentsProductsVirtualTerminalConfigurationInformation { TemplateId = Guid.Parse("9FA1BB94-5119-48D3-B2E5-A81FD3C657B5") } + }; + + payments.VirtualTerminal = virtualTerminal; + + PaymentsProductsTax customerInvoicing = new PaymentsProductsTax + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true } + }; + + payments.CustomerInvoicing = customerInvoicing; + selectedProducts.Payments = payments; + + RiskProducts risk = new RiskProducts(); + selectedProducts.Risk = risk; + + CommerceSolutionsProducts commerceSolutions = new CommerceSolutionsProducts(); + + CommerceSolutionsProductsTokenManagement tokenManagement = new CommerceSolutionsProductsTokenManagement + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true }, + ConfigurationInformation = new CommerceSolutionsProductsTokenManagementConfigurationInformation { TemplateId = Guid.Parse("D62BEE20-DCFD-4AA2-8723-BA3725958ABA") } + }; + + commerceSolutions.TokenManagement = tokenManagement; + selectedProducts.CommerceSolutions = commerceSolutions; + + ValueAddedServicesProducts valueAddedServices = new ValueAddedServicesProducts(); + + PaymentsProductsTax transactionSearch = new PaymentsProductsTax + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true } + }; + + valueAddedServices.TransactionSearch = transactionSearch; + + PaymentsProductsTax reporting = new PaymentsProductsTax + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true } + }; + + valueAddedServices.Reporting = reporting; + selectedProducts.ValueAddedServices = valueAddedServices; + + productInformation.SelectedProducts = selectedProducts; + reqObj.ProductInformation = productInformation; + + + + try + { + var configDictionary = new MerchantBoardingConfiguration().GetMerchantBoardingConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new MerchantBoardingApi(clientConfig); + InlineResponse2012 result = apiInstance.PostRegistration(reqObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/MerchantBoarding/MerchantBoardingTSYS.cs b/Source/Samples/MerchantBoarding/MerchantBoardingTSYS.cs new file mode 100644 index 0000000..b8c2dfe --- /dev/null +++ b/Source/Samples/MerchantBoarding/MerchantBoardingTSYS.cs @@ -0,0 +1,273 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.MerchantBoarding +{ + internal class MerchantBoardingTSYS + { + + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InlineResponse2012 Run() + { + + + PostRegistrationBody reqObj = new PostRegistrationBody(); + + Boardingv1registrationsOrganizationInformation organizationInformation = new Boardingv1registrationsOrganizationInformation + { + ParentOrganizationId = "apitester00", + Type = Boardingv1registrationsOrganizationInformation.TypeEnum.MERCHANT, + Configurable = true + }; + + Boardingv1registrationsOrganizationInformationBusinessInformation businessInformation = new Boardingv1registrationsOrganizationInformationBusinessInformation + { + Name = "StuartWickedFastEatz" + }; + + Boardingv1registrationsOrganizationInformationBusinessInformationAddress address = new Boardingv1registrationsOrganizationInformationBusinessInformationAddress + { + Country = "US", + Address1 = "123456 SandMarket", + Locality = "ORMOND BEACH", + AdministrativeArea = "FL", + PostalCode = "32176" + }; + + businessInformation.Address = address; + businessInformation.WebsiteUrl = "https://www.StuartWickedEats.com"; + businessInformation.PhoneNumber = "6574567813"; + + Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact businessContact = new Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact + { + FirstName = "Stuart", + LastName = "Stuart", + PhoneNumber = "6574567813", + Email = "svc_email_bt@corpdev.visa.com" + }; + + businessInformation.BusinessContact = businessContact; + businessInformation.MerchantCategoryCode = "5999"; + organizationInformation.BusinessInformation = businessInformation; + + reqObj.OrganizationInformation = organizationInformation; + + Boardingv1registrationsProductInformation productInformation = new Boardingv1registrationsProductInformation(); + Boardingv1registrationsProductInformationSelectedProducts selectedProducts = new Boardingv1registrationsProductInformationSelectedProducts(); + + PaymentsProducts payments = new PaymentsProducts(); + PaymentsProductsCardProcessing cardProcessing = new PaymentsProductsCardProcessing(); + PaymentsProductsCardProcessingSubscriptionInformation subscriptionInformation = new PaymentsProductsCardProcessingSubscriptionInformation(); + + subscriptionInformation.Enabled = true; + var features = new Dictionary(); + + PaymentsProductsCardProcessingSubscriptionInformationFeatures obj1 = new PaymentsProductsCardProcessingSubscriptionInformationFeatures + { + Enabled = true + }; + features["cardNotPresent"] = obj1; + features["cardPresent"] = obj1; + subscriptionInformation.Features = features; + cardProcessing.SubscriptionInformation = subscriptionInformation; + + PaymentsProductsCardProcessingConfigurationInformation configurationInformation = new PaymentsProductsCardProcessingConfigurationInformation(); + + CardProcessingConfig configurations = new CardProcessingConfig(); + CardProcessingConfigCommon common = new CardProcessingConfigCommon + { + MerchantCategoryCode = "5999", + ProcessLevel3Data = "ignored", + DefaultAuthTypeCode = CardProcessingConfigCommon.DefaultAuthTypeCodeEnum.FINAL, + EnablePartialAuth = false, + AmexVendorCode = "2233" + }; + + CardProcessingConfigCommonMerchantDescriptorInformation merchantDescriptorInformation = new CardProcessingConfigCommonMerchantDescriptorInformation + { + City = "cupertino", + Country = "USA", + Name = "kumar", + State = "CA", + Phone = "888555333", + Zip = "94043", + Street = "steet1" + }; + + common.MerchantDescriptorInformation = merchantDescriptorInformation; + + var processors = new Dictionary(); + CardProcessingConfigCommonProcessors obj5 = new CardProcessingConfigCommonProcessors + { + Acquirer = new CardProcessingConfigCommonAcquirer() + }; + + var currencies = new Dictionary(); + CardProcessingConfigCommonCurrencies1 obj6 = new CardProcessingConfigCommonCurrencies1 + { + Enabled = true, + EnabledCardPresent = true, + EnabledCardNotPresent = true, + TerminalId = "1234", + ServiceEnablementNumber = "" + }; + + currencies["CAD"] = obj6; + obj5.Currencies = currencies; + + var paymentTypes = new Dictionary(); + CardProcessingConfigCommonPaymentTypes obj7 = new CardProcessingConfigCommonPaymentTypes + { + Enabled = true + }; + + paymentTypes["MASTERCARD"] = obj7; + paymentTypes["VISA"] = obj7; + + obj5.PaymentTypes = paymentTypes; + + obj5.BankNumber = "234576"; + obj5.ChainNumber = "223344"; + obj5.BatchGroup = "vital_1130"; + obj5.EnhancedData = "disabled"; + obj5.IndustryCode = CardProcessingConfigCommonProcessors.IndustryCodeEnum.D; + obj5.MerchantBinNumber = "765576"; + obj5.MerchantId = "834215123456"; + obj5.MerchantLocationNumber = "00001"; + obj5.StoreID = "2563"; + obj5.VitalNumber = "71234567"; + obj5.QuasiCash = false; + obj5.SendAmexLevel2Data = null; + obj5.SoftDescriptorType = "1 - trans_ref_no"; + obj5.TravelAgencyCode = "2356"; + obj5.TravelAgencyName = "Agent"; + + processors["tsys"] = obj5; + common.Processors = processors; + + configurations.Common = common; + + CardProcessingConfigFeatures features2 = new CardProcessingConfigFeatures(); + CardProcessingConfigFeaturesCardNotPresent cardNotPresent = new CardProcessingConfigFeaturesCardNotPresent + { + VisaStraightThroughProcessingOnly = false, + AmexTransactionAdviceAddendum1 = null + }; + + features2.CardNotPresent = cardNotPresent; + + configurations.Features = features2; + configurationInformation.Configurations = configurations; + configurationInformation.TemplateId = new Guid("818048AD-2860-4D2D-BC39-2447654628A1"); + + cardProcessing.ConfigurationInformation = configurationInformation; + payments.CardProcessing = cardProcessing; + + PaymentsProductsVirtualTerminal virtualTerminal = new PaymentsProductsVirtualTerminal(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation5 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + virtualTerminal.SubscriptionInformation = subscriptionInformation5; + + PaymentsProductsVirtualTerminalConfigurationInformation configurationInformation5 = new PaymentsProductsVirtualTerminalConfigurationInformation + { + TemplateId = new Guid("9FA1BB94-5119-48D3-B2E5-A81FD3C657B5") + }; + + virtualTerminal.ConfigurationInformation = configurationInformation5; + payments.VirtualTerminal = virtualTerminal; + + PaymentsProductsTax customerInvoicing = new PaymentsProductsTax(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation6 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + customerInvoicing.SubscriptionInformation = subscriptionInformation6; + payments.CustomerInvoicing = customerInvoicing; + + selectedProducts.Payments = payments; + + RiskProducts risk = new RiskProducts(); + selectedProducts.Risk = risk; + + CommerceSolutionsProducts commerceSolutions = new CommerceSolutionsProducts(); + CommerceSolutionsProductsTokenManagement tokenManagement = new CommerceSolutionsProductsTokenManagement(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation7 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + tokenManagement.SubscriptionInformation = subscriptionInformation7; + + CommerceSolutionsProductsTokenManagementConfigurationInformation configurationInformation7 = new CommerceSolutionsProductsTokenManagementConfigurationInformation + { + TemplateId = new Guid("D62BEE20-DCFD-4AA2-8723-BA3725958ABA") + }; + + tokenManagement.ConfigurationInformation = configurationInformation7; + commerceSolutions.TokenManagement = tokenManagement; + selectedProducts.CommerceSolutions = commerceSolutions; + + ValueAddedServicesProducts valueAddedServices = new ValueAddedServicesProducts(); + + PaymentsProductsTax transactionSearch = new PaymentsProductsTax(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation9 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + transactionSearch.SubscriptionInformation = subscriptionInformation9; + valueAddedServices.TransactionSearch = transactionSearch; + + PaymentsProductsTax reporting = new PaymentsProductsTax(); + PaymentsProductsPayerAuthenticationSubscriptionInformation subscriptionInformation3 = new PaymentsProductsPayerAuthenticationSubscriptionInformation + { + Enabled = true + }; + + reporting.SubscriptionInformation = subscriptionInformation3; + valueAddedServices.Reporting = reporting; + + selectedProducts.ValueAddedServices = valueAddedServices; + + productInformation.SelectedProducts = selectedProducts; + reqObj.ProductInformation = productInformation; + + + + try + { + var configDictionary = new MerchantBoardingConfiguration().GetMerchantBoardingConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new MerchantBoardingApi(clientConfig); + InlineResponse2012 result = apiInstance.PostRegistration(reqObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/MerchantBoarding/MerchantBoardingVPC.cs b/Source/Samples/MerchantBoarding/MerchantBoardingVPC.cs new file mode 100644 index 0000000..0617b11 --- /dev/null +++ b/Source/Samples/MerchantBoarding/MerchantBoardingVPC.cs @@ -0,0 +1,272 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.MerchantBoarding +{ + internal class MerchantBoardingVPC + { + + + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static InlineResponse2012 Run() + { + + PostRegistrationBody reqObj = new PostRegistrationBody(); + + Boardingv1registrationsOrganizationInformation organizationInformation = new Boardingv1registrationsOrganizationInformation + { + ParentOrganizationId = "apitester00", + Type = Boardingv1registrationsOrganizationInformation.TypeEnum.MERCHANT, + Configurable = true + }; + + Boardingv1registrationsOrganizationInformationBusinessInformation businessInformation = new Boardingv1registrationsOrganizationInformationBusinessInformation + { + Name = "StuartWickedFastEatz" + }; + + Boardingv1registrationsOrganizationInformationBusinessInformationAddress address = new Boardingv1registrationsOrganizationInformationBusinessInformationAddress + { + Country = "US", + Address1 = "123456 SandMarket", + Locality = "ORMOND BEACH", + AdministrativeArea = "FL", + PostalCode = "32176" + }; + + businessInformation.Address = address; + businessInformation.WebsiteUrl = "https://www.StuartWickedEats.com"; + businessInformation.PhoneNumber = "6574567813"; + + Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact businessContact = new Boardingv1registrationsOrganizationInformationBusinessInformationBusinessContact + { + FirstName = "Stuart", + LastName = "Stuart", + PhoneNumber = "6574567813", + Email = "svc_email_bt@corpdev.visa.com" + }; + + businessInformation.BusinessContact = businessContact; + businessInformation.MerchantCategoryCode = "5999"; + organizationInformation.BusinessInformation = businessInformation; + + reqObj.OrganizationInformation = organizationInformation; + + + + + Boardingv1registrationsProductInformation productInformation = new Boardingv1registrationsProductInformation(); + Boardingv1registrationsProductInformationSelectedProducts selectedProducts = new Boardingv1registrationsProductInformationSelectedProducts(); + + PaymentsProducts payments = new PaymentsProducts(); + PaymentsProductsCardProcessing cardProcessing = new PaymentsProductsCardProcessing(); + PaymentsProductsCardProcessingSubscriptionInformation subscriptionInformation = new PaymentsProductsCardProcessingSubscriptionInformation + { + Enabled = true, + Features = new Dictionary + { + { "cardNotPresent", new PaymentsProductsCardProcessingSubscriptionInformationFeatures { Enabled = true } }, + { "cardPresent", new PaymentsProductsCardProcessingSubscriptionInformationFeatures { Enabled = true } } + } + }; + cardProcessing.SubscriptionInformation = subscriptionInformation; + + PaymentsProductsCardProcessingConfigurationInformation configurationInformation = new PaymentsProductsCardProcessingConfigurationInformation(); + CardProcessingConfig configurations = new CardProcessingConfig(); + CardProcessingConfigCommon common = new CardProcessingConfigCommon + { + MerchantCategoryCode = "1799", + DefaultAuthTypeCode = CardProcessingConfigCommon.DefaultAuthTypeCodeEnum.FINAL, + MasterCardAssignedId = null, + SicCode = null, + EnablePartialAuth = false, + EnableInterchangeOptimization = false, + EnableSplitShipment = false, + VisaDelegatedAuthenticationId = "123457", + DomesticMerchantId = false, + CreditCardRefundLimitPercent = "2", + BusinessCenterCreditCardRefundLimitPercent = "3", + AllowCapturesGreaterThanAuthorizations = false, + EnableDuplicateMerchantReferenceNumberBlocking = false, + Processors = new Dictionary + { + { + "VPC", new CardProcessingConfigCommonProcessors + { + Acquirer = new CardProcessingConfigCommonAcquirer + { + CountryCode = "840_usa", + FileDestinationBin = "444500", + InterbankCardAssociationId = "3684", + InstitutionId = "444571", + DiscoverInstitutionId = null + }, + PaymentTypes = new Dictionary + { + { + "VISA", new CardProcessingConfigCommonPaymentTypes + { + Enabled = true, + Currencies = new Dictionary + { + { + "CAD", new CardProcessingConfigCommonCurrencies + { + Enabled = true, + EnabledCardPresent = false, + EnabledCardNotPresent = true, + TerminalId = "113366", + MerchantId = "113355", + ServiceEnablementNumber = null + } + }, + { + "USD", new CardProcessingConfigCommonCurrencies + { + Enabled = true, + EnabledCardPresent = false, + EnabledCardNotPresent = true, + TerminalId = "113366", + MerchantId = "113355", + ServiceEnablementNumber = null + } + } + } + } + } + }, + AcquirerMerchantId = "123456", + AllowMultipleBills = false, + BatchGroup = "vdcvantiv_est_00", + BusinessApplicationId = "AA", + EnableAutoAuthReversalAfterVoid = true, + EnableExpresspayPanTranslation = null, + MerchantVerificationValue = "123456", + QuasiCash = false, + EnableTransactionReferenceNumber = true + } + } + } + }; + configurations.Common = common; + + CardProcessingConfigFeatures features2 = new CardProcessingConfigFeatures + { + CardNotPresent = new CardProcessingConfigFeaturesCardNotPresent + { + Processors = new Dictionary + { + { + "VPC", new CardProcessingConfigFeaturesCardNotPresentProcessors + { + EnableEmsTransactionRiskScore = null, + RelaxAddressVerificationSystem = true, + RelaxAddressVerificationSystemAllowExpiredCard = true, + RelaxAddressVerificationSystemAllowZipWithoutCountry = true + } + } + }, + VisaStraightThroughProcessingOnly = false, + IgnoreAddressVerificationSystem = true + }, + CardPresent = new CardProcessingConfigFeaturesCardPresent + { + Processors = new Dictionary + { + { + "VPC", new CardProcessingConfigFeaturesCardPresentProcessors + { + DefaultPointOfSaleTerminalId = "223344" + } + } + }, + EnableTerminalIdLookup = false + } + }; + configurations.Features = features2; + configurationInformation.Configurations = configurations; + configurationInformation.TemplateId = Guid.Parse("D671CE88-2F09-469C-A1B4-52C47812F792"); + + cardProcessing.ConfigurationInformation = configurationInformation; + payments.CardProcessing = cardProcessing; + + PaymentsProductsVirtualTerminal virtualTerminal = new PaymentsProductsVirtualTerminal + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true }, + ConfigurationInformation = new PaymentsProductsVirtualTerminalConfigurationInformation { TemplateId = Guid.Parse("9FA1BB94-5119-48D3-B2E5-A81FD3C657B5") } + }; + payments.VirtualTerminal = virtualTerminal; + + PaymentsProductsTax customerInvoicing = new PaymentsProductsTax + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true } + }; + payments.CustomerInvoicing = customerInvoicing; + + selectedProducts.Payments = payments; + + RiskProducts risk = new RiskProducts(); + selectedProducts.Risk = risk; + + CommerceSolutionsProducts commerceSolutions = new CommerceSolutionsProducts(); + CommerceSolutionsProductsTokenManagement tokenManagement = new CommerceSolutionsProductsTokenManagement + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true }, + ConfigurationInformation = new CommerceSolutionsProductsTokenManagementConfigurationInformation { TemplateId = Guid.Parse("D62BEE20-DCFD-4AA2-8723-BA3725958ABA") } + }; + commerceSolutions.TokenManagement = tokenManagement; + selectedProducts.CommerceSolutions = commerceSolutions; + + ValueAddedServicesProducts valueAddedServices = new ValueAddedServicesProducts(); + + PaymentsProductsTax transactionSearch = new PaymentsProductsTax + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true } + }; + valueAddedServices.TransactionSearch = transactionSearch; + + PaymentsProductsTax reporting = new PaymentsProductsTax + { + SubscriptionInformation = new PaymentsProductsPayerAuthenticationSubscriptionInformation { Enabled = true } + }; + valueAddedServices.Reporting = reporting; + + selectedProducts.ValueAddedServices = valueAddedServices; + + productInformation.SelectedProducts = selectedProducts; + reqObj.ProductInformation = productInformation; + + + + try + { + var configDictionary = new MerchantBoardingConfiguration().GetMerchantBoardingConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new MerchantBoardingApi(clientConfig); + InlineResponse2012 result = apiInstance.PostRegistration(reqObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/NetworkToken/CreateInstrumentIdentifierEnrollForNetworkToken.cs b/Source/Samples/NetworkToken/CreateInstrumentIdentifierEnrollForNetworkToken.cs new file mode 100644 index 0000000..d8dffdf --- /dev/null +++ b/Source/Samples/NetworkToken/CreateInstrumentIdentifierEnrollForNetworkToken.cs @@ -0,0 +1,42 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; + +namespace Cybersource_rest_samples_dotnet.Samples.NetworkToken +{ + public class CreateInstrumentIdentifierEnrollForNetworkToken + { + public static PostInstrumentIdentifierRequest Run() + { + var profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + string type = "enrollable card"; + string cardNumber = "5204245750003216"; + string cardExpirationMonth = "12"; + string cardExpirationYear = "2025"; + TmsEmbeddedInstrumentIdentifierCard card = new TmsEmbeddedInstrumentIdentifierCard( + Number: cardNumber, + ExpirationMonth: cardExpirationMonth, + ExpirationYear: cardExpirationYear + ); + var requestObj = new PostInstrumentIdentifierRequest( + Type: type, + Card: card + ); + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InstrumentIdentifierApi(clientConfig); + PostInstrumentIdentifierRequest result = apiInstance.PostInstrumentIdentifier(requestObj, profileid); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/NetworkToken/NetworkToken.cs b/Source/Samples/NetworkToken/NetworkToken.cs new file mode 100644 index 0000000..5e38b93 --- /dev/null +++ b/Source/Samples/NetworkToken/NetworkToken.cs @@ -0,0 +1,40 @@ +using CyberSource.Utilities; + +using System.Collections.Generic; +using AuthenticationSdk.core; +using System; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.NetworkToken +{ + public class NetworkToken + { + public static String Run() + { + + Dictionary configDictionary = new Configuration().GetConfiguration(); + + MerchantConfig merchantConfig = new MerchantConfig(configDictionary); + + try + { + // Step-I + PostInstrumentIdentifierRequest createInstrumentIdentifierEnrollForNetworkTokenResponse = CreateInstrumentIdentifierEnrollForNetworkToken.Run(); + + //Step-II + var encodedResponse = PaymentCredentialsFromNetworkToken.Run(createInstrumentIdentifierEnrollForNetworkTokenResponse.Id); + + //Step-III + var result = JWEUtility.DecryptJWEResponse(encodedResponse, merchantConfig); + + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception while decrypting the JWE Response : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/NetworkToken/PaymentCredentialsFromNetworkToken.cs b/Source/Samples/NetworkToken/PaymentCredentialsFromNetworkToken.cs new file mode 100644 index 0000000..fc7aecd --- /dev/null +++ b/Source/Samples/NetworkToken/PaymentCredentialsFromNetworkToken.cs @@ -0,0 +1,34 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; + +namespace Cybersource_rest_samples_dotnet.Samples.NetworkToken +{ + public class PaymentCredentialsFromNetworkToken + { + public static string Run(string TokenId = null) + { + var profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + if (null == TokenId) + { + TokenId = CreateInstrumentIdentifierEnrollForNetworkToken.Run().Id; + } + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new TokenApi(clientConfig); + var postPaymentCredentialsRequest = new PostPaymentCredentialsRequest(); + var result = apiInstance.PostTokenPaymentCredentials(TokenId, postPaymentCredentialsRequest, profileid); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/AuthenticationWithNORedirect.cs b/Source/Samples/PayerAuthentication/AuthenticationWithNORedirect.cs new file mode 100644 index 0000000..479bc7f --- /dev/null +++ b/Source/Samples/PayerAuthentication/AuthenticationWithNORedirect.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class AuthenticationWithNORedirect + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationsPost201Response Run() + { + string clientReferenceInformationCode = "cybs_test"; + string clientReferenceInformationPartnerDeveloperId = "7891234"; + string clientReferenceInformationPartnerSolutionId = "89012345"; + Riskv1decisionsClientReferenceInformationPartner clientReferenceInformationPartner = new Riskv1decisionsClientReferenceInformationPartner( + DeveloperId: clientReferenceInformationPartnerDeveloperId, + SolutionId: clientReferenceInformationPartnerSolutionId + ); + + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "10.99"; + Riskv1authenticationsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1authenticationsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToAddress2 = "Address 2"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToPhoneNumber = "4158880000"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPostalCode = "94105"; + Riskv1authenticationsOrderInformationBillTo orderInformationBillTo = new Riskv1authenticationsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1authenticationsOrderInformation orderInformation = new Riskv1authenticationsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string paymentInformationCardType = "001"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + string paymentInformationCardNumber = "4000990000000004"; + Riskv1authenticationsetupsPaymentInformationCard paymentInformationCard = new Riskv1authenticationsetupsPaymentInformationCard( + Type: paymentInformationCardType, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Number: paymentInformationCardNumber + ); + + Riskv1authenticationsPaymentInformation paymentInformation = new Riskv1authenticationsPaymentInformation( + Card: paymentInformationCard + ); + + var requestObj = new CheckPayerAuthEnrollmentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationsPost201Response result = apiInstance.CheckPayerAuthEnrollment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/AuthenticationWithNewAccount.cs b/Source/Samples/PayerAuthentication/AuthenticationWithNewAccount.cs new file mode 100644 index 0000000..def1ae2 --- /dev/null +++ b/Source/Samples/PayerAuthentication/AuthenticationWithNewAccount.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class AuthenticationWithNewAccount + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationsPost201Response Run() + { + string clientReferenceInformationCode = "New Account"; + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "10.99"; + Riskv1authenticationsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1authenticationsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToAddress2 = "Address 2"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToPhoneNumber = "4158880000"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPostalCode = "94105"; + Riskv1authenticationsOrderInformationBillTo orderInformationBillTo = new Riskv1authenticationsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1authenticationsOrderInformation orderInformation = new Riskv1authenticationsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string paymentInformationCardType = "001"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + string paymentInformationCardNumber = "4000990000000004"; + Riskv1authenticationsetupsPaymentInformationCard paymentInformationCard = new Riskv1authenticationsetupsPaymentInformationCard( + Type: paymentInformationCardType, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Number: paymentInformationCardNumber + ); + + Riskv1authenticationsPaymentInformation paymentInformation = new Riskv1authenticationsPaymentInformation( + Card: paymentInformationCard + ); + + string consumerAuthenticationInformationTransactionMode = "MOTO"; + Riskv1decisionsConsumerAuthenticationInformation consumerAuthenticationInformation = new Riskv1decisionsConsumerAuthenticationInformation( + TransactionMode: consumerAuthenticationInformationTransactionMode + ); + + string riskInformationBuyerHistoryCustomerAccountCreationHistory = "NEW_ACCOUNT"; + Ptsv2paymentsRiskInformationBuyerHistoryCustomerAccount riskInformationBuyerHistoryCustomerAccount = new Ptsv2paymentsRiskInformationBuyerHistoryCustomerAccount( + CreationHistory: riskInformationBuyerHistoryCustomerAccountCreationHistory + ); + + bool riskInformationBuyerHistoryAccountHistoryFirstUseOfShippingAddress = false; + Ptsv2paymentsRiskInformationBuyerHistoryAccountHistory riskInformationBuyerHistoryAccountHistory = new Ptsv2paymentsRiskInformationBuyerHistoryAccountHistory( + FirstUseOfShippingAddress: riskInformationBuyerHistoryAccountHistoryFirstUseOfShippingAddress + ); + + Ptsv2paymentsRiskInformationBuyerHistory riskInformationBuyerHistory = new Ptsv2paymentsRiskInformationBuyerHistory( + CustomerAccount: riskInformationBuyerHistoryCustomerAccount, + AccountHistory: riskInformationBuyerHistoryAccountHistory + ); + + Riskv1authenticationsRiskInformation riskInformation = new Riskv1authenticationsRiskInformation( + BuyerHistory: riskInformationBuyerHistory + ); + + var requestObj = new CheckPayerAuthEnrollmentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + PaymentInformation: paymentInformation, + ConsumerAuthenticationInformation: consumerAuthenticationInformation, + RiskInformation: riskInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationsPost201Response result = apiInstance.CheckPayerAuthEnrollment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/EnrollWithCustomerIdAsPaymentInformation.cs b/Source/Samples/PayerAuthentication/EnrollWithCustomerIdAsPaymentInformation.cs new file mode 100644 index 0000000..9f85a76 --- /dev/null +++ b/Source/Samples/PayerAuthentication/EnrollWithCustomerIdAsPaymentInformation.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class EnrollWithCustomerIdAsPaymentInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationsPost201Response Run() + { + string clientReferenceInformationCode = "UNKNOWN"; + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "10.99"; + Riskv1authenticationsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1authenticationsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToAddress2 = "Address 2"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToPhoneNumber = "4158880000"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPostalCode = "94105"; + Riskv1authenticationsOrderInformationBillTo orderInformationBillTo = new Riskv1authenticationsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1authenticationsOrderInformation orderInformation = new Riskv1authenticationsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string paymentInformationCustomerCustomerId = "AB695DA801DD1BB6E05341588E0A3BDC"; + Riskv1authenticationsPaymentInformationCustomer paymentInformationCustomer = new Riskv1authenticationsPaymentInformationCustomer( + CustomerId: paymentInformationCustomerCustomerId + ); + + Riskv1authenticationsPaymentInformation paymentInformation = new Riskv1authenticationsPaymentInformation( + Customer: paymentInformationCustomer + ); + + var requestObj = new CheckPayerAuthEnrollmentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationsPost201Response result = apiInstance.CheckPayerAuthEnrollment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/EnrollWithPendingAuthentication.cs b/Source/Samples/PayerAuthentication/EnrollWithPendingAuthentication.cs new file mode 100644 index 0000000..d32e801 --- /dev/null +++ b/Source/Samples/PayerAuthentication/EnrollWithPendingAuthentication.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class EnrollWithPendingAuthentication + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationsPost201Response Run() + { + string clientReferenceInformationCode = "cybs_test"; + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "10.99"; + Riskv1authenticationsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1authenticationsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToAddress2 = "Address 2"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToPhoneNumber = "4158880000"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPostalCode = "94105"; + Riskv1authenticationsOrderInformationBillTo orderInformationBillTo = new Riskv1authenticationsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1authenticationsOrderInformation orderInformation = new Riskv1authenticationsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string paymentInformationCardType = "001"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + string paymentInformationCardNumber = "4000000000000101"; + Riskv1authenticationsetupsPaymentInformationCard paymentInformationCard = new Riskv1authenticationsetupsPaymentInformationCard( + Type: paymentInformationCardType, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Number: paymentInformationCardNumber + ); + + Riskv1authenticationsPaymentInformation paymentInformation = new Riskv1authenticationsPaymentInformation( + Card: paymentInformationCard + ); + + int buyerInformationMobilePhone = 1245789632; + Riskv1authenticationsBuyerInformation buyerInformation = new Riskv1authenticationsBuyerInformation( + MobilePhone: buyerInformationMobilePhone + ); + + string consumerAuthenticationInformationTransactionMode = "MOTO"; + Riskv1decisionsConsumerAuthenticationInformation consumerAuthenticationInformation = new Riskv1decisionsConsumerAuthenticationInformation( + TransactionMode: consumerAuthenticationInformationTransactionMode + ); + + var requestObj = new CheckPayerAuthEnrollmentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + PaymentInformation: paymentInformation, + BuyerInformation: buyerInformation, + ConsumerAuthenticationInformation: consumerAuthenticationInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationsPost201Response result = apiInstance.CheckPayerAuthEnrollment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/EnrollWithTransientToken.cs b/Source/Samples/PayerAuthentication/EnrollWithTransientToken.cs new file mode 100644 index 0000000..5aeb03f --- /dev/null +++ b/Source/Samples/PayerAuthentication/EnrollWithTransientToken.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class EnrollWithTransientToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationsPost201Response Run() + { + string clientReferenceInformationCode = "UNKNOWN"; + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "10.99"; + Riskv1authenticationsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1authenticationsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToAddress2 = "Address 2"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToPhoneNumber = "4158880000"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPostalCode = "94105"; + Riskv1authenticationsOrderInformationBillTo orderInformationBillTo = new Riskv1authenticationsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1authenticationsOrderInformation orderInformation = new Riskv1authenticationsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string tokenInformationTransientToken = "1D5ZX4HMOV20FKEBE3IO240JWYJ0NJ90B4V9XQ6SCK4BDN0W96E65E2A39052056"; + Riskv1authenticationsetupsTokenInformation tokenInformation = new Riskv1authenticationsetupsTokenInformation( + TransientToken: tokenInformationTransientToken + ); + + var requestObj = new CheckPayerAuthEnrollmentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + TokenInformation: tokenInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationsPost201Response result = apiInstance.CheckPayerAuthEnrollment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/EnrollWithTravelInformation.cs b/Source/Samples/PayerAuthentication/EnrollWithTravelInformation.cs new file mode 100644 index 0000000..c51fa4c --- /dev/null +++ b/Source/Samples/PayerAuthentication/EnrollWithTravelInformation.cs @@ -0,0 +1,158 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class EnrollWithTravelInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationsPost201Response Run() + { + string clientReferenceInformationCode = "cybs_test"; + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "10.99"; + Riskv1authenticationsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1authenticationsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToAddress2 = "Address 2"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToPhoneNumber = "4158880000"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPostalCode = "94105"; + Riskv1authenticationsOrderInformationBillTo orderInformationBillTo = new Riskv1authenticationsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1authenticationsOrderInformation orderInformation = new Riskv1authenticationsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string paymentInformationCardType = "002"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + string paymentInformationCardNumber = "5200340000000015"; + Riskv1authenticationsetupsPaymentInformationCard paymentInformationCard = new Riskv1authenticationsetupsPaymentInformationCard( + Type: paymentInformationCardType, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Number: paymentInformationCardNumber + ); + + Riskv1authenticationsPaymentInformation paymentInformation = new Riskv1authenticationsPaymentInformation( + Card: paymentInformationCard + ); + + int buyerInformationMobilePhone = 1245789632; + Riskv1authenticationsBuyerInformation buyerInformation = new Riskv1authenticationsBuyerInformation( + MobilePhone: buyerInformationMobilePhone + ); + + string consumerAuthenticationInformationTransactionMode = "MOTO"; + Riskv1decisionsConsumerAuthenticationInformation consumerAuthenticationInformation = new Riskv1decisionsConsumerAuthenticationInformation( + TransactionMode: consumerAuthenticationInformationTransactionMode + ); + + + List travelInformationLegs = new List(); + string travelInformationLegsDestination1 = "DEF"; + string travelInformationLegsCarrierCode1 = "UA"; + string travelInformationLegsDepartureDate1 = "2019-01-01"; + travelInformationLegs.Add(new Riskv1decisionsTravelInformationLegs( + Destination: travelInformationLegsDestination1, + CarrierCode: travelInformationLegsCarrierCode1, + DepartureDate: travelInformationLegsDepartureDate1 + )); + + string travelInformationLegsDestination2 = "RES"; + string travelInformationLegsCarrierCode2 = "AS"; + string travelInformationLegsDepartureDate2 = "2019-02-21"; + travelInformationLegs.Add(new Riskv1decisionsTravelInformationLegs( + Destination: travelInformationLegsDestination2, + CarrierCode: travelInformationLegsCarrierCode2, + DepartureDate: travelInformationLegsDepartureDate2 + )); + + int travelInformationNumberOfPassengers = 2; + + List travelInformationPassengers = new List(); + string travelInformationPassengersFirstName1 = "Raj"; + string travelInformationPassengersLastName1 = "Charles"; + travelInformationPassengers.Add(new Riskv1decisionsTravelInformationPassengers( + FirstName: travelInformationPassengersFirstName1, + LastName: travelInformationPassengersLastName1 + )); + + string travelInformationPassengersFirstName2 = "Potter"; + string travelInformationPassengersLastName2 = "Suhember"; + travelInformationPassengers.Add(new Riskv1decisionsTravelInformationPassengers( + FirstName: travelInformationPassengersFirstName2, + LastName: travelInformationPassengersLastName2 + )); + + Riskv1authenticationsTravelInformation travelInformation = new Riskv1authenticationsTravelInformation( + Legs: travelInformationLegs, + NumberOfPassengers: travelInformationNumberOfPassengers, + Passengers: travelInformationPassengers + ); + + var requestObj = new CheckPayerAuthEnrollmentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + PaymentInformation: paymentInformation, + BuyerInformation: buyerInformation, + ConsumerAuthenticationInformation: consumerAuthenticationInformation, + TravelInformation: travelInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationsPost201Response result = apiInstance.CheckPayerAuthEnrollment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/PendingAuthenticationWithUnknownPath.cs b/Source/Samples/PayerAuthentication/PendingAuthenticationWithUnknownPath.cs new file mode 100644 index 0000000..34c9f96 --- /dev/null +++ b/Source/Samples/PayerAuthentication/PendingAuthenticationWithUnknownPath.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class PendingAuthenticationWithUnknownPath + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationsPost201Response Run() + { + string clientReferenceInformationCode = "UNKNOWN"; + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "10.99"; + Riskv1authenticationsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1authenticationsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToAddress2 = "Address 2"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToPhoneNumber = "4158880000"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPostalCode = "94105"; + Riskv1authenticationsOrderInformationBillTo orderInformationBillTo = new Riskv1authenticationsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1authenticationsOrderInformation orderInformation = new Riskv1authenticationsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string paymentInformationCardType = "001"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + string paymentInformationCardNumber = "4012001037490014"; + Riskv1authenticationsetupsPaymentInformationCard paymentInformationCard = new Riskv1authenticationsetupsPaymentInformationCard( + Type: paymentInformationCardType, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Number: paymentInformationCardNumber + ); + + Riskv1authenticationsPaymentInformation paymentInformation = new Riskv1authenticationsPaymentInformation( + Card: paymentInformationCard + ); + + var requestObj = new CheckPayerAuthEnrollmentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationsPost201Response result = apiInstance.CheckPayerAuthEnrollment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/SetupCompletionWithCardNumber.cs b/Source/Samples/PayerAuthentication/SetupCompletionWithCardNumber.cs new file mode 100644 index 0000000..3595f0e --- /dev/null +++ b/Source/Samples/PayerAuthentication/SetupCompletionWithCardNumber.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class SetupCompletionWithCardNumber + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationSetupsPost201Response Run() + { + string clientReferenceInformationCode = "cybs_test"; + string clientReferenceInformationPartnerDeveloperId = "7891234"; + string clientReferenceInformationPartnerSolutionId = "89012345"; + Riskv1decisionsClientReferenceInformationPartner clientReferenceInformationPartner = new Riskv1decisionsClientReferenceInformationPartner( + DeveloperId: clientReferenceInformationPartnerDeveloperId, + SolutionId: clientReferenceInformationPartnerSolutionId + ); + + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + string paymentInformationCardType = "001"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + string paymentInformationCardNumber = "4000000000000101"; + Riskv1authenticationsetupsPaymentInformationCard paymentInformationCard = new Riskv1authenticationsetupsPaymentInformationCard( + Type: paymentInformationCardType, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Number: paymentInformationCardNumber + ); + + Riskv1authenticationsetupsPaymentInformation paymentInformation = new Riskv1authenticationsetupsPaymentInformation( + Card: paymentInformationCard + ); + + var requestObj = new PayerAuthSetupRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationSetupsPost201Response result = apiInstance.PayerAuthSetup(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/SetupCompletionWithFlexTransientToken.cs b/Source/Samples/PayerAuthentication/SetupCompletionWithFlexTransientToken.cs new file mode 100644 index 0000000..cb47ffc --- /dev/null +++ b/Source/Samples/PayerAuthentication/SetupCompletionWithFlexTransientToken.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class SetupCompletionWithFlexTransientToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationSetupsPost201Response Run() + { + string clientReferenceInformationCode = "cybs_test"; + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string tokenInformationTransientToken = "1D5ZX4HMOV20FKEBE3IO240JWYJ0NJ90B4V9XQ6SCK4BDN0W96E65E2A39052056"; + Riskv1authenticationsetupsTokenInformation tokenInformation = new Riskv1authenticationsetupsTokenInformation( + TransientToken: tokenInformationTransientToken + ); + + var requestObj = new PayerAuthSetupRequest( + ClientReferenceInformation: clientReferenceInformation, + TokenInformation: tokenInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationSetupsPost201Response result = apiInstance.PayerAuthSetup(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/SetupCompletionWithFluidDataValueAndPaymentSolution.cs b/Source/Samples/PayerAuthentication/SetupCompletionWithFluidDataValueAndPaymentSolution.cs new file mode 100644 index 0000000..bafbee1 --- /dev/null +++ b/Source/Samples/PayerAuthentication/SetupCompletionWithFluidDataValueAndPaymentSolution.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class SetupCompletionWithFluidDataValueAndPaymentSolution + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationSetupsPost201Response Run() + { + string clientReferenceInformationCode = "cybs_test"; + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationFluidDataValue = "eyJkYXRhIjoiOFJTK2o1a2ZLRjZkTnkzNVwvOTluR3ZEVis0WUVlaStBb2VmUUNMXC9SNTN0TnVMeHJxTzh4b1g2SnBScm9WWUVUOUNvUkhIWFZMRjJNSVNIZlVtM25UczltdGFPTUdqcW1oeWdjTFpWVWI3OHhxYVVUT2JwWUxLelY0dFR1QmhvRkV4UVJ1d2lvTmo2bXJsRlRjUm5LNzdcL2lCR01yYVlZcXZTVnhGK3ViK1JXK3BGeTRDNUVUOVhmcHBkS2xHYXVpODdzcTBtYVlYVk9qOGFaNTFMWjZvS1NKZkR1clhvWEtLNHRqd1wvaDVRK1dcL0x2dnJxSUhmZmVhK21MZXVRY3RHK0k3UUN6MTRpVmdROUFEMW1oWFUrbVdwZXRUQWZ5WXhoVituZlh1NlpISGRDWFV1cUp6djQydHg4UlwvN0lvdld5OWx6Z0N3YnpuclVsY3pUcThkb3JtV3A4eXhYQklDNnJHRTdlTVJrS3oxZFwvUFFDXC9DS2J1NDhNK0R4XC9VejNoUFwvZ1NnRGoxakJNcUllUUZiRWFzcTRWTUV1ZG9FNUh1UjBcLzRQMXJmdG9EVlpwNnhFdnF1STY5dkt2YnZHcXpmTkpUNjVnPT0iLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiNzQ2NTczNzQ2MTcwNzA2QzY5NjM2MTc0Njk2RjZFNjQ2MTc0NjEiLCJ0cmFuc2FjdGlvbklkIjoiNzQ2NTczNzQ3NDcyNjE2RTczNjE2Mzc0Njk2RjZFNjk2NCIsImVwaGVtZXJhbFB1YmxpY0tleSI6Ik1JSUJTekNDQVFNR0J5cUdTTTQ5QWdFd2dmY0NBUUV3TEFZSEtvWkl6ajBCQVFJaEFQXC9cL1wvXC84QUFBQUJBQUFBQUFBQUFBQUFBQUFBXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9NRnNFSVBcL1wvXC9cLzhBQUFBQkFBQUFBQUFBQUFBQUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC84QkNCYXhqWFlxanFUNTdQcnZWVjJtSWE4WlIwR3NNeFRzUFk3emp3K0o5SmdTd01WQU1TZE5naUc1d1NUYW1aNDRST2RKcmVCbjM2UUJFRUVheGZSOHVFc1FrZjR2T2JsWTZSQThuY0RmWUV0NnpPZzlLRTVSZGlZd3BaUDQwTGlcL2hwXC9tNDduNjBwOEQ1NFdLODR6VjJzeFhzN0x0a0JvTjc5UjlRSWhBUFwvXC9cL1wvOEFBQUFBXC9cL1wvXC9cL1wvXC9cL1wvXC8rODV2cXRweGVlaFBPNXlzTDhZeVZSQWdFQkEwSUFCQmJHK2xtTHJIWWtKSVwvSUUwcTU3dEN0bE5jK2pBWHNudVMrSnFlOFVcLzc0cSs5NVRnbzVFRjBZNks3b01LTUt5cTMwY3VQbmtIenkwMjVpU1BGdWczRT0iLCJwdWJsaWNLZXlIYXNoIjoieCtQbUhHMzdUNjdBWUFIenVqbGJyaW1JdzZZaFlYaVpjYjV3WnJCNGpRdz0ifSwic2lnbmF0dXJlIjoiTUlJRFFnWUpLb1pJaHZjTkFRY0NvSUlETXpDQ0F5OENBUUV4Q3pBSkJnVXJEZ01DR2dVQU1Bc0dDU3FHU0liM0RRRUhBYUNDQWlzd2dnSW5NSUlCbEtBREFnRUNBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWRCUUF3SnpFbE1DTUdBMVVFQXg0Y0FHTUFhQUJ0QUdFQWFRQkFBSFlBYVFCekFHRUFMZ0JqQUc4QWJUQWVGdzB4TkRBeE1ERXdOakF3TURCYUZ3MHlOREF4TURFd05qQXdNREJhTUNjeEpUQWpCZ05WQkFNZUhBQmpBR2dBYlFCaEFHa0FRQUIyQUdrQWN3QmhBQzRBWXdCdkFHMHdnWjh3RFFZSktvWklodmNOQVFFQkJRQURnWTBBTUlHSkFvR0JBTkM4K2tndGdtdldGMU96amdETnJqVEVCUnVvXC81TUt2bE0xNDZwQWY3R3g0MWJsRTl3NGZJWEpBRDdGZk83UUtqSVhZTnQzOXJMeXk3eER3YlwvNUlrWk02MFRaMmlJMXBqNTVVYzhmZDRmek9wazNmdFphUUdYTkxZcHRHMWQ5VjdJUzgyT3VwOU1NbzFCUFZyWFRQSE5jc005OUVQVW5QcWRiZUdjODdtMHJBZ01CQUFHalhEQmFNRmdHQTFVZEFRUlJNRStBRUhaV1ByV3RKZDdZWjQzMWhDZzdZRlNoS1RBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRnaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWRCUUFEZ1lFQWJVS1lDa3VJS1M5UVEybUZjTVlSRUltMmwrWGc4XC9KWHYrR0JWUUprT0tvc2NZNGlOREZBXC9iUWxvZ2Y5TExVODRUSHdOUm5zdlYzUHJ2N1JUWTgxZ3EwZHRDOHpZY0FhQWtDSElJM3lxTW5KNEFPdTZFT1c5a0prMjMyZ1NFN1dsQ3RIYmZMU0tmdVNnUVg4S1hRWXVaTGsyUnI2M044QXBYc1h3QkwzY0oweGdlQXdnZDBDQVFFd096QW5NU1V3SXdZRFZRUURIaHdBWXdCb0FHMEFZUUJwQUVBQWRnQnBBSE1BWVFBdUFHTUFid0J0QWhCY2wrUGYzK1U0cGsxM25WRDlud1FRTUFrR0JTc09Bd0lhQlFBd0RRWUpLb1pJaHZjTkFRRUJCUUFFZ1lBMG9MXC9KSWFTN0tra1RFNG1pOGRmU2tQVVwvdlp2cVwva2NYZ1pUdGJZbENtTFM4YzNuS2VZNVE0c2s4MXJnZkI1ampBMWJRZldhUHBKc05tVWNSS3gzS0FGUEtpNzE0WWVYdGUrcmc2V1k4MnVxcnlwRERiTkhqSWVpNjVqV0dvcGRZUEx6TEk5c1Z3NDh5OHlqSXY3SjFaQVlycnp6YjBwNzUzcUJUQ0ZEN1p3PT0ifQ=="; + Riskv1authenticationsetupsPaymentInformationFluidData paymentInformationFluidData = new Riskv1authenticationsetupsPaymentInformationFluidData( + Value: paymentInformationFluidDataValue + ); + + Riskv1authenticationsetupsPaymentInformation paymentInformation = new Riskv1authenticationsetupsPaymentInformation( + FluidData: paymentInformationFluidData + ); + + string processingInformationPaymentSolution = "001"; + Riskv1authenticationsetupsProcessingInformation processingInformation = new Riskv1authenticationsetupsProcessingInformation( + PaymentSolution: processingInformationPaymentSolution + ); + + var requestObj = new PayerAuthSetupRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + ProcessingInformation: processingInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationSetupsPost201Response result = apiInstance.PayerAuthSetup(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/SetupCompletionWithSecureStorageToken.cs b/Source/Samples/PayerAuthentication/SetupCompletionWithSecureStorageToken.cs new file mode 100644 index 0000000..3cacdff --- /dev/null +++ b/Source/Samples/PayerAuthentication/SetupCompletionWithSecureStorageToken.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class SetupCompletionWithSecureStorageToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationSetupsPost201Response Run() + { + string clientReferenceInformationCode = "cybs_test"; + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCustomerCustomerId = "5795045921830181636348"; + Riskv1authenticationsetupsPaymentInformationCustomer paymentInformationCustomer = new Riskv1authenticationsetupsPaymentInformationCustomer( + CustomerId: paymentInformationCustomerCustomerId + ); + + Riskv1authenticationsetupsPaymentInformation paymentInformation = new Riskv1authenticationsetupsPaymentInformation( + Customer: paymentInformationCustomer + ); + + var requestObj = new PayerAuthSetupRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationSetupsPost201Response result = apiInstance.PayerAuthSetup(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/SetupCompletionWithTMSToken.cs b/Source/Samples/PayerAuthentication/SetupCompletionWithTMSToken.cs new file mode 100644 index 0000000..b848e6c --- /dev/null +++ b/Source/Samples/PayerAuthentication/SetupCompletionWithTMSToken.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class SetupCompletionWithTMSToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationSetupsPost201Response Run() + { + string clientReferenceInformationCode = "cybs_test"; + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCustomerCustomerId = "AB695DA801DD1BB6E05341588E0A3BDC"; + Riskv1authenticationsetupsPaymentInformationCustomer paymentInformationCustomer = new Riskv1authenticationsetupsPaymentInformationCustomer( + CustomerId: paymentInformationCustomerCustomerId + ); + + Riskv1authenticationsetupsPaymentInformation paymentInformation = new Riskv1authenticationsetupsPaymentInformation( + Customer: paymentInformationCustomer + ); + + var requestObj = new PayerAuthSetupRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationSetupsPost201Response result = apiInstance.PayerAuthSetup(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/SetupCompletionWithTokenizedCard.cs b/Source/Samples/PayerAuthentication/SetupCompletionWithTokenizedCard.cs new file mode 100644 index 0000000..279c6e4 --- /dev/null +++ b/Source/Samples/PayerAuthentication/SetupCompletionWithTokenizedCard.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class SetupCompletionWithTokenizedCard + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationSetupsPost201Response Run() + { + string clientReferenceInformationCode = "cybs_test"; + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationTokenizedCardTransactionType = "1"; + string paymentInformationTokenizedCardType = "001"; + string paymentInformationTokenizedCardExpirationMonth = "11"; + string paymentInformationTokenizedCardExpirationYear = "2025"; + string paymentInformationTokenizedCardNumber = "4111111111111111"; + Riskv1authenticationsetupsPaymentInformationTokenizedCard paymentInformationTokenizedCard = new Riskv1authenticationsetupsPaymentInformationTokenizedCard( + TransactionType: paymentInformationTokenizedCardTransactionType, + Type: paymentInformationTokenizedCardType, + ExpirationMonth: paymentInformationTokenizedCardExpirationMonth, + ExpirationYear: paymentInformationTokenizedCardExpirationYear, + Number: paymentInformationTokenizedCardNumber + ); + + Riskv1authenticationsetupsPaymentInformation paymentInformation = new Riskv1authenticationsetupsPaymentInformation( + TokenizedCard: paymentInformationTokenizedCard + ); + + var requestObj = new PayerAuthSetupRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationSetupsPost201Response result = apiInstance.PayerAuthSetup(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/PayerAuthentication/ValidateAuthenticationResults.cs b/Source/Samples/PayerAuthentication/ValidateAuthenticationResults.cs new file mode 100644 index 0000000..d06e447 --- /dev/null +++ b/Source/Samples/PayerAuthentication/ValidateAuthenticationResults.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.PayerAuthentication +{ + public class ValidateAuthenticationResults + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AuthenticationResultsPost201Response Run() + { + string clientReferenceInformationCode = "pavalidatecheck"; + string clientReferenceInformationPartnerDeveloperId = "7891234"; + string clientReferenceInformationPartnerSolutionId = "89012345"; + Riskv1decisionsClientReferenceInformationPartner clientReferenceInformationPartner = new Riskv1decisionsClientReferenceInformationPartner( + DeveloperId: clientReferenceInformationPartnerDeveloperId, + SolutionId: clientReferenceInformationPartnerSolutionId + ); + + Riskv1authenticationsetupsClientReferenceInformation clientReferenceInformation = new Riskv1authenticationsetupsClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "200.00"; + Riskv1authenticationresultsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1authenticationresultsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + + // List orderInformationLineItems = new List(); + // string orderInformationLineItemsUnitPrice1 = "10"; + // int orderInformationLineItemsQuantity1 = 2; + // string orderInformationLineItemsTaxAmount1 = "32.40"; + // orderInformationLineItems.Add(new Riskv1authenticationresultsOrderInformationLineItems( + // UnitPrice: orderInformationLineItemsUnitPrice1, + // Quantity: orderInformationLineItemsQuantity1, + // TaxAmount: orderInformationLineItemsTaxAmount1 + // )); + + Riskv1authenticationresultsOrderInformation orderInformation = new Riskv1authenticationresultsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string paymentInformationCardType = "002"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + string paymentInformationCardNumber = "5200000000000007"; + Riskv1authenticationresultsPaymentInformationCard paymentInformationCard = new Riskv1authenticationresultsPaymentInformationCard( + Type: paymentInformationCardType, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Number: paymentInformationCardNumber + ); + + Riskv1authenticationresultsPaymentInformation paymentInformation = new Riskv1authenticationresultsPaymentInformation( + Card: paymentInformationCard + ); + + string consumerAuthenticationInformationAuthenticationTransactionId = "PYffv9G3sa1e0CQr5fV0"; + string consumerAuthenticationInformationSignedPares = "eNqdmFmT4jgSgN+J4D90zD4yMz45PEFVhHzgA2zwjXnzhQ984Nvw61dAV1"; + Riskv1authenticationresultsConsumerAuthenticationInformation consumerAuthenticationInformation = new Riskv1authenticationresultsConsumerAuthenticationInformation( + AuthenticationTransactionId: consumerAuthenticationInformationAuthenticationTransactionId, + SignedPares: consumerAuthenticationInformationSignedPares + ); + + var requestObj = new ValidateRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + PaymentInformation: paymentInformation, + ConsumerAuthenticationInformation: consumerAuthenticationInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayerAuthenticationApi(clientConfig); + RiskV1AuthenticationResultsPost201Response result = apiInstance.ValidateAuthenticationResults(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Capture/CaptureOfAuthorizationThatUsedSwipedTrackData.cs b/Source/Samples/Payments/Capture/CaptureOfAuthorizationThatUsedSwipedTrackData.cs new file mode 100644 index 0000000..7dd96da --- /dev/null +++ b/Source/Samples/Payments/Capture/CaptureOfAuthorizationThatUsedSwipedTrackData.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class CaptureOfAuthorizationThatUsedSwipedTrackData + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsCapturesPost201Response Run() + { + var processPaymentId = AuthorizationUsingSwipedTrackData.Run().Id; + string clientReferenceInformationCode = "1234567890"; + string clientReferenceInformationPartnerThirdPartyCertificationNumber = "123456789012"; + Ptsv2paymentsClientReferenceInformationPartner clientReferenceInformationPartner = new Ptsv2paymentsClientReferenceInformationPartner( + ThirdPartyCertificationNumber: clientReferenceInformationPartnerThirdPartyCertificationNumber + ); + + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + string orderInformationAmountDetailsTotalAmount = "100"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsidcapturesOrderInformation orderInformation = new Ptsv2paymentsidcapturesOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new CapturePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CaptureApi(clientConfig); + + PtsV2PaymentsCapturesPost201Response result = apiInstance.CapturePayment(requestObj, processPaymentId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Capture/CapturePayment.cs b/Source/Samples/Payments/Capture/CapturePayment.cs new file mode 100644 index 0000000..6b5de61 --- /dev/null +++ b/Source/Samples/Payments/Capture/CapturePayment.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class CapturePayment + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsCapturesPost201Response Run() + { + var id = SimpleAuthorizationInternet.Run().Id; + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsidcapturesOrderInformation orderInformation = new Ptsv2paymentsidcapturesOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new CapturePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CaptureApi(clientConfig); + PtsV2PaymentsCapturesPost201Response result = apiInstance.CapturePayment(requestObj, id); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Capture/CapturePaymentServiceFee.cs b/Source/Samples/Payments/Capture/CapturePaymentServiceFee.cs new file mode 100644 index 0000000..36dc285 --- /dev/null +++ b/Source/Samples/Payments/Capture/CapturePaymentServiceFee.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class CapturePaymentServiceFee + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsCapturesPost201Response Run() + { + ServiceFeesWithCreditCardTransaction.CaptureTrueForProcessPayment = false; + var id = ServiceFeesWithCreditCardTransaction.Run().Id; + + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationAmountDetailsTotalAmount = "2325.00"; + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsServiceFeeAmount = "30.00"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency, + ServiceFeeAmount: orderInformationAmountDetailsServiceFeeAmount + ); + + Ptsv2paymentsidcapturesOrderInformation orderInformation = new Ptsv2paymentsidcapturesOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string merchantInformationServiceFeeDescriptorName = "Vacations Service Fee"; + string merchantInformationServiceFeeDescriptorContact = "8009999999"; + string merchantInformationServiceFeeDescriptorState = "CA"; + Ptsv2paymentsMerchantInformationServiceFeeDescriptor merchantInformationServiceFeeDescriptor = new Ptsv2paymentsMerchantInformationServiceFeeDescriptor( + Name: merchantInformationServiceFeeDescriptorName, + Contact: merchantInformationServiceFeeDescriptorContact, + State: merchantInformationServiceFeeDescriptorState + ); + + Ptsv2paymentsidcapturesMerchantInformation merchantInformation = new Ptsv2paymentsidcapturesMerchantInformation( + ServiceFeeDescriptor: merchantInformationServiceFeeDescriptor + ); + + var requestObj = new CapturePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + MerchantInformation: merchantInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CaptureApi(clientConfig); + PtsV2PaymentsCapturesPost201Response result = apiInstance.CapturePayment(requestObj, id); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Capture/RestaurantCaptureWithGratuity.cs b/Source/Samples/Payments/Capture/RestaurantCaptureWithGratuity.cs new file mode 100644 index 0000000..c3326d9 --- /dev/null +++ b/Source/Samples/Payments/Capture/RestaurantCaptureWithGratuity.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class RestaurantCaptureWithGratuity + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsCapturesPost201Response Run() + { + var processPaymentId = RestaurantAuthorization.Run().Id; + string clientReferenceInformationCode = "1234567890"; + string clientReferenceInformationPartnerThirdPartyCertificationNumber = "123456789012"; + Ptsv2paymentsClientReferenceInformationPartner clientReferenceInformationPartner = new Ptsv2paymentsClientReferenceInformationPartner( + ThirdPartyCertificationNumber: clientReferenceInformationPartnerThirdPartyCertificationNumber + ); + + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + string processingInformationIndustryDataType = "restaurant"; + Ptsv2paymentsidcapturesProcessingInformation processingInformation = new Ptsv2paymentsidcapturesProcessingInformation( + IndustryDataType: processingInformationIndustryDataType + ); + + string orderInformationAmountDetailsTotalAmount = "100"; + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsGratuityAmount = "11.50"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency, + GratuityAmount: orderInformationAmountDetailsGratuityAmount + ); + + Ptsv2paymentsidcapturesOrderInformation orderInformation = new Ptsv2paymentsidcapturesOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new CapturePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CaptureApi(clientConfig); + + PtsV2PaymentsCapturesPost201Response result = apiInstance.CapturePayment(requestObj, processPaymentId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Credit/Credit.cs b/Source/Samples/Payments/Credit/Credit.cs new file mode 100644 index 0000000..6d1ca62 --- /dev/null +++ b/Source/Samples/Payments/Credit/Credit.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class Credit + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2CreditsPost201Response Run() + { + string clientReferenceInformationCode = "12345678"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "03"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardType = "001"; + Ptsv2paymentsidrefundsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsidrefundsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Type: paymentInformationCardType + ); + + Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "200"; + string orderInformationAmountDetailsCurrency = "usd"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Deo"; + string orderInformationBillToAddress1 = "900 Metro Center Blvd"; + string orderInformationBillToLocality = "Foster City"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "48104-2201"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "9321499232"; + Ptsv2paymentsidcapturesOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsidcapturesOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreateCreditRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreditApi(clientConfig); + PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Credit/CreditUsingBluefinPCIP2PEForCardPresentEnabledAcquirer.cs b/Source/Samples/Payments/Credit/CreditUsingBluefinPCIP2PEForCardPresentEnabledAcquirer.cs new file mode 100644 index 0000000..81ba14f --- /dev/null +++ b/Source/Samples/Payments/Credit/CreditUsingBluefinPCIP2PEForCardPresentEnabledAcquirer.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class CreditUsingBluefinPCIP2PEForCardPresentEnabledAcquirer + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2CreditsPost201Response Run() + { + string clientReferenceInformationCode = "demomerchant"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string processingInformationCommerceIndicator = "retail"; + Ptsv2creditsProcessingInformation processingInformation = new Ptsv2creditsProcessingInformation( + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2050"; + Ptsv2paymentsidrefundsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsidrefundsPaymentInformationCard( + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + string paymentInformationFluidDataDescriptor = "Ymx1ZWZpbg=="; + string paymentInformationFluidDataValue = "02d700801f3c20008383252a363031312a2a2a2a2a2a2a2a303030395e46444d53202020202020202020202020202020202020202020205e323231322a2a2a2a2a2a2a2a3f2a3b363031312a2a2a2a2a2a2a2a303030393d323231322a2a2a2a2a2a2a2a3f2a7a75ad15d25217290c54b3d9d1c3868602136c68d339d52d98423391f3e631511d548fff08b414feac9ff6c6dede8fb09bae870e4e32f6f462d6a75fa0a178c3bd18d0d3ade21bc7a0ea687a2eef64551751e502d97cb98dc53ea55162cdfa395431323439323830303762994901000001a000731a8003"; + Ptsv2paymentsPaymentInformationFluidData paymentInformationFluidData = new Ptsv2paymentsPaymentInformationFluidData( + Descriptor: paymentInformationFluidDataDescriptor, + Value: paymentInformationFluidDataValue + ); + + Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( + Card: paymentInformationCard, + FluidData: paymentInformationFluidData + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Deo"; + string orderInformationBillToAddress1 = "201 S. Division St."; + string orderInformationBillToLocality = "Ann Arbor"; + string orderInformationBillToAdministrativeArea = "MI"; + string orderInformationBillToPostalCode = "48104-2201"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "999999999"; + Ptsv2paymentsidcapturesOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsidcapturesOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + int pointOfSaleInformationCatLevel = 1; + string pointOfSaleInformationEntryMode = "keyed"; + int pointOfSaleInformationTerminalCapability = 2; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + CatLevel: pointOfSaleInformationCatLevel, + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability + ); + + var requestObj = new CreateCreditRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreditApi(clientConfig); + PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Credit/CreditUsingBluefinPCIP2PEWithVisaPlatformConnect.cs b/Source/Samples/Payments/Credit/CreditUsingBluefinPCIP2PEWithVisaPlatformConnect.cs new file mode 100644 index 0000000..b0407ef --- /dev/null +++ b/Source/Samples/Payments/Credit/CreditUsingBluefinPCIP2PEWithVisaPlatformConnect.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class CreditUsingBluefinPCIP2PEWithVisaPlatformConnect + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2CreditsPost201Response Run() + { + string clientReferenceInformationCode = "demomerchant"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string processingInformationCommerceIndicator = "retail"; + Ptsv2creditsProcessingInformation processingInformation = new Ptsv2creditsProcessingInformation( + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2050"; + Ptsv2paymentsidrefundsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsidrefundsPaymentInformationCard( + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + string paymentInformationFluidDataDescriptor = "Ymx1ZWZpbg=="; + string paymentInformationFluidDataValue = "02d700801f3c20008383252a363031312a2a2a2a2a2a2a2a303030395e46444d53202020202020202020202020202020202020202020205e323231322a2a2a2a2a2a2a2a3f2a3b363031312a2a2a2a2a2a2a2a303030393d323231322a2a2a2a2a2a2a2a3f2a7a75ad15d25217290c54b3d9d1c3868602136c68d339d52d98423391f3e631511d548fff08b414feac9ff6c6dede8fb09bae870e4e32f6f462d6a75fa0a178c3bd18d0d3ade21bc7a0ea687a2eef64551751e502d97cb98dc53ea55162cdfa395431323439323830303762994901000001a000731a8003"; + Ptsv2paymentsPaymentInformationFluidData paymentInformationFluidData = new Ptsv2paymentsPaymentInformationFluidData( + Descriptor: paymentInformationFluidDataDescriptor, + Value: paymentInformationFluidDataValue + ); + + Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( + Card: paymentInformationCard, + FluidData: paymentInformationFluidData + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Deo"; + string orderInformationBillToAddress1 = "201 S. Division St."; + string orderInformationBillToLocality = "Ann Arbor"; + string orderInformationBillToAdministrativeArea = "MI"; + string orderInformationBillToPostalCode = "48104-2201"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "999999999"; + Ptsv2paymentsidcapturesOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsidcapturesOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + int pointOfSaleInformationCatLevel = 1; + string pointOfSaleInformationEntryMode = "keyed"; + int pointOfSaleInformationTerminalCapability = 2; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + CatLevel: pointOfSaleInformationCatLevel, + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability + ); + + var requestObj = new CreateCreditRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreditApi(clientConfig); + PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Credit/CreditWithCustomerPaymentInstrumentAndShippingAddressTokenId.cs b/Source/Samples/Payments/Credit/CreditWithCustomerPaymentInstrumentAndShippingAddressTokenId.cs new file mode 100644 index 0000000..2a86d22 --- /dev/null +++ b/Source/Samples/Payments/Credit/CreditWithCustomerPaymentInstrumentAndShippingAddressTokenId.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class CreditWithCustomerPaymentInstrumentAndShippingAddressTokenId + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2CreditsPost201Response Run() + { + string clientReferenceInformationCode = "12345678"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCustomerId = "AB695DA801DD1BB6E05341588E0A3BDC"; + Ptsv2paymentsPaymentInformationCustomer paymentInformationCustomer = new Ptsv2paymentsPaymentInformationCustomer( + Id: paymentInformationCustomerId + ); + + string paymentInformationPaymentInstrumentId = "AB6A54B982A6FCB6E05341588E0A3935"; + Ptsv2paymentsPaymentInformationPaymentInstrument paymentInformationPaymentInstrument = new Ptsv2paymentsPaymentInformationPaymentInstrument( + Id: paymentInformationPaymentInstrumentId + ); + + string paymentInformationShippingAddressId = "AB6A54B97C00FCB6E05341588E0A3935"; + Ptsv2paymentsPaymentInformationShippingAddress paymentInformationShippingAddress = new Ptsv2paymentsPaymentInformationShippingAddress( + Id: paymentInformationShippingAddressId + ); + + Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( + Customer: paymentInformationCustomer, + PaymentInstrument: paymentInformationPaymentInstrument, + ShippingAddress: paymentInformationShippingAddress + ); + + string orderInformationAmountDetailsTotalAmount = "200"; + string orderInformationAmountDetailsCurrency = "usd"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new CreateCreditRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreditApi(clientConfig); + PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Credit/CreditWithCustomerTokenId.cs b/Source/Samples/Payments/Credit/CreditWithCustomerTokenId.cs new file mode 100644 index 0000000..7772628 --- /dev/null +++ b/Source/Samples/Payments/Credit/CreditWithCustomerTokenId.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class CreditWithCustomerTokenId + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2CreditsPost201Response Run() + { + string clientReferenceInformationCode = "12345678"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCustomerId = "AB695DA801DD1BB6E05341588E0A3BDC"; + Ptsv2paymentsPaymentInformationCustomer paymentInformationCustomer = new Ptsv2paymentsPaymentInformationCustomer( + Id: paymentInformationCustomerId + ); + + Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( + Customer: paymentInformationCustomer + ); + + string orderInformationAmountDetailsTotalAmount = "200"; + string orderInformationAmountDetailsCurrency = "usd"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new CreateCreditRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreditApi(clientConfig); + PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Credit/CreditWithInstrumentIdentifierTokenId.cs b/Source/Samples/Payments/Credit/CreditWithInstrumentIdentifierTokenId.cs new file mode 100644 index 0000000..a3ce4a8 --- /dev/null +++ b/Source/Samples/Payments/Credit/CreditWithInstrumentIdentifierTokenId.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class CreditWithInstrumentIdentifierTokenId + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2CreditsPost201Response Run() + { + string clientReferenceInformationCode = "12345678"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardExpirationMonth = "03"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardType = "001"; + Ptsv2paymentsidrefundsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsidrefundsPaymentInformationCard( + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Type: paymentInformationCardType + ); + + string paymentInformationInstrumentIdentifierId = "7010000000016241111"; + Ptsv2paymentsPaymentInformationInstrumentIdentifier paymentInformationInstrumentIdentifier = new Ptsv2paymentsPaymentInformationInstrumentIdentifier( + Id: paymentInformationInstrumentIdentifierId + ); + + Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( + Card: paymentInformationCard, + InstrumentIdentifier: paymentInformationInstrumentIdentifier + ); + + string orderInformationAmountDetailsTotalAmount = "200"; + string orderInformationAmountDetailsCurrency = "usd"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Deo"; + string orderInformationBillToAddress1 = "900 Metro Center Blvd"; + string orderInformationBillToLocality = "Foster City"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "48104-2201"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "9321499232"; + Ptsv2paymentsidcapturesOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsidcapturesOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreateCreditRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreditApi(clientConfig); + PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Credit/EBTMerchandiseReturnCreditVoucherFromSNAP.cs b/Source/Samples/Payments/Credit/EBTMerchandiseReturnCreditVoucherFromSNAP.cs new file mode 100644 index 0000000..f698cb1 --- /dev/null +++ b/Source/Samples/Payments/Credit/EBTMerchandiseReturnCreditVoucherFromSNAP.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class EBTMerchandiseReturnCreditVoucherFromSNAP + { + public static PtsV2CreditsPost201Response Run() + { + string clientReferenceInformationCode = "Merchandise Return / Credit Voucher from SNAP"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string processingInformationCommerceIndicator = "retail"; + bool processingInformationPurchaseOptionsIsElectronicBenefitsTransfer = true; + Ptsv2creditsProcessingInformationPurchaseOptions processingInformationPurchaseOptions = new Ptsv2creditsProcessingInformationPurchaseOptions( + IsElectronicBenefitsTransfer: processingInformationPurchaseOptionsIsElectronicBenefitsTransfer + ); + + string processingInformationElectronicBenefitsTransferCategory = "FOOD"; + Ptsv2creditsProcessingInformationElectronicBenefitsTransfer processingInformationElectronicBenefitsTransfer = new Ptsv2creditsProcessingInformationElectronicBenefitsTransfer( + Category: processingInformationElectronicBenefitsTransferCategory + ); + + Ptsv2creditsProcessingInformation processingInformation = new Ptsv2creditsProcessingInformation( + CommerceIndicator: processingInformationCommerceIndicator, + PurchaseOptions: processingInformationPurchaseOptions, + ElectronicBenefitsTransfer: processingInformationElectronicBenefitsTransfer + ); + + string paymentInformationCardType = "001"; + Ptsv2paymentsidrefundsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsidrefundsPaymentInformationCard( + Type: paymentInformationCardType + ); + + string paymentInformationPaymentTypeName = "CARD"; + string paymentInformationPaymentTypeSubTypeName = "DEBIT"; + Ptsv2paymentsidrefundsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsidrefundsPaymentInformationPaymentType( + Name: paymentInformationPaymentTypeName, + SubTypeName: paymentInformationPaymentTypeSubTypeName + ); + + Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( + Card: paymentInformationCard, + PaymentType: paymentInformationPaymentType + ); + + string orderInformationAmountDetailsTotalAmount = "204.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + int merchantInformationCategoryCode = 5411; + Ptsv2paymentsidrefundsMerchantInformation merchantInformation = new Ptsv2paymentsidrefundsMerchantInformation( + CategoryCode: merchantInformationCategoryCode + ); + + string pointOfSaleInformationEntryMode = "swiped"; + int pointOfSaleInformationTerminalCapability = 4; + string pointOfSaleInformationTrackData = "%B4111111111111111^JONES/JONES ^3112101976110000868000000?;4111111111111111=16121019761186800000?"; + int pointOfSaleInformationPinBlockEncodingFormat = 1; + string pointOfSaleInformationEncryptedPin = "52F20658C04DB351"; + string pointOfSaleInformationEncryptedKeySerialNumber = "FFFF1B1D140000000005"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + TrackData: pointOfSaleInformationTrackData, + PinBlockEncodingFormat: pointOfSaleInformationPinBlockEncodingFormat, + EncryptedPin: pointOfSaleInformationEncryptedPin, + EncryptedKeySerialNumber: pointOfSaleInformationEncryptedKeySerialNumber + ); + + var requestObj = new CreateCreditRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + MerchantInformation: merchantInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetAlternativeConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreditApi(clientConfig); + PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Credit/ElectronicCheckStandAloneCredits.cs b/Source/Samples/Payments/Credit/ElectronicCheckStandAloneCredits.cs new file mode 100644 index 0000000..946f358 --- /dev/null +++ b/Source/Samples/Payments/Credit/ElectronicCheckStandAloneCredits.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class ElectronicCheckStandAloneCredits + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2CreditsPost201Response Run() + { + string clientReferenceInformationCode = "TC46125-1"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationBankAccountType = "C"; + string paymentInformationBankAccountNumber = "4100"; + string paymentInformationBankAccountCheckNumber = "123456"; + Ptsv2paymentsidrefundsPaymentInformationBankAccount paymentInformationBankAccount = new Ptsv2paymentsidrefundsPaymentInformationBankAccount( + Type: paymentInformationBankAccountType, + Number: paymentInformationBankAccountNumber, + CheckNumber: paymentInformationBankAccountCheckNumber + ); + + string paymentInformationBankRoutingNumber = "071923284"; + Ptsv2paymentsidrefundsPaymentInformationBank paymentInformationBank = new Ptsv2paymentsidrefundsPaymentInformationBank( + Account: paymentInformationBankAccount, + RoutingNumber: paymentInformationBankRoutingNumber + ); + + string paymentInformationPaymentTypeName = "CHECK"; + Ptsv2paymentsidrefundsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsidrefundsPaymentInformationPaymentType( + Name: paymentInformationPaymentTypeName + ); + + Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( + Bank: paymentInformationBank, + PaymentType: paymentInformationPaymentType + ); + + string orderInformationAmountDetailsTotalAmount = "100"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsidcapturesOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsidcapturesOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreateCreditRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreditApi(clientConfig); + PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Credit/PinDebitCreditUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect.cs b/Source/Samples/Payments/Credit/PinDebitCreditUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect.cs new file mode 100644 index 0000000..eab20d8 --- /dev/null +++ b/Source/Samples/Payments/Credit/PinDebitCreditUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class PinDebitCreditUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect + { + public static PtsV2CreditsPost201Response Run() + { + string clientReferenceInformationCode = "2.2 Credit"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string processingInformationCommerceIndicator = "retail"; + Ptsv2creditsProcessingInformation processingInformation = new Ptsv2creditsProcessingInformation( + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationPaymentTypeName = "CARD"; + string paymentInformationPaymentTypeSubTypeName = "DEBIT"; + Ptsv2paymentsidrefundsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsidrefundsPaymentInformationPaymentType( + Name: paymentInformationPaymentTypeName, + SubTypeName: paymentInformationPaymentTypeSubTypeName + ); + + Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( + PaymentType: paymentInformationPaymentType + ); + + string orderInformationAmountDetailsTotalAmount = "202.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + Ptsv2paymentsidrefundsMerchantInformation merchantInformation = new Ptsv2paymentsidrefundsMerchantInformation( + ); + + string pointOfSaleInformationEntryMode = "contactless"; + int pointOfSaleInformationTerminalCapability = 4; + string pointOfSaleInformationEmvTags = "9F3303204000950500000000009F3704518823719F100706011103A000009F26081E1756ED0E2134E29F36020015820200009C01009F1A0208409A030006219F02060000000020005F2A0208409F0306000000000000"; + string pointOfSaleInformationEmvCardSequenceNumber = "1"; + bool pointOfSaleInformationEmvFallback = false; + Ptsv2paymentsPointOfSaleInformationEmv pointOfSaleInformationEmv = new Ptsv2paymentsPointOfSaleInformationEmv( + Tags: pointOfSaleInformationEmvTags, + CardSequenceNumber: pointOfSaleInformationEmvCardSequenceNumber, + Fallback: pointOfSaleInformationEmvFallback + ); + + string pointOfSaleInformationTrackData = "%B4111111111111111^JONES/JONES ^3112101976110000868000000?;4111111111111111=16121019761186800000?"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + Emv: pointOfSaleInformationEmv, + TrackData: pointOfSaleInformationTrackData + ); + + var requestObj = new CreateCreditRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + MerchantInformation: merchantInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetAlternativeConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreditApi(clientConfig); + PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Credit/PinDebitCreditUsingSwipedTrackDataWithVisaPlatformConnect.cs b/Source/Samples/Payments/Credit/PinDebitCreditUsingSwipedTrackDataWithVisaPlatformConnect.cs new file mode 100644 index 0000000..04dfb7a --- /dev/null +++ b/Source/Samples/Payments/Credit/PinDebitCreditUsingSwipedTrackDataWithVisaPlatformConnect.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class PinDebitCreditUsingSwipedTrackDataWithVisaPlatformConnect + { + public static PtsV2CreditsPost201Response Run() + { + string clientReferenceInformationCode = "2.2 Credit"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string processingInformationCommerceIndicator = "retail"; + Ptsv2creditsProcessingInformation processingInformation = new Ptsv2creditsProcessingInformation( + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationPaymentTypeName = "CARD"; + string paymentInformationPaymentTypeSubTypeName = "DEBIT"; + Ptsv2paymentsidrefundsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsidrefundsPaymentInformationPaymentType( + Name: paymentInformationPaymentTypeName, + SubTypeName: paymentInformationPaymentTypeSubTypeName + ); + + Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( + PaymentType: paymentInformationPaymentType + ); + + string orderInformationAmountDetailsTotalAmount = "202.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + Ptsv2paymentsidrefundsMerchantInformation merchantInformation = new Ptsv2paymentsidrefundsMerchantInformation( + ); + + string pointOfSaleInformationEntryMode = "swiped"; + string pointOfSaleInformationTrackData = "%B4111111111111111^JONES/JONES ^3112101976110000868000000?;4111111111111111=16121019761186800000?"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TrackData: pointOfSaleInformationTrackData + ); + + var requestObj = new CreateCreditRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + MerchantInformation: merchantInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetAlternativeConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreditApi(clientConfig); + PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Credit/ServiceFeesCredit.cs b/Source/Samples/Payments/Credit/ServiceFeesCredit.cs new file mode 100644 index 0000000..9831877 --- /dev/null +++ b/Source/Samples/Payments/Credit/ServiceFeesCredit.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class ServiceFeesCredit + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2CreditsPost201Response Run() + { + string clientReferenceInformationCode = "12345678"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "03"; + string paymentInformationCardExpirationYear = "2031"; + Ptsv2paymentsidrefundsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsidrefundsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "2325.00"; + string orderInformationAmountDetailsCurrency = "usd"; + string orderInformationAmountDetailsServiceFeeAmount = "30.0"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency, + ServiceFeeAmount: orderInformationAmountDetailsServiceFeeAmount + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsidcapturesOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsidcapturesOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreateCreditRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreditApi(clientConfig); + PtsV2CreditsPost201Response result = apiInstance.CreateCredit(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AmericanExpressDirectEMVWithContactRead.cs b/Source/Samples/Payments/Payments/AmericanExpressDirectEMVWithContactRead.cs new file mode 100644 index 0000000..0def616 --- /dev/null +++ b/Source/Samples/Payments/Payments/AmericanExpressDirectEMVWithContactRead.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AmericanExpressDirectEMVWithContactRead + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "123456"; + string clientReferenceInformationPartnerOriginalTransactionId = "510be4aef90711e6acbc7d88388d803d"; + Ptsv2paymentsClientReferenceInformationPartner clientReferenceInformationPartner = new Ptsv2paymentsClientReferenceInformationPartner( + OriginalTransactionId: clientReferenceInformationPartnerOriginalTransactionId + ); + + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + int pointOfSaleInformationCatLevel = 1; + string pointOfSaleInformationEntryMode = "contact"; + int pointOfSaleInformationTerminalCapability = 4; + string pointOfSaleInformationEmvTags = "9F3303204000950500000000009F3704518823719F100706011103A000009F26081E1756ED0E2134E29F36020015820200009C01009F1A0208409A030006219F02060000000020005F2A0208409F0306000000000000"; + int pointOfSaleInformationEmvCardholderVerificationMethodUsed = 2; + string pointOfSaleInformationEmvCardSequenceNumber = "1"; + bool pointOfSaleInformationEmvFallback = false; + Ptsv2paymentsPointOfSaleInformationEmv pointOfSaleInformationEmv = new Ptsv2paymentsPointOfSaleInformationEmv( + Tags: pointOfSaleInformationEmvTags, + CardholderVerificationMethodUsed: pointOfSaleInformationEmvCardholderVerificationMethodUsed, + CardSequenceNumber: pointOfSaleInformationEmvCardSequenceNumber, + Fallback: pointOfSaleInformationEmvFallback + ); + + string pointOfSaleInformationTrackData = "%B4111111111111111^TEST/CYBS ^2012121019761100 00868000000?;"; + + List pointOfSaleInformationCardholderVerificationMethod = new List(); + pointOfSaleInformationCardholderVerificationMethod.Add("pin"); + pointOfSaleInformationCardholderVerificationMethod.Add("signature"); + + List pointOfSaleInformationTerminalInputCapability = new List(); + pointOfSaleInformationTerminalInputCapability.Add("contact"); + pointOfSaleInformationTerminalInputCapability.Add("contactless"); + pointOfSaleInformationTerminalInputCapability.Add("keyed"); + pointOfSaleInformationTerminalInputCapability.Add("swiped"); + string pointOfSaleInformationTerminalCardCaptureCapability = "1"; + string pointOfSaleInformationDeviceId = "123lkjdIOBK34981slviLI39bj"; + string pointOfSaleInformationEncryptedKeySerialNumber = "01043191"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + CatLevel: pointOfSaleInformationCatLevel, + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + Emv: pointOfSaleInformationEmv, + TrackData: pointOfSaleInformationTrackData, + CardholderVerificationMethod: pointOfSaleInformationCardholderVerificationMethod, + TerminalInputCapability: pointOfSaleInformationTerminalInputCapability, + TerminalCardCaptureCapability: pointOfSaleInformationTerminalCardCaptureCapability, + DeviceId: pointOfSaleInformationDeviceId, + EncryptedKeySerialNumber: pointOfSaleInformationEncryptedKeySerialNumber + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationCaptureForTimeoutVoidFlow.cs b/Source/Samples/Payments/Payments/AuthorizationCaptureForTimeoutVoidFlow.cs new file mode 100644 index 0000000..8930c95 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationCaptureForTimeoutVoidFlow.cs @@ -0,0 +1,112 @@ +using System; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; +using Cybersource_rest_samples_dotnet.Resource; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationCaptureForTimeoutVoidFlow + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + SampleCode.TimeoutVoidTransactionId = NumericUtility.LongRandom(1000, 1000000000 + 1); + string clientReferenceInformationCode = "TC50171_3"; + string clientReferenceInformationTransactionId = SampleCode.TimeoutVoidTransactionId; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode, + TransactionId: clientReferenceInformationTransactionId + ); + + bool processingInformationCapture = true; + + string processingInformationCommerceIndicator = "internet"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToAddress2 = "Address 2"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationForIncrementalAuthorizationFlow.cs b/Source/Samples/Payments/Payments/AuthorizationForIncrementalAuthorizationFlow.cs new file mode 100644 index 0000000..44be296 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationForIncrementalAuthorizationFlow.cs @@ -0,0 +1,277 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationForIncrementalAuthorizationFlow + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + bool processingInformationCapture = false; + string processingInformationIndustryDataType = "lodging"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + IndustryDataType: processingInformationIndustryDataType + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardType = "001"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Type: paymentInformationCardType + ); + + string paymentInformationTokenizedCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationTokenizedCard paymentInformationTokenizedCard = new Ptsv2paymentsPaymentInformationTokenizedCard( + SecurityCode: paymentInformationTokenizedCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard, + TokenizedCard: paymentInformationTokenizedCard + ); + + string orderInformationAmountDetailsTotalAmount = "20"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToAddress1 = "201 S. Division St."; + string orderInformationBillToAddress2 = "Suite 500"; + string orderInformationBillToLocality = "Ann Arbor"; + string orderInformationBillToAdministrativeArea = "MI"; + string orderInformationBillToPostalCode = "12345"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "null@cybersource.com"; + string orderInformationBillToPhoneNumber = "514-670-8700"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + string orderInformationShipToFirstName = "Olivia"; + string orderInformationShipToLastName = "White"; + string orderInformationShipToAddress1 = "1295 Charleston Rd"; + string orderInformationShipToAddress2 = "Cube 2386"; + string orderInformationShipToLocality = "Mountain View"; + string orderInformationShipToAdministrativeArea = "CA"; + string orderInformationShipToPostalCode = "94041"; + string orderInformationShipToCountry = "AE"; + string orderInformationShipToPhoneNumber = "650-965-6000"; + Ptsv2paymentsOrderInformationShipTo orderInformationShipTo = new Ptsv2paymentsOrderInformationShipTo( + FirstName: orderInformationShipToFirstName, + LastName: orderInformationShipToLastName, + Address1: orderInformationShipToAddress1, + Address2: orderInformationShipToAddress2, + Locality: orderInformationShipToLocality, + AdministrativeArea: orderInformationShipToAdministrativeArea, + PostalCode: orderInformationShipToPostalCode, + Country: orderInformationShipToCountry, + PhoneNumber: orderInformationShipToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo + ); + + string merchantInformationMerchantDescriptorContact = "965-6000"; + Ptsv2paymentsMerchantInformationMerchantDescriptor merchantInformationMerchantDescriptor = new Ptsv2paymentsMerchantInformationMerchantDescriptor( + Contact: merchantInformationMerchantDescriptorContact + ); + + Ptsv2paymentsMerchantInformation merchantInformation = new Ptsv2paymentsMerchantInformation( + MerchantDescriptor: merchantInformationMerchantDescriptor + ); + + string consumerAuthenticationInformationCavv = "ABCDEabcde12345678900987654321abcdeABCDE"; + string consumerAuthenticationInformationXid = "12345678909876543210ABCDEabcdeABCDEF1234"; + Ptsv2paymentsConsumerAuthenticationInformation consumerAuthenticationInformation = new Ptsv2paymentsConsumerAuthenticationInformation( + Cavv: consumerAuthenticationInformationCavv, + Xid: consumerAuthenticationInformationXid + ); + + string installmentInformationAmount = "1200"; + string installmentInformationFrequency = "W"; + int installmentInformationSequence = 34; + string installmentInformationTotalAmount = "2000"; + int installmentInformationTotalCount = 12; + Ptsv2paymentsInstallmentInformation installmentInformation = new Ptsv2paymentsInstallmentInformation( + Amount: installmentInformationAmount, + Frequency: installmentInformationFrequency, + Sequence: installmentInformationSequence, + TotalAmount: installmentInformationTotalAmount, + TotalCount: installmentInformationTotalCount + ); + + string travelInformationDuration = "3"; + string travelInformationLodgingCheckInDate = "11062019"; + string travelInformationLodgingCheckOutDate = "11092019"; + + List travelInformationLodgingRoom = new List(); + string travelInformationLodgingRoomDailyRate1 = "1.50"; + int travelInformationLodgingRoomNumberOfNights1 = 5; + travelInformationLodgingRoom.Add(new Ptsv2paymentsTravelInformationLodgingRoom( + DailyRate: travelInformationLodgingRoomDailyRate1, + NumberOfNights: travelInformationLodgingRoomNumberOfNights1 + )); + + string travelInformationLodgingRoomDailyRate2 = "11.50"; + int travelInformationLodgingRoomNumberOfNights2 = 5; + travelInformationLodgingRoom.Add(new Ptsv2paymentsTravelInformationLodgingRoom( + DailyRate: travelInformationLodgingRoomDailyRate2, + NumberOfNights: travelInformationLodgingRoomNumberOfNights2 + )); + + string travelInformationLodgingSmokingPreference = "yes"; + int travelInformationLodgingNumberOfRooms = 1; + int travelInformationLodgingNumberOfGuests = 3; + string travelInformationLodgingRoomBedType = "king"; + string travelInformationLodgingRoomTaxType = "tourist"; + string travelInformationLodgingRoomRateType = "sr citizen"; + string travelInformationLodgingGuestName = "Tulasi"; + string travelInformationLodgingCustomerServicePhoneNumber = "+13304026334"; + string travelInformationLodgingCorporateClientCode = "HDGGASJDGSUY"; + string travelInformationLodgingAdditionalDiscountAmount = "99.123456781"; + string travelInformationLodgingRoomLocation = "seaview"; + string travelInformationLodgingSpecialProgramCode = "2"; + string travelInformationLodgingTotalTaxAmount = "99.1234567891"; + string travelInformationLodgingPrepaidCost = "9999999999.99"; + string travelInformationLodgingFoodAndBeverageCost = "9999999999.99"; + string travelInformationLodgingRoomTaxAmount = "9999999999.99"; + string travelInformationLodgingAdjustmentAmount = "9999999999.99"; + string travelInformationLodgingPhoneCost = "9999999999.99"; + string travelInformationLodgingRestaurantCost = "9999999999.99"; + string travelInformationLodgingRoomServiceCost = "9999999999.99"; + string travelInformationLodgingMiniBarCost = "9999999999.99"; + string travelInformationLodgingLaundryCost = "9999999999.99"; + string travelInformationLodgingMiscellaneousCost = "9999999999.99"; + string travelInformationLodgingGiftShopCost = "9999999999.99"; + string travelInformationLodgingMovieCost = "9999999999.99"; + string travelInformationLodgingHealthClubCost = "9999999999.99"; + string travelInformationLodgingValetParkingCost = "9999999999.99"; + string travelInformationLodgingCashDisbursementCost = "9999999999.99"; + string travelInformationLodgingNonRoomCost = "9999999999.99"; + string travelInformationLodgingBusinessCenterCost = "9999999999.99"; + string travelInformationLodgingLoungeBarCost = "9999999999.99"; + string travelInformationLodgingTransportationCost = "9999999999.99"; + string travelInformationLodgingGratuityAmount = "9999999999.99"; + string travelInformationLodgingConferenceRoomCost = "9999999999.99"; + string travelInformationLodgingAudioVisualCost = "9999999999.99"; + string travelInformationLodgingNonRoomTaxAmount = "9999999999.99"; + string travelInformationLodgingEarlyCheckOutCost = "9999999999.99"; + string travelInformationLodgingInternetAccessCost = "9999999999.99"; + Ptsv2paymentsTravelInformationLodging travelInformationLodging = new Ptsv2paymentsTravelInformationLodging( + CheckInDate: travelInformationLodgingCheckInDate, + CheckOutDate: travelInformationLodgingCheckOutDate, + Room: travelInformationLodgingRoom, + SmokingPreference: travelInformationLodgingSmokingPreference, + NumberOfRooms: travelInformationLodgingNumberOfRooms, + NumberOfGuests: travelInformationLodgingNumberOfGuests, + RoomBedType: travelInformationLodgingRoomBedType, + RoomTaxType: travelInformationLodgingRoomTaxType, + RoomRateType: travelInformationLodgingRoomRateType, + GuestName: travelInformationLodgingGuestName, + CustomerServicePhoneNumber: travelInformationLodgingCustomerServicePhoneNumber, + CorporateClientCode: travelInformationLodgingCorporateClientCode, + AdditionalDiscountAmount: travelInformationLodgingAdditionalDiscountAmount, + RoomLocation: travelInformationLodgingRoomLocation, + SpecialProgramCode: travelInformationLodgingSpecialProgramCode, + TotalTaxAmount: travelInformationLodgingTotalTaxAmount, + PrepaidCost: travelInformationLodgingPrepaidCost, + FoodAndBeverageCost: travelInformationLodgingFoodAndBeverageCost, + RoomTaxAmount: travelInformationLodgingRoomTaxAmount, + AdjustmentAmount: travelInformationLodgingAdjustmentAmount, + PhoneCost: travelInformationLodgingPhoneCost, + RestaurantCost: travelInformationLodgingRestaurantCost, + RoomServiceCost: travelInformationLodgingRoomServiceCost, + MiniBarCost: travelInformationLodgingMiniBarCost, + LaundryCost: travelInformationLodgingLaundryCost, + MiscellaneousCost: travelInformationLodgingMiscellaneousCost, + GiftShopCost: travelInformationLodgingGiftShopCost, + MovieCost: travelInformationLodgingMovieCost, + HealthClubCost: travelInformationLodgingHealthClubCost, + ValetParkingCost: travelInformationLodgingValetParkingCost, + CashDisbursementCost: travelInformationLodgingCashDisbursementCost, + NonRoomCost: travelInformationLodgingNonRoomCost, + BusinessCenterCost: travelInformationLodgingBusinessCenterCost, + LoungeBarCost: travelInformationLodgingLoungeBarCost, + TransportationCost: travelInformationLodgingTransportationCost, + GratuityAmount: travelInformationLodgingGratuityAmount, + ConferenceRoomCost: travelInformationLodgingConferenceRoomCost, + AudioVisualCost: travelInformationLodgingAudioVisualCost, + NonRoomTaxAmount: travelInformationLodgingNonRoomTaxAmount, + EarlyCheckOutCost: travelInformationLodgingEarlyCheckOutCost, + InternetAccessCost: travelInformationLodgingInternetAccessCost + ); + + Ptsv2paymentsTravelInformation travelInformation = new Ptsv2paymentsTravelInformation( + Duration: travelInformationDuration, + Lodging: travelInformationLodging + ); + + string promotionInformationAdditionalCode = "9999999999.99"; + Ptsv2paymentsPromotionInformation promotionInformation = new Ptsv2paymentsPromotionInformation( + AdditionalCode: promotionInformationAdditionalCode + ); + + var requestObj = new CreatePaymentRequest( + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + MerchantInformation: merchantInformation, + ConsumerAuthenticationInformation: consumerAuthenticationInformation, + InstallmentInformation: installmentInformation, + TravelInformation: travelInformation, + PromotionInformation: promotionInformation + ); + + try + { + var configDictionary = new Configuration().GetAlternativeConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationForTimeoutReversalFlow.cs b/Source/Samples/Payments/Payments/AuthorizationForTimeoutReversalFlow.cs new file mode 100644 index 0000000..efbd12b --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationForTimeoutReversalFlow.cs @@ -0,0 +1,118 @@ +using System; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; +using Cybersource_rest_samples_dotnet.Resource; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationForTimeoutReversalFlow + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static bool CaptureTrueForProcessPayment { get; set; } = false; + + public static PtsV2PaymentsPost201Response Run() + { + SampleCode.TimeoutReversalTransactionId = NumericUtility.LongRandom(1000, 1000000000 + 1); + string clientReferenceInformationCode = "TC50171_3"; + string clientReferenceInformationTransactionId = SampleCode.TimeoutReversalTransactionId; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode, + TransactionId: clientReferenceInformationTransactionId + ); + + bool processingInformationCapture = false; + if (CaptureTrueForProcessPayment) + { + processingInformationCapture = true; + } + + string processingInformationCommerceIndicator = "internet"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToAddress2 = "Address 2"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Payments/AuthorizationSkipDecisionManagerForSingleTransaction.cs b/Source/Samples/Payments/Payments/AuthorizationSkipDecisionManagerForSingleTransaction.cs new file mode 100644 index 0000000..909cd7d --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationSkipDecisionManagerForSingleTransaction.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationSkipDecisionManagerForSingleTransaction + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_16"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + List processingInformationActionList = new List(); + processingInformationActionList.Add("DECISION_SKIP"); + bool processingInformationCapture = false; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + ActionList: processingInformationActionList, + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "11"; + string paymentInformationCardExpirationYear = "2025"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "10"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationUsingBluefinPCIP2PEForCardPresentEnabledAcquirer.cs b/Source/Samples/Payments/Payments/AuthorizationUsingBluefinPCIP2PEForCardPresentEnabledAcquirer.cs new file mode 100644 index 0000000..bca1f0c --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationUsingBluefinPCIP2PEForCardPresentEnabledAcquirer.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationUsingBluefinPCIP2PEForCardPresentEnabledAcquirer + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "demomerchant"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2050"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + string paymentInformationFluidDataDescriptor = "Ymx1ZWZpbg=="; + string paymentInformationFluidDataValue = "02d700801f3c20008383252a363031312a2a2a2a2a2a2a2a303030395e46444d53202020202020202020202020202020202020202020205e323231322a2a2a2a2a2a2a2a3f2a3b363031312a2a2a2a2a2a2a2a303030393d323231322a2a2a2a2a2a2a2a3f2a7a75ad15d25217290c54b3d9d1c3868602136c68d339d52d98423391f3e631511d548fff08b414feac9ff6c6dede8fb09bae870e4e32f6f462d6a75fa0a178c3bd18d0d3ade21bc7a0ea687a2eef64551751e502d97cb98dc53ea55162cdfa395431323439323830303762994901000001a000731a8003"; + Ptsv2paymentsPaymentInformationFluidData paymentInformationFluidData = new Ptsv2paymentsPaymentInformationFluidData( + Descriptor: paymentInformationFluidDataDescriptor, + Value: paymentInformationFluidDataValue + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard, + FluidData: paymentInformationFluidData + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Deo"; + string orderInformationBillToAddress1 = "201 S. Division St."; + string orderInformationBillToLocality = "Ann Arbor"; + string orderInformationBillToAdministrativeArea = "MI"; + string orderInformationBillToPostalCode = "48104-2201"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToDistrict = "MI"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "999999999"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + District: orderInformationBillToDistrict, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + int pointOfSaleInformationCatLevel = 1; + string pointOfSaleInformationEntryMode = "keyed"; + int pointOfSaleInformationTerminalCapability = 2; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + CatLevel: pointOfSaleInformationCatLevel, + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationUsingBluefinPCIP2PEWithVisaPlatformConnect.cs b/Source/Samples/Payments/Payments/AuthorizationUsingBluefinPCIP2PEWithVisaPlatformConnect.cs new file mode 100644 index 0000000..5aaf850 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationUsingBluefinPCIP2PEWithVisaPlatformConnect.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationUsingBluefinPCIP2PEWithVisaPlatformConnect + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "demomerchant"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + bool processingInformationAuthorizationOptionsPartialAuthIndicator = true; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = true; + bool processingInformationAuthorizationOptionsIgnoreCvResult = true; + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + PartialAuthIndicator: processingInformationAuthorizationOptionsPartialAuthIndicator, + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2050"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + string paymentInformationFluidDataDescriptor = "Ymx1ZWZpbg=="; + string paymentInformationFluidDataValue = "02d700801f3c20008383252a363031312a2a2a2a2a2a2a2a303030395e46444d53202020202020202020202020202020202020202020205e323231322a2a2a2a2a2a2a2a3f2a3b363031312a2a2a2a2a2a2a2a303030393d323231322a2a2a2a2a2a2a2a3f2a7a75ad15d25217290c54b3d9d1c3868602136c68d339d52d98423391f3e631511d548fff08b414feac9ff6c6dede8fb09bae870e4e32f6f462d6a75fa0a178c3bd18d0d3ade21bc7a0ea687a2eef64551751e502d97cb98dc53ea55162cdfa395431323439323830303762994901000001a000731a8003"; + Ptsv2paymentsPaymentInformationFluidData paymentInformationFluidData = new Ptsv2paymentsPaymentInformationFluidData( + Descriptor: paymentInformationFluidDataDescriptor, + Value: paymentInformationFluidDataValue + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard, + FluidData: paymentInformationFluidData + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Deo"; + string orderInformationBillToAddress1 = "201 S. Division St."; + string orderInformationBillToLocality = "Ann Arbor"; + string orderInformationBillToAdministrativeArea = "MI"; + string orderInformationBillToPostalCode = "48104-2201"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToDistrict = "MI"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "999999999"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + District: orderInformationBillToDistrict, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + int pointOfSaleInformationCatLevel = 1; + string pointOfSaleInformationEntryMode = "keyed"; + int pointOfSaleInformationTerminalCapability = 2; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + CatLevel: pointOfSaleInformationCatLevel, + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationUsingSwipedTrackData.cs b/Source/Samples/Payments/Payments/AuthorizationUsingSwipedTrackData.cs new file mode 100644 index 0000000..b425960 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationUsingSwipedTrackData.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationUsingSwipedTrackData + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "ABC123"; + string clientReferenceInformationPartnerThirdPartyCertificationNumber = "123456789012"; + Ptsv2paymentsClientReferenceInformationPartner clientReferenceInformationPartner = new Ptsv2paymentsClientReferenceInformationPartner( + ThirdPartyCertificationNumber: clientReferenceInformationPartnerThirdPartyCertificationNumber + ); + + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + bool processingInformationAuthorizationOptionsPartialAuthIndicator = true; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = false; + bool processingInformationAuthorizationOptionsIgnoreCvResult = false; + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + PartialAuthIndicator: processingInformationAuthorizationOptionsPartialAuthIndicator, + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string pointOfSaleInformationEntryMode = "swiped"; + int pointOfSaleInformationTerminalCapability = 2; + string pointOfSaleInformationTrackData = "%B38000000000006^TEST/CYBS ^2012121019761100 00868000000?"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + TrackData: pointOfSaleInformationTrackData + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithCaptureSale.cs b/Source/Samples/Payments/Payments/AuthorizationWithCaptureSale.cs new file mode 100644 index 0000000..0d7de7a --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithCaptureSale.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithCaptureSale + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = true; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithCustomerPaymentInstrumentAndShippingAddressTokenId.cs b/Source/Samples/Payments/Payments/AuthorizationWithCustomerPaymentInstrumentAndShippingAddressTokenId.cs new file mode 100644 index 0000000..7bbcc30 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithCustomerPaymentInstrumentAndShippingAddressTokenId.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithCustomerPaymentInstrumentAndShippingAddressTokenId + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCustomerId = "AB695DA801DD1BB6E05341588E0A3BDC"; + Ptsv2paymentsPaymentInformationCustomer paymentInformationCustomer = new Ptsv2paymentsPaymentInformationCustomer( + Id: paymentInformationCustomerId + ); + + string paymentInformationPaymentInstrumentId = "AB6A54B982A6FCB6E05341588E0A3935"; + Ptsv2paymentsPaymentInformationPaymentInstrument paymentInformationPaymentInstrument = new Ptsv2paymentsPaymentInformationPaymentInstrument( + Id: paymentInformationPaymentInstrumentId + ); + + string paymentInformationShippingAddressId = "AB6A54B97C00FCB6E05341588E0A3935"; + Ptsv2paymentsPaymentInformationShippingAddress paymentInformationShippingAddress = new Ptsv2paymentsPaymentInformationShippingAddress( + Id: paymentInformationShippingAddressId + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Customer: paymentInformationCustomer, + PaymentInstrument: paymentInformationPaymentInstrument, + ShippingAddress: paymentInformationShippingAddress + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithCustomerTokenCreation.cs b/Source/Samples/Payments/Payments/AuthorizationWithCustomerTokenCreation.cs new file mode 100644 index 0000000..6402052 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithCustomerTokenCreation.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithCustomerTokenCreation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + List processingInformationActionList = new List(); + processingInformationActionList.Add("TOKEN_CREATE"); + + List processingInformationActionTokenTypes = new List(); + processingInformationActionTokenTypes.Add("customer"); + processingInformationActionTokenTypes.Add("paymentInstrument"); + processingInformationActionTokenTypes.Add("shippingAddress"); + bool processingInformationCapture = false; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + ActionList: processingInformationActionList, + ActionTokenTypes: processingInformationActionTokenTypes, + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + string orderInformationShipToFirstName = "John"; + string orderInformationShipToLastName = "Doe"; + string orderInformationShipToAddress1 = "1 Market St"; + string orderInformationShipToLocality = "san francisco"; + string orderInformationShipToAdministrativeArea = "CA"; + string orderInformationShipToPostalCode = "94105"; + string orderInformationShipToCountry = "US"; + Ptsv2paymentsOrderInformationShipTo orderInformationShipTo = new Ptsv2paymentsOrderInformationShipTo( + FirstName: orderInformationShipToFirstName, + LastName: orderInformationShipToLastName, + Address1: orderInformationShipToAddress1, + Locality: orderInformationShipToLocality, + AdministrativeArea: orderInformationShipToAdministrativeArea, + PostalCode: orderInformationShipToPostalCode, + Country: orderInformationShipToCountry + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithCustomerTokenDefaultPaymentInstrumentAndShippingAddressCreation.cs b/Source/Samples/Payments/Payments/AuthorizationWithCustomerTokenDefaultPaymentInstrumentAndShippingAddressCreation.cs new file mode 100644 index 0000000..8dcbb95 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithCustomerTokenDefaultPaymentInstrumentAndShippingAddressCreation.cs @@ -0,0 +1,155 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithCustomerTokenDefaultPaymentInstrumentAndShippingAddressCreation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + List processingInformationActionList = new List (); + processingInformationActionList.Add("TOKEN_CREATE"); + + List processingInformationActionTokenTypes = new List (); + processingInformationActionTokenTypes.Add("paymentInstrument"); + processingInformationActionTokenTypes.Add("shippingAddress"); + bool processingInformationCapture = false; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + ActionList: processingInformationActionList, + ActionTokenTypes: processingInformationActionTokenTypes, + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + string paymentInformationCustomerId = "AB695DA801DD1BB6E05341588E0A3BDC"; + Ptsv2paymentsPaymentInformationCustomer paymentInformationCustomer = new Ptsv2paymentsPaymentInformationCustomer( + Id: paymentInformationCustomerId + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard, + Customer: paymentInformationCustomer + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + string orderInformationShipToFirstName = "John"; + string orderInformationShipToLastName = "Doe"; + string orderInformationShipToAddress1 = "1 Market St"; + string orderInformationShipToLocality = "san francisco"; + string orderInformationShipToAdministrativeArea = "CA"; + string orderInformationShipToPostalCode = "94105"; + string orderInformationShipToCountry = "US"; + Ptsv2paymentsOrderInformationShipTo orderInformationShipTo = new Ptsv2paymentsOrderInformationShipTo( + FirstName: orderInformationShipToFirstName, + LastName: orderInformationShipToLastName, + Address1: orderInformationShipToAddress1, + Locality: orderInformationShipToLocality, + AdministrativeArea: orderInformationShipToAdministrativeArea, + PostalCode: orderInformationShipToPostalCode, + Country: orderInformationShipToCountry + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo + ); + + bool tokenInformationPaymentInstrument_default = true; + Ptsv2paymentsTokenInformationPaymentInstrument tokenInformationPaymentInstrument = new Ptsv2paymentsTokenInformationPaymentInstrument( + Default: tokenInformationPaymentInstrument_default + ); + + bool tokenInformationShippingAddress_default = true; + Ptsv2paymentsTokenInformationShippingAddress tokenInformationShippingAddress = new Ptsv2paymentsTokenInformationShippingAddress( + Default: tokenInformationShippingAddress_default + ); + + Ptsv2paymentsTokenInformation tokenInformation = new Ptsv2paymentsTokenInformation( + PaymentInstrument: tokenInformationPaymentInstrument, + ShippingAddress: tokenInformationShippingAddress + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + TokenInformation: tokenInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithCustomerTokenId.cs b/Source/Samples/Payments/Payments/AuthorizationWithCustomerTokenId.cs new file mode 100644 index 0000000..30e67be --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithCustomerTokenId.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithCustomerTokenId + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCustomerId = "AB695DA801DD1BB6E05341588E0A3BDC"; + Ptsv2paymentsPaymentInformationCustomer paymentInformationCustomer = new Ptsv2paymentsPaymentInformationCustomer( + Id: paymentInformationCustomerId + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Customer: paymentInformationCustomer + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithDMAcceptPAEnroll.cs b/Source/Samples/Payments/Payments/AuthorizationWithDMAcceptPAEnroll.cs new file mode 100644 index 0000000..e30bd43 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithDMAcceptPAEnroll.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithDMAcceptPAEnroll + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "cbys_test"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + List processingInformationActionList = new List(); + processingInformationActionList.Add("CONSUMER_AUTHENTICATION"); + bool processingInformationCapture = false; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + ActionList: processingInformationActionList, + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "340000000001007"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "1234"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "1.00"; + string orderInformationAmountDetailsCurrency = "usd"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "accept@cybersource.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithDMRejectPAEnroll.cs b/Source/Samples/Payments/Payments/AuthorizationWithDMRejectPAEnroll.cs new file mode 100644 index 0000000..e19f9c6 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithDMRejectPAEnroll.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithDMRejectPAEnroll + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + List processingInformationActionList = new List(); + processingInformationActionList.Add("CONSUMER_AUTHENTICATION"); + bool processingInformationCapture = false; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + ActionList: processingInformationActionList, + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "372425119311008"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "1234"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "reject@domain.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithDMReviewPAEnroll.cs b/Source/Samples/Payments/Payments/AuthorizationWithDMReviewPAEnroll.cs new file mode 100644 index 0000000..29da2cf --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithDMReviewPAEnroll.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithDMReviewPAEnroll + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + List processingInformationActionList = new List(); + processingInformationActionList.Add("CONSUMER_AUTHENTICATION"); + bool processingInformationCapture = false; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + ActionList: processingInformationActionList, + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "372425119311008"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "1234"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "review@domain.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithDecisionManager.cs b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManager.cs new file mode 100644 index 0000000..a3010c4 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManager.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithDecisionManager + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TSYS_Eh_FE_01"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "11"; + string paymentInformationCardExpirationYear = "2025"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "10"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "JSON"; + string orderInformationBillToLastName = "RTS"; + string orderInformationBillToAddress1 = "201 S. Division St._1"; + string orderInformationBillToLocality = "Foster City"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94404"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "beforeauth@cybersource.com"; + string orderInformationBillToPhoneNumber = "6504327113"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerBuyerInformation.cs b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerBuyerInformation.cs new file mode 100644 index 0000000..a3dbdb7 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerBuyerInformation.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithDecisionManagerBuyerInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "54323007"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4444444444444448"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2020"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "144.14"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "James"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToAddress1 = "96, powers street"; + string orderInformationBillToLocality = "Clearwater milford"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToPostalCode = "03055"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@visa.com"; + string orderInformationBillToPhoneNumber = "7606160717"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string buyerInformationDateOfBirth = "19980505"; + + List buyerInformationPersonalIdentification = new List(); + string buyerInformationPersonalIdentificationType1 = "CPF"; + string buyerInformationPersonalIdentificationId1 = "1a23apwe98"; + buyerInformationPersonalIdentification.Add(new Ptsv2paymentsBuyerInformationPersonalIdentification( + Type: buyerInformationPersonalIdentificationType1, + Id: buyerInformationPersonalIdentificationId1 + )); + + string buyerInformationHashedPassword = ""; + Ptsv2paymentsBuyerInformation buyerInformation = new Ptsv2paymentsBuyerInformation( + DateOfBirth: buyerInformationDateOfBirth, + PersonalIdentification: buyerInformationPersonalIdentification, + HashedPassword: buyerInformationHashedPassword + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + BuyerInformation: buyerInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerCustomSetup.cs b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerCustomSetup.cs new file mode 100644 index 0000000..95add8f --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerCustomSetup.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithDecisionManagerCustomSetup + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_16"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + List processingInformationActionList = new List(); + processingInformationActionList.Add("DECISION"); + bool processingInformationCapture = false; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + ActionList: processingInformationActionList, + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "11"; + string paymentInformationCardExpirationYear = "2025"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "10"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerDeviceInformation.cs b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerDeviceInformation.cs new file mode 100644 index 0000000..505fe13 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerDeviceInformation.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithDecisionManagerDeviceInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "54323007"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4444444444444448"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2020"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "144.14"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "James"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToAddress1 = "96, powers street"; + string orderInformationBillToLocality = "Clearwater milford"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToPostalCode = "03055"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@visa.com"; + string orderInformationBillToPhoneNumber = "7606160717"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string deviceInformationHostName = "host.com"; + string deviceInformationIpAddress = "64.124.61.215"; + string deviceInformationUserAgent = "Chrome"; + string deviceInformationHttpBrowserEmail = "xyz@gmail.com"; + Ptsv2paymentsDeviceInformation deviceInformation = new Ptsv2paymentsDeviceInformation( + HostName: deviceInformationHostName, + IpAddress: deviceInformationIpAddress, + UserAgent: deviceInformationUserAgent, + HttpBrowserEmail: deviceInformationHttpBrowserEmail + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + DeviceInformation: deviceInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerMerchantDefinedInformation.cs b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerMerchantDefinedInformation.cs new file mode 100644 index 0000000..92a9623 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerMerchantDefinedInformation.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithDecisionManagerMerchantDefinedInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "54323007"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4444444444444448"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2020"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "144.14"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "James"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToAddress1 = "96, powers street"; + string orderInformationBillToLocality = "Clearwater milford"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToPostalCode = "03055"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@visa.com"; + string orderInformationBillToPhoneNumber = "7606160717"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + + List merchantDefinedInformation = new List(); + string merchantDefinedInformationKey1 = "1"; + string merchantDefinedInformationValue1 = "Test"; + merchantDefinedInformation.Add(new Ptsv2paymentsMerchantDefinedInformation( + Key: merchantDefinedInformationKey1, + Value: merchantDefinedInformationValue1 + )); + + string merchantDefinedInformationKey2 = "2"; + string merchantDefinedInformationValue2 = "Test2"; + merchantDefinedInformation.Add(new Ptsv2paymentsMerchantDefinedInformation( + Key: merchantDefinedInformationKey2, + Value: merchantDefinedInformationValue2 + )); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + MerchantDefinedInformation: merchantDefinedInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerShippingInformation.cs b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerShippingInformation.cs new file mode 100644 index 0000000..f1a8192 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerShippingInformation.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithDecisionManagerShippingInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "54323007"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4444444444444448"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2020"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "144.14"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "James"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToAddress1 = "96, powers street"; + string orderInformationBillToLocality = "Clearwater milford"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToPostalCode = "03055"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@visa.com"; + string orderInformationBillToPhoneNumber = "7606160717"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + string orderInformationShipToFirstName = "James"; + string orderInformationShipToLastName = "Smith"; + string orderInformationShipToAddress1 = "96, powers street"; + string orderInformationShipToLocality = "Clearwater milford"; + string orderInformationShipToAdministrativeArea = "KA"; + string orderInformationShipToPostalCode = "560056"; + string orderInformationShipToCountry = "IN"; + string orderInformationShipToPhoneNumber = "7606160717"; + Ptsv2paymentsOrderInformationShipTo orderInformationShipTo = new Ptsv2paymentsOrderInformationShipTo( + FirstName: orderInformationShipToFirstName, + LastName: orderInformationShipToLastName, + Address1: orderInformationShipToAddress1, + Locality: orderInformationShipToLocality, + AdministrativeArea: orderInformationShipToAdministrativeArea, + PostalCode: orderInformationShipToPostalCode, + Country: orderInformationShipToCountry, + PhoneNumber: orderInformationShipToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerTravelInformation.cs b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerTravelInformation.cs new file mode 100644 index 0000000..e179e6d --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithDecisionManagerTravelInformation.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithDecisionManagerTravelInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "54323007"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4444444444444448"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2020"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "144.14"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "James"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToAddress1 = "96, powers street"; + string orderInformationBillToLocality = "Clearwater milford"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToPostalCode = "03055"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@visa.com"; + string orderInformationBillToPhoneNumber = "7606160717"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + Ptsv2paymentsTravelInformation travelInformation = new Ptsv2paymentsTravelInformation( + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + TravelInformation: travelInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithInstrumentIdentifierTokenCreation.cs b/Source/Samples/Payments/Payments/AuthorizationWithInstrumentIdentifierTokenCreation.cs new file mode 100644 index 0000000..f3aaef0 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithInstrumentIdentifierTokenCreation.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithInstrumentIdentifierTokenCreation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + List processingInformationActionList = new List (); + processingInformationActionList.Add("TOKEN_CREATE"); + + List processingInformationActionTokenTypes = new List (); + processingInformationActionTokenTypes.Add("instrumentIdentifier"); + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "internet"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + ActionList: processingInformationActionList, + ActionTokenTypes: processingInformationActionTokenTypes, + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + string orderInformationShipToFirstName = "John"; + string orderInformationShipToLastName = "Doe"; + string orderInformationShipToAddress1 = "1 Market St"; + string orderInformationShipToLocality = "san francisco"; + string orderInformationShipToAdministrativeArea = "CA"; + string orderInformationShipToPostalCode = "94105"; + string orderInformationShipToCountry = "US"; + Ptsv2paymentsOrderInformationShipTo orderInformationShipTo = new Ptsv2paymentsOrderInformationShipTo( + FirstName: orderInformationShipToFirstName, + LastName: orderInformationShipToLastName, + Address1: orderInformationShipToAddress1, + Locality: orderInformationShipToLocality, + AdministrativeArea: orderInformationShipToAdministrativeArea, + PostalCode: orderInformationShipToPostalCode, + Country: orderInformationShipToCountry + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithInstrumentIdentifierTokenId.cs b/Source/Samples/Payments/Payments/AuthorizationWithInstrumentIdentifierTokenId.cs new file mode 100644 index 0000000..4eab0e9 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithInstrumentIdentifierTokenId.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithInstrumentIdentifierTokenId + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "internet"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationCardExpirationMonth = "03"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardType = "001"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Type: paymentInformationCardType + ); + + string paymentInformationInstrumentIdentifierId = "7010000000016241111"; + Ptsv2paymentsPaymentInformationInstrumentIdentifier paymentInformationInstrumentIdentifier = new Ptsv2paymentsPaymentInformationInstrumentIdentifier( + Id: paymentInformationInstrumentIdentifierId + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard, + InstrumentIdentifier: paymentInformationInstrumentIdentifier + ); + + string orderInformationAmountDetailsTotalAmount = "200"; + string orderInformationAmountDetailsCurrency = "usd"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Deo"; + string orderInformationBillToAddress1 = "900 Metro Center Blvd"; + string orderInformationBillToLocality = "Foster City"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "48104-2201"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "9321499232"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithLegacyToken.cs b/Source/Samples/Payments/Payments/AuthorizationWithLegacyToken.cs new file mode 100644 index 0000000..94e8f5d --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithLegacyToken.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithLegacyToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationLegacyTokenId = "7010000000016241111"; + Ptsv2paymentsPaymentInformationLegacyToken paymentInformationLegacyToken = new Ptsv2paymentsPaymentInformationLegacyToken( + Id: paymentInformationLegacyTokenId + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + LegacyToken: paymentInformationLegacyToken + ); + + string orderInformationAmountDetailsTotalAmount = "22"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithPAEnrollAuthenticationNeeded.cs b/Source/Samples/Payments/Payments/AuthorizationWithPAEnrollAuthenticationNeeded.cs new file mode 100644 index 0000000..5398be1 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithPAEnrollAuthenticationNeeded.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithPAEnrollAuthenticationNeeded + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + List processingInformationActionList = new List(); + processingInformationActionList.Add("CONSUMER_AUTHENTICATION"); + bool processingInformationCapture = false; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + ActionList: processingInformationActionList, + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "4000000000001091"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2023"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "usd"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToAddress1 = "201 S. Division St._1"; + string orderInformationBillToAddress2 = "Suite 500"; + string orderInformationBillToLocality = "Foster City"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94404"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "accept@cybersource.com"; + string orderInformationBillToPhoneNumber = "6504327113"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string consumerAuthenticationInformationRequestorId = "123123197675"; + string consumerAuthenticationInformationReferenceId = "CybsCruiseTester-8ac0b02f"; + Ptsv2paymentsConsumerAuthenticationInformation consumerAuthenticationInformation = new Ptsv2paymentsConsumerAuthenticationInformation( + RequestorId: consumerAuthenticationInformationRequestorId, + ReferenceId: consumerAuthenticationInformationReferenceId + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + ConsumerAuthenticationInformation: consumerAuthenticationInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithPayerAuthValidation.cs b/Source/Samples/Payments/Payments/AuthorizationWithPayerAuthValidation.cs new file mode 100644 index 0000000..234614d --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithPayerAuthValidation.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithPayerAuthValidation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + List processingInformationActionList = new List(); + processingInformationActionList.Add("VALIDATE_CONSUMER_AUTHENTICATION"); + bool processingInformationCapture = false; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + ActionList: processingInformationActionList, + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "4000000000001091"; + string paymentInformationCardExpirationMonth = "01"; + string paymentInformationCardExpirationYear = "2023"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToAddress1 = "201 S. Division St._1"; + string orderInformationBillToAddress2 = "Suite 500"; + string orderInformationBillToLocality = "Foster City"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94404"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "accept@cybs.com"; + string orderInformationBillToPhoneNumber = "6504327113"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + BillTo: orderInformationBillTo + ); + + string consumerAuthenticationInformationAuthenticationTransactionId = "OiCtXA1j1AxtSNDh5lt1"; + Ptsv2paymentsConsumerAuthenticationInformation consumerAuthenticationInformation = new Ptsv2paymentsConsumerAuthenticationInformation( + AuthenticationTransactionId: consumerAuthenticationInformationAuthenticationTransactionId + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + ConsumerAuthenticationInformation: consumerAuthenticationInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/AuthorizationWithTMSTokenBypassingNetworkToken.cs b/Source/Samples/Payments/Payments/AuthorizationWithTMSTokenBypassingNetworkToken.cs new file mode 100644 index 0000000..d8fbe55 --- /dev/null +++ b/Source/Samples/Payments/Payments/AuthorizationWithTMSTokenBypassingNetworkToken.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class AuthorizationWithTMSTokenBypassingNetworkToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationInstrumentIdentifierId = "7010000000016241111"; + Ptsv2paymentsPaymentInformationInstrumentIdentifier paymentInformationInstrumentIdentifier = new Ptsv2paymentsPaymentInformationInstrumentIdentifier( + Id: paymentInformationInstrumentIdentifierId + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + InstrumentIdentifier: paymentInformationInstrumentIdentifier + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string tokenInformationNetworkTokenOption = "ignore"; + Ptsv2paymentsTokenInformation tokenInformation = new Ptsv2paymentsTokenInformation( + NetworkTokenOption: tokenInformationNetworkTokenOption + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + TokenInformation: tokenInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/CITInitiatingInstalmentSubscriptionUK.cs b/Source/Samples/Payments/Payments/CITInitiatingInstalmentSubscriptionUK.cs new file mode 100644 index 0000000..5b75870 --- /dev/null +++ b/Source/Samples/Payments/Payments/CITInitiatingInstalmentSubscriptionUK.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class CITInitiatingInstalmentSubscriptionUK + { + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "vbv"; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = false; + bool processingInformationAuthorizationOptionsIgnoreCvResult = false; + bool processingInformationAuthorizationOptionsInitiatorCredentialStoredOnFile = true; + Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator( + CredentialStoredOnFile: processingInformationAuthorizationOptionsInitiatorCredentialStoredOnFile + ); + + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult, + Initiator: processingInformationAuthorizationOptionsInitiator + ); + + bool processingInformationRecurringOptionsLoanPayment = false; + bool processingInformationRecurringOptionsFirstRecurringPayment = true; + Ptsv2paymentsProcessingInformationRecurringOptions processingInformationRecurringOptions = new Ptsv2paymentsProcessingInformationRecurringOptions( + LoanPayment: processingInformationRecurringOptionsLoanPayment, + FirstRecurringPayment: processingInformationRecurringOptionsFirstRecurringPayment + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions, + RecurringOptions: processingInformationRecurringOptions + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "GBP"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string consumerAuthenticationInformationCavv = "EHuWW9PiBkWvqE5juRwDzAUFBAk="; + Ptsv2paymentsConsumerAuthenticationInformation consumerAuthenticationInformation = new Ptsv2paymentsConsumerAuthenticationInformation( + Cavv: consumerAuthenticationInformationCavv + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + ConsumerAuthenticationInformation: consumerAuthenticationInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Payments/CITInitiatingRecurringSubscription.cs b/Source/Samples/Payments/Payments/CITInitiatingRecurringSubscription.cs new file mode 100644 index 0000000..e035f50 --- /dev/null +++ b/Source/Samples/Payments/Payments/CITInitiatingRecurringSubscription.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class CITInitiatingRecurringSubscription + { + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "vbv"; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = false; + bool processingInformationAuthorizationOptionsIgnoreCvResult = false; + bool processingInformationAuthorizationOptionsInitiatorCredentialStoredOnFile = true; + Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator( + CredentialStoredOnFile: processingInformationAuthorizationOptionsInitiatorCredentialStoredOnFile + ); + + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult, + Initiator: processingInformationAuthorizationOptionsInitiator + ); + + bool processingInformationRecurringOptionsLoanPayment = false; + bool processingInformationRecurringOptionsFirstRecurringPayment = true; + Ptsv2paymentsProcessingInformationRecurringOptions processingInformationRecurringOptions = new Ptsv2paymentsProcessingInformationRecurringOptions( + LoanPayment: processingInformationRecurringOptionsLoanPayment, + FirstRecurringPayment: processingInformationRecurringOptionsFirstRecurringPayment + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions, + RecurringOptions: processingInformationRecurringOptions + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "GBP"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string consumerAuthenticationInformationCavv = "EHuWW9PiBkWvqE5juRwDzAUFBAk="; + Ptsv2paymentsConsumerAuthenticationInformation consumerAuthenticationInformation = new Ptsv2paymentsConsumerAuthenticationInformation( + Cavv: consumerAuthenticationInformationCavv + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + ConsumerAuthenticationInformation: consumerAuthenticationInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Payments/CITPlacingCredentialOnFile.cs b/Source/Samples/Payments/Payments/CITPlacingCredentialOnFile.cs new file mode 100644 index 0000000..fd8033a --- /dev/null +++ b/Source/Samples/Payments/Payments/CITPlacingCredentialOnFile.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class CITPlacingCredentialOnFile + { + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "vbv"; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = false; + bool processingInformationAuthorizationOptionsIgnoreCvResult = false; + bool processingInformationAuthorizationOptionsInitiatorCredentialStoredOnFile = true; + Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator( + CredentialStoredOnFile: processingInformationAuthorizationOptionsInitiatorCredentialStoredOnFile + ); + + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult, + Initiator: processingInformationAuthorizationOptionsInitiator + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "GBP"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string consumerAuthenticationInformationCavv = "EHuWW9PiBkWvqE5juRwDzAUFBAk="; + Ptsv2paymentsConsumerAuthenticationInformation consumerAuthenticationInformation = new Ptsv2paymentsConsumerAuthenticationInformation( + Cavv: consumerAuthenticationInformationCavv + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + ConsumerAuthenticationInformation: consumerAuthenticationInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Payments/DigitalPaymentGooglePay.cs b/Source/Samples/Payments/Payments/DigitalPaymentGooglePay.cs new file mode 100644 index 0000000..380945a --- /dev/null +++ b/Source/Samples/Payments/Payments/DigitalPaymentGooglePay.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class DigitalPaymentGooglePay + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static bool CaptureTrueForProcessPayment { get; set; } = false; + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC_1231223"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + if (CaptureTrueForProcessPayment) + { + processingInformationCapture = true; + } + string processingInformationPaymentSolution = "012"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + PaymentSolution: processingInformationPaymentSolution + ); + + string paymentInformationTokenizedCardNumber = "4111111111111111"; + string paymentInformationTokenizedCardExpirationMonth = "12"; + string paymentInformationTokenizedCardExpirationYear = "2020"; + string paymentInformationTokenizedCardCryptogram = "EHuWW9PiBkWvqE5juRwDzAUFBAk="; + string paymentInformationTokenizedCardTransactionType = "1"; + Ptsv2paymentsPaymentInformationTokenizedCard paymentInformationTokenizedCard = new Ptsv2paymentsPaymentInformationTokenizedCard( + Number: paymentInformationTokenizedCardNumber, + ExpirationMonth: paymentInformationTokenizedCardExpirationMonth, + ExpirationYear: paymentInformationTokenizedCardExpirationYear, + Cryptogram: paymentInformationTokenizedCardCryptogram, + TransactionType: paymentInformationTokenizedCardTransactionType + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + TokenizedCard: paymentInformationTokenizedCard + ); + + string orderInformationAmountDetailsTotalAmount = "20"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Deo"; + string orderInformationBillToAddress1 = "901 Metro Center Blvd"; + string orderInformationBillToLocality = "Foster City"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94404"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "6504327113"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/DigitalPaymentsApplePay.cs b/Source/Samples/Payments/Payments/DigitalPaymentsApplePay.cs new file mode 100644 index 0000000..31fa1aa --- /dev/null +++ b/Source/Samples/Payments/Payments/DigitalPaymentsApplePay.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class DigitalPaymentsApplePay + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static bool CaptureTrueForProcessPayment { get; set; } = false; + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC_1231223"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + if (CaptureTrueForProcessPayment) + { + processingInformationCapture = true; + } + string processingInformationPaymentSolution = "001"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + PaymentSolution: processingInformationPaymentSolution + ); + + string paymentInformationTokenizedCardNumber = "4111111111111111"; + string paymentInformationTokenizedCardExpirationMonth = "12"; + string paymentInformationTokenizedCardExpirationYear = "2031"; + string paymentInformationTokenizedCardCryptogram = "AceY+igABPs3jdwNaDg3MAACAAA="; + string paymentInformationTokenizedCardTransactionType = "1"; + Ptsv2paymentsPaymentInformationTokenizedCard paymentInformationTokenizedCard = new Ptsv2paymentsPaymentInformationTokenizedCard( + Number: paymentInformationTokenizedCardNumber, + ExpirationMonth: paymentInformationTokenizedCardExpirationMonth, + ExpirationYear: paymentInformationTokenizedCardExpirationYear, + Cryptogram: paymentInformationTokenizedCardCryptogram, + TransactionType: paymentInformationTokenizedCardTransactionType + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + TokenizedCard: paymentInformationTokenizedCard + ); + + string orderInformationAmountDetailsTotalAmount = "10"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Deo"; + string orderInformationBillToAddress1 = "901 Metro Center Blvd"; + string orderInformationBillToLocality = "Foster City"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94404"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "6504327113"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/EBTElectronicVoucherPurchaseFromSNAPAccountWithVisaPlatformConnect.cs b/Source/Samples/Payments/Payments/EBTElectronicVoucherPurchaseFromSNAPAccountWithVisaPlatformConnect.cs new file mode 100644 index 0000000..5e45d56 --- /dev/null +++ b/Source/Samples/Payments/Payments/EBTElectronicVoucherPurchaseFromSNAPAccountWithVisaPlatformConnect.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments.Payments +{ + public class EBTElectronicVoucherPurchaseFromSNAPAccountWithVisaPlatformConnect + { + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "EBT - Voucher Purchase From SNAP Account"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + bool processingInformationPurchaseOptionsIsElectronicBenefitsTransfer = true; + Ptsv2paymentsProcessingInformationPurchaseOptions processingInformationPurchaseOptions = new Ptsv2paymentsProcessingInformationPurchaseOptions( + IsElectronicBenefitsTransfer: processingInformationPurchaseOptionsIsElectronicBenefitsTransfer + ); + + string processingInformationElectronicBenefitsTransferCategory = "FOOD"; + string processingInformationElectronicBenefitsTransferVoucherSerialNumber = "123451234512345"; + Ptsv2paymentsProcessingInformationElectronicBenefitsTransfer processingInformationElectronicBenefitsTransfer = new Ptsv2paymentsProcessingInformationElectronicBenefitsTransfer( + Category: processingInformationElectronicBenefitsTransferCategory, + VoucherSerialNumber: processingInformationElectronicBenefitsTransferVoucherSerialNumber + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + PurchaseOptions: processingInformationPurchaseOptions, + ElectronicBenefitsTransfer: processingInformationElectronicBenefitsTransfer + ); + + string paymentInformationCardNumber = "4012002000013007"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "25"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + string paymentInformationPaymentTypeName = "CARD"; + string paymentInformationPaymentTypeSubTypeName = "DEBIT"; + Ptsv2paymentsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsPaymentInformationPaymentType( + Name: paymentInformationPaymentTypeName, + SubTypeName: paymentInformationPaymentTypeSubTypeName + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard, + PaymentType: paymentInformationPaymentType + ); + + string orderInformationAmountDetailsTotalAmount = "103.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string pointOfSaleInformationEntryMode = "keyed"; + int pointOfSaleInformationTerminalCapability = 4; + string pointOfSaleInformationTrackData = "%B4111111111111111^JONES/JONES ^3112101976110000868000000?;4111111111111111=16121019761186800000?"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + TrackData: pointOfSaleInformationTrackData + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetAlternativeConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Payments/EBTPurchaseFromCashBenefitsAccountWithCashback.cs b/Source/Samples/Payments/Payments/EBTPurchaseFromCashBenefitsAccountWithCashback.cs new file mode 100644 index 0000000..81a5d49 --- /dev/null +++ b/Source/Samples/Payments/Payments/EBTPurchaseFromCashBenefitsAccountWithCashback.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments.Payments +{ + public class EBTPurchaseFromCashBenefitsAccountWithCashback + { + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "EBT - Purchase from Cash Benefits Account with CB"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + bool processingInformationPurchaseOptionsIsElectronicBenefitsTransfer = true; + Ptsv2paymentsProcessingInformationPurchaseOptions processingInformationPurchaseOptions = new Ptsv2paymentsProcessingInformationPurchaseOptions( + IsElectronicBenefitsTransfer: processingInformationPurchaseOptionsIsElectronicBenefitsTransfer + ); + + string processingInformationElectronicBenefitsTransferCategory = "CASH"; + Ptsv2paymentsProcessingInformationElectronicBenefitsTransfer processingInformationElectronicBenefitsTransfer = new Ptsv2paymentsProcessingInformationElectronicBenefitsTransfer( + Category: processingInformationElectronicBenefitsTransferCategory + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + PurchaseOptions: processingInformationPurchaseOptions, + ElectronicBenefitsTransfer: processingInformationElectronicBenefitsTransfer + ); + + string paymentInformationCardType = "001"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Type: paymentInformationCardType + ); + + string paymentInformationPaymentTypeName = "CARD"; + string paymentInformationPaymentTypeSubTypeName = "DEBIT"; + Ptsv2paymentsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsPaymentInformationPaymentType( + Name: paymentInformationPaymentTypeName, + SubTypeName: paymentInformationPaymentTypeSubTypeName + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard, + PaymentType: paymentInformationPaymentType + ); + + string orderInformationAmountDetailsTotalAmount = "702.00"; + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsCashbackAmount = "45.00"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency, + CashbackAmount: orderInformationAmountDetailsCashbackAmount + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string pointOfSaleInformationEntryMode = "swiped"; + int pointOfSaleInformationTerminalCapability = 4; + string pointOfSaleInformationTrackData = "%B4111111111111111^JONES/JONES ^3112101976110000868000000?;4111111111111111=16121019761186800000?"; + int pointOfSaleInformationPinBlockEncodingFormat = 1; + string pointOfSaleInformationEncryptedPin = "52F20658C04DB351"; + string pointOfSaleInformationEncryptedKeySerialNumber = "FFFF1B1D140000000005"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + TrackData: pointOfSaleInformationTrackData, + PinBlockEncodingFormat: pointOfSaleInformationPinBlockEncodingFormat, + EncryptedPin: pointOfSaleInformationEncryptedPin, + EncryptedKeySerialNumber: pointOfSaleInformationEncryptedKeySerialNumber + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetAlternativeConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Payments/EBTPurchaseFromSNAPAccountWithVisaPlatformConnect.cs b/Source/Samples/Payments/Payments/EBTPurchaseFromSNAPAccountWithVisaPlatformConnect.cs new file mode 100644 index 0000000..a4939d0 --- /dev/null +++ b/Source/Samples/Payments/Payments/EBTPurchaseFromSNAPAccountWithVisaPlatformConnect.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments.Payments +{ + public class EBTPurchaseFromSNAPAccountWithVisaPlatformConnect + { + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "EBT - Purchase From SNAP Account"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + bool processingInformationPurchaseOptionsIsElectronicBenefitsTransfer = true; + Ptsv2paymentsProcessingInformationPurchaseOptions processingInformationPurchaseOptions = new Ptsv2paymentsProcessingInformationPurchaseOptions( + IsElectronicBenefitsTransfer: processingInformationPurchaseOptionsIsElectronicBenefitsTransfer + ); + + string processingInformationElectronicBenefitsTransferCategory = "FOOD"; + Ptsv2paymentsProcessingInformationElectronicBenefitsTransfer processingInformationElectronicBenefitsTransfer = new Ptsv2paymentsProcessingInformationElectronicBenefitsTransfer( + Category: processingInformationElectronicBenefitsTransferCategory + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + PurchaseOptions: processingInformationPurchaseOptions, + ElectronicBenefitsTransfer: processingInformationElectronicBenefitsTransfer + ); + + string paymentInformationPaymentTypeName = "CARD"; + string paymentInformationPaymentTypeSubTypeName = "DEBIT"; + Ptsv2paymentsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsPaymentInformationPaymentType( + Name: paymentInformationPaymentTypeName, + SubTypeName: paymentInformationPaymentTypeSubTypeName + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + PaymentType: paymentInformationPaymentType + ); + + string orderInformationAmountDetailsTotalAmount = "101.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string pointOfSaleInformationEntryMode = "swiped"; + int pointOfSaleInformationTerminalCapability = 4; + string pointOfSaleInformationTrackData = "%B4111111111111111^JONES/JONES ^3112101976110000868000000?;4111111111111111=16121019761186800000?"; + int pointOfSaleInformationPinBlockEncodingFormat = 1; + string pointOfSaleInformationEncryptedPin = "52F20658C04DB351"; + string pointOfSaleInformationEncryptedKeySerialNumber = "FFFF1B1D140000000005"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + TrackData: pointOfSaleInformationTrackData, + PinBlockEncodingFormat: pointOfSaleInformationPinBlockEncodingFormat, + EncryptedPin: pointOfSaleInformationEncryptedPin, + EncryptedKeySerialNumber: pointOfSaleInformationEncryptedKeySerialNumber + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetAlternativeConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Payments/ElectronicCheckDebits.cs b/Source/Samples/Payments/Payments/ElectronicCheckDebits.cs new file mode 100644 index 0000000..2acea29 --- /dev/null +++ b/Source/Samples/Payments/Payments/ElectronicCheckDebits.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class ElectronicCheckDebits + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + string paymentInformationBankAccountType = "C"; + string paymentInformationBankAccountNumber = "4100"; + Ptsv2paymentsPaymentInformationBankAccount paymentInformationBankAccount = new Ptsv2paymentsPaymentInformationBankAccount( + Type: paymentInformationBankAccountType, + Number: paymentInformationBankAccountNumber + ); + + string paymentInformationBankRoutingNumber = "071923284"; + Ptsv2paymentsPaymentInformationBank paymentInformationBank = new Ptsv2paymentsPaymentInformationBank( + Account: paymentInformationBankAccount, + RoutingNumber: paymentInformationBankRoutingNumber + ); + + string paymentInformationPaymentTypeName = "CHECK"; + Ptsv2paymentsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsPaymentInformationPaymentType( + Name: paymentInformationPaymentTypeName + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Bank: paymentInformationBank, + PaymentType: paymentInformationPaymentType + ); + + string orderInformationAmountDetailsTotalAmount = "100"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/ElectronicCheckDebitsWithLegacyToken.cs b/Source/Samples/Payments/Payments/ElectronicCheckDebitsWithLegacyToken.cs new file mode 100644 index 0000000..a79ecbd --- /dev/null +++ b/Source/Samples/Payments/Payments/ElectronicCheckDebitsWithLegacyToken.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class ElectronicCheckDebitsWithLegacyToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationLegacyTokenId = "AB7C01E66529EA42E05341588E0A22AD"; + Ptsv2paymentsPaymentInformationLegacyToken paymentInformationLegacyToken = new Ptsv2paymentsPaymentInformationLegacyToken( + Id: paymentInformationLegacyTokenId + ); + + string paymentInformationPaymentTypeName = "CHECK"; + Ptsv2paymentsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsPaymentInformationPaymentType( + Name: paymentInformationPaymentTypeName + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + LegacyToken: paymentInformationLegacyToken, + PaymentType: paymentInformationPaymentType + ); + + string orderInformationAmountDetailsTotalAmount = "100"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/IncrementalAuthorization.cs b/Source/Samples/Payments/Payments/IncrementalAuthorization.cs new file mode 100644 index 0000000..b794ef7 --- /dev/null +++ b/Source/Samples/Payments/Payments/IncrementalAuthorization.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class IncrementalAuthorization + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2IncrementalAuthorizationPatch201Response Run() + { + string id = AuthorizationForIncrementalAuthorizationFlow.Run().Id; + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsidClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsidClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed = true; + Ptsv2paymentsidProcessingInformationAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new Ptsv2paymentsidProcessingInformationAuthorizationOptionsInitiator( + StoredCredentialUsed: processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed + ); + + Ptsv2paymentsidProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsidProcessingInformationAuthorizationOptions( + Initiator: processingInformationAuthorizationOptionsInitiator + ); + + Ptsv2paymentsidProcessingInformation processingInformation = new Ptsv2paymentsidProcessingInformation( + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string orderInformationAmountDetailsAdditionalAmount = "22.49"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsidOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidOrderInformationAmountDetails( + AdditionalAmount: orderInformationAmountDetailsAdditionalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsidOrderInformation orderInformation = new Ptsv2paymentsidOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string merchantInformationTransactionLocalDateTime = "20191002080000"; + Ptsv2paymentsidMerchantInformation merchantInformation = new Ptsv2paymentsidMerchantInformation( + TransactionLocalDateTime: merchantInformationTransactionLocalDateTime + ); + + string travelInformationDuration = "4"; + Ptsv2paymentsidTravelInformation travelInformation = new Ptsv2paymentsidTravelInformation( + Duration: travelInformationDuration + ); + + var requestObj = new IncrementAuthRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + MerchantInformation: merchantInformation, + TravelInformation: travelInformation + ); + + try + { + var configDictionary = new Configuration().GetAlternativeConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2IncrementalAuthorizationPatch201Response result = apiInstance.IncrementAuth(id, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/LevelIIData.cs b/Source/Samples/Payments/Payments/LevelIIData.cs new file mode 100644 index 0000000..e7fea39 --- /dev/null +++ b/Source/Samples/Payments/Payments/LevelIIData.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class LevelIIData + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static bool CaptureTrueForProcessPayment { get; set; } = false; + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_12"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + if (CaptureTrueForProcessPayment) + { + processingInformationCapture = true; + } + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardType = "001"; + string paymentInformationCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Type: paymentInformationCardType, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "112.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + string orderInformationInvoiceDetailsPurchaseOrderNumber = "LevelII Auth Po"; + Ptsv2paymentsOrderInformationInvoiceDetails orderInformationInvoiceDetails = new Ptsv2paymentsOrderInformationInvoiceDetails( + PurchaseOrderNumber: orderInformationInvoiceDetailsPurchaseOrderNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo, + InvoiceDetails: orderInformationInvoiceDetails + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/LevelIIIData.cs b/Source/Samples/Payments/Payments/LevelIIIData.cs new file mode 100644 index 0000000..8c90f9b --- /dev/null +++ b/Source/Samples/Payments/Payments/LevelIIIData.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class LevelIIIData + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static bool CaptureTrueForProcessPayment { get; set; } = false; + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_14"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + if (CaptureTrueForProcessPayment) + { + processingInformationCapture = true; + } + + string processingInformationPurchaseLevel = "3"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + PurchaseLevel: processingInformationPurchaseLevel + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardType = "001"; + string paymentInformationCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Type: paymentInformationCardType, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsProductCode1 = "default"; + int orderInformationLineItemsQuantity1 = 10; + string orderInformationLineItemsUnitPrice1 = "10.00"; + string orderInformationLineItemsTotalAmount1 = "100"; + bool orderInformationLineItemsAmountIncludesTax1 = false; + bool orderInformationLineItemsDiscountApplied1 = false; + orderInformationLineItems.Add(new Ptsv2paymentsOrderInformationLineItems( + ProductCode: orderInformationLineItemsProductCode1, + Quantity: orderInformationLineItemsQuantity1, + UnitPrice: orderInformationLineItemsUnitPrice1, + TotalAmount: orderInformationLineItemsTotalAmount1, + AmountIncludesTax: orderInformationLineItemsAmountIncludesTax1, + DiscountApplied: orderInformationLineItemsDiscountApplied1 + )); + + string orderInformationInvoiceDetailsPurchaseOrderNumber = "LevelIII Auth Po"; + Ptsv2paymentsOrderInformationInvoiceDetails orderInformationInvoiceDetails = new Ptsv2paymentsOrderInformationInvoiceDetails( + PurchaseOrderNumber: orderInformationInvoiceDetailsPurchaseOrderNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo, + LineItems: orderInformationLineItems, + InvoiceDetails: orderInformationInvoiceDetails + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/MITIndustryPracticeDelayedCharge3RIVisa.cs b/Source/Samples/Payments/Payments/MITIndustryPracticeDelayedCharge3RIVisa.cs new file mode 100644 index 0000000..3df6884 --- /dev/null +++ b/Source/Samples/Payments/Payments/MITIndustryPracticeDelayedCharge3RIVisa.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class MITIndustryPracticeDelayedCharge3RIVisa + { + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "vbv"; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = false; + bool processingInformationAuthorizationOptionsIgnoreCvResult = false; + string processingInformationAuthorizationOptionsInitiatorType = "merchant"; + bool processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed = true; + string processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionReason = "2"; + string processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionPreviousTransactionId = "123456789012345"; + Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction( + Reason: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionReason, + PreviousTransactionId: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionPreviousTransactionId + ); + + Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator( + Type: processingInformationAuthorizationOptionsInitiatorType, + StoredCredentialUsed: processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed, + MerchantInitiatedTransaction: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction + ); + + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult, + Initiator: processingInformationAuthorizationOptionsInitiator + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardType = "001"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Type: paymentInformationCardType + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "GBP"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string consumerAuthenticationInformationCavv = "EHuWW9PiBkWvqE5juRwDzAUFBAk="; + string consumerAuthenticationInformationParesStatus = "Y"; + Ptsv2paymentsConsumerAuthenticationInformation consumerAuthenticationInformation = new Ptsv2paymentsConsumerAuthenticationInformation( + Cavv: consumerAuthenticationInformationCavv, + ParesStatus: consumerAuthenticationInformationParesStatus + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + ConsumerAuthenticationInformation: consumerAuthenticationInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Payments/MITIndustryPracticeResubmission.cs b/Source/Samples/Payments/Payments/MITIndustryPracticeResubmission.cs new file mode 100644 index 0000000..b2a183f --- /dev/null +++ b/Source/Samples/Payments/Payments/MITIndustryPracticeResubmission.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class MITIndustryPracticeResubmission + { + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "moto"; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = false; + bool processingInformationAuthorizationOptionsIgnoreCvResult = false; + string processingInformationAuthorizationOptionsInitiatorType = "merchant"; + bool processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed = true; + string processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionReason = "1"; + string processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionPreviousTransactionId = "123456789012345"; + Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction( + Reason: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionReason, + PreviousTransactionId: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionPreviousTransactionId + ); + + Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator( + Type: processingInformationAuthorizationOptionsInitiatorType, + StoredCredentialUsed: processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed, + MerchantInitiatedTransaction: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction + ); + + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult, + Initiator: processingInformationAuthorizationOptionsInitiator + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardType = "001"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Type: paymentInformationCardType + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "GBP"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Payments/MITInstalment.cs b/Source/Samples/Payments/Payments/MITInstalment.cs new file mode 100644 index 0000000..5b19269 --- /dev/null +++ b/Source/Samples/Payments/Payments/MITInstalment.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class MITInstalment + { + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "install"; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = false; + bool processingInformationAuthorizationOptionsIgnoreCvResult = false; + string processingInformationAuthorizationOptionsInitiatorType = "merchant"; + bool processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed = true; + string processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionPreviousTransactionId = "123456789012345"; + Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction( + PreviousTransactionId: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionPreviousTransactionId + ); + + Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator( + Type: processingInformationAuthorizationOptionsInitiatorType, + StoredCredentialUsed: processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed, + MerchantInitiatedTransaction: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction + ); + + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult, + Initiator: processingInformationAuthorizationOptionsInitiator + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardType = "001"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Type: paymentInformationCardType + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "GBP"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Payments/MITRecurring.cs b/Source/Samples/Payments/Payments/MITRecurring.cs new file mode 100644 index 0000000..324c564 --- /dev/null +++ b/Source/Samples/Payments/Payments/MITRecurring.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class MITRecurring + { + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "recurring"; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = false; + bool processingInformationAuthorizationOptionsIgnoreCvResult = false; + string processingInformationAuthorizationOptionsInitiatorType = "merchant"; + bool processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed = true; + string processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionPreviousTransactionId = "123456789012345"; + Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction( + PreviousTransactionId: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionPreviousTransactionId + ); + + Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator( + Type: processingInformationAuthorizationOptionsInitiatorType, + StoredCredentialUsed: processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed, + MerchantInitiatedTransaction: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction + ); + + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult, + Initiator: processingInformationAuthorizationOptionsInitiator + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardType = "001"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Type: paymentInformationCardType + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "GBP"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Payments/MITUnscheduledCredentialOnFile.cs b/Source/Samples/Payments/Payments/MITUnscheduledCredentialOnFile.cs new file mode 100644 index 0000000..d122dea --- /dev/null +++ b/Source/Samples/Payments/Payments/MITUnscheduledCredentialOnFile.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class MITUnscheduledCredentialOnFile + { + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "internet"; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = false; + bool processingInformationAuthorizationOptionsIgnoreCvResult = false; + string processingInformationAuthorizationOptionsInitiatorType = "merchant"; + bool processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed = true; + string processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionPreviousTransactionId = "123456789012345"; + Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction( + PreviousTransactionId: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionPreviousTransactionId + ); + + Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new Ptsv2paymentsProcessingInformationAuthorizationOptionsInitiator( + Type: processingInformationAuthorizationOptionsInitiatorType, + StoredCredentialUsed: processingInformationAuthorizationOptionsInitiatorStoredCredentialUsed, + MerchantInitiatedTransaction: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction + ); + + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult, + Initiator: processingInformationAuthorizationOptionsInitiator + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardType = "001"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + Type: paymentInformationCardType + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "GBP"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Payments/PartialAuthorization.cs b/Source/Samples/Payments/Payments/PartialAuthorization.cs new file mode 100644 index 0000000..3ea3d31 --- /dev/null +++ b/Source/Samples/Payments/Payments/PartialAuthorization.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class PartialAuthorization + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "1234567890"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "7012.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + int pointOfSaleInformationCatLevel = 6; + int pointOfSaleInformationTerminalCapability = 4; + bool pointOfSaleInformationEmvFallback = false; + int pointOfSaleInformationEmvFallbackCondition = 1; + Ptsv2paymentsPointOfSaleInformationEmv pointOfSaleInformationEmv = new Ptsv2paymentsPointOfSaleInformationEmv( + Fallback: pointOfSaleInformationEmvFallback, + FallbackCondition: pointOfSaleInformationEmvFallbackCondition + ); + + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + CatLevel: pointOfSaleInformationCatLevel, + TerminalCapability: pointOfSaleInformationTerminalCapability, + Emv: pointOfSaleInformationEmv + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/PaymentNetworkTokenization.cs b/Source/Samples/Payments/Payments/PaymentNetworkTokenization.cs new file mode 100644 index 0000000..375d084 --- /dev/null +++ b/Source/Samples/Payments/Payments/PaymentNetworkTokenization.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class PaymentNetworkTokenization + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static bool CaptureTrueForProcessPayment { get; set; } = false; + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC_123122"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + if (CaptureTrueForProcessPayment) + { + processingInformationCapture = true; + } + + string processingInformationCommerceIndicator = "vbv"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationTokenizedCardNumber = "4111111111111111"; + string paymentInformationTokenizedCardExpirationMonth = "12"; + string paymentInformationTokenizedCardExpirationYear = "2031"; + string paymentInformationTokenizedCardTransactionType = "1"; + Ptsv2paymentsPaymentInformationTokenizedCard paymentInformationTokenizedCard = new Ptsv2paymentsPaymentInformationTokenizedCard( + Number: paymentInformationTokenizedCardNumber, + ExpirationMonth: paymentInformationTokenizedCardExpirationMonth, + ExpirationYear: paymentInformationTokenizedCardExpirationYear, + TransactionType: paymentInformationTokenizedCardTransactionType + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + TokenizedCard: paymentInformationTokenizedCard + ); + + string orderInformationAmountDetailsTotalAmount = "100"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string consumerAuthenticationInformationCavv = "AAABCSIIAAAAAAACcwgAEMCoNh+="; + string consumerAuthenticationInformationXid = "T1Y0OVcxMVJJdkI0WFlBcXptUzE="; + Ptsv2paymentsConsumerAuthenticationInformation consumerAuthenticationInformation = new Ptsv2paymentsConsumerAuthenticationInformation( + Cavv: consumerAuthenticationInformationCavv, + Xid: consumerAuthenticationInformationXid + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + ConsumerAuthenticationInformation: consumerAuthenticationInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/PaymentWithFlexToken.cs b/Source/Samples/Payments/Payments/PaymentWithFlexToken.cs new file mode 100644 index 0000000..9d44aae --- /dev/null +++ b/Source/Samples/Payments/Payments/PaymentWithFlexToken.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class PaymentWithFlexToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "RTS"; + string orderInformationBillToLastName = "VDP"; + string orderInformationBillToAddress1 = "201 S. Division St."; + string orderInformationBillToLocality = "Ann Arbor"; + string orderInformationBillToAdministrativeArea = "MI"; + string orderInformationBillToPostalCode = "48104-2201"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToDistrict = "MI"; + string orderInformationBillToBuildingNumber = "123"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "999999999"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + District: orderInformationBillToDistrict, + BuildingNumber: orderInformationBillToBuildingNumber, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string tokenInformationTransientTokenJwt = "eyJraWQiOiIwN0JwSE9abkhJM3c3UVAycmhNZkhuWE9XQlhwa1ZHTiIsImFsZyI6IlJTMjU2In0.eyJkYXRhIjp7ImV4cGlyYXRpb25ZZWFyIjoiMjAyMCIsIm51bWJlciI6IjQxMTExMVhYWFhYWDExMTEiLCJleHBpcmF0aW9uTW9udGgiOiIxMCIsInR5cGUiOiIwMDEifSwiaXNzIjoiRmxleC8wNyIsImV4cCI6MTU5MTc0NjAyNCwidHlwZSI6Im1mLTAuMTEuMCIsImlhdCI6MTU5MTc0NTEyNCwianRpIjoiMUMzWjdUTkpaVjI4OVM5MTdQM0JHSFM1T0ZQNFNBRERCUUtKMFFKMzMzOEhRR0MwWTg0QjVFRTAxREU4NEZDQiJ9.cfwzUMJf115K2T9-wE_A_k2jZptXlovls8-fKY0muO8YzGatE5fu9r6aC4q7n0YOvEU6G7XdH4ASG32mWnYu-kKlqN4IY_cquRJeUvV89ZPZ5WTttyrgVH17LSTE2EvwMawKNYnjh0lJwqYJ51cLnJiVlyqTdEAv3DJ3vInXP1YeQjLX5_vF-OWEuZfJxahHfUdsjeGhGaaOGVMUZJSkzpTu9zDLTvpb1px3WGGPu8FcHoxrcCGGpcKk456AZgYMBSHNjr-pPkRr3Dnd7XgNF6shfzIPbcXeWDYPTpS4PNY8ZsWKx8nFQIeROMWCSxIZOmu3Wt71KN9iK6DfOPro7w"; + Ptsv2paymentsTokenInformation tokenInformation = new Ptsv2paymentsTokenInformation( + TransientTokenJwt: tokenInformationTransientTokenJwt + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + TokenInformation: tokenInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/PaymentWithFlexTokenCreatePermanentTMSToken.cs b/Source/Samples/Payments/Payments/PaymentWithFlexTokenCreatePermanentTMSToken.cs new file mode 100644 index 0000000..0a7489b --- /dev/null +++ b/Source/Samples/Payments/Payments/PaymentWithFlexTokenCreatePermanentTMSToken.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class PaymentWithFlexTokenCreatePermanentTMSToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + List processingInformationActionList = new List(); + processingInformationActionList.Add("TOKEN_CREATE"); + + List processingInformationActionTokenTypes = new List(); + processingInformationActionTokenTypes.Add("customer"); + processingInformationActionTokenTypes.Add("paymentInstrument"); + processingInformationActionTokenTypes.Add("shippingAddress"); + bool processingInformationCapture = false; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + ActionList: processingInformationActionList, + ActionTokenTypes: processingInformationActionTokenTypes, + Capture: processingInformationCapture + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + string orderInformationShipToFirstName = "John"; + string orderInformationShipToLastName = "Doe"; + string orderInformationShipToAddress1 = "1 Market St"; + string orderInformationShipToLocality = "san francisco"; + string orderInformationShipToAdministrativeArea = "CA"; + string orderInformationShipToPostalCode = "94105"; + string orderInformationShipToCountry = "US"; + Ptsv2paymentsOrderInformationShipTo orderInformationShipTo = new Ptsv2paymentsOrderInformationShipTo( + FirstName: orderInformationShipToFirstName, + LastName: orderInformationShipToLastName, + Address1: orderInformationShipToAddress1, + Locality: orderInformationShipToLocality, + AdministrativeArea: orderInformationShipToAdministrativeArea, + PostalCode: orderInformationShipToPostalCode, + Country: orderInformationShipToCountry + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo + ); + + string tokenInformationTransientTokenJwt = "eyJraWQiOiIwOHAwWWVyTTBJSnpvYlpMMENyalVsRnQ4QXlIdXc4TSIsImFsZyI6IlJTMjU2In0.eyJkYXRhIjp7ImV4cGlyYXRpb25ZZWFyIjoiMjAyMyIsIm51bWJlciI6IjQxMTExMVhYWFhYWDExMTEiLCJleHBpcmF0aW9uTW9udGgiOiIwNyIsInR5cGUiOiIwMDEifSwiaXNzIjoiRmxleC8wOCIsImV4cCI6MTU5OTU2MDU3OSwidHlwZSI6Im1mLTAuMTEuMCIsImlhdCI6MTU5OTU1OTY3OSwianRpIjoiMUUyWjRMNjYxMENPSExHUUIxMlBXQk5OUjE1WFUwU1ROTTQ5UlA5WlJaUEtBVE1NOVo5UzVGNTc1QjgzNEFDOCJ9.Va9-Rf3nBtxHXVvb1M-mQqzOa86Uj5wY3qejFmYmMiSjMOSF_DpNepjOYat-8WqdacmhUemtwQfOtDEVDpd6X3YpBNydZ4dzVt3baq2Z1KAH1lEJxyvAyHX77tnO-wzfZrQm-HH-qtrGmt6ZvuNknvYPxwPcqnOryGaIQE70znBK6GVf3vgdE0xedxAQWl97ZfpZKafVjCvtGIMuJ0QdtrqM0OmtkoDKrqmXGzKlfSbpEep_yaDdpRkX_NdOgiVomRb3P6nqkT1OO0Czzu4HyxaMfVyCgGUAHd_SjXrwqM2vuchE4Scg1DicjWAJxXb_tZoAuUU0EN8HwVnrHiFAiQ"; + Ptsv2paymentsTokenInformation tokenInformation = new Ptsv2paymentsTokenInformation( + TransientTokenJwt: tokenInformationTransientTokenJwt + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + TokenInformation: tokenInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/PinDebitPurchaseUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect.cs b/Source/Samples/Payments/Payments/PinDebitPurchaseUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect.cs new file mode 100644 index 0000000..34bf389 --- /dev/null +++ b/Source/Samples/Payments/Payments/PinDebitPurchaseUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class PinDebitPurchaseUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect + { + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "2.2 Purchase"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + ); + + string orderInformationAmountDetailsTotalAmount = "202.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string pointOfSaleInformationEntryMode = "contactless"; + int pointOfSaleInformationTerminalCapability = 4; + string pointOfSaleInformationEmvTags = "9F3303204000950500000000009F3704518823719F100706011103A000009F26081E1756ED0E2134E29F36020015820200009C01009F1A0208409A030006219F02060000000020005F2A0208409F0306000000000000"; + string pointOfSaleInformationEmvCardSequenceNumber = "1"; + bool pointOfSaleInformationEmvFallback = false; + Ptsv2paymentsPointOfSaleInformationEmv pointOfSaleInformationEmv = new Ptsv2paymentsPointOfSaleInformationEmv( + Tags: pointOfSaleInformationEmvTags, + CardSequenceNumber: pointOfSaleInformationEmvCardSequenceNumber, + Fallback: pointOfSaleInformationEmvFallback + ); + + string pointOfSaleInformationTrackData = "%B4111111111111111^JONES/JONES ^3112101976110000868000000?;4111111111111111=16121019761186800000?"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + Emv: pointOfSaleInformationEmv, + TrackData: pointOfSaleInformationTrackData + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetAlternativeConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/PinDebitPurchaseUsingSwipedTrackDataWithVisaPlatformConnect.cs b/Source/Samples/Payments/Payments/PinDebitPurchaseUsingSwipedTrackDataWithVisaPlatformConnect.cs new file mode 100644 index 0000000..716752b --- /dev/null +++ b/Source/Samples/Payments/Payments/PinDebitPurchaseUsingSwipedTrackDataWithVisaPlatformConnect.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class PinDebitPurchaseUsingSwipedTrackDataWithVisaPlatformConnect + { + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "2.2 Purchase"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string processingInformationCommerceIndicator = "retail"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationPaymentTypeName = "CARD"; + Ptsv2paymentsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsPaymentInformationPaymentType( + Name: paymentInformationPaymentTypeName + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + PaymentType: paymentInformationPaymentType + ); + + string orderInformationAmountDetailsTotalAmount = "202.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string pointOfSaleInformationEntryMode = "swiped"; + string pointOfSaleInformationTrackData = "%B4111111111111111^JONES/JONES ^3112101976110000868000000?;4111111111111111=16121019761186800000?"; + int pointOfSaleInformationTerminalCapability = 1; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TrackData: pointOfSaleInformationTrackData, + TerminalCapability: pointOfSaleInformationTerminalCapability + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetAlternativeConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/RestaurantAuthorization.cs b/Source/Samples/Payments/Payments/RestaurantAuthorization.cs new file mode 100644 index 0000000..60eeba0 --- /dev/null +++ b/Source/Samples/Payments/Payments/RestaurantAuthorization.cs @@ -0,0 +1,96 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class RestaurantAuthorization + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "demomerchant"; + string clientReferenceInformationPartnerThirdPartyCertificationNumber = "123456789012"; + Ptsv2paymentsClientReferenceInformationPartner clientReferenceInformationPartner = new Ptsv2paymentsClientReferenceInformationPartner( + ThirdPartyCertificationNumber: clientReferenceInformationPartnerThirdPartyCertificationNumber + ); + + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + bool processingInformationAuthorizationOptionsPartialAuthIndicator = true; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = false; + bool processingInformationAuthorizationOptionsIgnoreCvResult = false; + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + PartialAuthIndicator: processingInformationAuthorizationOptionsPartialAuthIndicator, + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string pointOfSaleInformationEntryMode = "swiped"; + int pointOfSaleInformationTerminalCapability = 2; + string pointOfSaleInformationTrackData = "%B38000000000006^TEST/CYBS ^2012121019761100 00868000000?"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + TrackData: pointOfSaleInformationTrackData + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactReadOneForCardPresentEnabledAcquirer.cs b/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactReadOneForCardPresentEnabledAcquirer.cs new file mode 100644 index 0000000..faebdce --- /dev/null +++ b/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactReadOneForCardPresentEnabledAcquirer.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class SaleUsingEMVTechnologyWithContactReadOneForCardPresentEnabledAcquirer + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "123456"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + int pointOfSaleInformationCatLevel = 1; + string pointOfSaleInformationEntryMode = "contact"; + int pointOfSaleInformationTerminalCapability = 1; + string pointOfSaleInformationEmvCardSequenceNumber = "0"; + bool pointOfSaleInformationEmvFallback = false; + Ptsv2paymentsPointOfSaleInformationEmv pointOfSaleInformationEmv = new Ptsv2paymentsPointOfSaleInformationEmv( + CardSequenceNumber: pointOfSaleInformationEmvCardSequenceNumber, + Fallback: pointOfSaleInformationEmvFallback + ); + + string pointOfSaleInformationTrackData = "%B4111111111111111^TEST/CYBS ^2012121019761100 00868000000?;"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + CatLevel: pointOfSaleInformationCatLevel, + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + Emv: pointOfSaleInformationEmv, + TrackData: pointOfSaleInformationTrackData + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactReadTwoForCardPresentEnabledAcquirer.cs b/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactReadTwoForCardPresentEnabledAcquirer.cs new file mode 100644 index 0000000..8280266 --- /dev/null +++ b/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactReadTwoForCardPresentEnabledAcquirer.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class SaleUsingEMVTechnologyWithContactReadTwoForCardPresentEnabledAcquirer + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "123456"; + string clientReferenceInformationPartnerOriginalTransactionId = "510be4aef90711e6acbc7d88388d803d"; + Ptsv2paymentsClientReferenceInformationPartner clientReferenceInformationPartner = new Ptsv2paymentsClientReferenceInformationPartner( + OriginalTransactionId: clientReferenceInformationPartnerOriginalTransactionId + ); + + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + bool processingInformationCapture = true; + string processingInformationCommerceIndicator = "retail"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + int pointOfSaleInformationCatLevel = 1; + string pointOfSaleInformationEntryMode = "contact"; + int pointOfSaleInformationTerminalCapability = 4; + string pointOfSaleInformationEmvTags = "9F3303204000950500000000009F3704518823719F100706011103A000009F26081E1756ED0E2134E29F36020015820200009C01009F1A0208409A030006219F02060000000020005F2A0208409F0306000000000000"; + int pointOfSaleInformationEmvCardholderVerificationMethodUsed = 2; + string pointOfSaleInformationEmvCardSequenceNumber = "1"; + bool pointOfSaleInformationEmvFallback = false; + Ptsv2paymentsPointOfSaleInformationEmv pointOfSaleInformationEmv = new Ptsv2paymentsPointOfSaleInformationEmv( + Tags: pointOfSaleInformationEmvTags, + CardholderVerificationMethodUsed: pointOfSaleInformationEmvCardholderVerificationMethodUsed, + CardSequenceNumber: pointOfSaleInformationEmvCardSequenceNumber, + Fallback: pointOfSaleInformationEmvFallback + ); + + string pointOfSaleInformationTrackData = "%B4111111111111111^TEST/CYBS ^2012121019761100 00868000000?;"; + + List pointOfSaleInformationCardholderVerificationMethod = new List(); + pointOfSaleInformationCardholderVerificationMethod.Add("pin"); + pointOfSaleInformationCardholderVerificationMethod.Add("signature"); + + List pointOfSaleInformationTerminalInputCapability = new List(); + pointOfSaleInformationTerminalInputCapability.Add("contact"); + pointOfSaleInformationTerminalInputCapability.Add("contactless"); + pointOfSaleInformationTerminalInputCapability.Add("keyed"); + pointOfSaleInformationTerminalInputCapability.Add("swiped"); + string pointOfSaleInformationTerminalCardCaptureCapability = "1"; + string pointOfSaleInformationDeviceId = "123lkjdIOBK34981slviLI39bj"; + string pointOfSaleInformationEncryptedKeySerialNumber = "01043191"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + CatLevel: pointOfSaleInformationCatLevel, + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + Emv: pointOfSaleInformationEmv, + TrackData: pointOfSaleInformationTrackData, + CardholderVerificationMethod: pointOfSaleInformationCardholderVerificationMethod, + TerminalInputCapability: pointOfSaleInformationTerminalInputCapability, + TerminalCardCaptureCapability: pointOfSaleInformationTerminalCardCaptureCapability, + DeviceId: pointOfSaleInformationDeviceId, + EncryptedKeySerialNumber: pointOfSaleInformationEncryptedKeySerialNumber + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactReadWithVisaPlatformConnect.cs b/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactReadWithVisaPlatformConnect.cs new file mode 100644 index 0000000..a809c2e --- /dev/null +++ b/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactReadWithVisaPlatformConnect.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class SaleUsingEMVTechnologyWithContactReadWithVisaPlatformConnect + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "123456"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + bool processingInformationAuthorizationOptionsPartialAuthIndicator = true; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = false; + bool processingInformationAuthorizationOptionsIgnoreCvResult = false; + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + PartialAuthIndicator: processingInformationAuthorizationOptionsPartialAuthIndicator, + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + int pointOfSaleInformationCatLevel = 1; + string pointOfSaleInformationEntryMode = "contact"; + int pointOfSaleInformationTerminalCapability = 4; + string pointOfSaleInformationEmvTags = "9F3303204000950500000000009F3704518823719F100706011103A000009F26081E1756ED0E2134E29F36020015820200009C01009F1A0208409A030006219F02060000000020005F2A0208409F0306000000000000"; + string pointOfSaleInformationEmvCardSequenceNumber = "1"; + bool pointOfSaleInformationEmvFallback = false; + Ptsv2paymentsPointOfSaleInformationEmv pointOfSaleInformationEmv = new Ptsv2paymentsPointOfSaleInformationEmv( + Tags: pointOfSaleInformationEmvTags, + CardSequenceNumber: pointOfSaleInformationEmvCardSequenceNumber, + Fallback: pointOfSaleInformationEmvFallback + ); + + string pointOfSaleInformationTrackData = "%B4111111111111111^TEST/CYBS ^2012121019761100 00868000000?;"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + CatLevel: pointOfSaleInformationCatLevel, + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + Emv: pointOfSaleInformationEmv, + TrackData: pointOfSaleInformationTrackData + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactless.cs b/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactless.cs new file mode 100644 index 0000000..5951879 --- /dev/null +++ b/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactless.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class SaleUsingEMVTechnologyWithContactless + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "123456"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + int pointOfSaleInformationCatLevel = 2; + string pointOfSaleInformationEntryMode = "contactless"; + int pointOfSaleInformationTerminalCapability = 2; + string pointOfSaleInformationEmvCardSequenceNumber = "999"; + bool pointOfSaleInformationEmvFallback = false; + Ptsv2paymentsPointOfSaleInformationEmv pointOfSaleInformationEmv = new Ptsv2paymentsPointOfSaleInformationEmv( + CardSequenceNumber: pointOfSaleInformationEmvCardSequenceNumber, + Fallback: pointOfSaleInformationEmvFallback + ); + + string pointOfSaleInformationTrackData = "%B38000000000006^TEST/CYBS ^2012121019761100 00868000000?;38000000000006=20121210197611868000?"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + CatLevel: pointOfSaleInformationCatLevel, + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + Emv: pointOfSaleInformationEmv, + TrackData: pointOfSaleInformationTrackData + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactlessReadForCardPresentEnabledAcquirer.cs b/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactlessReadForCardPresentEnabledAcquirer.cs new file mode 100644 index 0000000..327e303 --- /dev/null +++ b/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactlessReadForCardPresentEnabledAcquirer.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class SaleUsingEMVTechnologyWithContactlessReadForCardPresentEnabledAcquirer + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "123456"; + string clientReferenceInformationPartnerOriginalTransactionId = "510be4aef90711e6acbc7d88388d803d"; + Ptsv2paymentsClientReferenceInformationPartner clientReferenceInformationPartner = new Ptsv2paymentsClientReferenceInformationPartner( + OriginalTransactionId: clientReferenceInformationPartnerOriginalTransactionId + ); + + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + bool processingInformationCapture = true; + string processingInformationCommerceIndicator = "retail"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + int pointOfSaleInformationCatLevel = 1; + string pointOfSaleInformationEntryMode = "contactless"; + int pointOfSaleInformationTerminalCapability = 5; + string pointOfSaleInformationEmvTags = "9F3303204000950500000000009F3704518823719F100706011103A000009F26081E1756ED0E2134E29F36020015820200009C01009F1A0208409A030006219F02060000000020005F2A0208409F0306000000000000"; + int pointOfSaleInformationEmvCardholderVerificationMethodUsed = 2; + string pointOfSaleInformationEmvCardSequenceNumber = "1"; + bool pointOfSaleInformationEmvFallback = false; + Ptsv2paymentsPointOfSaleInformationEmv pointOfSaleInformationEmv = new Ptsv2paymentsPointOfSaleInformationEmv( + Tags: pointOfSaleInformationEmvTags, + CardholderVerificationMethodUsed: pointOfSaleInformationEmvCardholderVerificationMethodUsed, + CardSequenceNumber: pointOfSaleInformationEmvCardSequenceNumber, + Fallback: pointOfSaleInformationEmvFallback + ); + + string pointOfSaleInformationTrackData = "%B4111111111111111^TEST/CYBS ^2012121019761100 00868000000?;"; + + List pointOfSaleInformationCardholderVerificationMethod = new List(); + pointOfSaleInformationCardholderVerificationMethod.Add("pin"); + pointOfSaleInformationCardholderVerificationMethod.Add("signature"); + + List pointOfSaleInformationTerminalInputCapability = new List(); + pointOfSaleInformationTerminalInputCapability.Add("contact"); + pointOfSaleInformationTerminalInputCapability.Add("contactless"); + pointOfSaleInformationTerminalInputCapability.Add("keyed"); + pointOfSaleInformationTerminalInputCapability.Add("swiped"); + string pointOfSaleInformationTerminalCardCaptureCapability = "1"; + string pointOfSaleInformationDeviceId = "123lkjdIOBK34981slviLI39bj"; + string pointOfSaleInformationEncryptedKeySerialNumber = "01043191"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + CatLevel: pointOfSaleInformationCatLevel, + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + Emv: pointOfSaleInformationEmv, + TrackData: pointOfSaleInformationTrackData, + CardholderVerificationMethod: pointOfSaleInformationCardholderVerificationMethod, + TerminalInputCapability: pointOfSaleInformationTerminalInputCapability, + TerminalCardCaptureCapability: pointOfSaleInformationTerminalCardCaptureCapability, + DeviceId: pointOfSaleInformationDeviceId, + EncryptedKeySerialNumber: pointOfSaleInformationEncryptedKeySerialNumber + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect.cs b/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect.cs new file mode 100644 index 0000000..67fef17 --- /dev/null +++ b/Source/Samples/Payments/Payments/SaleUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class SaleUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "123456"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + bool processingInformationAuthorizationOptionsPartialAuthIndicator = true; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = false; + bool processingInformationAuthorizationOptionsIgnoreCvResult = false; + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + PartialAuthIndicator: processingInformationAuthorizationOptionsPartialAuthIndicator, + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + int pointOfSaleInformationCatLevel = 2; + string pointOfSaleInformationEntryMode = "contactless"; + int pointOfSaleInformationTerminalCapability = 5; + string pointOfSaleInformationEmvTags = "9F3303204000950500000000009F3704518823719F100706011103A000009F26081E1756ED0E2134E29F36020015820200009C01009F1A0208409A030006219F02060000000020005F2A0208409F0306000000000000"; + string pointOfSaleInformationEmvCardSequenceNumber = "1"; + bool pointOfSaleInformationEmvFallback = false; + Ptsv2paymentsPointOfSaleInformationEmv pointOfSaleInformationEmv = new Ptsv2paymentsPointOfSaleInformationEmv( + Tags: pointOfSaleInformationEmvTags, + CardSequenceNumber: pointOfSaleInformationEmvCardSequenceNumber, + Fallback: pointOfSaleInformationEmvFallback + ); + + string pointOfSaleInformationTrackData = "%B38000000000006^TEST/CYBS ^2012121019761100 00868000000?;38000000000006=20121210197611868000?"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + CatLevel: pointOfSaleInformationCatLevel, + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + Emv: pointOfSaleInformationEmv, + TrackData: pointOfSaleInformationTrackData + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/SaleUsingKeyedDataForCardPresentEnabledAcquirer.cs b/Source/Samples/Payments/Payments/SaleUsingKeyedDataForCardPresentEnabledAcquirer.cs new file mode 100644 index 0000000..1bdceba --- /dev/null +++ b/Source/Samples/Payments/Payments/SaleUsingKeyedDataForCardPresentEnabledAcquirer.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class SaleUsingKeyedDataForCardPresentEnabledAcquirer + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "123456"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = true; + string processingInformationCommerceIndicator = "retail"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string pointOfSaleInformationEntryMode = "keyed"; + int pointOfSaleInformationTerminalCapability = 2; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/SaleUsingKeyedDataWithBalanceInquiry.cs b/Source/Samples/Payments/Payments/SaleUsingKeyedDataWithBalanceInquiry.cs new file mode 100644 index 0000000..49904c5 --- /dev/null +++ b/Source/Samples/Payments/Payments/SaleUsingKeyedDataWithBalanceInquiry.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class SaleUsingKeyedDataWithBalanceInquiry + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "123456"; + string clientReferenceInformationPartnerThirdPartyCertificationNumber = "123456789012"; + Ptsv2paymentsClientReferenceInformationPartner clientReferenceInformationPartner = new Ptsv2paymentsClientReferenceInformationPartner( + ThirdPartyCertificationNumber: clientReferenceInformationPartnerThirdPartyCertificationNumber + ); + + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + bool processingInformationCapture = true; + string processingInformationCommerceIndicator = "retail"; + bool processingInformationAuthorizationOptionsPartialAuthIndicator = true; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = true; + bool processingInformationAuthorizationOptionsIgnoreCvResult = true; + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + PartialAuthIndicator: processingInformationAuthorizationOptionsPartialAuthIndicator, + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string pointOfSaleInformationEntryMode = "keyed"; + int pointOfSaleInformationTerminalCapability = 2; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/SaleUsingKeyedDataWithVisaPlatformConnect.cs b/Source/Samples/Payments/Payments/SaleUsingKeyedDataWithVisaPlatformConnect.cs new file mode 100644 index 0000000..53981b5 --- /dev/null +++ b/Source/Samples/Payments/Payments/SaleUsingKeyedDataWithVisaPlatformConnect.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class SaleUsingKeyedDataWithVisaPlatformConnect + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "123456"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = true; + string processingInformationCommerceIndicator = "retail"; + bool processingInformationAuthorizationOptionsPartialAuthIndicator = true; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = true; + bool processingInformationAuthorizationOptionsIgnoreCvResult = true; + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + PartialAuthIndicator: processingInformationAuthorizationOptionsPartialAuthIndicator, + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string pointOfSaleInformationEntryMode = "keyed"; + int pointOfSaleInformationTerminalCapability = 2; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/SaleUsingSwipedTrackDataForCardPresentEnabledAcquirer.cs b/Source/Samples/Payments/Payments/SaleUsingSwipedTrackDataForCardPresentEnabledAcquirer.cs new file mode 100644 index 0000000..48fca03 --- /dev/null +++ b/Source/Samples/Payments/Payments/SaleUsingSwipedTrackDataForCardPresentEnabledAcquirer.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class SaleUsingSwipedTrackDataForCardPresentEnabledAcquirer + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "123456"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = true; + string processingInformationCommerceIndicator = "retail"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string pointOfSaleInformationEntryMode = "swiped"; + int pointOfSaleInformationTerminalCapability = 2; + string pointOfSaleInformationTrackData = "%B38000000000006^TEST/CYBS ^2012121019761100 00868000000?;38000000000006=20121210197611868000?"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + TrackData: pointOfSaleInformationTrackData + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/SaleUsingSwipedTrackDataWithVisaPlatformConnect.cs b/Source/Samples/Payments/Payments/SaleUsingSwipedTrackDataWithVisaPlatformConnect.cs new file mode 100644 index 0000000..31d68af --- /dev/null +++ b/Source/Samples/Payments/Payments/SaleUsingSwipedTrackDataWithVisaPlatformConnect.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class SaleUsingSwipedTrackDataWithVisaPlatformConnect + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "123456"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = true; + string processingInformationCommerceIndicator = "retail"; + bool processingInformationAuthorizationOptionsPartialAuthIndicator = true; + bool processingInformationAuthorizationOptionsIgnoreAvsResult = false; + bool processingInformationAuthorizationOptionsIgnoreCvResult = false; + Ptsv2paymentsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Ptsv2paymentsProcessingInformationAuthorizationOptions( + PartialAuthIndicator: processingInformationAuthorizationOptionsPartialAuthIndicator, + IgnoreAvsResult: processingInformationAuthorizationOptionsIgnoreAvsResult, + IgnoreCvResult: processingInformationAuthorizationOptionsIgnoreCvResult + ); + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string pointOfSaleInformationEntryMode = "swiped"; + int pointOfSaleInformationTerminalCapability = 2; + string pointOfSaleInformationTrackData = "%B38000000000006^TEST/CYBS ^2012121019761100 00868000000?;38000000000006=20121210197611868000?"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + TrackData: pointOfSaleInformationTrackData + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/ServiceFeesWithCreditCardTransaction.cs b/Source/Samples/Payments/Payments/ServiceFeesWithCreditCardTransaction.cs new file mode 100644 index 0000000..17dcce4 --- /dev/null +++ b/Source/Samples/Payments/Payments/ServiceFeesWithCreditCardTransaction.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class ServiceFeesWithCreditCardTransaction + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static bool CaptureTrueForProcessPayment { get; set; } = false; + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + if (CaptureTrueForProcessPayment) + { + processingInformationCapture = true; + } + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "2325.00"; + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsServiceFeeAmount = "30.0"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency, + ServiceFeeAmount: orderInformationAmountDetailsServiceFeeAmount + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string merchantInformationServiceFeeDescriptorName = "Vacations Service Fee"; + string merchantInformationServiceFeeDescriptorContact = "8009999999"; + string merchantInformationServiceFeeDescriptorState = "CA"; + Ptsv2paymentsMerchantInformationServiceFeeDescriptor merchantInformationServiceFeeDescriptor = new Ptsv2paymentsMerchantInformationServiceFeeDescriptor( + Name: merchantInformationServiceFeeDescriptorName, + Contact: merchantInformationServiceFeeDescriptorContact, + State: merchantInformationServiceFeeDescriptorState + ); + + Ptsv2paymentsMerchantInformation merchantInformation = new Ptsv2paymentsMerchantInformation( + ServiceFeeDescriptor: merchantInformationServiceFeeDescriptor + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + MerchantInformation: merchantInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/SimpleAuthorizationInternet.cs b/Source/Samples/Payments/Payments/SimpleAuthorizationInternet.cs new file mode 100644 index 0000000..3160b63 --- /dev/null +++ b/Source/Samples/Payments/Payments/SimpleAuthorizationInternet.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class SimpleAuthorizationInternet + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static bool CaptureTrueForProcessPayment { get; set; } = false; + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + if (CaptureTrueForProcessPayment) + { + processingInformationCapture = true; + } + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch(ApiException e) + { + Console.WriteLine("Error Code: " + e.ErrorCode); + Console.WriteLine("Error Message: " + e.Message); + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/Swiped.cs b/Source/Samples/Payments/Payments/Swiped.cs new file mode 100644 index 0000000..6738e8b --- /dev/null +++ b/Source/Samples/Payments/Payments/Swiped.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class Swiped + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "123456"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + string processingInformationCommerceIndicator = "retail"; + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string pointOfSaleInformationEntryMode = "swiped"; + int pointOfSaleInformationTerminalCapability = 2; + string pointOfSaleInformationTrackData = "%B38000000000006^TEST/CYBS ^2012121019761100 00868000000?;38000000000006=20121210197611868000?"; + Ptsv2paymentsPointOfSaleInformation pointOfSaleInformation = new Ptsv2paymentsPointOfSaleInformation( + EntryMode: pointOfSaleInformationEntryMode, + TerminalCapability: pointOfSaleInformationTerminalCapability, + TrackData: pointOfSaleInformationTrackData + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation, + PointOfSaleInformation: pointOfSaleInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Payments/ZeroDollarAuthorization.cs b/Source/Samples/Payments/Payments/ZeroDollarAuthorization.cs new file mode 100644 index 0000000..1e0ddad --- /dev/null +++ b/Source/Samples/Payments/Payments/ZeroDollarAuthorization.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class ZeroDollarAuthorization + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static bool CaptureTrueForProcessPayment { get; set; } = false; + public static PtsV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "1234567890"; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + bool processingInformationCapture = false; + if (CaptureTrueForProcessPayment) + { + processingInformationCapture = true; + } + + Ptsv2paymentsProcessingInformation processingInformation = new Ptsv2paymentsProcessingInformation( + Capture: processingInformationCapture + ); + + string paymentInformationCardNumber = "5555555555554444"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2031"; + string paymentInformationCardSecurityCode = "123"; + Ptsv2paymentsPaymentInformationCard paymentInformationCard = new Ptsv2paymentsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear, + SecurityCode: paymentInformationCardSecurityCode + ); + + Ptsv2paymentsPaymentInformation paymentInformation = new Ptsv2paymentsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsTotalAmount = "0"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "san francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToEmail = "test@cybs.com"; + string orderInformationBillToPhoneNumber = "4158880000"; + Ptsv2paymentsOrderInformationBillTo orderInformationBillTo = new Ptsv2paymentsOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry, + Email: orderInformationBillToEmail, + PhoneNumber: orderInformationBillToPhoneNumber + ); + + Ptsv2paymentsOrderInformation orderInformation = new Ptsv2paymentsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentsApi(clientConfig); + PtsV2PaymentsPost201Response result = apiInstance.CreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Refund/ElectronicCheckFollowonRefund.cs b/Source/Samples/Payments/Refund/ElectronicCheckFollowonRefund.cs new file mode 100644 index 0000000..bc6c848 --- /dev/null +++ b/Source/Samples/Payments/Refund/ElectronicCheckFollowonRefund.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class ElectronicCheckFollowonRefund + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsRefundPost201Response Run() + { + var id = ElectronicCheckDebits.Run().Id; + + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsidrefundsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsidrefundsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + Ptsv2paymentsidrefundsProcessingInformation processingInformation = new Ptsv2paymentsidrefundsProcessingInformation( + ); + + string paymentInformationPaymentTypeName = "CHECK"; + Ptsv2paymentsidrefundsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsidrefundsPaymentInformationPaymentType( + Name: paymentInformationPaymentTypeName + ); + + Ptsv2paymentsidrefundsPaymentInformation paymentInformation = new Ptsv2paymentsidrefundsPaymentInformation( + PaymentType: paymentInformationPaymentType + ); + + string orderInformationAmountDetailsTotalAmount = "100"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new RefundPaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new RefundApi(clientConfig); + PtsV2PaymentsRefundPost201Response result = apiInstance.RefundPayment(requestObj, id); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Refund/RefundCapture.cs b/Source/Samples/Payments/Refund/RefundCapture.cs new file mode 100644 index 0000000..a7ad1e3 --- /dev/null +++ b/Source/Samples/Payments/Refund/RefundCapture.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class RefundCapture + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsRefundPost201Response Run() + { + var id = CapturePayment.Run().Id; + + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsidrefundsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsidrefundsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationAmountDetailsTotalAmount = "102.21"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new RefundCaptureRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new RefundApi(clientConfig); + PtsV2PaymentsRefundPost201Response result = apiInstance.RefundCapture(requestObj, id); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Refund/RefundPayment.cs b/Source/Samples/Payments/Refund/RefundPayment.cs new file mode 100644 index 0000000..385a357 --- /dev/null +++ b/Source/Samples/Payments/Refund/RefundPayment.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class RefundPayment + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsRefundPost201Response Run() + { + SimpleAuthorizationInternet.CaptureTrueForProcessPayment = true; + var id = SimpleAuthorizationInternet.Run().Id; + + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsidrefundsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsidrefundsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationAmountDetailsTotalAmount = "10"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsidcapturesOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidcapturesOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsidrefundsOrderInformation orderInformation = new Ptsv2paymentsidrefundsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new RefundPaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new RefundApi(clientConfig); + PtsV2PaymentsRefundPost201Response result = apiInstance.RefundPayment(requestObj, id); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Reversal/ProcessAuthorizationReversal.cs b/Source/Samples/Payments/Reversal/ProcessAuthorizationReversal.cs new file mode 100644 index 0000000..25c93ed --- /dev/null +++ b/Source/Samples/Payments/Reversal/ProcessAuthorizationReversal.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class ProcessAuthorizationReversal + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsReversalsPost201Response Run() + { + SimpleAuthorizationInternet.CaptureTrueForProcessPayment = false; + var id = SimpleAuthorizationInternet.Run().Id; + + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsidreversalsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsidreversalsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string reversalInformationAmountDetailsTotalAmount = "102.21"; + Ptsv2paymentsidreversalsReversalInformationAmountDetails reversalInformationAmountDetails = new Ptsv2paymentsidreversalsReversalInformationAmountDetails( + TotalAmount: reversalInformationAmountDetailsTotalAmount + ); + + string reversalInformationReason = "testing"; + Ptsv2paymentsidreversalsReversalInformation reversalInformation = new Ptsv2paymentsidreversalsReversalInformation( + AmountDetails: reversalInformationAmountDetails, + Reason: reversalInformationReason + ); + + var requestObj = new AuthReversalRequest( + ClientReferenceInformation: clientReferenceInformation, + ReversalInformation: reversalInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReversalApi(clientConfig); + PtsV2PaymentsReversalsPost201Response result = apiInstance.AuthReversal(id, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Reversal/ServiceFeesAuthorizationReversal.cs b/Source/Samples/Payments/Reversal/ServiceFeesAuthorizationReversal.cs new file mode 100644 index 0000000..5a9becc --- /dev/null +++ b/Source/Samples/Payments/Reversal/ServiceFeesAuthorizationReversal.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class ServiceFeesAuthorizationReversal + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsReversalsPost201Response Run() + { + var id = ServiceFeesWithCreditCardTransaction.Run().Id; + + string clientReferenceInformationCode = "TC50171_3"; + Ptsv2paymentsidreversalsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsidreversalsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string reversalInformationAmountDetailsTotalAmount = "2325.00"; + Ptsv2paymentsidreversalsReversalInformationAmountDetails reversalInformationAmountDetails = new Ptsv2paymentsidreversalsReversalInformationAmountDetails( + TotalAmount: reversalInformationAmountDetailsTotalAmount + ); + + string reversalInformationReason = "34"; + Ptsv2paymentsidreversalsReversalInformation reversalInformation = new Ptsv2paymentsidreversalsReversalInformation( + AmountDetails: reversalInformationAmountDetails, + Reason: reversalInformationReason + ); + + var requestObj = new AuthReversalRequest( + ClientReferenceInformation: clientReferenceInformation, + ReversalInformation: reversalInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReversalApi(clientConfig); + PtsV2PaymentsReversalsPost201Response result = apiInstance.AuthReversal(id, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Reversal/TimeoutReversal.cs b/Source/Samples/Payments/Reversal/TimeoutReversal.cs new file mode 100644 index 0000000..2b2bf30 --- /dev/null +++ b/Source/Samples/Payments/Reversal/TimeoutReversal.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class TimeoutReversal + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsReversalsPost201Response Run() + { + AuthorizationForTimeoutReversalFlow.Run(); + var clientReferenceInformationTransactionId = SampleCode.TimeoutReversalTransactionId; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + TransactionId: clientReferenceInformationTransactionId + ); + + string reversalInformationAmountDetailsTotalAmount = "102.21"; + + Ptsv2paymentsidreversalsReversalInformationAmountDetails reversalInformationAmountDetails = new Ptsv2paymentsidreversalsReversalInformationAmountDetails( + TotalAmount: reversalInformationAmountDetailsTotalAmount + ); + + string reversalInformationReason = "Testing"; + + Ptsv2paymentsidreversalsReversalInformation reversalInformation = new Ptsv2paymentsidreversalsReversalInformation( + AmountDetails: reversalInformationAmountDetails, + Reason: reversalInformationReason + ); + + var requestObj = new MitReversalRequest( + ClientReferenceInformation: clientReferenceInformation, + ReversalInformation: reversalInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReversalApi(clientConfig); + PtsV2PaymentsReversalsPost201Response result = apiInstance.MitReversal(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Void/EBTReversalOfPurchaseFromSNAPAccount.cs b/Source/Samples/Payments/Void/EBTReversalOfPurchaseFromSNAPAccount.cs new file mode 100644 index 0000000..c14bdd2 --- /dev/null +++ b/Source/Samples/Payments/Void/EBTReversalOfPurchaseFromSNAPAccount.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class EBTReversalOfPurchaseFromSNAPAccount + { + public static PtsV2PaymentsVoidsPost201Response Run() + { + var id = EBTMerchandiseReturnCreditVoucherFromSNAP.Run().Id; + string clientReferenceInformationCode = "Reversal of Purchase from SNAP Account"; + Ptsv2paymentsidreversalsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsidreversalsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationPaymentTypeName = "CARD"; + string paymentInformationPaymentTypeSubTypeName = "DEBIT"; + Ptsv2paymentsidrefundsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsidrefundsPaymentInformationPaymentType( + Name: paymentInformationPaymentTypeName, + SubTypeName: paymentInformationPaymentTypeSubTypeName + ); + + Ptsv2paymentsidvoidsPaymentInformation paymentInformation = new Ptsv2paymentsidvoidsPaymentInformation( + PaymentType: paymentInformationPaymentType + ); + + string orderInformationAmountDetailsTotalAmount = "204.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2paymentsidreversalsReversalInformationAmountDetails orderInformationAmountDetails = new Ptsv2paymentsidreversalsReversalInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2paymentsidvoidsOrderInformation orderInformation = new Ptsv2paymentsidvoidsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new VoidPaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetAlternativeConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VoidApi(clientConfig); + PtsV2PaymentsVoidsPost201Response result = apiInstance.VoidPayment(requestObj, id); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Payments/Void/PinDebitPurchaseReversalVoid.cs b/Source/Samples/Payments/Void/PinDebitPurchaseReversalVoid.cs new file mode 100644 index 0000000..7f3ad0f --- /dev/null +++ b/Source/Samples/Payments/Void/PinDebitPurchaseReversalVoid.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class PinDebitPurchaseReversalVoid + { + public static PtsV2PaymentsVoidsPost201Response Run() + { + var id = PinDebitPurchaseUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect.Run().Id; + string clientReferenceInformationCode = "Pin Debit Purchase Reversal(Void)"; + Ptsv2paymentsidreversalsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsidreversalsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationPaymentTypeName = "CARD"; + Ptsv2paymentsidrefundsPaymentInformationPaymentType paymentInformationPaymentType = new Ptsv2paymentsidrefundsPaymentInformationPaymentType( + Name: paymentInformationPaymentTypeName + ); + + Ptsv2paymentsidvoidsPaymentInformation paymentInformation = new Ptsv2paymentsidvoidsPaymentInformation( + PaymentType: paymentInformationPaymentType + ); + + + string amountDetailsCurrency = "USD"; + string amountDetailsTotalAmount = "202.00"; + Ptsv2paymentsidreversalsReversalInformationAmountDetails amountDetails = new Ptsv2paymentsidreversalsReversalInformationAmountDetails( + Currency: amountDetailsCurrency, + TotalAmount: amountDetailsTotalAmount + ); + Ptsv2paymentsidvoidsOrderInformation orderInformation = new Ptsv2paymentsidvoidsOrderInformation( + AmountDetails: amountDetails); + + var requestObj = new VoidPaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetAlternativeConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + var apiInstance = new VoidApi(clientConfig); + PtsV2PaymentsVoidsPost201Response result = apiInstance.VoidPayment(requestObj, id); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Void/TimeoutVoid.cs b/Source/Samples/Payments/Void/TimeoutVoid.cs new file mode 100644 index 0000000..78a685d --- /dev/null +++ b/Source/Samples/Payments/Void/TimeoutVoid.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class TimeoutVoid + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsVoidsPost201Response Run() + { + AuthorizationCaptureForTimeoutVoidFlow.Run(); + string clientReferenceInformationTransactionId = SampleCode.TimeoutVoidTransactionId; + Ptsv2paymentsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsClientReferenceInformation( + TransactionId: clientReferenceInformationTransactionId + ); + + var requestObj = new MitVoidRequest( + ClientReferenceInformation: clientReferenceInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VoidApi(clientConfig); + PtsV2PaymentsVoidsPost201Response result = apiInstance.MitVoid(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Void/VoidCapture.cs b/Source/Samples/Payments/Void/VoidCapture.cs new file mode 100644 index 0000000..d2479f0 --- /dev/null +++ b/Source/Samples/Payments/Void/VoidCapture.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class VoidCapture + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsVoidsPost201Response Run() + { + var id = CapturePayment.Run().Id; + string clientReferenceInformationCode = "test_void"; + Ptsv2paymentsidreversalsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsidreversalsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + var requestObj = new VoidCaptureRequest( + ClientReferenceInformation: clientReferenceInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VoidApi(clientConfig); + PtsV2PaymentsVoidsPost201Response result = apiInstance.VoidCapture(requestObj, id); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Void/VoidCredit.cs b/Source/Samples/Payments/Void/VoidCredit.cs new file mode 100644 index 0000000..02e6952 --- /dev/null +++ b/Source/Samples/Payments/Void/VoidCredit.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class VoidCredit + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsVoidsPost201Response Run() + { + var id = Credit.Run().Id; + + string clientReferenceInformationCode = "test_void"; + Ptsv2paymentsidreversalsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsidreversalsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + var requestObj = new VoidCreditRequest( + ClientReferenceInformation: clientReferenceInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VoidApi(clientConfig); + PtsV2PaymentsVoidsPost201Response result = apiInstance.VoidCredit(requestObj, id); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Void/VoidPayment.cs b/Source/Samples/Payments/Void/VoidPayment.cs new file mode 100644 index 0000000..2513746 --- /dev/null +++ b/Source/Samples/Payments/Void/VoidPayment.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class VoidPayment + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsVoidsPost201Response Run() + { + SimpleAuthorizationInternet.CaptureTrueForProcessPayment = true; + var id = SimpleAuthorizationInternet.Run().Id; + + string clientReferenceInformationCode = "test_void"; + Ptsv2paymentsidreversalsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsidreversalsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + var requestObj = new VoidPaymentRequest( + ClientReferenceInformation: clientReferenceInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VoidApi(clientConfig); + PtsV2PaymentsVoidsPost201Response result = apiInstance.VoidPayment(requestObj, id); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payments/Void/VoidRefund.cs b/Source/Samples/Payments/Void/VoidRefund.cs new file mode 100644 index 0000000..8e55651 --- /dev/null +++ b/Source/Samples/Payments/Void/VoidRefund.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payments +{ + public class VoidRefund + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PaymentsVoidsPost201Response Run() + { + var id = RefundPayment.Run().Id; + + string clientReferenceInformationCode = "test_void"; + Ptsv2paymentsidreversalsClientReferenceInformation clientReferenceInformation = new Ptsv2paymentsidreversalsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + var requestObj = new VoidRefundRequest( + ClientReferenceInformation: clientReferenceInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VoidApi(clientConfig); + PtsV2PaymentsVoidsPost201Response result = apiInstance.VoidRefund(requestObj, id); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payouts/PayoutCardNotToken.cs b/Source/Samples/Payouts/PayoutCardNotToken.cs new file mode 100644 index 0000000..ec70d54 --- /dev/null +++ b/Source/Samples/Payouts/PayoutCardNotToken.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payouts +{ + public class PayoutCardNotToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PayoutsPost201Response Run() + { + string clientReferenceInformationCode = "33557799"; + Ptsv2payoutsClientReferenceInformation clientReferenceInformation = new Ptsv2payoutsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationAmountDetailsTotalAmount = "100.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2payoutsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2payoutsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2payoutsOrderInformation orderInformation = new Ptsv2payoutsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string merchantInformationMerchantDescriptorName = "Sending Company Name"; + string merchantInformationMerchantDescriptorLocality = "FC"; + string merchantInformationMerchantDescriptorCountry = "US"; + string merchantInformationMerchantDescriptorAdministrativeArea = "CA"; + string merchantInformationMerchantDescriptorPostalCode = "94440"; + Ptsv2payoutsMerchantInformationMerchantDescriptor merchantInformationMerchantDescriptor = new Ptsv2payoutsMerchantInformationMerchantDescriptor( + Name: merchantInformationMerchantDescriptorName, + Locality: merchantInformationMerchantDescriptorLocality, + Country: merchantInformationMerchantDescriptorCountry, + AdministrativeArea: merchantInformationMerchantDescriptorAdministrativeArea, + PostalCode: merchantInformationMerchantDescriptorPostalCode + ); + + Ptsv2payoutsMerchantInformation merchantInformation = new Ptsv2payoutsMerchantInformation( + MerchantDescriptor: merchantInformationMerchantDescriptor + ); + + string recipientInformationFirstName = "John"; + string recipientInformationLastName = "Doe"; + string recipientInformationAddress1 = "Paseo Padre Boulevard"; + string recipientInformationLocality = "Foster City"; + string recipientInformationAdministrativeArea = "CA"; + string recipientInformationCountry = "US"; + string recipientInformationPostalCode = "94400"; + string recipientInformationPhoneNumber = "6504320556"; + Ptsv2payoutsRecipientInformation recipientInformation = new Ptsv2payoutsRecipientInformation( + FirstName: recipientInformationFirstName, + LastName: recipientInformationLastName, + Address1: recipientInformationAddress1, + Locality: recipientInformationLocality, + AdministrativeArea: recipientInformationAdministrativeArea, + Country: recipientInformationCountry, + PostalCode: recipientInformationPostalCode, + PhoneNumber: recipientInformationPhoneNumber + ); + + string senderInformationReferenceNumber = "1234567890"; + string senderInformationAccountFundsSource = "05"; + Ptsv2payoutsSenderInformationAccount senderInformationAccount = new Ptsv2payoutsSenderInformationAccount( + FundsSource: senderInformationAccountFundsSource + ); + + string senderInformationName = "Company Name"; + string senderInformationAddress1 = "900 Metro Center Blvd.900"; + string senderInformationLocality = "Foster City"; + string senderInformationAdministrativeArea = "CA"; + string senderInformationCountryCode = "US"; + Ptsv2payoutsSenderInformation senderInformation = new Ptsv2payoutsSenderInformation( + ReferenceNumber: senderInformationReferenceNumber, + Account: senderInformationAccount, + Name: senderInformationName, + Address1: senderInformationAddress1, + Locality: senderInformationLocality, + AdministrativeArea: senderInformationAdministrativeArea, + CountryCode: senderInformationCountryCode + ); + + string processingInformationBusinessApplicationId = "FD"; + string processingInformationNetworkRoutingOrder = "V8"; + string processingInformationCommerceIndicator = "internet"; + Ptsv2payoutsProcessingInformation processingInformation = new Ptsv2payoutsProcessingInformation( + BusinessApplicationId: processingInformationBusinessApplicationId, + NetworkRoutingOrder: processingInformationNetworkRoutingOrder, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationCardType = "001"; + string paymentInformationCardNumber = "4111111111111111"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + Ptsv2payoutsPaymentInformationCard paymentInformationCard = new Ptsv2payoutsPaymentInformationCard( + Type: paymentInformationCardType, + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Ptsv2payoutsPaymentInformation paymentInformation = new Ptsv2payoutsPaymentInformation( + Card: paymentInformationCard + ); + + var requestObj = new OctCreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + MerchantInformation: merchantInformation, + RecipientInformation: recipientInformation, + SenderInformation: senderInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayoutsApi(clientConfig); + PtsV2PayoutsPost201Response result = apiInstance.OctCreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Payouts/PayoutToken.cs b/Source/Samples/Payouts/PayoutToken.cs new file mode 100644 index 0000000..b29f8a1 --- /dev/null +++ b/Source/Samples/Payouts/PayoutToken.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Payouts +{ + public class PayoutToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV2PayoutsPost201Response Run() + { + string clientReferenceInformationCode = "111111113"; + Ptsv2payoutsClientReferenceInformation clientReferenceInformation = new Ptsv2payoutsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationAmountDetailsTotalAmount = "111.00"; + string orderInformationAmountDetailsCurrency = "USD"; + Ptsv2payoutsOrderInformationAmountDetails orderInformationAmountDetails = new Ptsv2payoutsOrderInformationAmountDetails( + TotalAmount: orderInformationAmountDetailsTotalAmount, + Currency: orderInformationAmountDetailsCurrency + ); + + Ptsv2payoutsOrderInformation orderInformation = new Ptsv2payoutsOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + string merchantInformationMerchantDescriptorName = "Sending Company Name"; + string merchantInformationMerchantDescriptorLocality = "FC"; + string merchantInformationMerchantDescriptorCountry = "US"; + string merchantInformationMerchantDescriptorAdministrativeArea = "CA"; + string merchantInformationMerchantDescriptorPostalCode = "94440"; + Ptsv2payoutsMerchantInformationMerchantDescriptor merchantInformationMerchantDescriptor = new Ptsv2payoutsMerchantInformationMerchantDescriptor( + Name: merchantInformationMerchantDescriptorName, + Locality: merchantInformationMerchantDescriptorLocality, + Country: merchantInformationMerchantDescriptorCountry, + AdministrativeArea: merchantInformationMerchantDescriptorAdministrativeArea, + PostalCode: merchantInformationMerchantDescriptorPostalCode + ); + + Ptsv2payoutsMerchantInformation merchantInformation = new Ptsv2payoutsMerchantInformation( + MerchantDescriptor: merchantInformationMerchantDescriptor + ); + + string recipientInformationFirstName = "John"; + string recipientInformationLastName = "Doe"; + string recipientInformationAddress1 = "Paseo Padre Boulevard"; + string recipientInformationLocality = "Foster City"; + string recipientInformationAdministrativeArea = "CA"; + string recipientInformationCountry = "US"; + string recipientInformationPostalCode = "94400"; + string recipientInformationPhoneNumber = "6504320556"; + Ptsv2payoutsRecipientInformation recipientInformation = new Ptsv2payoutsRecipientInformation( + FirstName: recipientInformationFirstName, + LastName: recipientInformationLastName, + Address1: recipientInformationAddress1, + Locality: recipientInformationLocality, + AdministrativeArea: recipientInformationAdministrativeArea, + Country: recipientInformationCountry, + PostalCode: recipientInformationPostalCode, + PhoneNumber: recipientInformationPhoneNumber + ); + + string senderInformationReferenceNumber = "1234567890"; + string senderInformationAccountFundsSource = "05"; + string senderInformationAccountNumber = "1234567890123456789012345678901234"; + Ptsv2payoutsSenderInformationAccount senderInformationAccount = new Ptsv2payoutsSenderInformationAccount( + FundsSource: senderInformationAccountFundsSource, + Number: senderInformationAccountNumber + ); + + string senderInformationName = "Company Name"; + string senderInformationAddress1 = "900 Metro Center Blvd.900"; + string senderInformationLocality = "Foster City"; + string senderInformationAdministrativeArea = "CA"; + string senderInformationCountryCode = "US"; + Ptsv2payoutsSenderInformation senderInformation = new Ptsv2payoutsSenderInformation( + ReferenceNumber: senderInformationReferenceNumber, + Account: senderInformationAccount, + Name: senderInformationName, + Address1: senderInformationAddress1, + Locality: senderInformationLocality, + AdministrativeArea: senderInformationAdministrativeArea, + CountryCode: senderInformationCountryCode + ); + + string processingInformationBusinessApplicationId = "FD"; + string processingInformationNetworkRoutingOrder = "V8"; + string processingInformationCommerceIndicator = "internet"; + Ptsv2payoutsProcessingInformation processingInformation = new Ptsv2payoutsProcessingInformation( + BusinessApplicationId: processingInformationBusinessApplicationId, + NetworkRoutingOrder: processingInformationNetworkRoutingOrder, + CommerceIndicator: processingInformationCommerceIndicator + ); + + string paymentInformationCustomerCustomerId = "7500BB199B4270EFE05340588D0AFCAD"; + Ptsv2paymentsPaymentInformationCustomer paymentInformationCustomer = new Ptsv2paymentsPaymentInformationCustomer( + CustomerId: paymentInformationCustomerCustomerId + ); + + Ptsv2payoutsPaymentInformation paymentInformation = new Ptsv2payoutsPaymentInformation( + Customer: paymentInformationCustomer + ); + + var requestObj = new OctCreatePaymentRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + MerchantInformation: merchantInformation, + RecipientInformation: recipientInformation, + SenderInformation: senderInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PayoutsApi(clientConfig); + PtsV2PayoutsPost201Response result = apiInstance.OctCreatePayment(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RecurringBillingSubscriptions/Plans/ActivatePlan.cs b/Source/Samples/RecurringBillingSubscriptions/Plans/ActivatePlan.cs new file mode 100644 index 0000000..93cd8db --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Plans/ActivatePlan.cs @@ -0,0 +1,33 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class ActivatePlan + { + public static ActivateDeactivatePlanResponse Run() + { + try + { + var planId = CreatePlan.Run().Id; + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PlansApi(clientConfig); + var result = apiInstance.ActivatePlan(planId); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/RecurringBillingSubscriptions/Plans/CreatePlan.cs b/Source/Samples/RecurringBillingSubscriptions/Plans/CreatePlan.cs new file mode 100644 index 0000000..2438651 --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Plans/CreatePlan.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class CreatePlan + { + public static CreatePlanResponse Run() + { + // Required to make the sample code ActivatePlan.cs work + string planStatus = "DRAFT"; + + string planInformationName = "Gold Plan"; + string planInformationDescription = "New Gold Plan"; + string planInformationBillingPeriodLength = "1"; + string planInformationBillingPeriodUnit = "M"; + GetAllPlansResponsePlanInformationBillingPeriod planInformationBillingPeriod = new GetAllPlansResponsePlanInformationBillingPeriod( + Length: planInformationBillingPeriodLength, + Unit: planInformationBillingPeriodUnit + ); + + string planInformationBillingCyclesTotal = "12"; + Rbsv1plansPlanInformationBillingCycles planInformationBillingCycles = new Rbsv1plansPlanInformationBillingCycles( + Total: planInformationBillingCyclesTotal + ); + + Rbsv1plansPlanInformation planInformation = new Rbsv1plansPlanInformation( + Name: planInformationName, + Description: planInformationDescription, + BillingPeriod: planInformationBillingPeriod, + BillingCycles: planInformationBillingCycles, + Status: planStatus + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsBillingAmount = "10"; + string orderInformationAmountDetailsSetupFee = "2"; + Rbsv1plansOrderInformationAmountDetails orderInformationAmountDetails = new Rbsv1plansOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + BillingAmount: orderInformationAmountDetailsBillingAmount, + SetupFee: orderInformationAmountDetailsSetupFee + ); + + Rbsv1plansOrderInformation orderInformation = new Rbsv1plansOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new CreatePlanRequest( + PlanInformation: planInformation, + OrderInformation: orderInformation + ); + CreatePlanResponse response = null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PlansApi(clientConfig); + response = apiInstance.CreatePlan(requestObj); + Console.WriteLine(response); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + return response; + } + } +} \ No newline at end of file diff --git a/Source/Samples/RecurringBillingSubscriptions/Plans/DeactivatePlan.cs b/Source/Samples/RecurringBillingSubscriptions/Plans/DeactivatePlan.cs new file mode 100644 index 0000000..3c1adf2 --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Plans/DeactivatePlan.cs @@ -0,0 +1,33 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class DeactivatePlan + { + public static ActivateDeactivatePlanResponse Run() + { + try + { + var planId = ActivatePlan.Run().Id; + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PlansApi(clientConfig); + var result = apiInstance.DeactivatePlan(planId); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/RecurringBillingSubscriptions/Plans/DeletePlan.cs b/Source/Samples/RecurringBillingSubscriptions/Plans/DeletePlan.cs new file mode 100644 index 0000000..e01f3b9 --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Plans/DeletePlan.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class DeletePlan + { + public static void Run() + { + try + { + var id = CreatePlan.Run().Id; + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PlansApi(clientConfig); + apiInstance.DeletePlan(id); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/RecurringBillingSubscriptions/Plans/GetListOfPlans.cs b/Source/Samples/RecurringBillingSubscriptions/Plans/GetListOfPlans.cs new file mode 100644 index 0000000..ce4e66f --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Plans/GetListOfPlans.cs @@ -0,0 +1,38 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class GetListOfPlans + { + public static GetAllPlansResponse Run() + { + int? offset = (int?)null; + int? limit = (int?)null; + string code = null; + string status = null; + string name = null; + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PlansApi(clientConfig); + var result = apiInstance.GetPlans(offset, limit, code, status, name); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/RecurringBillingSubscriptions/Plans/GetPlan.cs b/Source/Samples/RecurringBillingSubscriptions/Plans/GetPlan.cs new file mode 100644 index 0000000..6ad5a22 --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Plans/GetPlan.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using ApiSdk.model; +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class GetPlan + { + public static GetPlanResponse Run() + { + try + { + var planId = CreatePlan.Run().Id; + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PlansApi(clientConfig); + var result = apiInstance.GetPlan(planId); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/RecurringBillingSubscriptions/Plans/GetPlanCode.cs b/Source/Samples/RecurringBillingSubscriptions/Plans/GetPlanCode.cs new file mode 100644 index 0000000..809ab15 --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Plans/GetPlanCode.cs @@ -0,0 +1,32 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class GetPlanCode + { + public static GetPlanCodeResponse Run() + { + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PlansApi(clientConfig); + var result = apiInstance.GetPlanCode(); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/RecurringBillingSubscriptions/Plans/UpdatePlan.cs b/Source/Samples/RecurringBillingSubscriptions/Plans/UpdatePlan.cs new file mode 100644 index 0000000..14c40af --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Plans/UpdatePlan.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class UpdatePlan + { + public static void Run() + { + string planInformationName = "Gold Plan NA"; + string planInformationDescription = "Updated Gold Plan"; + string planInformationBillingPeriodLength = "2"; + string planInformationBillingPeriodUnit = "W"; + GetAllPlansResponsePlanInformationBillingPeriod planInformationBillingPeriod = new GetAllPlansResponsePlanInformationBillingPeriod( + Length: planInformationBillingPeriodLength, + Unit: planInformationBillingPeriodUnit + ); + + string planInformationBillingCyclesTotal = "11"; + Rbsv1plansPlanInformationBillingCycles planInformationBillingCycles = new Rbsv1plansPlanInformationBillingCycles( + Total: planInformationBillingCyclesTotal + ); + + Rbsv1plansidPlanInformation planInformation = new Rbsv1plansidPlanInformation( + Name: planInformationName, + Description: planInformationDescription, + BillingPeriod: planInformationBillingPeriod, + BillingCycles: planInformationBillingCycles + ); + + string processingInformationSubscriptionBillingOptionsApplyTo = "ALL"; + Rbsv1plansidProcessingInformationSubscriptionBillingOptions processingInformationSubscriptionBillingOptions = new Rbsv1plansidProcessingInformationSubscriptionBillingOptions( + ApplyTo: processingInformationSubscriptionBillingOptionsApplyTo + ); + + Rbsv1plansidProcessingInformation processingInformation = new Rbsv1plansidProcessingInformation( + SubscriptionBillingOptions: processingInformationSubscriptionBillingOptions + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsBillingAmount = "11"; + string orderInformationAmountDetailsSetupFee = "2"; + GetAllPlansResponseOrderInformationAmountDetails orderInformationAmountDetails = new GetAllPlansResponseOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + BillingAmount: orderInformationAmountDetailsBillingAmount, + SetupFee: orderInformationAmountDetailsSetupFee + ); + + GetAllPlansResponseOrderInformation orderInformation = new GetAllPlansResponseOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new UpdatePlanRequest( + PlanInformation: planInformation, + ProcessingInformation: processingInformation, + OrderInformation: orderInformation + ); + + try + { + var id = CreatePlan.Run().Id; + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PlansApi(clientConfig); + apiInstance.UpdatePlan(id, requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/RecurringBillingSubscriptions/Subscriptions/ActivateSubscription.cs b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/ActivateSubscription.cs new file mode 100644 index 0000000..ab0cbae --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/ActivateSubscription.cs @@ -0,0 +1,33 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class ActivateSubscription + { + public static ActivateSubscriptionResponse Run() + { + try + { + var subscriptionId = CancelSubscription.Run().Id; + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new SubscriptionsApi(clientConfig); + var result = apiInstance.ActivateSubscription(subscriptionId); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/RecurringBillingSubscriptions/Subscriptions/CancelSubscription.cs b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/CancelSubscription.cs new file mode 100644 index 0000000..c454442 --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/CancelSubscription.cs @@ -0,0 +1,33 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class CancelSubscription + { + public static CancelSubscriptionResponse Run() + { + try + { + var subscriptionId = CreateSubscription.Run().Id; + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new SubscriptionsApi(clientConfig); + var result = apiInstance.CancelSubscription(subscriptionId); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/RecurringBillingSubscriptions/Subscriptions/CreateSubscription.cs b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/CreateSubscription.cs new file mode 100644 index 0000000..e52309c --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/CreateSubscription.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class CreateSubscription + { + public static CreateSubscriptionResponse Run() + { + string clientReferenceInformationCode = "TC501713"; + string clientReferenceInformationPartnerDeveloperId = "ABCD1234"; + string clientReferenceInformationPartnerSolutionId = "GEF1234"; + Riskv1decisionsClientReferenceInformationPartner clientReferenceInformationPartner = new Riskv1decisionsClientReferenceInformationPartner( + DeveloperId: clientReferenceInformationPartnerDeveloperId, + SolutionId: clientReferenceInformationPartnerSolutionId + ); + + string clientReferenceInformationApplicationName = "CYBS-SDK"; + string clientReferenceInformationApplicationVersion = "v1"; + Rbsv1subscriptionsClientReferenceInformation clientReferenceInformation = new Rbsv1subscriptionsClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner, + ApplicationName: clientReferenceInformationApplicationName, + ApplicationVersion: clientReferenceInformationApplicationVersion + ); + + string processingInformationCommerceIndicator = "recurring"; + string processingInformationAuthorizationOptionsInitiatorType = "merchant"; + Rbsv1subscriptionsProcessingInformationAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new Rbsv1subscriptionsProcessingInformationAuthorizationOptionsInitiator( + Type: processingInformationAuthorizationOptionsInitiatorType + ); + + Rbsv1subscriptionsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Rbsv1subscriptionsProcessingInformationAuthorizationOptions( + Initiator: processingInformationAuthorizationOptionsInitiator + ); + + Rbsv1subscriptionsProcessingInformation processingInformation = new Rbsv1subscriptionsProcessingInformation( + CommerceIndicator: processingInformationCommerceIndicator, + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string subscriptionInformationPlanId = "6868912495476705603955"; + string subscriptionInformationName = "Subscription with PlanId"; + string subscriptionInformationStartDate = "2024-06-11"; + Rbsv1subscriptionsSubscriptionInformation subscriptionInformation = new Rbsv1subscriptionsSubscriptionInformation( + PlanId: subscriptionInformationPlanId, + Name: subscriptionInformationName, + StartDate: subscriptionInformationStartDate + ); + + string paymentInformationCustomerId = "C24F5921EB870D99E053AF598E0A4105"; + Rbsv1subscriptionsPaymentInformationCustomer paymentInformationCustomer = new Rbsv1subscriptionsPaymentInformationCustomer( + Id: paymentInformationCustomerId + ); + + Rbsv1subscriptionsPaymentInformation paymentInformation = new Rbsv1subscriptionsPaymentInformation( + Customer: paymentInformationCustomer + ); + + var requestObj = new CreateSubscriptionRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + SubscriptionInformation: subscriptionInformation, + PaymentInformation: paymentInformation + ); + + CreateSubscriptionResponse response = null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new SubscriptionsApi(clientConfig); + response = apiInstance.CreateSubscription(requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + return response; + } + } +} \ No newline at end of file diff --git a/Source/Samples/RecurringBillingSubscriptions/Subscriptions/GetListOfSubscriptions.cs b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/GetListOfSubscriptions.cs new file mode 100644 index 0000000..507a03c --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/GetListOfSubscriptions.cs @@ -0,0 +1,38 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class GetListOfSubscriptions + { + public static GetAllSubscriptionsResponse Run() + { + int? offset = (int?)null; + int? limit = (int?)null; + string code = null; + string status = null; + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new SubscriptionsApi(clientConfig); + var result = apiInstance.GetAllSubscriptions(offset, limit, code, status); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/RecurringBillingSubscriptions/Subscriptions/GetSubscription.cs b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/GetSubscription.cs new file mode 100644 index 0000000..c00d7fc --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/GetSubscription.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class GetSubscription + { + public static void Run() + { + try + { + var id = CreateSubscription.Run().Id; + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new SubscriptionsApi(clientConfig); + apiInstance.GetSubscription(id); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/RecurringBillingSubscriptions/Subscriptions/GetSubscriptionCode.cs b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/GetSubscriptionCode.cs new file mode 100644 index 0000000..714adf0 --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/GetSubscriptionCode.cs @@ -0,0 +1,32 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class GetSubscriptionCode + { + public static GetSubscriptionCodeResponse Run() + { + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new SubscriptionsApi(clientConfig); + var result = apiInstance.GetSubscriptionCode(); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/RecurringBillingSubscriptions/Subscriptions/SuspendSubscription.cs b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/SuspendSubscription.cs new file mode 100644 index 0000000..d9402dc --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/SuspendSubscription.cs @@ -0,0 +1,33 @@ +using CyberSource.Api; +using CyberSource.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class SuspendSubscription + { + public static SuspendSubscriptionResponse Run() + { + try + { + var subscriptionId = CreateSubscription.Run().Id; + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new SubscriptionsApi(clientConfig); + var result = apiInstance.SuspendSubscription(subscriptionId); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/RecurringBillingSubscriptions/Subscriptions/UpdateSubscription.cs b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/UpdateSubscription.cs new file mode 100644 index 0000000..488c891 --- /dev/null +++ b/Source/Samples/RecurringBillingSubscriptions/Subscriptions/UpdateSubscription.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RecurringBillingSubscriptions +{ + public class UpdateSubscription + { + public static void Run() + { + string clientReferenceInformationCode = "APGHU"; + string clientReferenceInformationPartnerDeveloperId = "ABCD1234"; + string clientReferenceInformationPartnerSolutionId = "GEF1234"; + Riskv1decisionsClientReferenceInformationPartner clientReferenceInformationPartner = new Riskv1decisionsClientReferenceInformationPartner( + DeveloperId: clientReferenceInformationPartnerDeveloperId, + SolutionId: clientReferenceInformationPartnerSolutionId + ); + + Rbsv1subscriptionsClientReferenceInformation clientReferenceInformation = new Rbsv1subscriptionsClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + string processingInformationAuthorizationOptionsInitiatorType = "merchant"; + Rbsv1subscriptionsProcessingInformationAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new Rbsv1subscriptionsProcessingInformationAuthorizationOptionsInitiator( + Type: processingInformationAuthorizationOptionsInitiatorType + ); + + Rbsv1subscriptionsProcessingInformationAuthorizationOptions processingInformationAuthorizationOptions = new Rbsv1subscriptionsProcessingInformationAuthorizationOptions( + Initiator: processingInformationAuthorizationOptionsInitiator + ); + + Rbsv1subscriptionsProcessingInformation processingInformation = new Rbsv1subscriptionsProcessingInformation( + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + string subscriptionInformationPlanId = "424242442"; + string subscriptionInformationName = "Gold subs"; + string subscriptionInformationStartDate = "2024-06-15"; + Rbsv1subscriptionsidSubscriptionInformation subscriptionInformation = new Rbsv1subscriptionsidSubscriptionInformation( + PlanId: subscriptionInformationPlanId, + Name: subscriptionInformationName, + StartDate: subscriptionInformationStartDate + ); + + string orderInformationAmountDetailsBillingAmount = "10"; + string orderInformationAmountDetailsSetupFee = "5"; + Rbsv1subscriptionsidOrderInformationAmountDetails orderInformationAmountDetails = new Rbsv1subscriptionsidOrderInformationAmountDetails( + BillingAmount: orderInformationAmountDetailsBillingAmount, + SetupFee: orderInformationAmountDetailsSetupFee + ); + + Rbsv1subscriptionsidOrderInformation orderInformation = new Rbsv1subscriptionsidOrderInformation( + AmountDetails: orderInformationAmountDetails + ); + + var requestObj = new CyberSource.Model.UpdateSubscription( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + SubscriptionInformation: subscriptionInformation, + OrderInformation: orderInformation + ); + + try + { + var id = CreateSubscription.Run().Id; + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new SubscriptionsApi(clientConfig); + apiInstance.UpdateSubscription(id, requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Reporting/ChargebackDetails/GetChargebackDetails.cs b/Source/Samples/Reporting/ChargebackDetails/GetChargebackDetails.cs new file mode 100644 index 0000000..5309c28 --- /dev/null +++ b/Source/Samples/Reporting/ChargebackDetails/GetChargebackDetails.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetChargebackDetails + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3ChargebackDetailsGet200Response Run() + { + // QUERY PARAMETERS + string organizationId = "testrest"; + var startTime = DateTime.ParseExact("2021-08-01T00:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + var endTime = DateTime.ParseExact("2021-09-01T23:59:59Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ChargebackDetailsApi(clientConfig); + ReportingV3ChargebackDetailsGet200Response result = apiInstance.GetChargebackDetails(startTime, endTime, organizationId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Reporting/ChargebackSummaries/GetChargebackSummaries.cs b/Source/Samples/Reporting/ChargebackSummaries/GetChargebackSummaries.cs new file mode 100644 index 0000000..087f2bd --- /dev/null +++ b/Source/Samples/Reporting/ChargebackSummaries/GetChargebackSummaries.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetChargebackSummaries + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3ChargebackSummariesGet200Response Run() + { + // QUERY PARAMETERS + string organizationId = "testrest"; + var startTime = DateTime.ParseExact("2021-08-01T00:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + var endTime = DateTime.ParseExact("2021-09-01T23:59:59Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ChargebackSummariesApi(clientConfig); + ReportingV3ChargebackSummariesGet200Response result = apiInstance.GetChargebackSummaries(startTime, endTime, organizationId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Reporting/ConversionDetails/GetConversionDetailTransactions.cs b/Source/Samples/Reporting/ConversionDetails/GetConversionDetailTransactions.cs new file mode 100644 index 0000000..07e7242 --- /dev/null +++ b/Source/Samples/Reporting/ConversionDetails/GetConversionDetailTransactions.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetConversionDetailTransactions + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3ConversionDetailsGet200Response Run() + { + var startTime = DateTime.ParseExact("2023-01-21T00:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + var endTime = DateTime.ParseExact("2023-01-21T23:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + string organizationId = "testrest"; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ConversionDetailsApi(clientConfig); + ReportingV3ConversionDetailsGet200Response result = apiInstance.GetConversionDetail(startTime, endTime, organizationId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Reporting/InterchangeClearingLevelDetails/InterchangeClearingLevelDataForAccountOrMerchant.cs b/Source/Samples/Reporting/InterchangeClearingLevelDetails/InterchangeClearingLevelDataForAccountOrMerchant.cs new file mode 100644 index 0000000..7859eaa --- /dev/null +++ b/Source/Samples/Reporting/InterchangeClearingLevelDetails/InterchangeClearingLevelDataForAccountOrMerchant.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class InterchangeClearingLevelDataForAccountOrMerchant + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3InterchangeClearingLevelDetailsGet200Response Run() + { + // QUERY PARAMETERS + string organizationId = "testrest"; + var startTime = DateTime.ParseExact("2021-08-01T00:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + var endTime = DateTime.ParseExact("2021-09-01T23:59:59Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InterchangeClearingLevelDetailsApi(clientConfig); + ReportingV3InterchangeClearingLevelDetailsGet200Response result = apiInstance.GetInterchangeClearingLevelDetails(startTime, endTime, organizationId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Reporting/NetFundings/GetNetfundingInformationForAccountOrMerchant.cs b/Source/Samples/Reporting/NetFundings/GetNetfundingInformationForAccountOrMerchant.cs new file mode 100644 index 0000000..06b6209 --- /dev/null +++ b/Source/Samples/Reporting/NetFundings/GetNetfundingInformationForAccountOrMerchant.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetNetfundingInformationForAccountOrMerchant + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3NetFundingsGet200Response Run() + { + var startTime = DateTime.ParseExact("2023-01-01T00:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + var endTime = DateTime.ParseExact("2023-01-02T23:59:59Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + string organizationId = "testrest"; + string groupName = null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new NetFundingsApi(clientConfig); + ReportingV3NetFundingsGet200Response result = apiInstance.GetNetFundingDetails(startTime, endTime, organizationId, groupName); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Reporting/NotificationOfChanges/GetNotificationOfChanges.cs b/Source/Samples/Reporting/NotificationOfChanges/GetNotificationOfChanges.cs new file mode 100644 index 0000000..1b77819 --- /dev/null +++ b/Source/Samples/Reporting/NotificationOfChanges/GetNotificationOfChanges.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetNotificationOfChanges + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3NotificationofChangesGet200Response Run() + { + var startTime = DateTime.ParseExact("2023-01-01T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + var endTime = DateTime.ParseExact("2023-01-10T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new NotificationOfChangesApi(clientConfig); + ReportingV3NotificationofChangesGet200Response result = apiInstance.GetNotificationOfChangeReport(startTime, endTime); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Reporting/PaymentBatchSummaries/GetPaymentBatchSummaryData.cs b/Source/Samples/Reporting/PaymentBatchSummaries/GetPaymentBatchSummaryData.cs new file mode 100644 index 0000000..ff00656 --- /dev/null +++ b/Source/Samples/Reporting/PaymentBatchSummaries/GetPaymentBatchSummaryData.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetPaymentBatchSummaryData + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3PaymentBatchSummariesGet200Response Run() + { + var startTime = DateTime.ParseExact("2023-01-01T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + var endTime = DateTime.ParseExact("2023-01-30T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + string organizationId = "testrest"; + string rollUp = null; + string breakdown = null; + int? startDayOfWeek = (int?)null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentBatchSummariesApi(clientConfig); + ReportingV3PaymentBatchSummariesGet200Response result = apiInstance.GetPaymentBatchSummary(startTime, endTime, organizationId, rollUp, breakdown, startDayOfWeek); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Reporting/PurchaseAndRefundDetails/GetPurchaseAndRefundDetails.cs b/Source/Samples/Reporting/PurchaseAndRefundDetails/GetPurchaseAndRefundDetails.cs new file mode 100644 index 0000000..1565781 --- /dev/null +++ b/Source/Samples/Reporting/PurchaseAndRefundDetails/GetPurchaseAndRefundDetails.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetPurchaseAndRefundDetails + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3PurchaseRefundDetailsGet200Response Run() + { + var startTime = DateTime.ParseExact("2023-01-01T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + var endTime = DateTime.ParseExact("2023-01-30T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + string organizationId = "testrest"; + string paymentSubtype = "VI"; + string viewBy = "requestDate"; + string groupName = "groupName"; + int? offset = 20; + int? limit = 2000; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PurchaseAndRefundDetailsApi(clientConfig); + ReportingV3PurchaseRefundDetailsGet200Response result = apiInstance.GetPurchaseAndRefundDetails(startTime, endTime, organizationId, paymentSubtype, viewBy, groupName, offset, limit); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Reporting/ReportDefinitions/GetReportDefinition.cs b/Source/Samples/Reporting/ReportDefinitions/GetReportDefinition.cs new file mode 100644 index 0000000..ee534ef --- /dev/null +++ b/Source/Samples/Reporting/ReportDefinitions/GetReportDefinition.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetReportDefinition + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3ReportDefinitionsNameGet200Response Run() + { + string reportDefinitionName = "SubscriptionDetailClass"; + string subscriptionType = null; + string reportMimeType = null; + string organizationId = "testrest"; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReportDefinitionsApi(clientConfig); + ReportingV3ReportDefinitionsNameGet200Response result = apiInstance.GetResourceInfoByReportDefinition(reportDefinitionName, subscriptionType, reportMimeType, organizationId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Reporting/ReportDefinitions/GetReportingResourceInformation.cs b/Source/Samples/Reporting/ReportDefinitions/GetReportingResourceInformation.cs new file mode 100644 index 0000000..7a4ca9a --- /dev/null +++ b/Source/Samples/Reporting/ReportDefinitions/GetReportingResourceInformation.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetReportingResourceInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3ReportDefinitionsGet200Response Run() + { + string subscriptionType = null; + string organizationId = "testrest"; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReportDefinitionsApi(clientConfig); + ReportingV3ReportDefinitionsGet200Response result = apiInstance.GetResourceV2Info(subscriptionType, organizationId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Reporting/ReportDownloads/DownloadReport.cs b/Source/Samples/Reporting/ReportDownloads/DownloadReport.cs new file mode 100644 index 0000000..a3ed756 --- /dev/null +++ b/Source/Samples/Reporting/ReportDownloads/DownloadReport.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Xml; +using System.Xml.Serialization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class DownloadReport + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + const string fileName = "DownloadedReport.csv"; + const string downloadFilePath = @".\Resource\" + fileName; + string organizationId = "testrest"; + var reportDate = DateTime.ParseExact("2020-05-03", "yyyy-MM-dd", CultureInfo.InvariantCulture); + string reportName = "testrest_subcription_v2989"; + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReportDownloadsApi(clientConfig); + var content = apiInstance.DownloadReportWithHttpInfo(reportDate, reportName, organizationId); + + // START : FILE DOWNLOAD FUNCTIONALITY + File.WriteAllText(downloadFilePath, CreateXml(content.Data)); + + Console.WriteLine("\nFile Downloaded at the following location : "); + Console.WriteLine($"{Path.GetFullPath(downloadFilePath)}\n"); + WriteLogAudit(content.StatusCode); + // END : FILE DOWNLOAD FUNCTIONALITY + } + catch (FileNotFoundException) + { + Console.WriteLine("File Not Found : Kindly verify the path."); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + + // START : STREAM SERIALIZER METHOD + private static string CreateXml(object obj) + { + var xmlDoc = new XmlDocument(); // Represents an XML Document + var xmlSerializer = new XmlSerializer(obj.GetType()); // Initializes a new instance of the XmlDocument class + + // Creates a stream whose backing store is memory + using (var xmlStream = new MemoryStream()) + { + xmlSerializer.Serialize(xmlStream, obj); + xmlStream.Position = 0; + + // Loads the XML document from the specified string + xmlDoc.Load(xmlStream); + return xmlDoc.InnerText; + } + } + // END : STREAM SERIALIZER METHOD + } +} diff --git a/Source/Samples/Reporting/ReportSubscriptions/CreateClassicStandardReportSubscription.cs b/Source/Samples/Reporting/ReportSubscriptions/CreateClassicStandardReportSubscription.cs new file mode 100644 index 0000000..1ab74ca --- /dev/null +++ b/Source/Samples/Reporting/ReportSubscriptions/CreateClassicStandardReportSubscription.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class CreateClassicStandardReportSubscription + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + string reportDefinitionName = "TransactionRequestClass"; + string subscriptionType = "CLASSIC"; + var requestObj = new PredefinedSubscriptionRequestBean( + ReportDefinitionName: reportDefinitionName, + SubscriptionType: subscriptionType + ); + + string organizationId = null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReportSubscriptionsApi(clientConfig); + apiInstance.CreateStandardOrClassicSubscription(requestObj, organizationId); + WriteLogAudit(apiInstance.GetStatusCode()); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + } +} diff --git a/Source/Samples/Reporting/ReportSubscriptions/CreateReportSubscription.cs b/Source/Samples/Reporting/ReportSubscriptions/CreateReportSubscription.cs new file mode 100644 index 0000000..e97f02d --- /dev/null +++ b/Source/Samples/Reporting/ReportSubscriptions/CreateReportSubscription.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class CreateReportSubscription + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + string reportDefinitionName = "TransactionRequestClass"; + + List reportFields = new List(); + reportFields.Add("Request.RequestID"); + reportFields.Add("Request.TransactionDate"); + reportFields.Add("Request.MerchantID"); + string reportMimeType = "application/xml"; + string reportFrequency = "WEEKLY"; + string reportName = "testrest_subcription_v1"; + string timezone = "GMT"; + string startTime = "0900"; + int startDay = 1; + var requestObj = new CreateReportSubscriptionRequest( + ReportDefinitionName: reportDefinitionName, + ReportFields: reportFields, + ReportMimeType: reportMimeType, + ReportFrequency: reportFrequency, + ReportName: reportName, + Timezone: timezone, + StartTime: startTime, + StartDay: startDay + ); + + string organizationId = null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReportSubscriptionsApi(clientConfig); + apiInstance.CreateSubscription(requestObj, organizationId); + WriteLogAudit(apiInstance.GetStatusCode()); + + DeleteSubscriptionOfReportNameByOrganization.ReportNameToDelete = reportName; + DeleteSubscriptionOfReportNameByOrganization.Run(); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + } +} diff --git a/Source/Samples/Reporting/ReportSubscriptions/DeleteSubscriptionOfReportNameByOrganization.cs b/Source/Samples/Reporting/ReportSubscriptions/DeleteSubscriptionOfReportNameByOrganization.cs new file mode 100644 index 0000000..4760ab6 --- /dev/null +++ b/Source/Samples/Reporting/ReportSubscriptions/DeleteSubscriptionOfReportNameByOrganization.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class DeleteSubscriptionOfReportNameByOrganization + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static string ReportNameToDelete { get; set; } + + public static void Run() + { + if (string.IsNullOrEmpty(ReportNameToDelete)) + { + ReportNameToDelete = "testrest_subcription_v1"; + } + + string reportName = ReportNameToDelete; + string organizationId = null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReportSubscriptionsApi(clientConfig); + apiInstance.DeleteSubscription(reportName, organizationId); + ReportNameToDelete = null; + WriteLogAudit(apiInstance.GetStatusCode()); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + } +} diff --git a/Source/Samples/Reporting/ReportSubscriptions/GetAllSubscriptions.cs b/Source/Samples/Reporting/ReportSubscriptions/GetAllSubscriptions.cs new file mode 100644 index 0000000..46124e5 --- /dev/null +++ b/Source/Samples/Reporting/ReportSubscriptions/GetAllSubscriptions.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetAllSubscriptions + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3ReportSubscriptionsGet200Response Run() + { + string organizationId = null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReportSubscriptionsApi(clientConfig); + ReportingV3ReportSubscriptionsGet200Response result = apiInstance.GetAllSubscriptions(organizationId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Reporting/ReportSubscriptions/GetSubscriptionForReportName.cs b/Source/Samples/Reporting/ReportSubscriptions/GetSubscriptionForReportName.cs new file mode 100644 index 0000000..9f53385 --- /dev/null +++ b/Source/Samples/Reporting/ReportSubscriptions/GetSubscriptionForReportName.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetSubscriptionForReportName + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3ReportSubscriptionsGet200ResponseSubscriptions Run() + { + var reportName = "testrest_subcription_v1"; + string organizationId = null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReportSubscriptionsApi(clientConfig); + ReportingV3ReportSubscriptionsGet200ResponseSubscriptions result = apiInstance.GetSubscription(reportName, organizationId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Reporting/Reports/CreateAdhocReport.cs b/Source/Samples/Reporting/Reports/CreateAdhocReport.cs new file mode 100644 index 0000000..9013e80 --- /dev/null +++ b/Source/Samples/Reporting/Reports/CreateAdhocReport.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class CreateAdhocReport + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + string reportDefinitionName = "TransactionRequestClass"; + + List reportFields = new List(); + reportFields.Add("Request.RequestID"); + reportFields.Add("Request.TransactionDate"); + reportFields.Add("Request.MerchantID"); + string reportMimeType = "application/xml"; + string reportName = "testrest_v2"; + string timezone = "GMT"; + var reportStartTime = DateTime.Parse("2023-02-01T17:30:00.000+05:30"); + var reportEndTime = DateTime.Parse("2023-02-02T17:30:00.000+05:30"); + bool reportPreferencesSignedAmounts = true; + string reportPreferencesFieldNameConvention = "SOAPI"; + Reportingv3reportsReportPreferences reportPreferences = new Reportingv3reportsReportPreferences( + SignedAmounts: reportPreferencesSignedAmounts, + FieldNameConvention: reportPreferencesFieldNameConvention + ); + + var requestObj = new CreateAdhocReportRequest( + ReportDefinitionName: reportDefinitionName, + ReportFields: reportFields, + ReportMimeType: reportMimeType, + ReportName: reportName, + Timezone: timezone, + ReportStartTime: reportStartTime, + ReportEndTime: reportEndTime, + ReportPreferences: reportPreferences + ); + + string organizationId = "testrest"; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReportsApi(clientConfig); + apiInstance.CreateReport(requestObj, organizationId); + WriteLogAudit(apiInstance.GetStatusCode()); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + } +} diff --git a/Source/Samples/Reporting/Reports/GetReportBasedOnReportId.cs b/Source/Samples/Reporting/Reports/GetReportBasedOnReportId.cs new file mode 100644 index 0000000..3ce01ee --- /dev/null +++ b/Source/Samples/Reporting/Reports/GetReportBasedOnReportId.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetReportBasedOnReportId + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3ReportsIdGet200Response Run() + { + string reportId = "79642c43-2368-0cd5-e053-a2588e0a7b3c"; + string organizationId = "testrest"; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReportsApi(clientConfig); + ReportingV3ReportsIdGet200Response result = apiInstance.GetReportByReportId(reportId, organizationId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Reporting/Reports/RetrieveAvailableReports.cs b/Source/Samples/Reporting/Reports/RetrieveAvailableReports.cs new file mode 100644 index 0000000..0bece27 --- /dev/null +++ b/Source/Samples/Reporting/Reports/RetrieveAvailableReports.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class RetrieveAvailableReports + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3ReportsGet200Response Run() + { + string organizationId = null; + var startTime = DateTime.ParseExact("2023-01-01T00:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + var endTime = DateTime.ParseExact("2023-01-03T23:59:59Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + string timeQueryType = "executedTime"; + string reportMimeType = "application/xml"; + string reportFrequency = null; + string reportName = null; + int? reportDefinitionId = (int?)null; + string reportStatus = null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReportsApi(clientConfig); + ReportingV3ReportsGet200Response result = apiInstance.SearchReports(startTime, endTime, timeQueryType, organizationId, reportMimeType, reportFrequency, reportName, reportDefinitionId, reportStatus); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Reporting/RetrievalDetails/GetRetrievalDetails.cs b/Source/Samples/Reporting/RetrievalDetails/GetRetrievalDetails.cs new file mode 100644 index 0000000..be41b82 --- /dev/null +++ b/Source/Samples/Reporting/RetrievalDetails/GetRetrievalDetails.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetRetrievalDetails + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3RetrievalDetailsGet200Response Run() + { + // QUERY PARAMETERS + string organizationId = "testrest"; + var startTime = DateTime.ParseExact("2021-08-01T00:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + var endTime = DateTime.ParseExact("2021-09-01T23:59:59Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new RetrievalDetailsApi(clientConfig); + ReportingV3RetrievalDetailsGet200Response result = apiInstance.GetRetrievalDetails(startTime, endTime, organizationId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Reporting/RetrievalSummaries/GetRetrievalSummaries.cs b/Source/Samples/Reporting/RetrievalSummaries/GetRetrievalSummaries.cs new file mode 100644 index 0000000..3305630 --- /dev/null +++ b/Source/Samples/Reporting/RetrievalSummaries/GetRetrievalSummaries.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Reporting +{ + public class GetRetrievalSummaries + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ReportingV3RetrievalSummariesGet200Response Run() + { + // QUERY PARAMETERS + string organizationId = "testrest"; + var startTime = DateTime.ParseExact("2021-08-01T00:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + var endTime = DateTime.ParseExact("2021-09-01T23:59:59Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new RetrievalSummariesApi(clientConfig); + ReportingV3RetrievalSummariesGet200Response result = apiInstance.GetRetrievalSummary(startTime, endTime, organizationId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/RiskManagement/DecisionManager/AddDataToList.cs b/Source/Samples/RiskManagement/DecisionManager/AddDataToList.cs new file mode 100644 index 0000000..7f8e239 --- /dev/null +++ b/Source/Samples/RiskManagement/DecisionManager/AddDataToList.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class AddDataToList + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1UpdatePost201Response Run() + { + string type = "negative"; + string orderInformationAddressAddress1 = "1234 Sample St."; + string orderInformationAddressAddress2 = "Mountain View"; + string orderInformationAddressLocality = "California"; + string orderInformationAddressCountry = "US"; + string orderInformationAddressAdministrativeArea = "CA"; + string orderInformationAddressPostalCode = "94043"; + Riskv1liststypeentriesOrderInformationAddress orderInformationAddress = new Riskv1liststypeentriesOrderInformationAddress( + Address1: orderInformationAddressAddress1, + Address2: orderInformationAddressAddress2, + Locality: orderInformationAddressLocality, + Country: orderInformationAddressCountry, + AdministrativeArea: orderInformationAddressAdministrativeArea, + PostalCode: orderInformationAddressPostalCode + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToEmail = "test@example.com"; + Riskv1liststypeentriesOrderInformationBillTo orderInformationBillTo = new Riskv1liststypeentriesOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Email: orderInformationBillToEmail + ); + + Riskv1liststypeentriesOrderInformation orderInformation = new Riskv1liststypeentriesOrderInformation( + Address: orderInformationAddress, + BillTo: orderInformationBillTo + ); + + Riskv1liststypeentriesPaymentInformation paymentInformation = new Riskv1liststypeentriesPaymentInformation( + ); + + string clientReferenceInformationCode = "54323007"; + string clientReferenceInformationPartnerDeveloperId = "7891234"; + string clientReferenceInformationPartnerSolutionId = "89012345"; + Riskv1decisionsClientReferenceInformationPartner clientReferenceInformationPartner = new Riskv1decisionsClientReferenceInformationPartner( + DeveloperId: clientReferenceInformationPartnerDeveloperId, + SolutionId: clientReferenceInformationPartnerSolutionId + ); + + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + string riskInformationMarkingDetailsAction = "add"; + Riskv1liststypeentriesRiskInformationMarkingDetails riskInformationMarkingDetails = new Riskv1liststypeentriesRiskInformationMarkingDetails( + Action: riskInformationMarkingDetailsAction + ); + + Riskv1liststypeentriesRiskInformation riskInformation = new Riskv1liststypeentriesRiskInformation( + MarkingDetails: riskInformationMarkingDetails + ); + + var requestObj = new AddNegativeListRequest( + OrderInformation: orderInformation, + PaymentInformation: paymentInformation, + ClientReferenceInformation: clientReferenceInformation, + RiskInformation: riskInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new DecisionManagerApi(clientConfig); + RiskV1UpdatePost201Response result = apiInstance.AddNegative(type, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/DecisionManager/AddDuplicateInformation.cs b/Source/Samples/RiskManagement/DecisionManager/AddDuplicateInformation.cs new file mode 100644 index 0000000..608bab4 --- /dev/null +++ b/Source/Samples/RiskManagement/DecisionManager/AddDuplicateInformation.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class AddDuplicateInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1UpdatePost201Response Run() + { + string type = "positive"; + string orderInformationAddressAddress1 = "1234 Sample St."; + string orderInformationAddressAddress2 = "Mountain View"; + string orderInformationAddressLocality = "California"; + string orderInformationAddressCountry = "US"; + string orderInformationAddressAdministrativeArea = "CA"; + string orderInformationAddressPostalCode = "94043"; + Riskv1liststypeentriesOrderInformationAddress orderInformationAddress = new Riskv1liststypeentriesOrderInformationAddress( + Address1: orderInformationAddressAddress1, + Address2: orderInformationAddressAddress2, + Locality: orderInformationAddressLocality, + Country: orderInformationAddressCountry, + AdministrativeArea: orderInformationAddressAdministrativeArea, + PostalCode: orderInformationAddressPostalCode + ); + + string orderInformationBillToFirstName = "John"; + string orderInformationBillToLastName = "Doe"; + string orderInformationBillToEmail = "nobody@example.com"; + Riskv1liststypeentriesOrderInformationBillTo orderInformationBillTo = new Riskv1liststypeentriesOrderInformationBillTo( + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Email: orderInformationBillToEmail + ); + + Riskv1liststypeentriesOrderInformation orderInformation = new Riskv1liststypeentriesOrderInformation( + Address: orderInformationAddress, + BillTo: orderInformationBillTo + ); + + Riskv1liststypeentriesPaymentInformation paymentInformation = new Riskv1liststypeentriesPaymentInformation( + ); + + string clientReferenceInformationCode = "54323007"; + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string riskInformationMarkingDetailsAction = "add"; + Riskv1liststypeentriesRiskInformationMarkingDetails riskInformationMarkingDetails = new Riskv1liststypeentriesRiskInformationMarkingDetails( + Action: riskInformationMarkingDetailsAction + ); + + Riskv1liststypeentriesRiskInformation riskInformation = new Riskv1liststypeentriesRiskInformation( + MarkingDetails: riskInformationMarkingDetails + ); + + var requestObj = new AddNegativeListRequest( + OrderInformation: orderInformation, + PaymentInformation: paymentInformation, + ClientReferenceInformation: clientReferenceInformation, + RiskInformation: riskInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new DecisionManagerApi(clientConfig); + RiskV1UpdatePost201Response result = apiInstance.AddNegative(type, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/DecisionManager/BasicDMTransaction.cs b/Source/Samples/RiskManagement/DecisionManager/BasicDMTransaction.cs new file mode 100644 index 0000000..5261cb0 --- /dev/null +++ b/Source/Samples/RiskManagement/DecisionManager/BasicDMTransaction.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class BasicDMTransaction + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1DecisionsPost201Response Run() + { + string clientReferenceInformationCode = "54323007"; + string clientReferenceInformationComments = "decision manager case"; + string clientReferenceInformationPartnerDeveloperId = "7891234"; + string clientReferenceInformationPartnerSolutionId = "89012345"; + Riskv1decisionsClientReferenceInformationPartner clientReferenceInformationPartner = new Riskv1decisionsClientReferenceInformationPartner( + DeveloperId: clientReferenceInformationPartnerDeveloperId, + SolutionId: clientReferenceInformationPartnerSolutionId + ); + + Riskv1decisionsClientReferenceInformation clientReferenceInformation = new Riskv1decisionsClientReferenceInformation( + Code: clientReferenceInformationCode, + Comments: clientReferenceInformationComments, + Partner: clientReferenceInformationPartner + ); + + string paymentInformationCardNumber = "4444444444444448"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + Riskv1decisionsPaymentInformationCard paymentInformationCard = new Riskv1decisionsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Riskv1decisionsPaymentInformation paymentInformation = new Riskv1decisionsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "144.14"; + Riskv1decisionsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1decisionsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationBillToAddress1 = "96, powers street"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Clearwater milford"; + string orderInformationBillToFirstName = "James"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToPhoneNumber = "7606160717"; + string orderInformationBillToEmail = "test@visa.com"; + string orderInformationBillToPostalCode = "03055"; + Riskv1decisionsOrderInformationBillTo orderInformationBillTo = new Riskv1decisionsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1decisionsOrderInformation orderInformation = new Riskv1decisionsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreateBundledDecisionManagerCaseRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new DecisionManagerApi(clientConfig); + RiskV1DecisionsPost201Response result = apiInstance.CreateBundledDecisionManagerCase(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/DecisionManager/DMWithBuyerInformation.cs b/Source/Samples/RiskManagement/DecisionManager/DMWithBuyerInformation.cs new file mode 100644 index 0000000..e78196d --- /dev/null +++ b/Source/Samples/RiskManagement/DecisionManager/DMWithBuyerInformation.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class DMWithBuyerInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1DecisionsPost201Response Run() + { + string clientReferenceInformationCode = "54323007"; + Riskv1decisionsClientReferenceInformation clientReferenceInformation = new Riskv1decisionsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4444444444444448"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + Riskv1decisionsPaymentInformationCard paymentInformationCard = new Riskv1decisionsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Riskv1decisionsPaymentInformation paymentInformation = new Riskv1decisionsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "144.14"; + Riskv1decisionsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1decisionsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationBillToAddress1 = "96, powers street"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Clearwater milford"; + string orderInformationBillToFirstName = "James"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToPhoneNumber = "7606160717"; + string orderInformationBillToEmail = "test@visa.com"; + string orderInformationBillToPostalCode = "03055"; + Riskv1decisionsOrderInformationBillTo orderInformationBillTo = new Riskv1decisionsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1decisionsOrderInformation orderInformation = new Riskv1decisionsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string buyerInformationHashedPassword = ""; + string buyerInformationDateOfBirth = "19980505"; + + List buyerInformationPersonalIdentification = new List(); + string buyerInformationPersonalIdentificationType1 = "CPF"; + string buyerInformationPersonalIdentificationId1 = "1a23apwe98"; + buyerInformationPersonalIdentification.Add(new Ptsv2paymentsBuyerInformationPersonalIdentification( + Type: buyerInformationPersonalIdentificationType1, + Id: buyerInformationPersonalIdentificationId1 + )); + + Riskv1decisionsBuyerInformation buyerInformation = new Riskv1decisionsBuyerInformation( + HashedPassword: buyerInformationHashedPassword, + DateOfBirth: buyerInformationDateOfBirth, + PersonalIdentification: buyerInformationPersonalIdentification + ); + + var requestObj = new CreateBundledDecisionManagerCaseRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + BuyerInformation: buyerInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new DecisionManagerApi(clientConfig); + RiskV1DecisionsPost201Response result = apiInstance.CreateBundledDecisionManagerCase(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/DecisionManager/DMWithDecisionProfileRejectResponse.cs b/Source/Samples/RiskManagement/DecisionManager/DMWithDecisionProfileRejectResponse.cs new file mode 100644 index 0000000..540af3c --- /dev/null +++ b/Source/Samples/RiskManagement/DecisionManager/DMWithDecisionProfileRejectResponse.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class DMWithDecisionProfileRejectResponse + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1DecisionsPost201Response Run() + { + string clientReferenceInformationCode = "54323007"; + Riskv1decisionsClientReferenceInformation clientReferenceInformation = new Riskv1decisionsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4444444444444448"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + Riskv1decisionsPaymentInformationCard paymentInformationCard = new Riskv1decisionsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Riskv1decisionsPaymentInformation paymentInformation = new Riskv1decisionsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "144.14"; + Riskv1decisionsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1decisionsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationBillToAddress1 = "96, powers street"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Clearwater milford"; + string orderInformationBillToFirstName = "James"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToPhoneNumber = "7606160717"; + string orderInformationBillToEmail = "test@visa.com"; + string orderInformationBillToPostalCode = "03055"; + Riskv1decisionsOrderInformationBillTo orderInformationBillTo = new Riskv1decisionsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1decisionsOrderInformation orderInformation = new Riskv1decisionsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string riskInformationProfileName = "profile2"; + Ptsv2paymentsRiskInformationProfile riskInformationProfile = new Ptsv2paymentsRiskInformationProfile( + Name: riskInformationProfileName + ); + + Riskv1decisionsRiskInformation riskInformation = new Riskv1decisionsRiskInformation( + Profile: riskInformationProfile + ); + + var requestObj = new CreateBundledDecisionManagerCaseRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + RiskInformation: riskInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new DecisionManagerApi(clientConfig); + RiskV1DecisionsPost201Response result = apiInstance.CreateBundledDecisionManagerCase(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/DecisionManager/DMWithDeviceInformation.cs b/Source/Samples/RiskManagement/DecisionManager/DMWithDeviceInformation.cs new file mode 100644 index 0000000..68adcba --- /dev/null +++ b/Source/Samples/RiskManagement/DecisionManager/DMWithDeviceInformation.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class DMWithDeviceInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1DecisionsPost201Response Run() + { + string clientReferenceInformationCode = "54323007"; + Riskv1decisionsClientReferenceInformation clientReferenceInformation = new Riskv1decisionsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4444444444444448"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + Riskv1decisionsPaymentInformationCard paymentInformationCard = new Riskv1decisionsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Riskv1decisionsPaymentInformation paymentInformation = new Riskv1decisionsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "144.14"; + Riskv1decisionsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1decisionsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationBillToAddress1 = "96, powers street"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Clearwater milford"; + string orderInformationBillToFirstName = "James"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToPhoneNumber = "7606160717"; + string orderInformationBillToEmail = "test@visa.com"; + string orderInformationBillToPostalCode = "03055"; + Riskv1decisionsOrderInformationBillTo orderInformationBillTo = new Riskv1decisionsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1decisionsOrderInformation orderInformation = new Riskv1decisionsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string deviceInformationCookiesAccepted = "yes"; + string deviceInformationIpAddress = "64.124.61.215"; + string deviceInformationHostName = "host.com"; + string deviceInformationHttpBrowserEmail = "xyz@gmail.com"; + string deviceInformationUserAgent = "Chrome"; + Riskv1decisionsDeviceInformation deviceInformation = new Riskv1decisionsDeviceInformation( + CookiesAccepted: deviceInformationCookiesAccepted, + IpAddress: deviceInformationIpAddress, + HostName: deviceInformationHostName, + HttpBrowserEmail: deviceInformationHttpBrowserEmail, + UserAgent: deviceInformationUserAgent + ); + + var requestObj = new CreateBundledDecisionManagerCaseRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + DeviceInformation: deviceInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new DecisionManagerApi(clientConfig); + RiskV1DecisionsPost201Response result = apiInstance.CreateBundledDecisionManagerCase(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/DecisionManager/DMWithMerchantDefinedInformation.cs b/Source/Samples/RiskManagement/DecisionManager/DMWithMerchantDefinedInformation.cs new file mode 100644 index 0000000..b3b44c7 --- /dev/null +++ b/Source/Samples/RiskManagement/DecisionManager/DMWithMerchantDefinedInformation.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class DMWithMerchantDefinedInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1DecisionsPost201Response Run() + { + string clientReferenceInformationCode = "54323007"; + Riskv1decisionsClientReferenceInformation clientReferenceInformation = new Riskv1decisionsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4444444444444448"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + Riskv1decisionsPaymentInformationCard paymentInformationCard = new Riskv1decisionsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Riskv1decisionsPaymentInformation paymentInformation = new Riskv1decisionsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "144.14"; + Riskv1decisionsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1decisionsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationBillToAddress1 = "96, powers street"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Clearwater milford"; + string orderInformationBillToFirstName = "James"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToPhoneNumber = "7606160717"; + string orderInformationBillToEmail = "test@visa.com"; + string orderInformationBillToPostalCode = "03055"; + Riskv1decisionsOrderInformationBillTo orderInformationBillTo = new Riskv1decisionsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1decisionsOrderInformation orderInformation = new Riskv1decisionsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + + List merchantDefinedInformation = new List(); + string merchantDefinedInformationKey1 = "1"; + string merchantDefinedInformationValue1 = "Test"; + merchantDefinedInformation.Add(new Riskv1decisionsMerchantDefinedInformation( + Key: merchantDefinedInformationKey1, + Value: merchantDefinedInformationValue1 + )); + + string merchantDefinedInformationKey2 = "2"; + string merchantDefinedInformationValue2 = "Test2"; + merchantDefinedInformation.Add(new Riskv1decisionsMerchantDefinedInformation( + Key: merchantDefinedInformationKey2, + Value: merchantDefinedInformationValue2 + )); + + var requestObj = new CreateBundledDecisionManagerCaseRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + MerchantDefinedInformation: merchantDefinedInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new DecisionManagerApi(clientConfig); + RiskV1DecisionsPost201Response result = apiInstance.CreateBundledDecisionManagerCase(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/DecisionManager/DMWithScoreExceedsThresholdResponse.cs b/Source/Samples/RiskManagement/DecisionManager/DMWithScoreExceedsThresholdResponse.cs new file mode 100644 index 0000000..1862d74 --- /dev/null +++ b/Source/Samples/RiskManagement/DecisionManager/DMWithScoreExceedsThresholdResponse.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class DMWithScoreExceedsThresholdResponse + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1DecisionsPost201Response Run() + { + string clientReferenceInformationCode = "54323007"; + Riskv1decisionsClientReferenceInformation clientReferenceInformation = new Riskv1decisionsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4444444444444448"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + Riskv1decisionsPaymentInformationCard paymentInformationCard = new Riskv1decisionsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Riskv1decisionsPaymentInformation paymentInformation = new Riskv1decisionsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "144.14"; + Riskv1decisionsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1decisionsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationShipToAddress1 = "96, powers street"; + string orderInformationShipToAddress2 = ""; + string orderInformationShipToAdministrativeArea = "KA"; + string orderInformationShipToCountry = "IN"; + string orderInformationShipToLocality = "Clearwater milford"; + string orderInformationShipToFirstName = "James"; + string orderInformationShipToLastName = "Smith"; + string orderInformationShipToPhoneNumber = "7606160717"; + string orderInformationShipToPostalCode = "560056"; + Riskv1decisionsOrderInformationShipTo orderInformationShipTo = new Riskv1decisionsOrderInformationShipTo( + Address1: orderInformationShipToAddress1, + Address2: orderInformationShipToAddress2, + AdministrativeArea: orderInformationShipToAdministrativeArea, + Country: orderInformationShipToCountry, + Locality: orderInformationShipToLocality, + FirstName: orderInformationShipToFirstName, + LastName: orderInformationShipToLastName, + PhoneNumber: orderInformationShipToPhoneNumber, + PostalCode: orderInformationShipToPostalCode + ); + + string orderInformationBillToAddress1 = "96, powers street"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Clearwater milford"; + string orderInformationBillToFirstName = "James"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToPhoneNumber = "7606160717"; + string orderInformationBillToEmail = "test@visa.com"; + string orderInformationBillToPostalCode = "03055"; + Riskv1decisionsOrderInformationBillTo orderInformationBillTo = new Riskv1decisionsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1decisionsOrderInformation orderInformation = new Riskv1decisionsOrderInformation( + AmountDetails: orderInformationAmountDetails, + ShipTo: orderInformationShipTo, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreateBundledDecisionManagerCaseRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new DecisionManagerApi(clientConfig); + RiskV1DecisionsPost201Response result = apiInstance.CreateBundledDecisionManagerCase(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/DecisionManager/DMWithShippingInformation.cs b/Source/Samples/RiskManagement/DecisionManager/DMWithShippingInformation.cs new file mode 100644 index 0000000..075ebea --- /dev/null +++ b/Source/Samples/RiskManagement/DecisionManager/DMWithShippingInformation.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class DMWithShippingInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1DecisionsPost201Response Run() + { + string clientReferenceInformationCode = "54323007"; + Riskv1decisionsClientReferenceInformation clientReferenceInformation = new Riskv1decisionsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4444444444444448"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + Riskv1decisionsPaymentInformationCard paymentInformationCard = new Riskv1decisionsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Riskv1decisionsPaymentInformation paymentInformation = new Riskv1decisionsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "144.14"; + Riskv1decisionsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1decisionsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationShipToAddress1 = "96, powers street"; + string orderInformationShipToAddress2 = ""; + string orderInformationShipToAdministrativeArea = "KA"; + string orderInformationShipToCountry = "IN"; + string orderInformationShipToLocality = "Clearwater milford"; + string orderInformationShipToFirstName = "James"; + string orderInformationShipToLastName = "Smith"; + string orderInformationShipToPhoneNumber = "7606160717"; + string orderInformationShipToPostalCode = "560056"; + Riskv1decisionsOrderInformationShipTo orderInformationShipTo = new Riskv1decisionsOrderInformationShipTo( + Address1: orderInformationShipToAddress1, + Address2: orderInformationShipToAddress2, + AdministrativeArea: orderInformationShipToAdministrativeArea, + Country: orderInformationShipToCountry, + Locality: orderInformationShipToLocality, + FirstName: orderInformationShipToFirstName, + LastName: orderInformationShipToLastName, + PhoneNumber: orderInformationShipToPhoneNumber, + PostalCode: orderInformationShipToPostalCode + ); + + string orderInformationBillToAddress1 = "96, powers street"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Clearwater milford"; + string orderInformationBillToFirstName = "James"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToPhoneNumber = "7606160717"; + string orderInformationBillToEmail = "test@visa.com"; + string orderInformationBillToPostalCode = "03055"; + Riskv1decisionsOrderInformationBillTo orderInformationBillTo = new Riskv1decisionsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1decisionsOrderInformation orderInformation = new Riskv1decisionsOrderInformation( + AmountDetails: orderInformationAmountDetails, + ShipTo: orderInformationShipTo, + BillTo: orderInformationBillTo + ); + + var requestObj = new CreateBundledDecisionManagerCaseRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new DecisionManagerApi(clientConfig); + RiskV1DecisionsPost201Response result = apiInstance.CreateBundledDecisionManagerCase(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/DecisionManager/DMWithTravelInformation.cs b/Source/Samples/RiskManagement/DecisionManager/DMWithTravelInformation.cs new file mode 100644 index 0000000..1adaa65 --- /dev/null +++ b/Source/Samples/RiskManagement/DecisionManager/DMWithTravelInformation.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class DMWithTravelInformation + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1DecisionsPost201Response Run() + { + string clientReferenceInformationCode = "54323007"; + Riskv1decisionsClientReferenceInformation clientReferenceInformation = new Riskv1decisionsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string paymentInformationCardNumber = "4444444444444448"; + string paymentInformationCardExpirationMonth = "12"; + string paymentInformationCardExpirationYear = "2025"; + Riskv1decisionsPaymentInformationCard paymentInformationCard = new Riskv1decisionsPaymentInformationCard( + Number: paymentInformationCardNumber, + ExpirationMonth: paymentInformationCardExpirationMonth, + ExpirationYear: paymentInformationCardExpirationYear + ); + + Riskv1decisionsPaymentInformation paymentInformation = new Riskv1decisionsPaymentInformation( + Card: paymentInformationCard + ); + + string orderInformationAmountDetailsCurrency = "USD"; + string orderInformationAmountDetailsTotalAmount = "144.14"; + Riskv1decisionsOrderInformationAmountDetails orderInformationAmountDetails = new Riskv1decisionsOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency, + TotalAmount: orderInformationAmountDetailsTotalAmount + ); + + string orderInformationBillToAddress1 = "96, powers street"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Clearwater milford"; + string orderInformationBillToFirstName = "James"; + string orderInformationBillToLastName = "Smith"; + string orderInformationBillToPhoneNumber = "7606160717"; + string orderInformationBillToEmail = "test@visa.com"; + string orderInformationBillToPostalCode = "03055"; + Riskv1decisionsOrderInformationBillTo orderInformationBillTo = new Riskv1decisionsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + PhoneNumber: orderInformationBillToPhoneNumber, + Email: orderInformationBillToEmail, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1decisionsOrderInformation orderInformation = new Riskv1decisionsOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo + ); + + string travelInformationCompleteRoute = "SFO-JFK:JFK-BLR"; + string travelInformationDepartureTime = "2011-03-20 11:30pm GMT"; + string travelInformationJourneyType = "One way"; + + List travelInformationLegs = new List(); + string travelInformationLegsOrigination1 = "SFO"; + string travelInformationLegsDestination1 = "JFK"; + travelInformationLegs.Add(new Riskv1decisionsTravelInformationLegs( + Origination: travelInformationLegsOrigination1, + Destination: travelInformationLegsDestination1 + )); + + string travelInformationLegsOrigination2 = "JFK"; + string travelInformationLegsDestination2 = "BLR"; + travelInformationLegs.Add(new Riskv1decisionsTravelInformationLegs( + Origination: travelInformationLegsOrigination2, + Destination: travelInformationLegsDestination2 + )); + + Riskv1decisionsTravelInformation travelInformation = new Riskv1decisionsTravelInformation( + CompleteRoute: travelInformationCompleteRoute, + DepartureTime: travelInformationDepartureTime, + JourneyType: travelInformationJourneyType, + Legs: travelInformationLegs + ); + + var requestObj = new CreateBundledDecisionManagerCaseRequest( + ClientReferenceInformation: clientReferenceInformation, + PaymentInformation: paymentInformation, + OrderInformation: orderInformation, + TravelInformation: travelInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new DecisionManagerApi(clientConfig); + RiskV1DecisionsPost201Response result = apiInstance.CreateBundledDecisionManagerCase(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/DecisionManager/MarkAsSuspect.cs b/Source/Samples/RiskManagement/DecisionManager/MarkAsSuspect.cs new file mode 100644 index 0000000..f2bd697 --- /dev/null +++ b/Source/Samples/RiskManagement/DecisionManager/MarkAsSuspect.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class MarkAsSuspect + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1UpdatePost201Response Run() + { + string id = "5825489395116729903003"; + string riskInformationMarkingDetailsNotes = "Adding this transaction as suspect"; + string riskInformationMarkingDetailsReason = "suspected"; + + List riskInformationMarkingDetailsFieldsIncluded = new List(); + riskInformationMarkingDetailsFieldsIncluded.Add("customer_email"); + riskInformationMarkingDetailsFieldsIncluded.Add("customer_phone"); + string riskInformationMarkingDetailsAction = "add"; + Riskv1decisionsidmarkingRiskInformationMarkingDetails riskInformationMarkingDetails = new Riskv1decisionsidmarkingRiskInformationMarkingDetails( + Notes: riskInformationMarkingDetailsNotes, + Reason: riskInformationMarkingDetailsReason, + FieldsIncluded: riskInformationMarkingDetailsFieldsIncluded, + Action: riskInformationMarkingDetailsAction + ); + + Riskv1decisionsidmarkingRiskInformation riskInformation = new Riskv1decisionsidmarkingRiskInformation( + MarkingDetails: riskInformationMarkingDetails + ); + + string clientReferenceInformationCode = "12345"; + string clientReferenceInformationPartnerDeveloperId = "1234"; + string clientReferenceInformationPartnerSolutionId = "3321"; + Riskv1decisionsClientReferenceInformationPartner clientReferenceInformationPartner = new Riskv1decisionsClientReferenceInformationPartner( + DeveloperId: clientReferenceInformationPartnerDeveloperId, + SolutionId: clientReferenceInformationPartnerSolutionId + ); + + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode, + Partner: clientReferenceInformationPartner + ); + + var requestObj = new FraudMarkingActionRequest( + RiskInformation: riskInformation, + ClientReferenceInformation: clientReferenceInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new DecisionManagerApi(clientConfig); + RiskV1UpdatePost201Response result = apiInstance.FraudUpdate(id, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/DecisionManager/RemoveFromHistory.cs b/Source/Samples/RiskManagement/DecisionManager/RemoveFromHistory.cs new file mode 100644 index 0000000..da45b4e --- /dev/null +++ b/Source/Samples/RiskManagement/DecisionManager/RemoveFromHistory.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class RemoveFromHistory + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1UpdatePost201Response Run() + { + string id = "5825489395116729903003"; + string riskInformationMarkingDetailsNotes = "Adding this transaction as suspect"; + string riskInformationMarkingDetailsReason = "suspected"; + string riskInformationMarkingDetailsAction = "hide"; + Riskv1decisionsidmarkingRiskInformationMarkingDetails riskInformationMarkingDetails = new Riskv1decisionsidmarkingRiskInformationMarkingDetails( + Notes: riskInformationMarkingDetailsNotes, + Reason: riskInformationMarkingDetailsReason, + Action: riskInformationMarkingDetailsAction + ); + + Riskv1decisionsidmarkingRiskInformation riskInformation = new Riskv1decisionsidmarkingRiskInformation( + MarkingDetails: riskInformationMarkingDetails + ); + + var requestObj = new FraudMarkingActionRequest( + RiskInformation: riskInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new DecisionManagerApi(clientConfig); + RiskV1UpdatePost201Response result = apiInstance.FraudUpdate(id, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/Verification/AddressMatchNotFound.cs b/Source/Samples/RiskManagement/Verification/AddressMatchNotFound.cs new file mode 100644 index 0000000..a382c8b --- /dev/null +++ b/Source/Samples/RiskManagement/Verification/AddressMatchNotFound.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class AddressMatchNotFound + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AddressVerificationsPost201Response Run() + { + string clientReferenceInformationCode = "addressEg"; + string clientReferenceInformationComments = "dav-error response check"; + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode, + Comments: clientReferenceInformationComments + ); + + string orderInformationBillToAddress1 = "Apt C "; + string orderInformationBillToAddress2 = ""; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Glendale"; + string orderInformationBillToPostalCode = "91204"; + Riskv1addressverificationsOrderInformationBillTo orderInformationBillTo = new Riskv1addressverificationsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + PostalCode: orderInformationBillToPostalCode + ); + + Riskv1addressverificationsOrderInformation orderInformation = new Riskv1addressverificationsOrderInformation( + BillTo: orderInformationBillTo + ); + + var requestObj = new VerifyCustomerAddressRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VerificationApi(clientConfig); + RiskV1AddressVerificationsPost201Response result = apiInstance.VerifyCustomerAddress(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/Verification/ApartmentNumberMissingOrNotFound.cs b/Source/Samples/RiskManagement/Verification/ApartmentNumberMissingOrNotFound.cs new file mode 100644 index 0000000..5bf6c41 --- /dev/null +++ b/Source/Samples/RiskManagement/Verification/ApartmentNumberMissingOrNotFound.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class ApartmentNumberMissingOrNotFound + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AddressVerificationsPost201Response Run() + { + string clientReferenceInformationCode = "addressEg"; + string clientReferenceInformationComments = "dav-error response check"; + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode, + Comments: clientReferenceInformationComments + ); + + string orderInformationBillToAddress1 = "6th 4th ave"; + string orderInformationBillToAddress2 = ""; + string orderInformationBillToAdministrativeArea = "NY"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "rensslaer"; + string orderInformationBillToPostalCode = "12144"; + Riskv1addressverificationsOrderInformationBillTo orderInformationBillTo = new Riskv1addressverificationsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + PostalCode: orderInformationBillToPostalCode + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsUnitPrice1 = "120.50"; + int orderInformationLineItemsQuantity1 = 3; + string orderInformationLineItemsProductSKU1 = "996633"; + string orderInformationLineItemsProductName1 = "qwerty"; + string orderInformationLineItemsProductCode1 = "handling"; + orderInformationLineItems.Add(new Riskv1addressverificationsOrderInformationLineItems( + UnitPrice: orderInformationLineItemsUnitPrice1, + Quantity: orderInformationLineItemsQuantity1, + ProductSKU: orderInformationLineItemsProductSKU1, + ProductName: orderInformationLineItemsProductName1, + ProductCode: orderInformationLineItemsProductCode1 + )); + + Riskv1addressverificationsOrderInformation orderInformation = new Riskv1addressverificationsOrderInformation( + BillTo: orderInformationBillTo, + LineItems: orderInformationLineItems + ); + + var requestObj = new VerifyCustomerAddressRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VerificationApi(clientConfig); + RiskV1AddressVerificationsPost201Response result = apiInstance.VerifyCustomerAddress(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/Verification/CanadianBillingDetails.cs b/Source/Samples/RiskManagement/Verification/CanadianBillingDetails.cs new file mode 100644 index 0000000..e92f51c --- /dev/null +++ b/Source/Samples/RiskManagement/Verification/CanadianBillingDetails.cs @@ -0,0 +1,98 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class CanadianBillingDetails + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AddressVerificationsPost201Response Run() + { + string clientReferenceInformationCode = "addressEg"; + string clientReferenceInformationComments = "dav-All fields"; + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode, + Comments: clientReferenceInformationComments + ); + + string orderInformationBillToAddress1 = "1650 Burton Ave"; + string orderInformationBillToAddress2 = ""; + string orderInformationBillToAddress3 = ""; + string orderInformationBillToAddress4 = ""; + string orderInformationBillToAdministrativeArea = "BC"; + string orderInformationBillToCountry = "CA"; + string orderInformationBillToLocality = "VICTORIA"; + string orderInformationBillToPostalCode = "V8T 2N6"; + Riskv1addressverificationsOrderInformationBillTo orderInformationBillTo = new Riskv1addressverificationsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + Address3: orderInformationBillToAddress3, + Address4: orderInformationBillToAddress4, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + PostalCode: orderInformationBillToPostalCode + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsUnitPrice1 = "120.50"; + int orderInformationLineItemsQuantity1 = 3; + string orderInformationLineItemsProductSKU1 = "9966223"; + string orderInformationLineItemsProductName1 = "headset"; + string orderInformationLineItemsProductCode1 = "electronic"; + orderInformationLineItems.Add(new Riskv1addressverificationsOrderInformationLineItems( + UnitPrice: orderInformationLineItemsUnitPrice1, + Quantity: orderInformationLineItemsQuantity1, + ProductSKU: orderInformationLineItemsProductSKU1, + ProductName: orderInformationLineItemsProductName1, + ProductCode: orderInformationLineItemsProductCode1 + )); + + Riskv1addressverificationsOrderInformation orderInformation = new Riskv1addressverificationsOrderInformation( + BillTo: orderInformationBillTo, + LineItems: orderInformationLineItems + ); + + string buyerInformationMerchantCustomerId = "ABCD"; + Riskv1addressverificationsBuyerInformation buyerInformation = new Riskv1addressverificationsBuyerInformation( + MerchantCustomerId: buyerInformationMerchantCustomerId + ); + + var requestObj = new VerifyCustomerAddressRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + BuyerInformation: buyerInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VerificationApi(clientConfig); + RiskV1AddressVerificationsPost201Response result = apiInstance.VerifyCustomerAddress(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/Verification/ComplianceStatusCompleted.cs b/Source/Samples/RiskManagement/Verification/ComplianceStatusCompleted.cs new file mode 100644 index 0000000..4773c7c --- /dev/null +++ b/Source/Samples/RiskManagement/Verification/ComplianceStatusCompleted.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class ComplianceStatusCompleted + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1ExportComplianceInquiriesPost201Response Run() + { + string clientReferenceInformationCode = "verification example"; + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationBillToAddress1 = "901 Metro Centre Blvd"; + string orderInformationBillToAddress2 = "2"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Foster City"; + string orderInformationBillToPostalCode = "94404"; + string orderInformationBillToFirstName = "Suman"; + string orderInformationBillToLastName = "Kumar"; + string orderInformationBillToEmail = "donewithhorizon@test.com"; + Riskv1exportcomplianceinquiriesOrderInformationBillTo orderInformationBillTo = new Riskv1exportcomplianceinquiriesOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + PostalCode: orderInformationBillToPostalCode, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Email: orderInformationBillToEmail + ); + + string orderInformationShipToCountry = "be"; + string orderInformationShipToFirstName = "DumbelDore"; + string orderInformationShipToLastName = "Albus"; + Riskv1exportcomplianceinquiriesOrderInformationShipTo orderInformationShipTo = new Riskv1exportcomplianceinquiriesOrderInformationShipTo( + Country: orderInformationShipToCountry, + FirstName: orderInformationShipToFirstName, + LastName: orderInformationShipToLastName + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsUnitPrice1 = "19.00"; + orderInformationLineItems.Add(new Riskv1exportcomplianceinquiriesOrderInformationLineItems( + UnitPrice: orderInformationLineItemsUnitPrice1 + )); + + Riskv1exportcomplianceinquiriesOrderInformation orderInformation = new Riskv1exportcomplianceinquiriesOrderInformation( + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo, + LineItems: orderInformationLineItems + ); + + string buyerInformationMerchantCustomerId = "87789"; + Riskv1addressverificationsBuyerInformation buyerInformation = new Riskv1addressverificationsBuyerInformation( + MerchantCustomerId: buyerInformationMerchantCustomerId + ); + + string exportComplianceInformationAddressOperator = "and"; + string exportComplianceInformationWeightsAddress = "abc"; + string exportComplianceInformationWeightsCompany = "def"; + string exportComplianceInformationWeightsName = "adb"; + Ptsv2paymentsWatchlistScreeningInformationWeights exportComplianceInformationWeights = new Ptsv2paymentsWatchlistScreeningInformationWeights( + Address: exportComplianceInformationWeightsAddress, + Company: exportComplianceInformationWeightsCompany, + Name: exportComplianceInformationWeightsName + ); + + + List exportComplianceInformationSanctionLists = new List(); + exportComplianceInformationSanctionLists.Add("abc"); + exportComplianceInformationSanctionLists.Add("acc"); + exportComplianceInformationSanctionLists.Add("bac"); + Riskv1exportcomplianceinquiriesExportComplianceInformation exportComplianceInformation = new Riskv1exportcomplianceinquiriesExportComplianceInformation( + AddressOperator: exportComplianceInformationAddressOperator, + Weights: exportComplianceInformationWeights, + SanctionLists: exportComplianceInformationSanctionLists + ); + + var requestObj = new ValidateExportComplianceRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + BuyerInformation: buyerInformation, + ExportComplianceInformation: exportComplianceInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VerificationApi(clientConfig); + RiskV1ExportComplianceInquiriesPost201Response result = apiInstance.ValidateExportCompliance(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/Verification/CustomerMatchDeniedPartiesList.cs b/Source/Samples/RiskManagement/Verification/CustomerMatchDeniedPartiesList.cs new file mode 100644 index 0000000..55e3734 --- /dev/null +++ b/Source/Samples/RiskManagement/Verification/CustomerMatchDeniedPartiesList.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class CustomerMatchDeniedPartiesList + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1ExportComplianceInquiriesPost201Response Run() + { + string clientReferenceInformationCode = "verification example"; + string clientReferenceInformationComments = "Export-basic"; + string clientReferenceInformationPartnerDeveloperId = "7891234"; + string clientReferenceInformationPartnerSolutionId = "89012345"; + Riskv1decisionsClientReferenceInformationPartner clientReferenceInformationPartner = new Riskv1decisionsClientReferenceInformationPartner( + DeveloperId: clientReferenceInformationPartnerDeveloperId, + SolutionId: clientReferenceInformationPartnerSolutionId + ); + + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode, + Comments: clientReferenceInformationComments, + Partner: clientReferenceInformationPartner + ); + + string orderInformationBillToAddress1 = "901 Metro Centre Blvd"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Foster City"; + string orderInformationBillToPostalCode = "94404"; + string orderInformationBillToCompanyName = "A & C International Trade, Inc"; + Riskv1exportcomplianceinquiriesOrderInformationBillToCompany orderInformationBillToCompany = new Riskv1exportcomplianceinquiriesOrderInformationBillToCompany( + Name: orderInformationBillToCompanyName + ); + + string orderInformationBillToFirstName = "ANDREE"; + string orderInformationBillToLastName = "AGNESE"; + string orderInformationBillToEmail = "test@domain.com"; + Riskv1exportcomplianceinquiriesOrderInformationBillTo orderInformationBillTo = new Riskv1exportcomplianceinquiriesOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + PostalCode: orderInformationBillToPostalCode, + Company: orderInformationBillToCompany, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Email: orderInformationBillToEmail + ); + + string orderInformationShipToCountry = "IN"; + string orderInformationShipToFirstName = "DumbelDore"; + string orderInformationShipToLastName = "Albus"; + Riskv1exportcomplianceinquiriesOrderInformationShipTo orderInformationShipTo = new Riskv1exportcomplianceinquiriesOrderInformationShipTo( + Country: orderInformationShipToCountry, + FirstName: orderInformationShipToFirstName, + LastName: orderInformationShipToLastName + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsUnitPrice1 = "120.50"; + int orderInformationLineItemsQuantity1 = 3; + string orderInformationLineItemsProductSKU1 = "123456"; + string orderInformationLineItemsProductName1 = "Qwe"; + string orderInformationLineItemsProductCode1 = "physical_software"; + orderInformationLineItems.Add(new Riskv1exportcomplianceinquiriesOrderInformationLineItems( + UnitPrice: orderInformationLineItemsUnitPrice1, + Quantity: orderInformationLineItemsQuantity1, + ProductSKU: orderInformationLineItemsProductSKU1, + ProductName: orderInformationLineItemsProductName1, + ProductCode: orderInformationLineItemsProductCode1 + )); + + Riskv1exportcomplianceinquiriesOrderInformation orderInformation = new Riskv1exportcomplianceinquiriesOrderInformation( + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo, + LineItems: orderInformationLineItems + ); + + var requestObj = new ValidateExportComplianceRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VerificationApi(clientConfig); + RiskV1ExportComplianceInquiriesPost201Response result = apiInstance.ValidateExportCompliance(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/Verification/ExportComplianceInformationProvided.cs b/Source/Samples/RiskManagement/Verification/ExportComplianceInformationProvided.cs new file mode 100644 index 0000000..2699761 --- /dev/null +++ b/Source/Samples/RiskManagement/Verification/ExportComplianceInformationProvided.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class ExportComplianceInformationProvided + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1ExportComplianceInquiriesPost201Response Run() + { + string clientReferenceInformationCode = "verification example"; + string clientReferenceInformationComments = "Export -fields"; + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode, + Comments: clientReferenceInformationComments + ); + + string orderInformationBillToAddress1 = "901 Metro Centre Blvd"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Foster City"; + string orderInformationBillToPostalCode = "94404"; + string orderInformationBillToCompanyName = "A & C International Trade, Inc"; + Riskv1exportcomplianceinquiriesOrderInformationBillToCompany orderInformationBillToCompany = new Riskv1exportcomplianceinquiriesOrderInformationBillToCompany( + Name: orderInformationBillToCompanyName + ); + + string orderInformationBillToFirstName = "ANDREE"; + string orderInformationBillToLastName = "AGNESE"; + string orderInformationBillToEmail = "test@domain.com"; + Riskv1exportcomplianceinquiriesOrderInformationBillTo orderInformationBillTo = new Riskv1exportcomplianceinquiriesOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + PostalCode: orderInformationBillToPostalCode, + Company: orderInformationBillToCompany, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Email: orderInformationBillToEmail + ); + + string orderInformationShipToCountry = "IN"; + string orderInformationShipToFirstName = "DumbelDore"; + string orderInformationShipToLastName = "Albus"; + Riskv1exportcomplianceinquiriesOrderInformationShipTo orderInformationShipTo = new Riskv1exportcomplianceinquiriesOrderInformationShipTo( + Country: orderInformationShipToCountry, + FirstName: orderInformationShipToFirstName, + LastName: orderInformationShipToLastName + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsUnitPrice1 = "120.50"; + int orderInformationLineItemsQuantity1 = 3; + string orderInformationLineItemsProductSKU1 = "123456"; + string orderInformationLineItemsProductName1 = "Qwe"; + string orderInformationLineItemsProductCode1 = "physical_software"; + orderInformationLineItems.Add(new Riskv1exportcomplianceinquiriesOrderInformationLineItems( + UnitPrice: orderInformationLineItemsUnitPrice1, + Quantity: orderInformationLineItemsQuantity1, + ProductSKU: orderInformationLineItemsProductSKU1, + ProductName: orderInformationLineItemsProductName1, + ProductCode: orderInformationLineItemsProductCode1 + )); + + Riskv1exportcomplianceinquiriesOrderInformation orderInformation = new Riskv1exportcomplianceinquiriesOrderInformation( + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo, + LineItems: orderInformationLineItems + ); + + string exportComplianceInformationAddressOperator = "and"; + string exportComplianceInformationWeightsAddress = "low"; + string exportComplianceInformationWeightsCompany = "exact"; + string exportComplianceInformationWeightsName = "exact"; + Ptsv2paymentsWatchlistScreeningInformationWeights exportComplianceInformationWeights = new Ptsv2paymentsWatchlistScreeningInformationWeights( + Address: exportComplianceInformationWeightsAddress, + Company: exportComplianceInformationWeightsCompany, + Name: exportComplianceInformationWeightsName + ); + + + List exportComplianceInformationSanctionLists = new List(); + exportComplianceInformationSanctionLists.Add("Bureau Of Industry and Security"); + Riskv1exportcomplianceinquiriesExportComplianceInformation exportComplianceInformation = new Riskv1exportcomplianceinquiriesExportComplianceInformation( + AddressOperator: exportComplianceInformationAddressOperator, + Weights: exportComplianceInformationWeights, + SanctionLists: exportComplianceInformationSanctionLists + ); + + var requestObj = new ValidateExportComplianceRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + ExportComplianceInformation: exportComplianceInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VerificationApi(clientConfig); + RiskV1ExportComplianceInquiriesPost201Response result = apiInstance.ValidateExportCompliance(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/Verification/MultipleLineItems.cs b/Source/Samples/RiskManagement/Verification/MultipleLineItems.cs new file mode 100644 index 0000000..3ae5607 --- /dev/null +++ b/Source/Samples/RiskManagement/Verification/MultipleLineItems.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class MultipleLineItems + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AddressVerificationsPost201Response Run() + { + string clientReferenceInformationCode = "addressEg"; + string clientReferenceInformationComments = "dav-All fields"; + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode, + Comments: clientReferenceInformationComments + ); + + string orderInformationBillToAddress1 = "12301 research st"; + string orderInformationBillToAddress2 = "1"; + string orderInformationBillToAddress3 = "2"; + string orderInformationBillToAddress4 = "3"; + string orderInformationBillToAdministrativeArea = "TX"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Austin"; + string orderInformationBillToPostalCode = "78759"; + Riskv1addressverificationsOrderInformationBillTo orderInformationBillTo = new Riskv1addressverificationsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + Address3: orderInformationBillToAddress3, + Address4: orderInformationBillToAddress4, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + PostalCode: orderInformationBillToPostalCode + ); + + string orderInformationShipToAddress1 = "PO Box 9088"; + string orderInformationShipToAddress2 = ""; + string orderInformationShipToAddress3 = ""; + string orderInformationShipToAddress4 = ""; + string orderInformationShipToAdministrativeArea = "CA"; + string orderInformationShipToCountry = "US"; + string orderInformationShipToLocality = "San Jose"; + string orderInformationShipToPostalCode = "95132"; + Riskv1addressverificationsOrderInformationShipTo orderInformationShipTo = new Riskv1addressverificationsOrderInformationShipTo( + Address1: orderInformationShipToAddress1, + Address2: orderInformationShipToAddress2, + Address3: orderInformationShipToAddress3, + Address4: orderInformationShipToAddress4, + AdministrativeArea: orderInformationShipToAdministrativeArea, + Country: orderInformationShipToCountry, + Locality: orderInformationShipToLocality, + PostalCode: orderInformationShipToPostalCode + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsUnitPrice1 = "120.50"; + int orderInformationLineItemsQuantity1 = 3; + string orderInformationLineItemsProductSKU1 = "9966223"; + string orderInformationLineItemsProductName1 = "headset"; + string orderInformationLineItemsProductCode1 = "electronix"; + orderInformationLineItems.Add(new Riskv1addressverificationsOrderInformationLineItems( + UnitPrice: orderInformationLineItemsUnitPrice1, + Quantity: orderInformationLineItemsQuantity1, + ProductSKU: orderInformationLineItemsProductSKU1, + ProductName: orderInformationLineItemsProductName1, + ProductCode: orderInformationLineItemsProductCode1 + )); + + string orderInformationLineItemsUnitPrice2 = "10.50"; + int orderInformationLineItemsQuantity2 = 2; + string orderInformationLineItemsProductSKU2 = "9966226"; + string orderInformationLineItemsProductName2 = "wwrdf"; + string orderInformationLineItemsProductCode2 = "electronic"; + orderInformationLineItems.Add(new Riskv1addressverificationsOrderInformationLineItems( + UnitPrice: orderInformationLineItemsUnitPrice2, + Quantity: orderInformationLineItemsQuantity2, + ProductSKU: orderInformationLineItemsProductSKU2, + ProductName: orderInformationLineItemsProductName2, + ProductCode: orderInformationLineItemsProductCode2 + )); + + Riskv1addressverificationsOrderInformation orderInformation = new Riskv1addressverificationsOrderInformation( + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo, + LineItems: orderInformationLineItems + ); + + string buyerInformationMerchantCustomerId = "QWERTY"; + Riskv1addressverificationsBuyerInformation buyerInformation = new Riskv1addressverificationsBuyerInformation( + MerchantCustomerId: buyerInformationMerchantCustomerId + ); + + var requestObj = new VerifyCustomerAddressRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + BuyerInformation: buyerInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VerificationApi(clientConfig); + RiskV1AddressVerificationsPost201Response result = apiInstance.VerifyCustomerAddress(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/Verification/MultipleSanctionLists.cs b/Source/Samples/RiskManagement/Verification/MultipleSanctionLists.cs new file mode 100644 index 0000000..5feb087 --- /dev/null +++ b/Source/Samples/RiskManagement/Verification/MultipleSanctionLists.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class MultipleSanctionLists + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1ExportComplianceInquiriesPost201Response Run() + { + string clientReferenceInformationCode = "verification example"; + string clientReferenceInformationComments = "All fields"; + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode, + Comments: clientReferenceInformationComments + ); + + string orderInformationBillToAddress1 = "901 Metro Centre Blvd"; + string orderInformationBillToAddress2 = " "; + string orderInformationBillToAddress3 = ""; + string orderInformationBillToAddress4 = "Foster City"; + string orderInformationBillToAdministrativeArea = "NH"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "CA"; + string orderInformationBillToPostalCode = "03055"; + string orderInformationBillToCompanyName = "A & C International Trade, Inc."; + Riskv1exportcomplianceinquiriesOrderInformationBillToCompany orderInformationBillToCompany = new Riskv1exportcomplianceinquiriesOrderInformationBillToCompany( + Name: orderInformationBillToCompanyName + ); + + string orderInformationBillToFirstName = "Suman"; + string orderInformationBillToLastName = "Kumar"; + string orderInformationBillToEmail = "test@domain.com"; + Riskv1exportcomplianceinquiriesOrderInformationBillTo orderInformationBillTo = new Riskv1exportcomplianceinquiriesOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + Address3: orderInformationBillToAddress3, + Address4: orderInformationBillToAddress4, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + PostalCode: orderInformationBillToPostalCode, + Company: orderInformationBillToCompany, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Email: orderInformationBillToEmail + ); + + string orderInformationShipToCountry = "IN"; + string orderInformationShipToFirstName = "DumbelDore"; + string orderInformationShipToLastName = "Albus"; + Riskv1exportcomplianceinquiriesOrderInformationShipTo orderInformationShipTo = new Riskv1exportcomplianceinquiriesOrderInformationShipTo( + Country: orderInformationShipToCountry, + FirstName: orderInformationShipToFirstName, + LastName: orderInformationShipToLastName + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsUnitPrice1 = "120.50"; + int orderInformationLineItemsQuantity1 = 3; + string orderInformationLineItemsProductSKU1 = "610009"; + string orderInformationLineItemsProductName1 = "Xer"; + string orderInformationLineItemsProductCode1 = "physical_software"; + orderInformationLineItems.Add(new Riskv1exportcomplianceinquiriesOrderInformationLineItems( + UnitPrice: orderInformationLineItemsUnitPrice1, + Quantity: orderInformationLineItemsQuantity1, + ProductSKU: orderInformationLineItemsProductSKU1, + ProductName: orderInformationLineItemsProductName1, + ProductCode: orderInformationLineItemsProductCode1 + )); + + Riskv1exportcomplianceinquiriesOrderInformation orderInformation = new Riskv1exportcomplianceinquiriesOrderInformation( + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo, + LineItems: orderInformationLineItems + ); + + string buyerInformationMerchantCustomerId = "Export1"; + Riskv1addressverificationsBuyerInformation buyerInformation = new Riskv1addressverificationsBuyerInformation( + MerchantCustomerId: buyerInformationMerchantCustomerId + ); + + string deviceInformationIpAddress = "127.0.0.1"; + string deviceInformationHostName = "www.cybersource.ir"; + Riskv1exportcomplianceinquiriesDeviceInformation deviceInformation = new Riskv1exportcomplianceinquiriesDeviceInformation( + IpAddress: deviceInformationIpAddress, + HostName: deviceInformationHostName + ); + + string exportComplianceInformationAddressOperator = "and"; + string exportComplianceInformationWeightsAddress = "low"; + string exportComplianceInformationWeightsCompany = "exact"; + string exportComplianceInformationWeightsName = "exact"; + Ptsv2paymentsWatchlistScreeningInformationWeights exportComplianceInformationWeights = new Ptsv2paymentsWatchlistScreeningInformationWeights( + Address: exportComplianceInformationWeightsAddress, + Company: exportComplianceInformationWeightsCompany, + Name: exportComplianceInformationWeightsName + ); + + + List exportComplianceInformationSanctionLists = new List(); + exportComplianceInformationSanctionLists.Add("Bureau Of Industry and Security"); + exportComplianceInformationSanctionLists.Add("DOS_DTC"); + exportComplianceInformationSanctionLists.Add("AUSTRALIA"); + Riskv1exportcomplianceinquiriesExportComplianceInformation exportComplianceInformation = new Riskv1exportcomplianceinquiriesExportComplianceInformation( + AddressOperator: exportComplianceInformationAddressOperator, + Weights: exportComplianceInformationWeights, + SanctionLists: exportComplianceInformationSanctionLists + ); + + var requestObj = new ValidateExportComplianceRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + BuyerInformation: buyerInformation, + DeviceInformation: deviceInformation, + ExportComplianceInformation: exportComplianceInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VerificationApi(clientConfig); + RiskV1ExportComplianceInquiriesPost201Response result = apiInstance.ValidateExportCompliance(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/Verification/NoCompanyName.cs b/Source/Samples/RiskManagement/Verification/NoCompanyName.cs new file mode 100644 index 0000000..e492f7f --- /dev/null +++ b/Source/Samples/RiskManagement/Verification/NoCompanyName.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class NoCompanyName + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1ExportComplianceInquiriesPost201Response Run() + { + string clientReferenceInformationCode = "verification example"; + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string orderInformationBillToAddress1 = "901 Metro Centre Blvd"; + string orderInformationBillToAddress2 = "2"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Foster City"; + string orderInformationBillToPostalCode = "94404"; + string orderInformationBillToFirstName = "Suman"; + string orderInformationBillToLastName = "Kumar"; + string orderInformationBillToEmail = "donewithhorizon@test.com"; + Riskv1exportcomplianceinquiriesOrderInformationBillTo orderInformationBillTo = new Riskv1exportcomplianceinquiriesOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + PostalCode: orderInformationBillToPostalCode, + FirstName: orderInformationBillToFirstName, + LastName: orderInformationBillToLastName, + Email: orderInformationBillToEmail + ); + + string orderInformationShipToCountry = "be"; + string orderInformationShipToFirstName = "DumbelDore"; + string orderInformationShipToLastName = "Albus"; + Riskv1exportcomplianceinquiriesOrderInformationShipTo orderInformationShipTo = new Riskv1exportcomplianceinquiriesOrderInformationShipTo( + Country: orderInformationShipToCountry, + FirstName: orderInformationShipToFirstName, + LastName: orderInformationShipToLastName + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsUnitPrice1 = "19.00"; + orderInformationLineItems.Add(new Riskv1exportcomplianceinquiriesOrderInformationLineItems( + UnitPrice: orderInformationLineItemsUnitPrice1 + )); + + Riskv1exportcomplianceinquiriesOrderInformation orderInformation = new Riskv1exportcomplianceinquiriesOrderInformation( + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo, + LineItems: orderInformationLineItems + ); + + string buyerInformationMerchantCustomerId = "87789"; + Riskv1addressverificationsBuyerInformation buyerInformation = new Riskv1addressverificationsBuyerInformation( + MerchantCustomerId: buyerInformationMerchantCustomerId + ); + + var requestObj = new ValidateExportComplianceRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + BuyerInformation: buyerInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VerificationApi(clientConfig); + RiskV1ExportComplianceInquiriesPost201Response result = apiInstance.ValidateExportCompliance(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/Verification/ShippingDetailsNotUSOrCanada.cs b/Source/Samples/RiskManagement/Verification/ShippingDetailsNotUSOrCanada.cs new file mode 100644 index 0000000..ef4bd5f --- /dev/null +++ b/Source/Samples/RiskManagement/Verification/ShippingDetailsNotUSOrCanada.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class ShippingDetailsNotUSOrCanada + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AddressVerificationsPost201Response Run() + { + string clientReferenceInformationCode = "addressEg"; + string clientReferenceInformationComments = "dav-All fields"; + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode, + Comments: clientReferenceInformationComments + ); + + string orderInformationBillToAddress1 = "12301 research st"; + string orderInformationBillToAddress2 = "1"; + string orderInformationBillToAddress3 = "2"; + string orderInformationBillToAddress4 = "3"; + string orderInformationBillToAdministrativeArea = "TX"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Austin"; + string orderInformationBillToPostalCode = "78759"; + Riskv1addressverificationsOrderInformationBillTo orderInformationBillTo = new Riskv1addressverificationsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + Address3: orderInformationBillToAddress3, + Address4: orderInformationBillToAddress4, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + PostalCode: orderInformationBillToPostalCode + ); + + string orderInformationShipToAddress1 = "4R.ILHA TERCEIRA,232-R/C-ESQ"; + string orderInformationShipToAddress2 = " "; + string orderInformationShipToAddress3 = ""; + string orderInformationShipToAddress4 = ""; + string orderInformationShipToAdministrativeArea = "WI"; + string orderInformationShipToCountry = "PT"; + string orderInformationShipToLocality = "Carcavelos"; + string orderInformationShipToPostalCode = "29681"; + Riskv1addressverificationsOrderInformationShipTo orderInformationShipTo = new Riskv1addressverificationsOrderInformationShipTo( + Address1: orderInformationShipToAddress1, + Address2: orderInformationShipToAddress2, + Address3: orderInformationShipToAddress3, + Address4: orderInformationShipToAddress4, + AdministrativeArea: orderInformationShipToAdministrativeArea, + Country: orderInformationShipToCountry, + Locality: orderInformationShipToLocality, + PostalCode: orderInformationShipToPostalCode + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsUnitPrice1 = "120.50"; + int orderInformationLineItemsQuantity1 = 3; + string orderInformationLineItemsProductSKU1 = "9966223"; + string orderInformationLineItemsProductName1 = "headset"; + string orderInformationLineItemsProductCode1 = "electronic"; + orderInformationLineItems.Add(new Riskv1addressverificationsOrderInformationLineItems( + UnitPrice: orderInformationLineItemsUnitPrice1, + Quantity: orderInformationLineItemsQuantity1, + ProductSKU: orderInformationLineItemsProductSKU1, + ProductName: orderInformationLineItemsProductName1, + ProductCode: orderInformationLineItemsProductCode1 + )); + + Riskv1addressverificationsOrderInformation orderInformation = new Riskv1addressverificationsOrderInformation( + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo, + LineItems: orderInformationLineItems + ); + + string buyerInformationMerchantCustomerId = "ABCD"; + Riskv1addressverificationsBuyerInformation buyerInformation = new Riskv1addressverificationsBuyerInformation( + MerchantCustomerId: buyerInformationMerchantCustomerId + ); + + var requestObj = new VerifyCustomerAddressRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + BuyerInformation: buyerInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VerificationApi(clientConfig); + RiskV1AddressVerificationsPost201Response result = apiInstance.VerifyCustomerAddress(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/RiskManagement/Verification/VerboseRequestWithAllFields.cs b/Source/Samples/RiskManagement/Verification/VerboseRequestWithAllFields.cs new file mode 100644 index 0000000..e76caeb --- /dev/null +++ b/Source/Samples/RiskManagement/Verification/VerboseRequestWithAllFields.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.RiskManagement +{ + public class VerboseRequestWithAllFields + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static RiskV1AddressVerificationsPost201Response Run() + { + string clientReferenceInformationCode = "addressEg"; + string clientReferenceInformationComments = "dav-All fields"; + string clientReferenceInformationPartnerDeveloperId = "7891234"; + string clientReferenceInformationPartnerSolutionId = "89012345"; + Riskv1decisionsClientReferenceInformationPartner clientReferenceInformationPartner = new Riskv1decisionsClientReferenceInformationPartner( + DeveloperId: clientReferenceInformationPartnerDeveloperId, + SolutionId: clientReferenceInformationPartnerSolutionId + ); + + Riskv1liststypeentriesClientReferenceInformation clientReferenceInformation = new Riskv1liststypeentriesClientReferenceInformation( + Code: clientReferenceInformationCode, + Comments: clientReferenceInformationComments, + Partner: clientReferenceInformationPartner + ); + + string orderInformationBillToAddress1 = "12301 research st"; + string orderInformationBillToAddress2 = "1"; + string orderInformationBillToAddress3 = "2"; + string orderInformationBillToAddress4 = "3"; + string orderInformationBillToAdministrativeArea = "TX"; + string orderInformationBillToCountry = "US"; + string orderInformationBillToLocality = "Austin"; + string orderInformationBillToPostalCode = "78759"; + Riskv1addressverificationsOrderInformationBillTo orderInformationBillTo = new Riskv1addressverificationsOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Address2: orderInformationBillToAddress2, + Address3: orderInformationBillToAddress3, + Address4: orderInformationBillToAddress4, + AdministrativeArea: orderInformationBillToAdministrativeArea, + Country: orderInformationBillToCountry, + Locality: orderInformationBillToLocality, + PostalCode: orderInformationBillToPostalCode + ); + + string orderInformationShipToAddress1 = "1715 oaks apt # 7"; + string orderInformationShipToAddress2 = " "; + string orderInformationShipToAddress3 = ""; + string orderInformationShipToAddress4 = ""; + string orderInformationShipToAdministrativeArea = "WI"; + string orderInformationShipToCountry = "US"; + string orderInformationShipToLocality = "SUPERIOR"; + string orderInformationShipToPostalCode = "29681"; + Riskv1addressverificationsOrderInformationShipTo orderInformationShipTo = new Riskv1addressverificationsOrderInformationShipTo( + Address1: orderInformationShipToAddress1, + Address2: orderInformationShipToAddress2, + Address3: orderInformationShipToAddress3, + Address4: orderInformationShipToAddress4, + AdministrativeArea: orderInformationShipToAdministrativeArea, + Country: orderInformationShipToCountry, + Locality: orderInformationShipToLocality, + PostalCode: orderInformationShipToPostalCode + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsUnitPrice1 = "120.50"; + int orderInformationLineItemsQuantity1 = 3; + string orderInformationLineItemsProductSKU1 = "9966223"; + string orderInformationLineItemsProductName1 = "headset"; + string orderInformationLineItemsProductCode1 = "electronic"; + orderInformationLineItems.Add(new Riskv1addressverificationsOrderInformationLineItems( + UnitPrice: orderInformationLineItemsUnitPrice1, + Quantity: orderInformationLineItemsQuantity1, + ProductSKU: orderInformationLineItemsProductSKU1, + ProductName: orderInformationLineItemsProductName1, + ProductCode: orderInformationLineItemsProductCode1 + )); + + Riskv1addressverificationsOrderInformation orderInformation = new Riskv1addressverificationsOrderInformation( + BillTo: orderInformationBillTo, + ShipTo: orderInformationShipTo, + LineItems: orderInformationLineItems + ); + + string buyerInformationMerchantCustomerId = "ABCD"; + Riskv1addressverificationsBuyerInformation buyerInformation = new Riskv1addressverificationsBuyerInformation( + MerchantCustomerId: buyerInformationMerchantCustomerId + ); + + var requestObj = new VerifyCustomerAddressRequest( + ClientReferenceInformation: clientReferenceInformation, + OrderInformation: orderInformation, + BuyerInformation: buyerInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new VerificationApi(clientConfig); + RiskV1AddressVerificationsPost201Response result = apiInstance.VerifyCustomerAddress(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/SecureFileShare/DownloadFileWithFileIdentifier.cs b/Source/Samples/SecureFileShare/DownloadFileWithFileIdentifier.cs new file mode 100644 index 0000000..b23ba15 --- /dev/null +++ b/Source/Samples/SecureFileShare/DownloadFileWithFileIdentifier.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Xml; +using System.Xml.Serialization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.SecureFileShare +{ + public class DownloadFileWithFileIdentifier + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + var fileId = "QmF0Y2hGaWxlc0RldGFpbFJlcG9ydC5jc3YtMjAyMC0wMS0zMA=="; + const string fileName = "DownloadedFileWithFileID.csv"; + const string downloadFilePath = @".\Resource\" + fileName; + string organizationId = "testrest"; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new SecureFileShareApi(clientConfig); + var content = apiInstance.GetFileWithHttpInfo(fileId, organizationId); + + // START : FILE DOWNLOAD FUNCTIONALITY + File.WriteAllText(downloadFilePath, CreateXml(content.Data)); + + Console.WriteLine("\nFile Downloaded at the following location : "); + Console.WriteLine($"{Path.GetFullPath(downloadFilePath)}\n"); + WriteLogAudit(apiInstance.GetStatusCode()); + // END : FILE DOWNLOAD FUNCTIONALITY + } + catch (FileNotFoundException) + { + Console.WriteLine("File Not Found : Kindly verify the path."); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + + // START : STREAM SERIALIZER METHOD + private static string CreateXml(object obj) + { + var xmlDoc = new XmlDocument(); // Represents an XML Document + var xmlSerializer = new XmlSerializer(obj.GetType()); // Initializes a new instance of the XmlDocument class + + // Creates a stream whose backing store is memory + using (var xmlStream = new MemoryStream()) + { + xmlSerializer.Serialize(xmlStream, obj); + xmlStream.Position = 0; + + // Loads the XML document from the specified string + xmlDoc.Load(xmlStream); + return xmlDoc.InnerText; + } + } + // END : STREAM SERIALIZER METHOD + } +} diff --git a/Source/Samples/SecureFileShare/GetListOfFiles.cs b/Source/Samples/SecureFileShare/GetListOfFiles.cs new file mode 100644 index 0000000..22f7aca --- /dev/null +++ b/Source/Samples/SecureFileShare/GetListOfFiles.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.SecureFileShare +{ + public class GetListOfFiles + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static V1FileDetailsGet200Response Run() + { + var startDate = DateTime.ParseExact("2020-07-20", "yyyy-MM-dd", CultureInfo.InvariantCulture); + var endDate = DateTime.ParseExact("2020-07-30", "yyyy-MM-dd", CultureInfo.InvariantCulture); + string organizationId = "testrest"; + string name = null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new SecureFileShareApi(clientConfig); + V1FileDetailsGet200Response result = apiInstance.GetFileDetail(startDate, endDate, organizationId, name); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/Customer/CreateCustomer.cs b/Source/Samples/TokenManagement/Customer/CreateCustomer.cs new file mode 100644 index 0000000..387522d --- /dev/null +++ b/Source/Samples/TokenManagement/Customer/CreateCustomer.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class CreateCustomer + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostCustomerRequest Run() + { + string buyerInformationMerchantCustomerID = "Your customer identifier"; + string buyerInformationEmail = "test@cybs.com"; + Tmsv2customersBuyerInformation buyerInformation = new Tmsv2customersBuyerInformation( + MerchantCustomerID: buyerInformationMerchantCustomerID, + Email: buyerInformationEmail + ); + + string clientReferenceInformationCode = "TC50171_3"; + Tmsv2customersClientReferenceInformation clientReferenceInformation = new Tmsv2customersClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + List merchantDefinedInformation = new List(); + string merchantDefinedInformationName1 = "data1"; + string merchantDefinedInformationValue1 = "Your customer data"; + merchantDefinedInformation.Add(new Tmsv2customersMerchantDefinedInformation( + Name: merchantDefinedInformationName1, + Value: merchantDefinedInformationValue1 + )); + + var requestObj = new PostCustomerRequest( + BuyerInformation: buyerInformation, + ClientReferenceInformation: clientReferenceInformation, + MerchantDefinedInformation: merchantDefinedInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerApi(clientConfig); + PostCustomerRequest result = apiInstance.PostCustomer(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/Customer/DeleteCustomer.cs b/Source/Samples/TokenManagement/Customer/DeleteCustomer.cs new file mode 100644 index 0000000..83d641b --- /dev/null +++ b/Source/Samples/TokenManagement/Customer/DeleteCustomer.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class DeleteCustomer + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + string customerTokenId = CreateCustomer.Run().Id; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerApi(clientConfig); + apiInstance.DeleteCustomer(customerTokenId); + Console.WriteLine($"Customer {customerTokenId} has been deleted."); + WriteLogAudit(apiInstance.GetStatusCode()); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + } +} diff --git a/Source/Samples/TokenManagement/Customer/RetrieveCustomer.cs b/Source/Samples/TokenManagement/Customer/RetrieveCustomer.cs new file mode 100644 index 0000000..80fb9be --- /dev/null +++ b/Source/Samples/TokenManagement/Customer/RetrieveCustomer.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class RetrieveCustomer + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostCustomerRequest Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerApi(clientConfig); + PostCustomerRequest result = apiInstance.GetCustomer(customerTokenId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/Customer/UpdateCustomer.cs b/Source/Samples/TokenManagement/Customer/UpdateCustomer.cs new file mode 100644 index 0000000..ca01d9a --- /dev/null +++ b/Source/Samples/TokenManagement/Customer/UpdateCustomer.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class UpdateCustomer + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PatchCustomerRequest Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + string buyerInformationMerchantCustomerID = "Your customer identifier"; + string buyerInformationEmail = "test@cybs.com"; + Tmsv2customersBuyerInformation buyerInformation = new Tmsv2customersBuyerInformation( + MerchantCustomerID: buyerInformationMerchantCustomerID, + Email: buyerInformationEmail + ); + + string clientReferenceInformationCode = "TC50171_3"; + Tmsv2customersClientReferenceInformation clientReferenceInformation = new Tmsv2customersClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + + List merchantDefinedInformation = new List(); + string merchantDefinedInformationName1 = "data1"; + string merchantDefinedInformationValue1 = "Your customer data"; + merchantDefinedInformation.Add(new Tmsv2customersMerchantDefinedInformation( + Name: merchantDefinedInformationName1, + Value: merchantDefinedInformationValue1 + )); + + var requestObj = new PatchCustomerRequest( + BuyerInformation: buyerInformation, + ClientReferenceInformation: clientReferenceInformation, + MerchantDefinedInformation: merchantDefinedInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerApi(clientConfig); + PatchCustomerRequest result = apiInstance.PatchCustomer(customerTokenId, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/Customer/UpdateCustomersDefaultPaymentInstrument.cs b/Source/Samples/TokenManagement/Customer/UpdateCustomersDefaultPaymentInstrument.cs new file mode 100644 index 0000000..686f0d7 --- /dev/null +++ b/Source/Samples/TokenManagement/Customer/UpdateCustomersDefaultPaymentInstrument.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class UpdateCustomersDefaultPaymentInstrument + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PatchCustomerRequest Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + string defaultPaymentInstrumentId = "AB6A54B982A6FCB6E05341588E0A3935"; + Tmsv2customersDefaultPaymentInstrument defaultPaymentInstrument = new Tmsv2customersDefaultPaymentInstrument( + Id: defaultPaymentInstrumentId + ); + + var requestObj = new PatchCustomerRequest( + DefaultPaymentInstrument: defaultPaymentInstrument + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerApi(clientConfig); + PatchCustomerRequest result = apiInstance.PatchCustomer(customerTokenId, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/Customer/UpdateCustomersDefaultShippingAddress.cs b/Source/Samples/TokenManagement/Customer/UpdateCustomersDefaultShippingAddress.cs new file mode 100644 index 0000000..24224ea --- /dev/null +++ b/Source/Samples/TokenManagement/Customer/UpdateCustomersDefaultShippingAddress.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class UpdateCustomersDefaultShippingAddress + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PatchCustomerRequest Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + string defaultShippingAddressId = "AB6A54B97C00FCB6E05341588E0A3935"; + Tmsv2customersDefaultShippingAddress defaultShippingAddress = new Tmsv2customersDefaultShippingAddress( + Id: defaultShippingAddressId + ); + + var requestObj = new PatchCustomerRequest( + DefaultShippingAddress: defaultShippingAddress + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerApi(clientConfig); + PatchCustomerRequest result = apiInstance.PatchCustomer(customerTokenId, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/CustomerPaymentInstrument/CreateCustomerDefaultPaymentInstrumentCard.cs b/Source/Samples/TokenManagement/CustomerPaymentInstrument/CreateCustomerDefaultPaymentInstrumentCard.cs new file mode 100644 index 0000000..9d74880 --- /dev/null +++ b/Source/Samples/TokenManagement/CustomerPaymentInstrument/CreateCustomerDefaultPaymentInstrumentCard.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class CreateCustomerDefaultPaymentInstrumentCard + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostCustomerPaymentInstrumentRequest Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + bool _default = true; + string cardExpirationMonth = "12"; + string cardExpirationYear = "2031"; + string cardType = "001"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentCard card = new Tmsv2customersEmbeddedDefaultPaymentInstrumentCard( + ExpirationMonth: cardExpirationMonth, + ExpirationYear: cardExpirationYear, + Type: cardType + ); + + string billToFirstName = "John"; + string billToLastName = "Doe"; + string billToCompany = "CyberSource"; + string billToAddress1 = "1 Market St"; + string billToLocality = "San Francisco"; + string billToAdministrativeArea = "CA"; + string billToPostalCode = "94105"; + string billToCountry = "US"; + string billToEmail = "test@cybs.com"; + string billToPhoneNumber = "4158880000"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo billTo = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + FirstName: billToFirstName, + LastName: billToLastName, + Company: billToCompany, + Address1: billToAddress1, + Locality: billToLocality, + AdministrativeArea: billToAdministrativeArea, + PostalCode: billToPostalCode, + Country: billToCountry, + Email: billToEmail, + PhoneNumber: billToPhoneNumber + ); + + string instrumentIdentifierId = "7010000000016241111"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier instrumentIdentifier = new Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + Id: instrumentIdentifierId + ); + + var requestObj = new PostCustomerPaymentInstrumentRequest( + Default: _default, + Card: card, + BillTo: billTo, + InstrumentIdentifier: instrumentIdentifier + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerPaymentInstrumentApi(clientConfig); + PostCustomerPaymentInstrumentRequest result = apiInstance.PostCustomerPaymentInstrument(customerTokenId, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/CustomerPaymentInstrument/CreateCustomerNonDefaultPaymentInstrumentCard.cs b/Source/Samples/TokenManagement/CustomerPaymentInstrument/CreateCustomerNonDefaultPaymentInstrumentCard.cs new file mode 100644 index 0000000..0940593 --- /dev/null +++ b/Source/Samples/TokenManagement/CustomerPaymentInstrument/CreateCustomerNonDefaultPaymentInstrumentCard.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class CreateCustomerNonDefaultPaymentInstrumentCard + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostCustomerPaymentInstrumentRequest Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + bool _default = false; + string cardExpirationMonth = "12"; + string cardExpirationYear = "2031"; + string cardType = "001"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentCard card = new Tmsv2customersEmbeddedDefaultPaymentInstrumentCard( + ExpirationMonth: cardExpirationMonth, + ExpirationYear: cardExpirationYear, + Type: cardType + ); + + string billToFirstName = "John"; + string billToLastName = "Doe"; + string billToCompany = "CyberSource"; + string billToAddress1 = "1 Market St"; + string billToLocality = "San Francisco"; + string billToAdministrativeArea = "CA"; + string billToPostalCode = "94105"; + string billToCountry = "US"; + string billToEmail = "test@cybs.com"; + string billToPhoneNumber = "4158880000"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo billTo = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + FirstName: billToFirstName, + LastName: billToLastName, + Company: billToCompany, + Address1: billToAddress1, + Locality: billToLocality, + AdministrativeArea: billToAdministrativeArea, + PostalCode: billToPostalCode, + Country: billToCountry, + Email: billToEmail, + PhoneNumber: billToPhoneNumber + ); + + string instrumentIdentifierId = "7010000000016241111"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier instrumentIdentifier = new Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + Id: instrumentIdentifierId + ); + + var requestObj = new PostCustomerPaymentInstrumentRequest( + Default: _default, + Card: card, + BillTo: billTo, + InstrumentIdentifier: instrumentIdentifier + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerPaymentInstrumentApi(clientConfig); + PostCustomerPaymentInstrumentRequest result = apiInstance.PostCustomerPaymentInstrument(customerTokenId, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/CustomerPaymentInstrument/CreateCustomerPaymentInstrumentBankAccount.cs b/Source/Samples/TokenManagement/CustomerPaymentInstrument/CreateCustomerPaymentInstrumentBankAccount.cs new file mode 100644 index 0000000..e1bb4e9 --- /dev/null +++ b/Source/Samples/TokenManagement/CustomerPaymentInstrument/CreateCustomerPaymentInstrumentBankAccount.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class CreateCustomerPaymentInstrumentBankAccount + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostCustomerPaymentInstrumentRequest Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + string bankAccountType = "savings"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentBankAccount bankAccount = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBankAccount( + Type: bankAccountType + ); + + string buyerInformationCompanyTaxID = "12345"; + string buyerInformationCurrency = "USD"; + DateTime buyerInformationDateOfBirth = Convert.ToDateTime("2000-12-13"); + + List buyerInformationPersonalIdentification = new List(); + string buyerInformationPersonalIdentificationId1 = "57684432111321"; + string buyerInformationPersonalIdentificationType1 = "driver license"; + string buyerInformationPersonalIdentificationIssuedByAdministrativeArea1 = "CA"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformationIssuedBy buyerInformationPersonalIdentificationIssuedBy1 = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformationIssuedBy( + AdministrativeArea: buyerInformationPersonalIdentificationIssuedByAdministrativeArea1 + ); + + buyerInformationPersonalIdentification.Add(new Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformationPersonalIdentification( + Id: buyerInformationPersonalIdentificationId1, + Type: buyerInformationPersonalIdentificationType1, + IssuedBy: buyerInformationPersonalIdentificationIssuedBy1 + )); + + Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformation buyerInformation = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformation( + CompanyTaxID: buyerInformationCompanyTaxID, + Currency: buyerInformationCurrency, + DateOfBirth: buyerInformationDateOfBirth, + PersonalIdentification: buyerInformationPersonalIdentification + ); + + string billToFirstName = "John"; + string billToLastName = "Doe"; + string billToCompany = "CyberSource"; + string billToAddress1 = "1 Market St"; + string billToLocality = "San Francisco"; + string billToAdministrativeArea = "CA"; + string billToPostalCode = "94105"; + string billToCountry = "US"; + string billToEmail = "test@cybs.com"; + string billToPhoneNumber = "4158880000"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo billTo = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + FirstName: billToFirstName, + LastName: billToLastName, + Company: billToCompany, + Address1: billToAddress1, + Locality: billToLocality, + AdministrativeArea: billToAdministrativeArea, + PostalCode: billToPostalCode, + Country: billToCountry, + Email: billToEmail, + PhoneNumber: billToPhoneNumber + ); + + string processingInformationBankTransferOptionsSeCCode = "WEB"; + TmsPaymentInstrumentProcessingInfoBankTransferOptions processingInformationBankTransferOptions = new TmsPaymentInstrumentProcessingInfoBankTransferOptions( + SECCode: processingInformationBankTransferOptionsSeCCode + ); + + TmsPaymentInstrumentProcessingInfo processingInformation = new TmsPaymentInstrumentProcessingInfo( + BankTransferOptions: processingInformationBankTransferOptions + ); + + string instrumentIdentifierId = "A7A91A2CA872B272E05340588D0A0699"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier instrumentIdentifier = new Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + Id: instrumentIdentifierId + ); + + var requestObj = new PostCustomerPaymentInstrumentRequest( + BankAccount: bankAccount, + BuyerInformation: buyerInformation, + BillTo: billTo, + ProcessingInformation: processingInformation, + InstrumentIdentifier: instrumentIdentifier + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerPaymentInstrumentApi(clientConfig); + PostCustomerPaymentInstrumentRequest result = apiInstance.PostCustomerPaymentInstrument(customerTokenId, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/CustomerPaymentInstrument/CreateCustomerPaymentInstrumentPinlessDebit.cs b/Source/Samples/TokenManagement/CustomerPaymentInstrument/CreateCustomerPaymentInstrumentPinlessDebit.cs new file mode 100644 index 0000000..a96d8c2 --- /dev/null +++ b/Source/Samples/TokenManagement/CustomerPaymentInstrument/CreateCustomerPaymentInstrumentPinlessDebit.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class CreateCustomerPaymentInstrumentPinlessDebit + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostCustomerPaymentInstrumentRequest Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + string cardExpirationMonth = "12"; + string cardExpirationYear = "2031"; + string cardType = "001"; + string cardIssueNumber = "01"; + string cardStartMonth = "01"; + string cardStartYear = "2020"; + string cardUseAs = "pinless debit"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentCard card = new Tmsv2customersEmbeddedDefaultPaymentInstrumentCard( + ExpirationMonth: cardExpirationMonth, + ExpirationYear: cardExpirationYear, + Type: cardType, + IssueNumber: cardIssueNumber, + StartMonth: cardStartMonth, + StartYear: cardStartYear, + UseAs: cardUseAs + ); + + string billToFirstName = "John"; + string billToLastName = "Doe"; + string billToCompany = "CyberSource"; + string billToAddress1 = "1 Market St"; + string billToLocality = "San Francisco"; + string billToAdministrativeArea = "CA"; + string billToPostalCode = "94105"; + string billToCountry = "US"; + string billToEmail = "test@cybs.com"; + string billToPhoneNumber = "4158880000"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo billTo = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + FirstName: billToFirstName, + LastName: billToLastName, + Company: billToCompany, + Address1: billToAddress1, + Locality: billToLocality, + AdministrativeArea: billToAdministrativeArea, + PostalCode: billToPostalCode, + Country: billToCountry, + Email: billToEmail, + PhoneNumber: billToPhoneNumber + ); + + string instrumentIdentifierId = "7010000000016241111"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier instrumentIdentifier = new Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + Id: instrumentIdentifierId + ); + + var requestObj = new PostCustomerPaymentInstrumentRequest( + Card: card, + BillTo: billTo, + InstrumentIdentifier: instrumentIdentifier + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerPaymentInstrumentApi(clientConfig); + PostCustomerPaymentInstrumentRequest result = apiInstance.PostCustomerPaymentInstrument(customerTokenId, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/CustomerPaymentInstrument/DeleteCustomerPaymentInstrument.cs b/Source/Samples/TokenManagement/CustomerPaymentInstrument/DeleteCustomerPaymentInstrument.cs new file mode 100644 index 0000000..3636da8 --- /dev/null +++ b/Source/Samples/TokenManagement/CustomerPaymentInstrument/DeleteCustomerPaymentInstrument.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class DeleteCustomerPaymentInstrument + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + string paymentInstrumentTokenId = CreateCustomerNonDefaultPaymentInstrumentCard.Run().Id; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerPaymentInstrumentApi(clientConfig); + apiInstance.DeleteCustomerPaymentInstrument(customerTokenId, paymentInstrumentTokenId); + Console.WriteLine($"Customer Payment Instrument {customerTokenId} --> {paymentInstrumentTokenId} has been deleted."); + WriteLogAudit(apiInstance.GetStatusCode()); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + } +} diff --git a/Source/Samples/TokenManagement/CustomerPaymentInstrument/ListPaymentInstrumentsForCustomer.cs b/Source/Samples/TokenManagement/CustomerPaymentInstrument/ListPaymentInstrumentsForCustomer.cs new file mode 100644 index 0000000..6da935a --- /dev/null +++ b/Source/Samples/TokenManagement/CustomerPaymentInstrument/ListPaymentInstrumentsForCustomer.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class ListPaymentInstrumentsForCustomer + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PaymentInstrumentList Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + string profileid = null; + long? offset = (long?)null; + long? limit = (long?)null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerPaymentInstrumentApi(clientConfig); + PaymentInstrumentList result = apiInstance.GetCustomerPaymentInstrumentsList(customerTokenId, profileid, offset, limit); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/CustomerPaymentInstrument/RetrieveCustomerPaymentInstrument.cs b/Source/Samples/TokenManagement/CustomerPaymentInstrument/RetrieveCustomerPaymentInstrument.cs new file mode 100644 index 0000000..411c2ed --- /dev/null +++ b/Source/Samples/TokenManagement/CustomerPaymentInstrument/RetrieveCustomerPaymentInstrument.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class RetrieveCustomerPaymentInstrument + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostCustomerPaymentInstrumentRequest Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + string paymentInstrumentTokenId = "AB6A54B982A6FCB6E05341588E0A3935"; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerPaymentInstrumentApi(clientConfig); + PostCustomerPaymentInstrumentRequest result = apiInstance.GetCustomerPaymentInstrument(customerTokenId, paymentInstrumentTokenId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/CustomerShippingAddress/CreateCustomerDefaultShippingAddress.cs b/Source/Samples/TokenManagement/CustomerShippingAddress/CreateCustomerDefaultShippingAddress.cs new file mode 100644 index 0000000..1033dd9 --- /dev/null +++ b/Source/Samples/TokenManagement/CustomerShippingAddress/CreateCustomerDefaultShippingAddress.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class CreateCustomerDefaultShippingAddress + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostCustomerShippingAddressRequest Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + bool _default = true; + string shipToFirstName = "John"; + string shipToLastName = "Doe"; + string shipToCompany = "CyberSource"; + string shipToAddress1 = "1 Market St"; + string shipToLocality = "San Francisco"; + string shipToAdministrativeArea = "CA"; + string shipToPostalCode = "94105"; + string shipToCountry = "US"; + string shipToEmail = "test@cybs.com"; + string shipToPhoneNumber = "4158880000"; + Tmsv2customersEmbeddedDefaultShippingAddressShipTo shipTo = new Tmsv2customersEmbeddedDefaultShippingAddressShipTo( + FirstName: shipToFirstName, + LastName: shipToLastName, + Company: shipToCompany, + Address1: shipToAddress1, + Locality: shipToLocality, + AdministrativeArea: shipToAdministrativeArea, + PostalCode: shipToPostalCode, + Country: shipToCountry, + Email: shipToEmail, + PhoneNumber: shipToPhoneNumber + ); + + var requestObj = new PostCustomerShippingAddressRequest( + Default: _default, + ShipTo: shipTo + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerShippingAddressApi(clientConfig); + PostCustomerShippingAddressRequest result = apiInstance.PostCustomerShippingAddress(customerTokenId, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/CustomerShippingAddress/CreateCustomerNonDefaultShippingAddress.cs b/Source/Samples/TokenManagement/CustomerShippingAddress/CreateCustomerNonDefaultShippingAddress.cs new file mode 100644 index 0000000..e180f3c --- /dev/null +++ b/Source/Samples/TokenManagement/CustomerShippingAddress/CreateCustomerNonDefaultShippingAddress.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class CreateCustomerNonDefaultShippingAddress + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostCustomerShippingAddressRequest Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + bool _default = false; + string shipToFirstName = "John"; + string shipToLastName = "Doe"; + string shipToCompany = "CyberSource"; + string shipToAddress1 = "1 Market St"; + string shipToLocality = "San Francisco"; + string shipToAdministrativeArea = "CA"; + string shipToPostalCode = "94105"; + string shipToCountry = "US"; + string shipToEmail = "test@cybs.com"; + string shipToPhoneNumber = "4158880000"; + Tmsv2customersEmbeddedDefaultShippingAddressShipTo shipTo = new Tmsv2customersEmbeddedDefaultShippingAddressShipTo( + FirstName: shipToFirstName, + LastName: shipToLastName, + Company: shipToCompany, + Address1: shipToAddress1, + Locality: shipToLocality, + AdministrativeArea: shipToAdministrativeArea, + PostalCode: shipToPostalCode, + Country: shipToCountry, + Email: shipToEmail, + PhoneNumber: shipToPhoneNumber + ); + + var requestObj = new PostCustomerShippingAddressRequest( + Default: _default, + ShipTo: shipTo + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerShippingAddressApi(clientConfig); + PostCustomerShippingAddressRequest result = apiInstance.PostCustomerShippingAddress(customerTokenId, requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/CustomerShippingAddress/DeleteCustomerShippingAddress.cs b/Source/Samples/TokenManagement/CustomerShippingAddress/DeleteCustomerShippingAddress.cs new file mode 100644 index 0000000..c8f29f3 --- /dev/null +++ b/Source/Samples/TokenManagement/CustomerShippingAddress/DeleteCustomerShippingAddress.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class DeleteCustomerShippingAddress + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + string shippingAddressTokenId = CreateCustomerNonDefaultShippingAddress.Run().Id; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerShippingAddressApi(clientConfig); + apiInstance.DeleteCustomerShippingAddress(customerTokenId, shippingAddressTokenId); + Console.WriteLine($"Customer Shipping Address {customerTokenId} --> {shippingAddressTokenId} has been deleted."); + WriteLogAudit(apiInstance.GetStatusCode()); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + } +} diff --git a/Source/Samples/TokenManagement/CustomerShippingAddress/ListShippingAddressesForCustomer.cs b/Source/Samples/TokenManagement/CustomerShippingAddress/ListShippingAddressesForCustomer.cs new file mode 100644 index 0000000..ff36361 --- /dev/null +++ b/Source/Samples/TokenManagement/CustomerShippingAddress/ListShippingAddressesForCustomer.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class ListShippingAddressesForCustomer + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static ShippingAddressListForCustomer Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + string profileid = null; + long? offset = (long?)null; + long? limit = (long?)null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerShippingAddressApi(clientConfig); + ShippingAddressListForCustomer result = apiInstance.GetCustomerShippingAddressesList(customerTokenId, profileid, offset, limit); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/CustomerShippingAddress/RetrieveCustomerShippingAddress.cs b/Source/Samples/TokenManagement/CustomerShippingAddress/RetrieveCustomerShippingAddress.cs new file mode 100644 index 0000000..fbad785 --- /dev/null +++ b/Source/Samples/TokenManagement/CustomerShippingAddress/RetrieveCustomerShippingAddress.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class RetrieveCustomerShippingAddress + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostCustomerShippingAddressRequest Run() + { + string customerTokenId = "AB695DA801DD1BB6E05341588E0A3BDC"; + string shippingAddressTokenId = "AB6A54B97C00FCB6E05341588E0A3935"; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CustomerShippingAddressApi(clientConfig); + PostCustomerShippingAddressRequest result = apiInstance.GetCustomerShippingAddress(customerTokenId, shippingAddressTokenId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/InstrumentIdentifier/CreateInstrumentIdentifierBankAccount.cs b/Source/Samples/TokenManagement/InstrumentIdentifier/CreateInstrumentIdentifierBankAccount.cs new file mode 100644 index 0000000..0682579 --- /dev/null +++ b/Source/Samples/TokenManagement/InstrumentIdentifier/CreateInstrumentIdentifierBankAccount.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class CreateInstrumentIdentifierBankAccount + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostInstrumentIdentifierRequest Run() + { + var profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + string bankAccountNumber = "4100"; + string bankAccountRoutingNumber = "071923284"; + TmsEmbeddedInstrumentIdentifierBankAccount bankAccount = new TmsEmbeddedInstrumentIdentifierBankAccount( + Number: bankAccountNumber, + RoutingNumber: bankAccountRoutingNumber + ); + + var requestObj = new PostInstrumentIdentifierRequest( + BankAccount: bankAccount + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InstrumentIdentifierApi(clientConfig); + PostInstrumentIdentifierRequest result = apiInstance.PostInstrumentIdentifier(requestObj, profileid); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/InstrumentIdentifier/CreateInstrumentIdentifierCard.cs b/Source/Samples/TokenManagement/InstrumentIdentifier/CreateInstrumentIdentifierCard.cs new file mode 100644 index 0000000..74905a8 --- /dev/null +++ b/Source/Samples/TokenManagement/InstrumentIdentifier/CreateInstrumentIdentifierCard.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class CreateInstrumentIdentifierCard + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostInstrumentIdentifierRequest Run() + { + var profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + string cardNumber = "411111111111111"; + TmsEmbeddedInstrumentIdentifierCard card = new TmsEmbeddedInstrumentIdentifierCard( + Number: cardNumber + ); + + var requestObj = new PostInstrumentIdentifierRequest( + Card: card + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InstrumentIdentifierApi(clientConfig); + PostInstrumentIdentifierRequest result = apiInstance.PostInstrumentIdentifier(requestObj, profileid); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/InstrumentIdentifier/CreateInstrumentIdentifierCardEnrollForNetworkToken.cs b/Source/Samples/TokenManagement/InstrumentIdentifier/CreateInstrumentIdentifierCardEnrollForNetworkToken.cs new file mode 100644 index 0000000..a1cdea6 --- /dev/null +++ b/Source/Samples/TokenManagement/InstrumentIdentifier/CreateInstrumentIdentifierCardEnrollForNetworkToken.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class CreateInstrumentIdentifierCardEnrollForNetworkToken + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostInstrumentIdentifierRequest Run() + { + var profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + string type = "enrollable card"; + string cardNumber = "4111111111111111"; + string cardExpirationMonth = "12"; + string cardExpirationYear = "2031"; + string cardSecurityCode = "123"; + TmsEmbeddedInstrumentIdentifierCard card = new TmsEmbeddedInstrumentIdentifierCard( + Number: cardNumber, + ExpirationMonth: cardExpirationMonth, + ExpirationYear: cardExpirationYear, + SecurityCode: cardSecurityCode + ); + + string billToAddress1 = "1 Market St"; + string billToLocality = "San Francisco"; + string billToAdministrativeArea = "CA"; + string billToPostalCode = "94105"; + string billToCountry = "US"; + TmsEmbeddedInstrumentIdentifierBillTo billTo = new TmsEmbeddedInstrumentIdentifierBillTo( + Address1: billToAddress1, + Locality: billToLocality, + AdministrativeArea: billToAdministrativeArea, + PostalCode: billToPostalCode, + Country: billToCountry + ); + + var requestObj = new PostInstrumentIdentifierRequest( + Type: type, + Card: card, + BillTo: billTo + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InstrumentIdentifierApi(clientConfig); + PostInstrumentIdentifierRequest result = apiInstance.PostInstrumentIdentifier(requestObj, profileid); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/InstrumentIdentifier/DeleteInstrumentIdentifier.cs b/Source/Samples/TokenManagement/InstrumentIdentifier/DeleteInstrumentIdentifier.cs new file mode 100644 index 0000000..bd1b88d --- /dev/null +++ b/Source/Samples/TokenManagement/InstrumentIdentifier/DeleteInstrumentIdentifier.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class DeleteInstrumentIdentifier + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + var profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + var tokenId = CreateInstrumentIdentifierCard.Run().Id; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InstrumentIdentifierApi(clientConfig); + apiInstance.DeleteInstrumentIdentifier(tokenId, profileid); + Console.WriteLine($"Instrument Identifier {tokenId} has been deleted."); + WriteLogAudit(apiInstance.GetStatusCode()); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + } +} diff --git a/Source/Samples/TokenManagement/InstrumentIdentifier/EnrollInstrumentIdentifierForNetworkTokenization.cs b/Source/Samples/TokenManagement/InstrumentIdentifier/EnrollInstrumentIdentifierForNetworkTokenization.cs new file mode 100644 index 0000000..90fe4e7 --- /dev/null +++ b/Source/Samples/TokenManagement/InstrumentIdentifier/EnrollInstrumentIdentifierForNetworkTokenization.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class EnrollInstrumentIdentifierForNetworkTokenization + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + string instrumentIdentifierTokenId = "7010000000016241111"; + string profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + + string type = "enrollable card"; + string cardExpirationMonth = "12"; + string cardExpirationYear = "2031"; + string cardSecurityCode = "123"; + TmsEmbeddedInstrumentIdentifierCard card = new TmsEmbeddedInstrumentIdentifierCard( + ExpirationMonth: cardExpirationMonth, + ExpirationYear: cardExpirationYear, + SecurityCode: cardSecurityCode + ); + + string billToAddress1 = "1 Market St"; + string billToLocality = "San Francisco"; + string billToAdministrativeArea = "CA"; + string billToPostalCode = "94105"; + string billToCountry = "US"; + TmsEmbeddedInstrumentIdentifierBillTo billTo = new TmsEmbeddedInstrumentIdentifierBillTo( + Address1: billToAddress1, + Locality: billToLocality, + AdministrativeArea: billToAdministrativeArea, + PostalCode: billToPostalCode, + Country: billToCountry + ); + + var requestObj = new PostInstrumentIdentifierEnrollmentRequest( + Type: type, + Card: card, + BillTo: billTo + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InstrumentIdentifierApi(clientConfig); + apiInstance.PostInstrumentIdentifierEnrollment(instrumentIdentifierTokenId, requestObj, profileid); + Console.WriteLine($"Instrument Identifier for Network Tokenized Card {instrumentIdentifierTokenId} has been enrolled."); + WriteLogAudit(apiInstance.GetStatusCode()); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + } +} diff --git a/Source/Samples/TokenManagement/InstrumentIdentifier/ListPaymentInstrumentsForInstrumentIdentifier.cs b/Source/Samples/TokenManagement/InstrumentIdentifier/ListPaymentInstrumentsForInstrumentIdentifier.cs new file mode 100644 index 0000000..10b5ccc --- /dev/null +++ b/Source/Samples/TokenManagement/InstrumentIdentifier/ListPaymentInstrumentsForInstrumentIdentifier.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class ListPaymentInstrumentsForInstrumentIdentifier + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PaymentInstrumentList1 Run() + { + string instrumentIdentifierTokenId = "7010000000016241111"; + string profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + long? offset = (long?)null; + long? limit = (long?)null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InstrumentIdentifierApi(clientConfig); + PaymentInstrumentList1 result = apiInstance.GetInstrumentIdentifierPaymentInstrumentsList(instrumentIdentifierTokenId, profileid, offset, limit); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/InstrumentIdentifier/RetrieveInstrumentIdentifier.cs b/Source/Samples/TokenManagement/InstrumentIdentifier/RetrieveInstrumentIdentifier.cs new file mode 100644 index 0000000..9d0f030 --- /dev/null +++ b/Source/Samples/TokenManagement/InstrumentIdentifier/RetrieveInstrumentIdentifier.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class RetrieveInstrumentIdentifier + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostInstrumentIdentifierRequest Run() + { + var profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + var tokenId = "7010000000016241111"; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InstrumentIdentifierApi(clientConfig); + PostInstrumentIdentifierRequest result = apiInstance.GetInstrumentIdentifier(tokenId, profileid); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/InstrumentIdentifier/UpdateInstrumentIdentifierPreviousTransactionId.cs b/Source/Samples/TokenManagement/InstrumentIdentifier/UpdateInstrumentIdentifierPreviousTransactionId.cs new file mode 100644 index 0000000..e2b0723 --- /dev/null +++ b/Source/Samples/TokenManagement/InstrumentIdentifier/UpdateInstrumentIdentifierPreviousTransactionId.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class UpdateInstrumentIdentifierPreviousTransactionId + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + string instrumentIdentifierTokenId = "7010000000016241111"; + string processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionPreviousTransactionId = "123456789012345"; + TmsAuthorizationOptionsInitiatorMerchantInitiatedTransaction processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction = new TmsAuthorizationOptionsInitiatorMerchantInitiatedTransaction( + PreviousTransactionId: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransactionPreviousTransactionId + ); + + TmsAuthorizationOptionsInitiator processingInformationAuthorizationOptionsInitiator = new TmsAuthorizationOptionsInitiator( + MerchantInitiatedTransaction: processingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction + ); + + TmsAuthorizationOptions processingInformationAuthorizationOptions = new TmsAuthorizationOptions( + Initiator: processingInformationAuthorizationOptionsInitiator + ); + + TmsEmbeddedInstrumentIdentifierProcessingInformation processingInformation = new TmsEmbeddedInstrumentIdentifierProcessingInformation( + AuthorizationOptions: processingInformationAuthorizationOptions + ); + + var requestObj = new PatchInstrumentIdentifierRequest( + ProcessingInformation: processingInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new InstrumentIdentifierApi(clientConfig); + apiInstance.PatchInstrumentIdentifier(instrumentIdentifierTokenId, requestObj); + Console.WriteLine($"Instrument Identifier {instrumentIdentifierTokenId} has been updated with previous transaction ID."); + WriteLogAudit(apiInstance.GetStatusCode()); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + } +} diff --git a/Source/Samples/TokenManagement/PaymentInstrument/CreatePaymentInstrumentBankAccount.cs b/Source/Samples/TokenManagement/PaymentInstrument/CreatePaymentInstrumentBankAccount.cs new file mode 100644 index 0000000..09ab3d4 --- /dev/null +++ b/Source/Samples/TokenManagement/PaymentInstrument/CreatePaymentInstrumentBankAccount.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class CreatePaymentInstrumentBankAccount + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostPaymentInstrumentRequest Run() + { + var profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + + string bankAccountType = "savings"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentBankAccount bankAccount = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBankAccount( + Type: bankAccountType + ); + + string buyerInformationCompanyTaxID = "12345"; + string buyerInformationCurrency = "USD"; + DateTime buyerInformationDateOfBirth = Convert.ToDateTime("2000-12-13"); + + List buyerInformationPersonalIdentification = new List(); + string buyerInformationPersonalIdentificationId1 = "57684432111321"; + string buyerInformationPersonalIdentificationType1 = "driver license"; + string buyerInformationPersonalIdentificationIssuedByAdministrativeArea1 = "CA"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformationIssuedBy buyerInformationPersonalIdentificationIssuedBy1 = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformationIssuedBy( + AdministrativeArea: buyerInformationPersonalIdentificationIssuedByAdministrativeArea1 + ); + + buyerInformationPersonalIdentification.Add(new Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformationPersonalIdentification( + Id: buyerInformationPersonalIdentificationId1, + Type: buyerInformationPersonalIdentificationType1, + IssuedBy: buyerInformationPersonalIdentificationIssuedBy1 + )); + + Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformation buyerInformation = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBuyerInformation( + CompanyTaxID: buyerInformationCompanyTaxID, + Currency: buyerInformationCurrency, + DateOfBirth: buyerInformationDateOfBirth, + PersonalIdentification: buyerInformationPersonalIdentification + ); + + string billToFirstName = "John"; + string billToLastName = "Doe"; + string billToCompany = "CyberSource"; + string billToAddress1 = "1 Market St"; + string billToLocality = "San Francisco"; + string billToAdministrativeArea = "CA"; + string billToPostalCode = "94105"; + string billToCountry = "US"; + string billToEmail = "test@cybs.com"; + string billToPhoneNumber = "4158880000"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo billTo = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + FirstName: billToFirstName, + LastName: billToLastName, + Company: billToCompany, + Address1: billToAddress1, + Locality: billToLocality, + AdministrativeArea: billToAdministrativeArea, + PostalCode: billToPostalCode, + Country: billToCountry, + Email: billToEmail, + PhoneNumber: billToPhoneNumber + ); + + string processingInformationBankTransferOptionsSeCCode = "WEB"; + TmsPaymentInstrumentProcessingInfoBankTransferOptions processingInformationBankTransferOptions = new TmsPaymentInstrumentProcessingInfoBankTransferOptions( + SECCode: processingInformationBankTransferOptionsSeCCode + ); + + TmsPaymentInstrumentProcessingInfo processingInformation = new TmsPaymentInstrumentProcessingInfo( + BankTransferOptions: processingInformationBankTransferOptions + ); + + string instrumentIdentifierId = "A7A91A2CA872B272E05340588D0A0699"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier instrumentIdentifier = new Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + Id: instrumentIdentifierId + ); + + var requestObj = new PostPaymentInstrumentRequest( + BankAccount: bankAccount, + BuyerInformation: buyerInformation, + BillTo: billTo, + ProcessingInformation: processingInformation, + InstrumentIdentifier: instrumentIdentifier + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentInstrumentApi(clientConfig); + PostPaymentInstrumentRequest result = apiInstance.PostPaymentInstrument(requestObj, profileid); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/PaymentInstrument/CreatePaymentInstrumentCard.cs b/Source/Samples/TokenManagement/PaymentInstrument/CreatePaymentInstrumentCard.cs new file mode 100644 index 0000000..2491042 --- /dev/null +++ b/Source/Samples/TokenManagement/PaymentInstrument/CreatePaymentInstrumentCard.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class CreatePaymentInstrumentCard + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostPaymentInstrumentRequest Run() + { + var profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + + string cardExpirationMonth = "12"; + string cardExpirationYear = "2031"; + string cardType = "visa"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentCard card = new Tmsv2customersEmbeddedDefaultPaymentInstrumentCard( + ExpirationMonth: cardExpirationMonth, + ExpirationYear: cardExpirationYear, + Type: cardType + ); + + string billToFirstName = "John"; + string billToLastName = "Doe"; + string billToCompany = "CyberSource"; + string billToAddress1 = "1 Market St"; + string billToLocality = "San Francisco"; + string billToAdministrativeArea = "CA"; + string billToPostalCode = "94105"; + string billToCountry = "US"; + string billToEmail = "test@cybs.com"; + string billToPhoneNumber = "4158880000"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo billTo = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + FirstName: billToFirstName, + LastName: billToLastName, + Company: billToCompany, + Address1: billToAddress1, + Locality: billToLocality, + AdministrativeArea: billToAdministrativeArea, + PostalCode: billToPostalCode, + Country: billToCountry, + Email: billToEmail, + PhoneNumber: billToPhoneNumber + ); + + string instrumentIdentifierId = "7010000000016241111"; + + Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier instrumentIdentifier = new Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + Id: instrumentIdentifierId + ); + + var requestObj = new PostPaymentInstrumentRequest( + Card: card, + BillTo: billTo, + InstrumentIdentifier: instrumentIdentifier + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentInstrumentApi(clientConfig); + PostPaymentInstrumentRequest result = apiInstance.PostPaymentInstrument(requestObj, profileid); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/PaymentInstrument/CreatePaymentInstrumentPinlessDebit.cs b/Source/Samples/TokenManagement/PaymentInstrument/CreatePaymentInstrumentPinlessDebit.cs new file mode 100644 index 0000000..d4be4f5 --- /dev/null +++ b/Source/Samples/TokenManagement/PaymentInstrument/CreatePaymentInstrumentPinlessDebit.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class CreatePaymentInstrumentPinlessDebit + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostPaymentInstrumentRequest Run() + { + var profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + + string cardExpirationMonth = "12"; + string cardExpirationYear = "2031"; + string cardType = "visa"; + string cardIssueNumber = "01"; + string cardStartMonth = "01"; + string cardStartYear = "2020"; + string cardUseAs = "pinless debit"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentCard card = new Tmsv2customersEmbeddedDefaultPaymentInstrumentCard( + ExpirationMonth: cardExpirationMonth, + ExpirationYear: cardExpirationYear, + Type: cardType, + IssueNumber: cardIssueNumber, + StartMonth: cardStartMonth, + StartYear: cardStartYear, + UseAs: cardUseAs + ); + + string billToFirstName = "John"; + string billToLastName = "Doe"; + string billToCompany = "CyberSource"; + string billToAddress1 = "1 Market St"; + string billToLocality = "San Francisco"; + string billToAdministrativeArea = "CA"; + string billToPostalCode = "94105"; + string billToCountry = "US"; + string billToEmail = "test@cybs.com"; + string billToPhoneNumber = "4158880000"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo billTo = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + FirstName: billToFirstName, + LastName: billToLastName, + Company: billToCompany, + Address1: billToAddress1, + Locality: billToLocality, + AdministrativeArea: billToAdministrativeArea, + PostalCode: billToPostalCode, + Country: billToCountry, + Email: billToEmail, + PhoneNumber: billToPhoneNumber + ); + + string instrumentIdentifierId = "7010000000016241111"; + + Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier instrumentIdentifier = new Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + Id: instrumentIdentifierId + ); + + var requestObj = new PostPaymentInstrumentRequest( + Card: card, + BillTo: billTo, + InstrumentIdentifier: instrumentIdentifier + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentInstrumentApi(clientConfig); + PostPaymentInstrumentRequest result = apiInstance.PostPaymentInstrument(requestObj, profileid); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/PaymentInstrument/DeletePaymentInstrument.cs b/Source/Samples/TokenManagement/PaymentInstrument/DeletePaymentInstrument.cs new file mode 100644 index 0000000..16cabbc --- /dev/null +++ b/Source/Samples/TokenManagement/PaymentInstrument/DeletePaymentInstrument.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class DeletePaymentInstrument + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + var profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + var tokenId = CreatePaymentInstrumentCard.Run().Id; + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentInstrumentApi(clientConfig); + apiInstance.DeletePaymentInstrument(tokenId, profileid); + Console.WriteLine($"Payment Instrument {tokenId} has been deleted."); + WriteLogAudit(apiInstance.GetStatusCode()); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + } +} diff --git a/Source/Samples/TokenManagement/PaymentInstrument/RetrievePaymentInstrument.cs b/Source/Samples/TokenManagement/PaymentInstrument/RetrievePaymentInstrument.cs new file mode 100644 index 0000000..90ebb90 --- /dev/null +++ b/Source/Samples/TokenManagement/PaymentInstrument/RetrievePaymentInstrument.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class RetrievePaymentInstrument + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PostPaymentInstrumentRequest Run() + { + var profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + var tokenId = "888454C31FB6150CE05340588D0AA9BE"; + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentInstrumentApi(clientConfig); + PostPaymentInstrumentRequest result = apiInstance.GetPaymentInstrument(tokenId, profileid); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TokenManagement/PaymentInstrument/UpdatePaymentInstrument.cs b/Source/Samples/TokenManagement/PaymentInstrument/UpdatePaymentInstrument.cs new file mode 100644 index 0000000..5cd1136 --- /dev/null +++ b/Source/Samples/TokenManagement/PaymentInstrument/UpdatePaymentInstrument.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TokenManagement +{ + public class UpdatePaymentInstrument + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PatchPaymentInstrumentRequest Run() + { + var profileid = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; + var paymentInstrumentTokenId = "888454C31FB6150CE05340588D0AA9BE"; + string cardExpirationMonth = "12"; + string cardExpirationYear = "2031"; + string cardType = "visa"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentCard card = new Tmsv2customersEmbeddedDefaultPaymentInstrumentCard( + ExpirationMonth: cardExpirationMonth, + ExpirationYear: cardExpirationYear, + Type: cardType + ); + + string billToFirstName = "Jack"; + string billToLastName = "Smith"; + string billToCompany = "CyberSource"; + string billToAddress1 = "1 Market St"; + string billToLocality = "San Francisco"; + string billToAdministrativeArea = "CA"; + string billToPostalCode = "94105"; + string billToCountry = "US"; + string billToEmail = "updatedemail@cybs.com"; + string billToPhoneNumber = "4158888674"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo billTo = new Tmsv2customersEmbeddedDefaultPaymentInstrumentBillTo( + FirstName: billToFirstName, + LastName: billToLastName, + Company: billToCompany, + Address1: billToAddress1, + Locality: billToLocality, + AdministrativeArea: billToAdministrativeArea, + PostalCode: billToPostalCode, + Country: billToCountry, + Email: billToEmail, + PhoneNumber: billToPhoneNumber + ); + + string instrumentIdentifierId = "7010000000016241111"; + Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier instrumentIdentifier = new Tmsv2customersEmbeddedDefaultPaymentInstrumentInstrumentIdentifier( + Id: instrumentIdentifierId + ); + + var requestObj = new PatchPaymentInstrumentRequest( + Card: card, + BillTo: billTo, + InstrumentIdentifier: instrumentIdentifier + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new PaymentInstrumentApi(clientConfig); + PatchPaymentInstrumentRequest result = apiInstance.PatchPaymentInstrument(paymentInstrumentTokenId, requestObj, profileid); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TransactionBatches/GetIndividualBatchFile.cs b/Source/Samples/TransactionBatches/GetIndividualBatchFile.cs new file mode 100644 index 0000000..cf67c10 --- /dev/null +++ b/Source/Samples/TransactionBatches/GetIndividualBatchFile.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TransactionBatches +{ + public class GetIndividualBatchFile + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV1TransactionBatchesIdGet200Response Run() + { + try + { + var id = "12345"; + + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new TransactionBatchesApi(clientConfig); + PtsV1TransactionBatchesIdGet200Response result = apiInstance.GetTransactionBatchId(id); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TransactionBatches/GetListOfBatchFiles.cs b/Source/Samples/TransactionBatches/GetListOfBatchFiles.cs new file mode 100644 index 0000000..3c603ec --- /dev/null +++ b/Source/Samples/TransactionBatches/GetListOfBatchFiles.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TransactionBatches +{ + public class GetListOfBatchFiles + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static PtsV1TransactionBatchesGet200Response Run() + { + var startTime = DateTime.ParseExact("2020-02-22T01:47:57Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + var endTime = DateTime.ParseExact("2020-02-22T22:47:57Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new TransactionBatchesApi(clientConfig); + PtsV1TransactionBatchesGet200Response result = apiInstance.GetTransactionBatches(startTime, endTime); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/src/Samples/TransactionBatches/CoreServices/GetTransactionDetailsForGivenBatchId.cs b/Source/Samples/TransactionBatches/GetTransactionDetailsForGivenBatchId.cs similarity index 55% rename from src/Samples/TransactionBatches/CoreServices/GetTransactionDetailsForGivenBatchId.cs rename to Source/Samples/TransactionBatches/GetTransactionDetailsForGivenBatchId.cs index 56dd179..9552a27 100644 --- a/src/Samples/TransactionBatches/CoreServices/GetTransactionDetailsForGivenBatchId.cs +++ b/Source/Samples/TransactionBatches/GetTransactionDetailsForGivenBatchId.cs @@ -1,63 +1,77 @@ -// Code Generated: getTransactionBatchDetails[Get transaction details for a given batch id] - using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Xml; using System.Xml.Serialization; + using CyberSource.Api; +using CyberSource.Client; using CyberSource.Model; -namespace Cybersource_rest_samples_dotnet.Samples.TransactionBatches.CoreServices +namespace Cybersource_rest_samples_dotnet.Samples.TransactionBatches { public class GetTransactionDetailsForGivenBatchId { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + public static void Run() { var id = "12345"; - // Provide the File Name const string fileName = "BatchDetailsReport.csv"; - - // Provide the path where the file needs to be downloaded - // This can be either a relative path or an absolute path const string downloadFilePath = @".\Resource\" + fileName; - + var uploadDate = DateTime.ParseExact("2019-08-30", "yyyy-MM-dd", CultureInfo.InvariantCulture); + string status = "Rejected"; try { var configDictionary = new Configuration().GetConfiguration(); var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); var apiInstance = new TransactionBatchesApi(clientConfig); - var content = apiInstance.GetTransactionBatchDetailsWithHttpInfo(id); + var content = apiInstance.GetTransactionBatchDetailsWithHttpInfo(id, uploadDate, status); + // START : FILE DOWNLOAD FUNCTIONALITY File.WriteAllText(downloadFilePath, CreateXml(content.Data)); - Console.WriteLine("\nDetails downloaded at the below location:"); + Console.WriteLine("\nFile Downloaded at the following location : "); Console.WriteLine($"{Path.GetFullPath(downloadFilePath)}\n"); + WriteLogAudit(apiInstance.GetStatusCode()); + // END : FILE DOWNLOAD FUNCTIONALITY + } + catch (FileNotFoundException) + { + Console.WriteLine("File Not Found : Kindly verify the path."); } - catch (Exception e) + catch (ApiException e) { Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); } } + // START : STREAM SERIALIZER METHOD private static string CreateXml(object obj) { - var xmlDoc = new XmlDocument(); // Represents an XML document - var xmlSerializer = new XmlSerializer(obj.GetType()); // Initializes a new instance of the XmlDocument class. + var xmlDoc = new XmlDocument(); // Represents an XML Document + var xmlSerializer = new XmlSerializer(obj.GetType()); // Initializes a new instance of the XmlDocument class - // Creates a stream whose backing store is memory. + // Creates a stream whose backing store is memory using (var xmlStream = new MemoryStream()) { xmlSerializer.Serialize(xmlStream, obj); xmlStream.Position = 0; - // Loads the XML document from the specified string. + // Loads the XML document from the specified string xmlDoc.Load(xmlStream); return xmlDoc.InnerText; } } + // END : STREAM SERIALIZER METHOD } -} \ No newline at end of file +} diff --git a/Source/Samples/TransactionDetails/RetrieveTransaction.cs b/Source/Samples/TransactionDetails/RetrieveTransaction.cs new file mode 100644 index 0000000..51443ab --- /dev/null +++ b/Source/Samples/TransactionDetails/RetrieveTransaction.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; +using Cybersource_rest_samples_dotnet.Samples.Payments; + +namespace Cybersource_rest_samples_dotnet.Samples.TransactionDetails +{ + public class RetrieveTransaction + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static TssV2TransactionsGet200Response Run() + { + string id = SimpleAuthorizationInternet.Run().Id; + + System.Threading.Thread.Sleep(15000); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new TransactionDetailsApi(clientConfig); + TssV2TransactionsGet200Response result = apiInstance.GetTransaction(id); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TransactionSearch/CreateSearchRequest.cs b/Source/Samples/TransactionSearch/CreateSearchRequest.cs new file mode 100644 index 0000000..3d7c762 --- /dev/null +++ b/Source/Samples/TransactionSearch/CreateSearchRequest.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TransactionSearch +{ + public class CreateSearchRequest + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static TssV2TransactionsPost201Response Run() + { + bool save = false; + string name = "MRN"; + string timezone = "America/Chicago"; + string query = "clientReferenceInformation.code:TC50171_3 AND submitTimeUtc:[NOW/DAY-7DAYS TO NOW/DAY+1DAY}"; + int offset = 0; + int limit = 100; + string sort = "id:asc,submitTimeUtc:asc"; + var requestObj = new CyberSource.Model.CreateSearchRequest( + Save: save, + Name: name, + Timezone: timezone, + Query: query, + Offset: offset, + Limit: limit, + Sort: sort + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new SearchTransactionsApi(clientConfig); + TssV2TransactionsPost201Response result = apiInstance.CreateSearch(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/TransactionSearch/GetSearchResults.cs b/Source/Samples/TransactionSearch/GetSearchResults.cs new file mode 100644 index 0000000..b644963 --- /dev/null +++ b/Source/Samples/TransactionSearch/GetSearchResults.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.TransactionSearch +{ + public class GetSearchResults + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static TssV2TransactionsPost201Response Run() + { + var searchId = CreateSearchRequest.Run().SearchId; + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new SearchTransactionsApi(clientConfig); + TssV2TransactionsPost201Response result = apiInstance.GetSearch(searchId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/UnifiedCheckout/GenerateUnifiedCheckout.cs b/Source/Samples/UnifiedCheckout/GenerateUnifiedCheckout.cs new file mode 100644 index 0000000..4dca0fe --- /dev/null +++ b/Source/Samples/UnifiedCheckout/GenerateUnifiedCheckout.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.UnifiedCheckout +{ + public class GenerateUnifiedCheckout + { + public static String Run() + { + + Upv1capturecontextsCaptureMandate captureMandate = new Upv1capturecontextsCaptureMandate( + BillingType: "FULL", + RequestEmail:true, + RequestPhone:true, + RequestShipping:true, + ShipToCountries: new List(){"US","GB" }, + ShowAcceptedNetworkIcons: true + ); + Upv1capturecontextsOrderInformationAmountDetails amountDetails= new Upv1capturecontextsOrderInformationAmountDetails( + TotalAmount: "21.00", + Currency: "USD" + ); + Upv1capturecontextsOrderInformation orderInformation = new Upv1capturecontextsOrderInformation( + AmountDetails: amountDetails + ); + + var requestObj = new GenerateUnifiedCheckoutCaptureContextRequest( + TargetOrigins: new List() { "https://the-up-demo.appspot.com" }, + ClientVersion: "0.15", + AllowedCardNetworks: new List() { "VISA","MASTERCARD", "AMEX" }, + AllowedPaymentTypes: new List() { "PANENTRY","SRC" }, + Country : "US", + Locale: "en_US", + CaptureMandate: captureMandate, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new UnifiedCheckoutCaptureContextApi(clientConfig); + String result = apiInstance.GenerateUnifiedCheckoutCaptureContext(requestObj); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} diff --git a/Source/Samples/UserManagement/UserManagement/GetUserInformationDeprecated.cs b/Source/Samples/UserManagement/UserManagement/GetUserInformationDeprecated.cs new file mode 100644 index 0000000..44f9c39 --- /dev/null +++ b/Source/Samples/UserManagement/UserManagement/GetUserInformationDeprecated.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.UserManagement +{ + public class GetUserInformationDeprecated + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static UmsV1UsersGet200Response Run() + { + string organizationId = "testrest"; + string userName = null; + string permissionId = "CustomerProfileViewPermission"; + string roleId = null; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new UserManagementApi(clientConfig); + UmsV1UsersGet200Response result = apiInstance.GetUsers(organizationId, userName, permissionId, roleId); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + Console.WriteLine(e.StackTrace); + return null; + } + } + } +} diff --git a/Source/Samples/ValueAddedService/BasicTaxCalculationRequest.cs b/Source/Samples/ValueAddedService/BasicTaxCalculationRequest.cs new file mode 100644 index 0000000..f247b73 --- /dev/null +++ b/Source/Samples/ValueAddedService/BasicTaxCalculationRequest.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.ValueAddedService +{ + public class BasicTaxCalculationRequest + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static VasV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TAX_TC001"; + Vasv2taxClientReferenceInformation clientReferenceInformation = new Vasv2taxClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string taxInformationShowTaxPerLineItem = "Yes"; + Vasv2taxTaxInformation taxInformation = new Vasv2taxTaxInformation( + ShowTaxPerLineItem: taxInformationShowTaxPerLineItem + ); + + string orderInformationAmountDetailsCurrency = "USD"; + RiskV1DecisionsPost201ResponseOrderInformationAmountDetails orderInformationAmountDetails = new RiskV1DecisionsPost201ResponseOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "San Francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + Vasv2taxOrderInformationBillTo orderInformationBillTo = new Vasv2taxOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsProductSKU1 = "07-12-00657"; + string orderInformationLineItemsProductCode1 = "50161815"; + int orderInformationLineItemsQuantity1 = 1; + string orderInformationLineItemsProductName1 = "Chewing Gum"; + string orderInformationLineItemsUnitPrice1 = "1200"; + orderInformationLineItems.Add(new Vasv2taxOrderInformationLineItems( + ProductSKU: orderInformationLineItemsProductSKU1, + ProductCode: orderInformationLineItemsProductCode1, + Quantity: orderInformationLineItemsQuantity1, + ProductName: orderInformationLineItemsProductName1, + UnitPrice: orderInformationLineItemsUnitPrice1 + )); + + string orderInformationLineItemsProductSKU2 = "07-12-00659"; + string orderInformationLineItemsProductCode2 = "50181905"; + int orderInformationLineItemsQuantity2 = 1; + string orderInformationLineItemsProductName2 = "Sugar Cookies"; + string orderInformationLineItemsUnitPrice2 = "1240"; + orderInformationLineItems.Add(new Vasv2taxOrderInformationLineItems( + ProductSKU: orderInformationLineItemsProductSKU2, + ProductCode: orderInformationLineItemsProductCode2, + Quantity: orderInformationLineItemsQuantity2, + ProductName: orderInformationLineItemsProductName2, + UnitPrice: orderInformationLineItemsUnitPrice2 + )); + + string orderInformationLineItemsProductSKU3 = "07-12-00658"; + string orderInformationLineItemsProductCode3 = "5020.11"; + int orderInformationLineItemsQuantity3 = 1; + string orderInformationLineItemsProductName3 = "Carbonated Water"; + string orderInformationLineItemsUnitPrice3 = "9001"; + orderInformationLineItems.Add(new Vasv2taxOrderInformationLineItems( + ProductSKU: orderInformationLineItemsProductSKU3, + ProductCode: orderInformationLineItemsProductCode3, + Quantity: orderInformationLineItemsQuantity3, + ProductName: orderInformationLineItemsProductName3, + UnitPrice: orderInformationLineItemsUnitPrice3 + )); + + Vasv2taxOrderInformation orderInformation = new Vasv2taxOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo, + LineItems: orderInformationLineItems + ); + + var requestObj = new TaxRequest( + ClientReferenceInformation: clientReferenceInformation, + TaxInformation: taxInformation, + OrderInformation: orderInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new TaxesApi(clientConfig); + VasV2PaymentsPost201Response result = apiInstance.CalculateTax(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/ValueAddedService/CommittedTaxCallRequest.cs b/Source/Samples/ValueAddedService/CommittedTaxCallRequest.cs new file mode 100644 index 0000000..e96c618 --- /dev/null +++ b/Source/Samples/ValueAddedService/CommittedTaxCallRequest.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.ValueAddedService +{ + public class CommittedTaxCallRequest + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static VasV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TAX_TC001"; + Vasv2taxClientReferenceInformation clientReferenceInformation = new Vasv2taxClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string taxInformationShowTaxPerLineItem = "Yes"; + bool taxInformationCommitIndicator = true; + Vasv2taxTaxInformation taxInformation = new Vasv2taxTaxInformation( + ShowTaxPerLineItem: taxInformationShowTaxPerLineItem, + CommitIndicator: taxInformationCommitIndicator + ); + + string orderInformationAmountDetailsCurrency = "USD"; + RiskV1DecisionsPost201ResponseOrderInformationAmountDetails orderInformationAmountDetails = new RiskV1DecisionsPost201ResponseOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "San Francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + Vasv2taxOrderInformationBillTo orderInformationBillTo = new Vasv2taxOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry + ); + + string orderInformationShippingDetailsShipFromLocality = "Cambridge Bay"; + string orderInformationShippingDetailsShipFromCountry = "CA"; + string orderInformationShippingDetailsShipFromPostalCode = "A0G 1T0"; + string orderInformationShippingDetailsShipFromAdministrativeArea = "NL"; + Vasv2taxOrderInformationShippingDetails orderInformationShippingDetails = new Vasv2taxOrderInformationShippingDetails( + ShipFromLocality: orderInformationShippingDetailsShipFromLocality, + ShipFromCountry: orderInformationShippingDetailsShipFromCountry, + ShipFromPostalCode: orderInformationShippingDetailsShipFromPostalCode, + ShipFromAdministrativeArea: orderInformationShippingDetailsShipFromAdministrativeArea + ); + + string orderInformationShipToCountry = "US"; + string orderInformationShipToAdministrativeArea = "FL"; + string orderInformationShipToLocality = "Panama City"; + string orderInformationShipToPostalCode = "32401"; + string orderInformationShipToAddress1 = "123 Russel St."; + Vasv2taxOrderInformationShipTo orderInformationShipTo = new Vasv2taxOrderInformationShipTo( + Country: orderInformationShipToCountry, + AdministrativeArea: orderInformationShipToAdministrativeArea, + Locality: orderInformationShipToLocality, + PostalCode: orderInformationShipToPostalCode, + Address1: orderInformationShipToAddress1 + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsProductSKU1 = "07-12-00657"; + string orderInformationLineItemsProductCode1 = "50161815"; + int orderInformationLineItemsQuantity1 = 1; + string orderInformationLineItemsProductName1 = "Chewing Gum"; + string orderInformationLineItemsUnitPrice1 = "1200"; + orderInformationLineItems.Add(new Vasv2taxOrderInformationLineItems( + ProductSKU: orderInformationLineItemsProductSKU1, + ProductCode: orderInformationLineItemsProductCode1, + Quantity: orderInformationLineItemsQuantity1, + ProductName: orderInformationLineItemsProductName1, + UnitPrice: orderInformationLineItemsUnitPrice1 + )); + + string orderInformationLineItemsProductSKU2 = "07-12-00659"; + string orderInformationLineItemsProductCode2 = "50181905"; + int orderInformationLineItemsQuantity2 = 1; + string orderInformationLineItemsProductName2 = "Sugar Cookies"; + string orderInformationLineItemsUnitPrice2 = "1240"; + orderInformationLineItems.Add(new Vasv2taxOrderInformationLineItems( + ProductSKU: orderInformationLineItemsProductSKU2, + ProductCode: orderInformationLineItemsProductCode2, + Quantity: orderInformationLineItemsQuantity2, + ProductName: orderInformationLineItemsProductName2, + UnitPrice: orderInformationLineItemsUnitPrice2 + )); + + string orderInformationLineItemsProductSKU3 = "07-12-00658"; + string orderInformationLineItemsProductCode3 = "5020.11"; + int orderInformationLineItemsQuantity3 = 1; + string orderInformationLineItemsProductName3 = "Carbonated Water"; + string orderInformationLineItemsUnitPrice3 = "9001"; + orderInformationLineItems.Add(new Vasv2taxOrderInformationLineItems( + ProductSKU: orderInformationLineItemsProductSKU3, + ProductCode: orderInformationLineItemsProductCode3, + Quantity: orderInformationLineItemsQuantity3, + ProductName: orderInformationLineItemsProductName3, + UnitPrice: orderInformationLineItemsUnitPrice3 + )); + + Vasv2taxOrderInformation orderInformation = new Vasv2taxOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo, + ShippingDetails: orderInformationShippingDetails, + ShipTo: orderInformationShipTo, + LineItems: orderInformationLineItems + ); + + string merchantInformationVatRegistrationNumber = "abcdef"; + Vasv2taxMerchantInformation merchantInformation = new Vasv2taxMerchantInformation( + VatRegistrationNumber: merchantInformationVatRegistrationNumber + ); + + var requestObj = new TaxRequest( + ClientReferenceInformation: clientReferenceInformation, + TaxInformation: taxInformation, + OrderInformation: orderInformation, + MerchantInformation: merchantInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new TaxesApi(clientConfig); + VasV2PaymentsPost201Response result = apiInstance.CalculateTax(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/ValueAddedService/CommittedTaxRefundCallRequest.cs b/Source/Samples/ValueAddedService/CommittedTaxRefundCallRequest.cs new file mode 100644 index 0000000..c45ee21 --- /dev/null +++ b/Source/Samples/ValueAddedService/CommittedTaxRefundCallRequest.cs @@ -0,0 +1,158 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.ValueAddedService +{ + public class CommittedTaxRefundCallRequest + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static VasV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TAX_TC001"; + Vasv2taxClientReferenceInformation clientReferenceInformation = new Vasv2taxClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string taxInformationShowTaxPerLineItem = "Yes"; + bool taxInformationCommitIndicator = true; + bool taxInformationRefundIndicator = true; + Vasv2taxTaxInformation taxInformation = new Vasv2taxTaxInformation( + ShowTaxPerLineItem: taxInformationShowTaxPerLineItem, + CommitIndicator: taxInformationCommitIndicator, + RefundIndicator: taxInformationRefundIndicator + ); + + string orderInformationAmountDetailsCurrency = "USD"; + RiskV1DecisionsPost201ResponseOrderInformationAmountDetails orderInformationAmountDetails = new RiskV1DecisionsPost201ResponseOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "San Francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + Vasv2taxOrderInformationBillTo orderInformationBillTo = new Vasv2taxOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry + ); + + string orderInformationShippingDetailsShipFromLocality = "Cambridge Bay"; + string orderInformationShippingDetailsShipFromCountry = "CA"; + string orderInformationShippingDetailsShipFromPostalCode = "A0G 1T0"; + string orderInformationShippingDetailsShipFromAdministrativeArea = "NL"; + Vasv2taxOrderInformationShippingDetails orderInformationShippingDetails = new Vasv2taxOrderInformationShippingDetails( + ShipFromLocality: orderInformationShippingDetailsShipFromLocality, + ShipFromCountry: orderInformationShippingDetailsShipFromCountry, + ShipFromPostalCode: orderInformationShippingDetailsShipFromPostalCode, + ShipFromAdministrativeArea: orderInformationShippingDetailsShipFromAdministrativeArea + ); + + string orderInformationShipToCountry = "US"; + string orderInformationShipToAdministrativeArea = "FL"; + string orderInformationShipToLocality = "Panama City"; + string orderInformationShipToPostalCode = "32401"; + string orderInformationShipToAddress1 = "123 Russel St."; + Vasv2taxOrderInformationShipTo orderInformationShipTo = new Vasv2taxOrderInformationShipTo( + Country: orderInformationShipToCountry, + AdministrativeArea: orderInformationShipToAdministrativeArea, + Locality: orderInformationShipToLocality, + PostalCode: orderInformationShipToPostalCode, + Address1: orderInformationShipToAddress1 + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsProductSKU1 = "07-12-00657"; + string orderInformationLineItemsProductCode1 = "50161815"; + int orderInformationLineItemsQuantity1 = 1; + string orderInformationLineItemsProductName1 = "Chewing Gum"; + string orderInformationLineItemsUnitPrice1 = "1200"; + orderInformationLineItems.Add(new Vasv2taxOrderInformationLineItems( + ProductSKU: orderInformationLineItemsProductSKU1, + ProductCode: orderInformationLineItemsProductCode1, + Quantity: orderInformationLineItemsQuantity1, + ProductName: orderInformationLineItemsProductName1, + UnitPrice: orderInformationLineItemsUnitPrice1 + )); + + string orderInformationLineItemsProductSKU2 = "07-12-00659"; + string orderInformationLineItemsProductCode2 = "50181905"; + int orderInformationLineItemsQuantity2 = 1; + string orderInformationLineItemsProductName2 = "Sugar Cookies"; + string orderInformationLineItemsUnitPrice2 = "1240"; + orderInformationLineItems.Add(new Vasv2taxOrderInformationLineItems( + ProductSKU: orderInformationLineItemsProductSKU2, + ProductCode: orderInformationLineItemsProductCode2, + Quantity: orderInformationLineItemsQuantity2, + ProductName: orderInformationLineItemsProductName2, + UnitPrice: orderInformationLineItemsUnitPrice2 + )); + + string orderInformationLineItemsProductSKU3 = "07-12-00658"; + string orderInformationLineItemsProductCode3 = "5020.11"; + int orderInformationLineItemsQuantity3 = 1; + string orderInformationLineItemsProductName3 = "Carbonated Water"; + string orderInformationLineItemsUnitPrice3 = "9001"; + orderInformationLineItems.Add(new Vasv2taxOrderInformationLineItems( + ProductSKU: orderInformationLineItemsProductSKU3, + ProductCode: orderInformationLineItemsProductCode3, + Quantity: orderInformationLineItemsQuantity3, + ProductName: orderInformationLineItemsProductName3, + UnitPrice: orderInformationLineItemsUnitPrice3 + )); + + Vasv2taxOrderInformation orderInformation = new Vasv2taxOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo, + ShippingDetails: orderInformationShippingDetails, + ShipTo: orderInformationShipTo, + LineItems: orderInformationLineItems + ); + + string merchantInformationVatRegistrationNumber = "abcdef"; + Vasv2taxMerchantInformation merchantInformation = new Vasv2taxMerchantInformation( + VatRegistrationNumber: merchantInformationVatRegistrationNumber + ); + + var requestObj = new TaxRequest( + ClientReferenceInformation: clientReferenceInformation, + TaxInformation: taxInformation, + OrderInformation: orderInformation, + MerchantInformation: merchantInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new TaxesApi(clientConfig); + VasV2PaymentsPost201Response result = apiInstance.CalculateTax(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/ValueAddedService/TaxRefundRequest.cs b/Source/Samples/ValueAddedService/TaxRefundRequest.cs new file mode 100644 index 0000000..388bdbf --- /dev/null +++ b/Source/Samples/ValueAddedService/TaxRefundRequest.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.ValueAddedService +{ + public class TaxRefundRequest + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static VasV2PaymentsPost201Response Run() + { + string clientReferenceInformationCode = "TAX_TC001"; + Vasv2taxClientReferenceInformation clientReferenceInformation = new Vasv2taxClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + string taxInformationShowTaxPerLineItem = "Yes"; + bool taxInformationRefundIndicator = true; + Vasv2taxTaxInformation taxInformation = new Vasv2taxTaxInformation( + ShowTaxPerLineItem: taxInformationShowTaxPerLineItem, + RefundIndicator: taxInformationRefundIndicator + ); + + string orderInformationAmountDetailsCurrency = "USD"; + RiskV1DecisionsPost201ResponseOrderInformationAmountDetails orderInformationAmountDetails = new RiskV1DecisionsPost201ResponseOrderInformationAmountDetails( + Currency: orderInformationAmountDetailsCurrency + ); + + string orderInformationBillToAddress1 = "1 Market St"; + string orderInformationBillToLocality = "San Francisco"; + string orderInformationBillToAdministrativeArea = "CA"; + string orderInformationBillToPostalCode = "94105"; + string orderInformationBillToCountry = "US"; + Vasv2taxOrderInformationBillTo orderInformationBillTo = new Vasv2taxOrderInformationBillTo( + Address1: orderInformationBillToAddress1, + Locality: orderInformationBillToLocality, + AdministrativeArea: orderInformationBillToAdministrativeArea, + PostalCode: orderInformationBillToPostalCode, + Country: orderInformationBillToCountry + ); + + string orderInformationShippingDetailsShipFromLocality = "Cambridge Bay"; + string orderInformationShippingDetailsShipFromCountry = "CA"; + string orderInformationShippingDetailsShipFromPostalCode = "A0G 1T0"; + string orderInformationShippingDetailsShipFromAdministrativeArea = "NL"; + Vasv2taxOrderInformationShippingDetails orderInformationShippingDetails = new Vasv2taxOrderInformationShippingDetails( + ShipFromLocality: orderInformationShippingDetailsShipFromLocality, + ShipFromCountry: orderInformationShippingDetailsShipFromCountry, + ShipFromPostalCode: orderInformationShippingDetailsShipFromPostalCode, + ShipFromAdministrativeArea: orderInformationShippingDetailsShipFromAdministrativeArea + ); + + string orderInformationShipToCountry = "US"; + string orderInformationShipToAdministrativeArea = "FL"; + string orderInformationShipToLocality = "Panama City"; + string orderInformationShipToPostalCode = "32401"; + string orderInformationShipToAddress1 = "123 Russel St."; + Vasv2taxOrderInformationShipTo orderInformationShipTo = new Vasv2taxOrderInformationShipTo( + Country: orderInformationShipToCountry, + AdministrativeArea: orderInformationShipToAdministrativeArea, + Locality: orderInformationShipToLocality, + PostalCode: orderInformationShipToPostalCode, + Address1: orderInformationShipToAddress1 + ); + + + List orderInformationLineItems = new List(); + string orderInformationLineItemsProductSKU1 = "07-12-00657"; + string orderInformationLineItemsProductCode1 = "50161815"; + int orderInformationLineItemsQuantity1 = 1; + string orderInformationLineItemsProductName1 = "Chewing Gum"; + string orderInformationLineItemsUnitPrice1 = "1200"; + orderInformationLineItems.Add(new Vasv2taxOrderInformationLineItems( + ProductSKU: orderInformationLineItemsProductSKU1, + ProductCode: orderInformationLineItemsProductCode1, + Quantity: orderInformationLineItemsQuantity1, + ProductName: orderInformationLineItemsProductName1, + UnitPrice: orderInformationLineItemsUnitPrice1 + )); + + string orderInformationLineItemsProductSKU2 = "07-12-00659"; + string orderInformationLineItemsProductCode2 = "50181905"; + int orderInformationLineItemsQuantity2 = 1; + string orderInformationLineItemsProductName2 = "Sugar Cookies"; + string orderInformationLineItemsUnitPrice2 = "1240"; + orderInformationLineItems.Add(new Vasv2taxOrderInformationLineItems( + ProductSKU: orderInformationLineItemsProductSKU2, + ProductCode: orderInformationLineItemsProductCode2, + Quantity: orderInformationLineItemsQuantity2, + ProductName: orderInformationLineItemsProductName2, + UnitPrice: orderInformationLineItemsUnitPrice2 + )); + + string orderInformationLineItemsProductSKU3 = "07-12-00658"; + string orderInformationLineItemsProductCode3 = "5020.11"; + int orderInformationLineItemsQuantity3 = 1; + string orderInformationLineItemsProductName3 = "Carbonated Water"; + string orderInformationLineItemsUnitPrice3 = "9001"; + orderInformationLineItems.Add(new Vasv2taxOrderInformationLineItems( + ProductSKU: orderInformationLineItemsProductSKU3, + ProductCode: orderInformationLineItemsProductCode3, + Quantity: orderInformationLineItemsQuantity3, + ProductName: orderInformationLineItemsProductName3, + UnitPrice: orderInformationLineItemsUnitPrice3 + )); + + Vasv2taxOrderInformation orderInformation = new Vasv2taxOrderInformation( + AmountDetails: orderInformationAmountDetails, + BillTo: orderInformationBillTo, + ShippingDetails: orderInformationShippingDetails, + ShipTo: orderInformationShipTo, + LineItems: orderInformationLineItems + ); + + string merchantInformationVatRegistrationNumber = "abcdef"; + Vasv2taxMerchantInformation merchantInformation = new Vasv2taxMerchantInformation( + VatRegistrationNumber: merchantInformationVatRegistrationNumber + ); + + var requestObj = new TaxRequest( + ClientReferenceInformation: clientReferenceInformation, + TaxInformation: taxInformation, + OrderInformation: orderInformation, + MerchantInformation: merchantInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new TaxesApi(clientConfig); + VasV2PaymentsPost201Response result = apiInstance.CalculateTax(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/ValueAddedService/VoidCommittedTaxCall.cs b/Source/Samples/ValueAddedService/VoidCommittedTaxCall.cs new file mode 100644 index 0000000..a1c5b79 --- /dev/null +++ b/Source/Samples/ValueAddedService/VoidCommittedTaxCall.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.ValueAddedService +{ + public class VoidCommittedTaxCall + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static VasV2TaxVoid200Response Run() + { + string id = CommittedTaxCallRequest.Run().Id; + string clientReferenceInformationCode = "TAX_TC001"; + Vasv2taxidClientReferenceInformation clientReferenceInformation = new Vasv2taxidClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + var requestObj = new VoidTaxRequest( + ClientReferenceInformation: clientReferenceInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new TaxesApi(clientConfig); + VasV2TaxVoid200Response result = apiInstance.VoidTax(requestObj, id); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/CreateAlternativePaymentsNotificationWebhook.cs b/Source/Samples/Webhooks/CreateNewWebhooks/CreateAlternativePaymentsNotificationWebhook.cs new file mode 100644 index 0000000..43866a6 --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/CreateAlternativePaymentsNotificationWebhook.cs @@ -0,0 +1,75 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class CreateAlternativePaymentsNotificationWebhook + { + public static void Run() + { + string name = "My Custom Webhook"; + string description = "Sample Webhook from Developer Center"; + string organizationId = ""; + string productId = "alternativePaymentMethods"; + + List eventTypes = new List (); + eventTypes.Add("payments.payments.updated"); + string webhookUrl = "https://MyWebhookServer.com:8443/simulateClient"; + string healthCheckUrl = "https://MyWebhookServer.com:8443/simulateClientHealthCheck"; + string notificationScope = "SELF"; + string retryPolicyAlgorithm = "ARITHMETIC"; + int retryPolicyFirstRetry = 1; + int retryPolicyInterval = 1; + int retryPolicyNumberOfRetries = 3; + string retryPolicyDeactivateFlag = "false"; + int retryPolicyRepeatSequenceCount = 0; + int retryPolicyRepeatSequenceWaitTime = 0; + Notificationsubscriptionsv1webhooksRetryPolicy retryPolicy = new Notificationsubscriptionsv1webhooksRetryPolicy( + Algorithm: retryPolicyAlgorithm, + FirstRetry: retryPolicyFirstRetry, + Interval: retryPolicyInterval, + NumberOfRetries: retryPolicyNumberOfRetries, + DeactivateFlag: retryPolicyDeactivateFlag, + RepeatSequenceCount: retryPolicyRepeatSequenceCount, + RepeatSequenceWaitTime: retryPolicyRepeatSequenceWaitTime + ); + + string securityPolicySecurityType = "KEY"; + string securityPolicyProxyType = "external"; + Notificationsubscriptionsv1webhooksSecurityPolicy1 securityPolicy = new Notificationsubscriptionsv1webhooksSecurityPolicy1( + SecurityType: securityPolicySecurityType, + ProxyType: securityPolicyProxyType + ); + + var requestObj = new CreateWebhookRequest( + Name: name, + Description: description, + OrganizationId: organizationId, + ProductId: productId, + EventTypes: eventTypes, + WebhookUrl: webhookUrl, + HealthCheckUrl: healthCheckUrl, + NotificationScope: notificationScope, + RetryPolicy: retryPolicy, + SecurityPolicy: securityPolicy + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.CreateWebhookSubscription(requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/CreateDecisionManagerWebhook.cs b/Source/Samples/Webhooks/CreateNewWebhooks/CreateDecisionManagerWebhook.cs new file mode 100644 index 0000000..7e64a61 --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/CreateDecisionManagerWebhook.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class CreateDecisionManagerWebhook + { + public static void Run() + { + string name = "My Custom Webhook"; + string description = "Sample Webhook from Developer Center"; + string organizationId = ""; + string productId = "decisionManager"; + + List eventTypes = new List (); + eventTypes.Add("risk.profile.decision.reject"); + eventTypes.Add("risk.casemanagement.addnote"); + eventTypes.Add("risk.casemanagement.decision.accept"); + eventTypes.Add("risk.casemanagement.decision.reject"); + string webhookUrl = "https://MyWebhookServer.com:8443/simulateClient"; + string healthCheckUrl = "https://MyWebhookServer.com:8443/simulateClientHealthCheck"; + string notificationScope = "SELF"; + string retryPolicyAlgorithm = "ARITHMETIC"; + int retryPolicyFirstRetry = 1; + int retryPolicyInterval = 1; + int retryPolicyNumberOfRetries = 3; + string retryPolicyDeactivateFlag = "false"; + int retryPolicyRepeatSequenceCount = 0; + int retryPolicyRepeatSequenceWaitTime = 0; + Notificationsubscriptionsv1webhooksRetryPolicy retryPolicy = new Notificationsubscriptionsv1webhooksRetryPolicy( + Algorithm: retryPolicyAlgorithm, + FirstRetry: retryPolicyFirstRetry, + Interval: retryPolicyInterval, + NumberOfRetries: retryPolicyNumberOfRetries, + DeactivateFlag: retryPolicyDeactivateFlag, + RepeatSequenceCount: retryPolicyRepeatSequenceCount, + RepeatSequenceWaitTime: retryPolicyRepeatSequenceWaitTime + ); + + string securityPolicySecurityType = "KEY"; + string securityPolicyProxyType = "external"; + Notificationsubscriptionsv1webhooksSecurityPolicy1 securityPolicy = new Notificationsubscriptionsv1webhooksSecurityPolicy1( + SecurityType: securityPolicySecurityType, + ProxyType: securityPolicyProxyType + ); + + var requestObj = new CreateWebhookRequest( + Name: name, + Description: description, + OrganizationId: organizationId, + ProductId: productId, + EventTypes: eventTypes, + WebhookUrl: webhookUrl, + HealthCheckUrl: healthCheckUrl, + NotificationScope: notificationScope, + RetryPolicy: retryPolicy, + SecurityPolicy: securityPolicy + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.CreateWebhookSubscription(requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/CreateFraudManagementWebhook.cs b/Source/Samples/Webhooks/CreateNewWebhooks/CreateFraudManagementWebhook.cs new file mode 100644 index 0000000..f8d1fb8 --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/CreateFraudManagementWebhook.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class CreateFraudManagementWebhook + { + public static void Run() + { + string name = "My Custom Webhook"; + string description = "Sample Webhook from Developer Center"; + string organizationId = ""; + string productId = "fraudManagementEssentials"; + + List eventTypes = new List (); + eventTypes.Add("risk.profile.decision.review"); + eventTypes.Add("risk.profile.decision.reject"); + eventTypes.Add("risk.profile.decision.monitor"); + eventTypes.Add("risk.casemanagement.addnote"); + eventTypes.Add("risk.casemanagement.decision.accept"); + eventTypes.Add("risk.casemanagement.decision.reject"); + string webhookUrl = "https://MyWebhookServer.com:8443/simulateClient"; + string healthCheckUrl = "https://MyWebhookServer.com:8443/simulateClientHealthCheck"; + string notificationScope = "SELF"; + string retryPolicyAlgorithm = "ARITHMETIC"; + int retryPolicyFirstRetry = 1; + int retryPolicyInterval = 1; + int retryPolicyNumberOfRetries = 3; + string retryPolicyDeactivateFlag = "false"; + int retryPolicyRepeatSequenceCount = 0; + int retryPolicyRepeatSequenceWaitTime = 0; + Notificationsubscriptionsv1webhooksRetryPolicy retryPolicy = new Notificationsubscriptionsv1webhooksRetryPolicy( + Algorithm: retryPolicyAlgorithm, + FirstRetry: retryPolicyFirstRetry, + Interval: retryPolicyInterval, + NumberOfRetries: retryPolicyNumberOfRetries, + DeactivateFlag: retryPolicyDeactivateFlag, + RepeatSequenceCount: retryPolicyRepeatSequenceCount, + RepeatSequenceWaitTime: retryPolicyRepeatSequenceWaitTime + ); + + string securityPolicySecurityType = "KEY"; + string securityPolicyProxyType = "external"; + Notificationsubscriptionsv1webhooksSecurityPolicy1 securityPolicy = new Notificationsubscriptionsv1webhooksSecurityPolicy1( + SecurityType: securityPolicySecurityType, + ProxyType: securityPolicyProxyType + ); + + var requestObj = new CreateWebhookRequest( + Name: name, + Description: description, + OrganizationId: organizationId, + ProductId: productId, + EventTypes: eventTypes, + WebhookUrl: webhookUrl, + HealthCheckUrl: healthCheckUrl, + NotificationScope: notificationScope, + RetryPolicy: retryPolicy, + SecurityPolicy: securityPolicy + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.CreateWebhookSubscription(requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/CreateInvoicingWebhook.cs b/Source/Samples/Webhooks/CreateNewWebhooks/CreateInvoicingWebhook.cs new file mode 100644 index 0000000..a3d57d9 --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/CreateInvoicingWebhook.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class CreateInvoicingWebhook + { + public static void Run() + { + string name = "My Custom Webhook"; + string description = "Sample Webhook from Developer Center"; + string organizationId = ""; + string productId = "customerInvoicing"; + + List eventTypes = new List (); + eventTypes.Add("invoicing.customer.invoice.cancel"); + eventTypes.Add("invoicing.customer.invoice.overdue-reminder"); + eventTypes.Add("invoicing.customer.invoice.paid"); + eventTypes.Add("invoicing.customer.invoice.partial-payment"); + eventTypes.Add("invoicing.customer.invoice.partial-resend"); + eventTypes.Add("invoicing.customer.invoice.reminder"); + eventTypes.Add("invoicing.customer.invoice.send"); + string webhookUrl = "https://MyWebhookServer.com:8443/simulateClient"; + string healthCheckUrl = "https://MyWebhookServer.com:8443/simulateClientHealthCheck"; + string notificationScope = "SELF"; + string retryPolicyAlgorithm = "ARITHMETIC"; + int retryPolicyFirstRetry = 1; + int retryPolicyInterval = 1; + int retryPolicyNumberOfRetries = 3; + string retryPolicyDeactivateFlag = "false"; + int retryPolicyRepeatSequenceCount = 0; + int retryPolicyRepeatSequenceWaitTime = 0; + Notificationsubscriptionsv1webhooksRetryPolicy retryPolicy = new Notificationsubscriptionsv1webhooksRetryPolicy( + Algorithm: retryPolicyAlgorithm, + FirstRetry: retryPolicyFirstRetry, + Interval: retryPolicyInterval, + NumberOfRetries: retryPolicyNumberOfRetries, + DeactivateFlag: retryPolicyDeactivateFlag, + RepeatSequenceCount: retryPolicyRepeatSequenceCount, + RepeatSequenceWaitTime: retryPolicyRepeatSequenceWaitTime + ); + + string securityPolicySecurityType = "KEY"; + string securityPolicyProxyType = "external"; + Notificationsubscriptionsv1webhooksSecurityPolicy1 securityPolicy = new Notificationsubscriptionsv1webhooksSecurityPolicy1( + SecurityType: securityPolicySecurityType, + ProxyType: securityPolicyProxyType + ); + + var requestObj = new CreateWebhookRequest( + Name: name, + Description: description, + OrganizationId: organizationId, + ProductId: productId, + EventTypes: eventTypes, + WebhookUrl: webhookUrl, + HealthCheckUrl: healthCheckUrl, + NotificationScope: notificationScope, + RetryPolicy: retryPolicy, + SecurityPolicy: securityPolicy + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.CreateWebhookSubscription(requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/CreateOutageAndKeyExpirationNotificationWebhook.cs b/Source/Samples/Webhooks/CreateNewWebhooks/CreateOutageAndKeyExpirationNotificationWebhook.cs new file mode 100644 index 0000000..a95a830 --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/CreateOutageAndKeyExpirationNotificationWebhook.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class CreateOutageAndKeyExpirationNotificationWebhook + { + public static void Run() + { + string name = "My Custom Webhook"; + string description = "Sample Webhook from Developer Center"; + string organizationId = ""; + string productId = "cns"; + + List eventTypes = new List (); + eventTypes.Add("cns.outage.notify.freeform"); + eventTypes.Add("cns.report.keyExpiration.detail"); + string webhookUrl = "https://MyWebhookServer.com:8443/simulateClient"; + string healthCheckUrl = "https://MyWebhookServer.com:8443/simulateClientHealthCheck"; + string notificationScope = "SELF"; + string retryPolicyAlgorithm = "ARITHMETIC"; + int retryPolicyFirstRetry = 1; + int retryPolicyInterval = 1; + int retryPolicyNumberOfRetries = 3; + string retryPolicyDeactivateFlag = "false"; + int retryPolicyRepeatSequenceCount = 0; + int retryPolicyRepeatSequenceWaitTime = 0; + Notificationsubscriptionsv1webhooksRetryPolicy retryPolicy = new Notificationsubscriptionsv1webhooksRetryPolicy( + Algorithm: retryPolicyAlgorithm, + FirstRetry: retryPolicyFirstRetry, + Interval: retryPolicyInterval, + NumberOfRetries: retryPolicyNumberOfRetries, + DeactivateFlag: retryPolicyDeactivateFlag, + RepeatSequenceCount: retryPolicyRepeatSequenceCount, + RepeatSequenceWaitTime: retryPolicyRepeatSequenceWaitTime + ); + + string securityPolicySecurityType = "KEY"; + string securityPolicyProxyType = "external"; + Notificationsubscriptionsv1webhooksSecurityPolicy1 securityPolicy = new Notificationsubscriptionsv1webhooksSecurityPolicy1( + SecurityType: securityPolicySecurityType, + ProxyType: securityPolicyProxyType + ); + + var requestObj = new CreateWebhookRequest( + Name: name, + Description: description, + OrganizationId: organizationId, + ProductId: productId, + EventTypes: eventTypes, + WebhookUrl: webhookUrl, + HealthCheckUrl: healthCheckUrl, + NotificationScope: notificationScope, + RetryPolicy: retryPolicy, + SecurityPolicy: securityPolicy + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.CreateWebhookSubscription(requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/CreateRecurringBillingWebhook.cs b/Source/Samples/Webhooks/CreateNewWebhooks/CreateRecurringBillingWebhook.cs new file mode 100644 index 0000000..efa95b5 --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/CreateRecurringBillingWebhook.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class CreateRecurringBillingWebhook + { + public static void Run() + { + string name = "My Custom Webhook"; + string description = "Sample Webhook from Developer Center"; + string organizationId = ""; + string productId = "recurringBilling"; + + List eventTypes = new List (); + eventTypes.Add("rbs.subscriptions.charge.pre-notified"); + eventTypes.Add("rbs.subscriptions.charge.created"); + eventTypes.Add("rbs.subscriptions.charge.failed"); + string webhookUrl = "https://MyWebhookServer.com:8443/simulateClient"; + string healthCheckUrl = "https://MyWebhookServer.com:8443/simulateClientHealthCheck"; + string notificationScope = "SELF"; + string retryPolicyAlgorithm = "ARITHMETIC"; + int retryPolicyFirstRetry = 1; + int retryPolicyInterval = 1; + int retryPolicyNumberOfRetries = 3; + string retryPolicyDeactivateFlag = "false"; + int retryPolicyRepeatSequenceCount = 0; + int retryPolicyRepeatSequenceWaitTime = 0; + Notificationsubscriptionsv1webhooksRetryPolicy retryPolicy = new Notificationsubscriptionsv1webhooksRetryPolicy( + Algorithm: retryPolicyAlgorithm, + FirstRetry: retryPolicyFirstRetry, + Interval: retryPolicyInterval, + NumberOfRetries: retryPolicyNumberOfRetries, + DeactivateFlag: retryPolicyDeactivateFlag, + RepeatSequenceCount: retryPolicyRepeatSequenceCount, + RepeatSequenceWaitTime: retryPolicyRepeatSequenceWaitTime + ); + + string securityPolicySecurityType = "KEY"; + string securityPolicyProxyType = "external"; + Notificationsubscriptionsv1webhooksSecurityPolicy1 securityPolicy = new Notificationsubscriptionsv1webhooksSecurityPolicy1( + SecurityType: securityPolicySecurityType, + ProxyType: securityPolicyProxyType + ); + + var requestObj = new CreateWebhookRequest( + Name: name, + Description: description, + OrganizationId: organizationId, + ProductId: productId, + EventTypes: eventTypes, + WebhookUrl: webhookUrl, + HealthCheckUrl: healthCheckUrl, + NotificationScope: notificationScope, + RetryPolicy: retryPolicy, + SecurityPolicy: securityPolicy + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.CreateWebhookSubscription(requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/CreateSecureAcceptanceWebhook.cs b/Source/Samples/Webhooks/CreateNewWebhooks/CreateSecureAcceptanceWebhook.cs new file mode 100644 index 0000000..fc244d1 --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/CreateSecureAcceptanceWebhook.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class CreateSecureAcceptanceWebhook + { + public static void Run() + { + string name = "My Custom Webhook"; + string description = "Sample Webhook from Developer Center"; + string organizationId = ""; + string productId = "secureAcceptance"; + + List eventTypes = new List (); + eventTypes.Add("sa.orders.rawtransactionresults"); + eventTypes.Add("sa.orders.cardholderreceipts"); + eventTypes.Add("sa.orders.merchantreceipts"); + string webhookUrl = "https://MyWebhookServer.com:8443/simulateClient"; + string healthCheckUrl = "https://MyWebhookServer.com:8443/simulateClientHealthCheck"; + string notificationScope = "SELF"; + string retryPolicyAlgorithm = "ARITHMETIC"; + int retryPolicyFirstRetry = 1; + int retryPolicyInterval = 1; + int retryPolicyNumberOfRetries = 3; + string retryPolicyDeactivateFlag = "false"; + int retryPolicyRepeatSequenceCount = 0; + int retryPolicyRepeatSequenceWaitTime = 0; + Notificationsubscriptionsv1webhooksRetryPolicy retryPolicy = new Notificationsubscriptionsv1webhooksRetryPolicy( + Algorithm: retryPolicyAlgorithm, + FirstRetry: retryPolicyFirstRetry, + Interval: retryPolicyInterval, + NumberOfRetries: retryPolicyNumberOfRetries, + DeactivateFlag: retryPolicyDeactivateFlag, + RepeatSequenceCount: retryPolicyRepeatSequenceCount, + RepeatSequenceWaitTime: retryPolicyRepeatSequenceWaitTime + ); + + string securityPolicySecurityType = "KEY"; + string securityPolicyProxyType = "external"; + Notificationsubscriptionsv1webhooksSecurityPolicy1 securityPolicy = new Notificationsubscriptionsv1webhooksSecurityPolicy1( + SecurityType: securityPolicySecurityType, + ProxyType: securityPolicyProxyType + ); + + var requestObj = new CreateWebhookRequest( + Name: name, + Description: description, + OrganizationId: organizationId, + ProductId: productId, + EventTypes: eventTypes, + WebhookUrl: webhookUrl, + HealthCheckUrl: healthCheckUrl, + NotificationScope: notificationScope, + RetryPolicy: retryPolicy, + SecurityPolicy: securityPolicy + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.CreateWebhookSubscription(requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/CreateTerminalManagementWebhook.cs b/Source/Samples/Webhooks/CreateNewWebhooks/CreateTerminalManagementWebhook.cs new file mode 100644 index 0000000..ab92489 --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/CreateTerminalManagementWebhook.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class CreateTerminalManagementWebhook + { + public static void Run() + { + string name = "My Custom Webhook"; + string description = "Sample Webhook from Developer Center"; + string organizationId = ""; + string productId = "terminalManagement"; + + List eventTypes = new List (); + eventTypes.Add("terminalManagement.assignment.update"); + eventTypes.Add("terminalManagement.status.update"); + eventTypes.Add("terminalManagement.reAssignment.update"); + string webhookUrl = "https://MyWebhookServer.com:8443/simulateClient"; + string healthCheckUrl = "https://MyWebhookServer.com:8443/simulateClientHealthCheck"; + string notificationScope = "SELF"; + string retryPolicyAlgorithm = "ARITHMETIC"; + int retryPolicyFirstRetry = 1; + int retryPolicyInterval = 1; + int retryPolicyNumberOfRetries = 3; + string retryPolicyDeactivateFlag = "false"; + int retryPolicyRepeatSequenceCount = 0; + int retryPolicyRepeatSequenceWaitTime = 0; + Notificationsubscriptionsv1webhooksRetryPolicy retryPolicy = new Notificationsubscriptionsv1webhooksRetryPolicy( + Algorithm: retryPolicyAlgorithm, + FirstRetry: retryPolicyFirstRetry, + Interval: retryPolicyInterval, + NumberOfRetries: retryPolicyNumberOfRetries, + DeactivateFlag: retryPolicyDeactivateFlag, + RepeatSequenceCount: retryPolicyRepeatSequenceCount, + RepeatSequenceWaitTime: retryPolicyRepeatSequenceWaitTime + ); + + string securityPolicySecurityType = "KEY"; + string securityPolicyProxyType = "external"; + Notificationsubscriptionsv1webhooksSecurityPolicy1 securityPolicy = new Notificationsubscriptionsv1webhooksSecurityPolicy1( + SecurityType: securityPolicySecurityType, + ProxyType: securityPolicyProxyType + ); + + var requestObj = new CreateWebhookRequest( + Name: name, + Description: description, + OrganizationId: organizationId, + ProductId: productId, + EventTypes: eventTypes, + WebhookUrl: webhookUrl, + HealthCheckUrl: healthCheckUrl, + NotificationScope: notificationScope, + RetryPolicy: retryPolicy, + SecurityPolicy: securityPolicy + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.CreateWebhookSubscription(requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/CreateTokenManagementWebhook.cs b/Source/Samples/Webhooks/CreateNewWebhooks/CreateTokenManagementWebhook.cs new file mode 100644 index 0000000..2054cff --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/CreateTokenManagementWebhook.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class CreateTokenManagementWebhook + { + public static void Run() + { + string name = "My Custom Webhook"; + string description = "Sample Webhook from Developer Center"; + string organizationId = ""; + string productId = "tokenManagement"; + + List eventTypes = new List (); + eventTypes.Add("tms.networktoken.provisioned"); + eventTypes.Add("tms.networktoken.updated"); + eventTypes.Add("tms.token.pan_updated"); + eventTypes.Add("tms.token.created"); + eventTypes.Add("tms.token.updated"); + string webhookUrl = "https://MyWebhookServer.com:8443/simulateClient"; + string healthCheckUrl = "https://MyWebhookServer.com:8443/simulateClientHealthCheck"; + string notificationScope = "SELF"; + string retryPolicyAlgorithm = "ARITHMETIC"; + int retryPolicyFirstRetry = 1; + int retryPolicyInterval = 1; + int retryPolicyNumberOfRetries = 3; + string retryPolicyDeactivateFlag = "false"; + int retryPolicyRepeatSequenceCount = 0; + int retryPolicyRepeatSequenceWaitTime = 0; + Notificationsubscriptionsv1webhooksRetryPolicy retryPolicy = new Notificationsubscriptionsv1webhooksRetryPolicy( + Algorithm: retryPolicyAlgorithm, + FirstRetry: retryPolicyFirstRetry, + Interval: retryPolicyInterval, + NumberOfRetries: retryPolicyNumberOfRetries, + DeactivateFlag: retryPolicyDeactivateFlag, + RepeatSequenceCount: retryPolicyRepeatSequenceCount, + RepeatSequenceWaitTime: retryPolicyRepeatSequenceWaitTime + ); + + string securityPolicySecurityType = "KEY"; + string securityPolicyProxyType = "external"; + Notificationsubscriptionsv1webhooksSecurityPolicy1 securityPolicy = new Notificationsubscriptionsv1webhooksSecurityPolicy1( + SecurityType: securityPolicySecurityType, + ProxyType: securityPolicyProxyType + ); + + var requestObj = new CreateWebhookRequest( + Name: name, + Description: description, + OrganizationId: organizationId, + ProductId: productId, + EventTypes: eventTypes, + WebhookUrl: webhookUrl, + HealthCheckUrl: healthCheckUrl, + NotificationScope: notificationScope, + RetryPolicy: retryPolicy, + SecurityPolicy: securityPolicy + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.CreateWebhookSubscription(requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/CreateWebhookSymmetricKey.cs b/Source/Samples/Webhooks/CreateNewWebhooks/CreateWebhookSymmetricKey.cs new file mode 100644 index 0000000..ac476e0 --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/CreateWebhookSymmetricKey.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class CreateWebhookSymmetricKey + { + public static void Run(string vCcorrelationId, string vCsenderOrganizationId, string vCpermissions) + { + string clientRequestAction = "CREATE"; + string keyInformationProvider = "nrtd"; + string keyInformationTenant = ""; + string keyInformationKeyType = "sharedSecret"; + string keyInformationOrganizationId = ""; + Kmsegressv2keyssymKeyInformation keyInformation = new Kmsegressv2keyssymKeyInformation( + Provider: keyInformationProvider, + Tenant: keyInformationTenant, + KeyType: keyInformationKeyType, + OrganizationId: keyInformationOrganizationId + ); + + var requestObj = new SaveSymEgressKey( + ClientRequestAction: clientRequestAction, + KeyInformation: keyInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.SaveSymEgressKey(vCsenderOrganizationId, vCpermissions, vCcorrelationId, requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/CreateWebhookUsingOAuthWithClientCredentials.cs b/Source/Samples/Webhooks/CreateNewWebhooks/CreateWebhookUsingOAuthWithClientCredentials.cs new file mode 100644 index 0000000..7410a0a --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/CreateWebhookUsingOAuthWithClientCredentials.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class CreateWebhookUsingOAuthWithClientCredentials + { + public static void Run() + { + string name = "My Custom Webhook"; + string description = "Sample Webhook from Developer Center"; + string organizationId = ""; + string productId = "terminalManagement"; + + List eventTypes = new List (); + eventTypes.Add("terminalManagement.assignment.update"); + string webhookUrl = "https://MyWebhookServer.com:8443/simulateClient"; + string healthCheckUrl = "https://MyWebhookServer.com:8443/simulateClientHealthCheck"; + string notificationScope = "SELF"; + string retryPolicyAlgorithm = "ARITHMETIC"; + int retryPolicyFirstRetry = 1; + int retryPolicyInterval = 1; + int retryPolicyNumberOfRetries = 3; + string retryPolicyDeactivateFlag = "false"; + int retryPolicyRepeatSequenceCount = 0; + int retryPolicyRepeatSequenceWaitTime = 0; + Notificationsubscriptionsv1webhooksRetryPolicy retryPolicy = new Notificationsubscriptionsv1webhooksRetryPolicy( + Algorithm: retryPolicyAlgorithm, + FirstRetry: retryPolicyFirstRetry, + Interval: retryPolicyInterval, + NumberOfRetries: retryPolicyNumberOfRetries, + DeactivateFlag: retryPolicyDeactivateFlag, + RepeatSequenceCount: retryPolicyRepeatSequenceCount, + RepeatSequenceWaitTime: retryPolicyRepeatSequenceWaitTime + ); + + string securityPolicySecurityType = "oAuth"; + string securityPolicyProxyType = "external"; + string securityPolicyConfigOAuthTokenExpiry = "365"; + string securityPolicyConfigOAuthURL = "https://MyWebhookServer.com:8443/oAuthToken"; + string securityPolicyConfigOAuthTokenType = "Bearer"; + Notificationsubscriptionsv1webhooksSecurityPolicy1Config securityPolicyConfig = new Notificationsubscriptionsv1webhooksSecurityPolicy1Config( + OAuthTokenExpiry: securityPolicyConfigOAuthTokenExpiry, + OAuthURL: securityPolicyConfigOAuthURL, + OAuthTokenType: securityPolicyConfigOAuthTokenType + ); + + Notificationsubscriptionsv1webhooksSecurityPolicy1 securityPolicy = new Notificationsubscriptionsv1webhooksSecurityPolicy1( + SecurityType: securityPolicySecurityType, + ProxyType: securityPolicyProxyType, + Config: securityPolicyConfig + ); + + var requestObj = new CreateWebhookRequest( + Name: name, + Description: description, + OrganizationId: organizationId, + ProductId: productId, + EventTypes: eventTypes, + WebhookUrl: webhookUrl, + HealthCheckUrl: healthCheckUrl, + NotificationScope: notificationScope, + RetryPolicy: retryPolicy, + SecurityPolicy: securityPolicy + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.CreateWebhookSubscription(requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/CreateWebhookUsingOAuthWithJWT.cs b/Source/Samples/Webhooks/CreateNewWebhooks/CreateWebhookUsingOAuthWithJWT.cs new file mode 100644 index 0000000..aca9051 --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/CreateWebhookUsingOAuthWithJWT.cs @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class CreateWebhookUsingOAuthWithJWT + { + public static void Run() + { + string name = "My Custom Webhook"; + string description = "Sample Webhook from Developer Center"; + string organizationId = ""; + string productId = "terminalManagement"; + + List eventTypes = new List (); + eventTypes.Add("terminalManagement.assignment.update"); + string webhookUrl = "https://MyWebhookServer.com:8443/simulateClient"; + string healthCheckUrl = "https://MyWebhookServer.com:8443/simulateClientHealthCheck"; + string notificationScope = "SELF"; + string retryPolicyAlgorithm = "ARITHMETIC"; + int retryPolicyFirstRetry = 1; + int retryPolicyInterval = 1; + int retryPolicyNumberOfRetries = 3; + string retryPolicyDeactivateFlag = "false"; + int retryPolicyRepeatSequenceCount = 0; + int retryPolicyRepeatSequenceWaitTime = 0; + Notificationsubscriptionsv1webhooksRetryPolicy retryPolicy = new Notificationsubscriptionsv1webhooksRetryPolicy( + Algorithm: retryPolicyAlgorithm, + FirstRetry: retryPolicyFirstRetry, + Interval: retryPolicyInterval, + NumberOfRetries: retryPolicyNumberOfRetries, + DeactivateFlag: retryPolicyDeactivateFlag, + RepeatSequenceCount: retryPolicyRepeatSequenceCount, + RepeatSequenceWaitTime: retryPolicyRepeatSequenceWaitTime + ); + + string securityPolicySecurityType = "oAuth_JWT"; + string securityPolicyProxyType = "external"; + string securityPolicyConfigOAuthTokenExpiry = "365"; + string securityPolicyConfigOAuthURL = "https://MyWebhookServer.com:8443/oAuthToken"; + string securityPolicyConfigOAuthTokenType = "Bearer"; + string securityPolicyConfigAdditionalConfigAud = "idp.api.myServer.com"; + string securityPolicyConfigAdditionalConfigClientId = "650538A1-7AB0-AD3A-51AB-932ABC57AD70"; + string securityPolicyConfigAdditionalConfigKeyId = "y-daaaAVyF0176M7-eAZ34pR9Ts"; + string securityPolicyConfigAdditionalConfigScope = "merchantacq:rte:write"; + Notificationsubscriptionsv1webhooksSecurityPolicy1ConfigAdditionalConfig securityPolicyConfigAdditionalConfig = new Notificationsubscriptionsv1webhooksSecurityPolicy1ConfigAdditionalConfig( + Aud: securityPolicyConfigAdditionalConfigAud, + ClientId: securityPolicyConfigAdditionalConfigClientId, + KeyId: securityPolicyConfigAdditionalConfigKeyId, + Scope: securityPolicyConfigAdditionalConfigScope + ); + + Notificationsubscriptionsv1webhooksSecurityPolicy1Config securityPolicyConfig = new Notificationsubscriptionsv1webhooksSecurityPolicy1Config( + OAuthTokenExpiry: securityPolicyConfigOAuthTokenExpiry, + OAuthURL: securityPolicyConfigOAuthURL, + OAuthTokenType: securityPolicyConfigOAuthTokenType, + AdditionalConfig: securityPolicyConfigAdditionalConfig + ); + + Notificationsubscriptionsv1webhooksSecurityPolicy1 securityPolicy = new Notificationsubscriptionsv1webhooksSecurityPolicy1( + SecurityType: securityPolicySecurityType, + ProxyType: securityPolicyProxyType, + Config: securityPolicyConfig + ); + + var requestObj = new CreateWebhookRequest( + Name: name, + Description: description, + OrganizationId: organizationId, + ProductId: productId, + EventTypes: eventTypes, + WebhookUrl: webhookUrl, + HealthCheckUrl: healthCheckUrl, + NotificationScope: notificationScope, + RetryPolicy: retryPolicy, + SecurityPolicy: securityPolicy + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.CreateWebhookSubscription(requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/FindProductsYouCanSubscribeTo.cs b/Source/Samples/Webhooks/CreateNewWebhooks/FindProductsYouCanSubscribeTo.cs new file mode 100644 index 0000000..699127e --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/FindProductsYouCanSubscribeTo.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class FindProductsYouCanSubscribeTo + { + public static void Run(string organizationId) + { + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.FindProductsToSubscribe(organizationId); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/CreateNewWebhooks/StoreOAuthCredentials.cs b/Source/Samples/Webhooks/CreateNewWebhooks/StoreOAuthCredentials.cs new file mode 100644 index 0000000..3fc414b --- /dev/null +++ b/Source/Samples/Webhooks/CreateNewWebhooks/StoreOAuthCredentials.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.CreateNewWebhooks +{ + public class StoreOAuthCredentials + { + public static void Run(string vCcorrelationId, string vCsenderOrganizationId, string vCpermissions) + { + string clientRequestAction = "STORE"; + string keyInformationProvider = ""; + string keyInformationTenant = "nrtd"; + string keyInformationKeyType = "oAuthClientCredentials"; + string keyInformationOrganizationId = ""; + string keyInformationClientKeyId = "client username"; + string keyInformationKey = "client secret"; + string keyInformationExpiryDuration = "365"; + Kmsegressv2keyssymKeyInformation keyInformation = new Kmsegressv2keyssymKeyInformation( + Provider: keyInformationProvider, + Tenant: keyInformationTenant, + KeyType: keyInformationKeyType, + OrganizationId: keyInformationOrganizationId, + ClientKeyId: keyInformationClientKeyId, + Key: keyInformationKey, + ExpiryDuration: keyInformationExpiryDuration + ); + + var requestObj = new SaveSymEgressKey( + ClientRequestAction: clientRequestAction, + KeyInformation: keyInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new CreateNewWebhooksApi(clientConfig); + apiInstance.SaveSymEgressKey(vCsenderOrganizationId, vCpermissions, vCcorrelationId, requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/ManageWebhooks/CreateAsymmetricKey.cs b/Source/Samples/Webhooks/ManageWebhooks/CreateAsymmetricKey.cs new file mode 100644 index 0000000..95b1733 --- /dev/null +++ b/Source/Samples/Webhooks/ManageWebhooks/CreateAsymmetricKey.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.ManageWebhooks +{ + public class CreateAsymmetricKey + { + public static InlineResponse2015 Run(string vCcorrelationId, string vCsenderOrganizationId, string vCpermissions) + { + string clientRequestAction = "STORE"; + string keyInformationProvider = "merchantName"; + string keyInformationTenant = "nrtd"; + string keyInformationKeyType = "publickey"; + string keyInformationOrganizationId = "merchantName"; + string keyInformationPub = "MIIDbDCCAlQCCQD4lcSlmasmCTANBgkqhkiG9w0BAQsFADB4MQswCQYDVQQGEwJVUzELMAkGA1UECAwCVFgxDzANBgNVBAcMBkF1c3RpbjENMAsGA1UECgwEVGVzdDEOMAwGA1UECwwFVGVzdDIxDjAMBgNVBAMMBVRlc3QzMRwwGgYJKoZIhvcNAQkBFg10ZXN0QHRlc3QuY29tMB4XDTIxMDgwOTE0MTcxNFoXDTIyMDgwOTE0MTcxNFoweDELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAlRYMQ8wDQYDVQQHDAZBdXN0aW4xDTALBgNVBAoMBFRlc3QxDjAMBgNVBAsMBVRlc3QyMQ4wDAYDVQQDDAVUZXN0MzEcMBoGCSqGSIb3DQEJARYNdGVzdEB0ZXN0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMcHQWZRETqim3XzUQlAiujFEvsHIi1uJZKj+1lvPH36Ucqo3ORcoh/MM/zxVdahjhSyyp7MHuKBWnzft6bFeDEul6qKWGPAAzaxG/2xZSV3FggA9SyAZEDUpJ6mblwqm/EY4KmZi1FrNBUHfW2wwaqDexHPRDesRG6aI7Wuu4GdQUUqoTa2+Nv7kVgEDmGcfIjoWkGKHe+Yan95EITrq4jEFCE5Tg/vERnMvHfK2SovENZ13/pnwFYbeh1kfJSBzWW7yq8AyQAgAE9iqJXbJ/MAasir2vjUQ2+Hcl7WbkpoVjLqDt3rzV1T0Bsd4T9SC3wij9qjJSxa6vAgV4xn6bECAwEAATANBgkqhkiG9w0BAQsFAAOCAQEADuMrtYW1Sf0IsZ4ZD9ipjUrFuTxqh+0M5Jk8h0QqAXEHA/MawedlU3JmE3NB/UR82/XUwdmtObGnFANuUQQ+8WMFpcNo/Sq2kg7juneHZroRh72o73UUMtHWHzo8s0fXElNal8h3SaAAnjMblCiN+gM1RvWMvhGrMTXp2XAcdIezXf8/FOZLlzOF9QylbSk1U4ayWBag6MydkxgHjkPKdShZROEm0oz/O7J/gNp/r7J8F42Rw9MmJh9qH3SFre13nQa8V7Kg+dJHZ/jpGtSlDHAxO0SSTrPXkwB+iBJ6hSkiL/J2Ep+lYHqVe3p5NXMOlTtJdbU4enHeLkD6PazKTw"; + string keyInformationExpiryDuration = "365"; + Kmsegressv2keysasymKeyInformation keyInformation = new Kmsegressv2keysasymKeyInformation( + Provider: keyInformationProvider, + Tenant: keyInformationTenant, + KeyType: keyInformationKeyType, + OrganizationId: keyInformationOrganizationId, + Pub: keyInformationPub, + ExpiryDuration: keyInformationExpiryDuration + ); + + var requestObj = new SaveAsymEgressKey( + ClientRequestAction: clientRequestAction, + KeyInformation: keyInformation + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ManageWebhooksApi(clientConfig); + InlineResponse2015 result = apiInstance.SaveAsymEgressKey(vCsenderOrganizationId, vCpermissions, requestObj, vCcorrelationId); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/ManageWebhooks/DeleteWebhookSubscription.cs b/Source/Samples/Webhooks/ManageWebhooks/DeleteWebhookSubscription.cs new file mode 100644 index 0000000..df80d99 --- /dev/null +++ b/Source/Samples/Webhooks/ManageWebhooks/DeleteWebhookSubscription.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.ManageWebhooks +{ + public class DeleteWebhookSubscription + { + public static void Run(string webhookId) + { + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ManageWebhooksApi(clientConfig); + apiInstance.DeleteWebhookSubscription(webhookId); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/ManageWebhooks/GetDetailsOnAllCreatedWebhooks.cs b/Source/Samples/Webhooks/ManageWebhooks/GetDetailsOnAllCreatedWebhooks.cs new file mode 100644 index 0000000..3f95284 --- /dev/null +++ b/Source/Samples/Webhooks/ManageWebhooks/GetDetailsOnAllCreatedWebhooks.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.ManageWebhooks +{ + public class GetDetailsOnAllCreatedWebhooks + { + public static List Run() + { + // QUERY PARAMETERS + string organizationId = "testrest"; + string productId = "testProductId"; + string eventType = "testEventType"; + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ManageWebhooksApi(clientConfig); + List result = apiInstance.GetWebhookSubscriptionsByOrg(organizationId, productId, eventType); + Console.WriteLine(result); + return result; + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + return null; + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/ManageWebhooks/GetDetailsOnSingleWebhook.cs b/Source/Samples/Webhooks/ManageWebhooks/GetDetailsOnSingleWebhook.cs new file mode 100644 index 0000000..badcdde --- /dev/null +++ b/Source/Samples/Webhooks/ManageWebhooks/GetDetailsOnSingleWebhook.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.ManageWebhooks +{ + public class GetDetailsOnSingleWebhook + { + public static void Run(string webhookId) + { + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ManageWebhooksApi(clientConfig); + apiInstance.GetWebhookSubscriptionById(webhookId); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/ManageWebhooks/ReplayFailedTransactionsBySetStartAndEndTime.cs b/Source/Samples/Webhooks/ManageWebhooks/ReplayFailedTransactionsBySetStartAndEndTime.cs new file mode 100644 index 0000000..87eb994 --- /dev/null +++ b/Source/Samples/Webhooks/ManageWebhooks/ReplayFailedTransactionsBySetStartAndEndTime.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.ManageWebhooks +{ + public class ReplayFailedTransactionsBySetStartAndEndTime + { + public static void Run(string webhookId) + { + string byDeliveryStatusStatus = "FAILED"; + var byDeliveryStatusStartTime = DateTime.Parse("2021-01-01T15:05:52.284+05:30"); + var byDeliveryStatusEndTime = DateTime.Parse("2021-01-02T03:05:52.284+05:30"); + string byDeliveryStatusProductId = "tokenManagement"; + string byDeliveryStatusEventType = "tms.token.created"; + Nrtfv1webhookswebhookIdreplaysByDeliveryStatus byDeliveryStatus = new Nrtfv1webhookswebhookIdreplaysByDeliveryStatus( + Status: byDeliveryStatusStatus, + StartTime: byDeliveryStatusStartTime, + EndTime: byDeliveryStatusEndTime, + ProductId: byDeliveryStatusProductId, + EventType: byDeliveryStatusEventType + ); + + var requestObj = new ReplayWebhooksRequest( + ByDeliveryStatus: byDeliveryStatus + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReplayWebhooksApi(clientConfig); + apiInstance.ReplayPreviousWebhooks(webhookId, requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/ManageWebhooks/ReplayFailedTransactionsInLast24Hours.cs b/Source/Samples/Webhooks/ManageWebhooks/ReplayFailedTransactionsInLast24Hours.cs new file mode 100644 index 0000000..b690384 --- /dev/null +++ b/Source/Samples/Webhooks/ManageWebhooks/ReplayFailedTransactionsInLast24Hours.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.ManageWebhooks +{ + public class ReplayFailedTransactionsInLast24Hours + { + public static void Run(string webhookId) + { + string byDeliveryStatusStatus = "FAILED"; + int byDeliveryStatusHoursBack = 24; + string byDeliveryStatusProductId = "tokenManagement"; + string byDeliveryStatusEventType = "tms.token.created"; + Nrtfv1webhookswebhookIdreplaysByDeliveryStatus byDeliveryStatus = new Nrtfv1webhookswebhookIdreplaysByDeliveryStatus( + Status: byDeliveryStatusStatus, + HoursBack: byDeliveryStatusHoursBack, + ProductId: byDeliveryStatusProductId, + EventType: byDeliveryStatusEventType + ); + + var requestObj = new ReplayWebhooksRequest( + ByDeliveryStatus: byDeliveryStatus + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReplayWebhooksApi(clientConfig); + apiInstance.ReplayPreviousWebhooks(webhookId, requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/ManageWebhooks/ReplaySpecificListOfTransactions.cs b/Source/Samples/Webhooks/ManageWebhooks/ReplaySpecificListOfTransactions.cs new file mode 100644 index 0000000..289caed --- /dev/null +++ b/Source/Samples/Webhooks/ManageWebhooks/ReplaySpecificListOfTransactions.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.ManageWebhooks +{ + public class ReplaySpecificListOfTransactions + { + public static void Run(string webhookId) + { + + List byTransactionTraceIdentifiers = new List (); + byTransactionTraceIdentifiers.Add("1f1d0bf4-9299-418d-99d8-faa3313829f1"); + byTransactionTraceIdentifiers.Add("d19fb205-20e5-43a2-867e-bd0f574b771e"); + byTransactionTraceIdentifiers.Add("2f2461a3-457c-40e9-867f-aced89662bbb"); + byTransactionTraceIdentifiers.Add("e23ddc19-93d5-4f1f-8482-d7cafbb3ed9b"); + byTransactionTraceIdentifiers.Add("eb9fc4a9-b31f-48d5-81a9-b1d773fd76d8"); + var requestObj = new ReplayWebhooksRequest( + ByTransactionTraceIdentifiers: byTransactionTraceIdentifiers + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ReplayWebhooksApi(clientConfig); + apiInstance.ReplayPreviousWebhooks(webhookId, requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/Source/Samples/Webhooks/ManageWebhooks/UpdateWebhook.cs b/Source/Samples/Webhooks/ManageWebhooks/UpdateWebhook.cs new file mode 100644 index 0000000..1493d18 --- /dev/null +++ b/Source/Samples/Webhooks/ManageWebhooks/UpdateWebhook.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Globalization; + +using CyberSource.Api; +using CyberSource.Model; + +namespace Cybersource_rest_samples_dotnet.Samples.Webhooks.ManageWebhooks +{ + public class UpdateWebhook + { + public static void Run(string webhookId) + { + string name = "My Sample Webhook"; + string description = "Update to my sample webhook"; + string organizationId = ""; + string productId = "terminalManagement"; + + List eventTypes = new List (); + eventTypes.Add("terminalManagement.assignment.update"); + eventTypes.Add("terminalManagement.status.update"); + string webhookUrl = "https://MyWebhookServer.com:8443:/simulateClient"; + string healthCheckUrl = "https://MyWebhookServer.com:8443:/simulateClientHealthCheck"; + string status = "INACTIVE"; + string notificationScopeScope = "SELF"; + Notificationsubscriptionsv1webhooksNotificationScope notificationScope = new Notificationsubscriptionsv1webhooksNotificationScope( + Scope: notificationScopeScope + ); + + var requestObj = new UpdateWebhookRequest( + Name: name, + Description: description, + OrganizationId: organizationId, + ProductId: productId, + EventTypes: eventTypes, + WebhookUrl: webhookUrl, + HealthCheckUrl: healthCheckUrl, + Status: status, + NotificationScope: notificationScope + ); + + try + { + var configDictionary = new Configuration().GetConfiguration(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new ManageWebhooksApi(clientConfig); + apiInstance.UpdateWebhookSubscription(webhookId, requestObj); + } + catch (Exception e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + } + } + } +} \ No newline at end of file diff --git a/src/Utilities.cs b/Source/Utilities.cs similarity index 100% rename from src/Utilities.cs rename to Source/Utilities.cs diff --git a/Source/lib/net461/ApiSdk.dll b/Source/lib/net461/ApiSdk.dll new file mode 100644 index 0000000..f41c381 Binary files /dev/null and b/Source/lib/net461/ApiSdk.dll differ diff --git a/Source/lib/netstandard/ApiSdk.dll b/Source/lib/netstandard/ApiSdk.dll new file mode 100644 index 0000000..ce21e60 Binary files /dev/null and b/Source/lib/netstandard/ApiSdk.dll differ diff --git a/Validation/ExpectedResults/csharp_expected_results.json b/Validation/ExpectedResults/csharp_expected_results.json new file mode 100644 index 0000000..ff3a6bb --- /dev/null +++ b/Validation/ExpectedResults/csharp_expected_results.json @@ -0,0 +1,209 @@ +{ + "StandAloneHttpSignature": "200", + "StandAloneJWT": "200", + "DeleteMethod": "200", + "GetMethod": "404", + "GetObjectMethod": "404", + "PostMethod": "201", + "PostObjectMethod": "201", + "PutMethod": "201", + "DeleteGenerateHeaders": "200", + "GetGenerateHeaders": "200", + "PostGenerateHeaders": "200", + "PutGenerateHeaders": "200", + "GenerateKeyLegacyTokenFormat": "200", + "FlexTokenizeCard": "200", + "GenerateKey": "200", + "CreateAndSendInvoiceImmediately": "201", + "CreateDraftInvoice": "201", + "CreateInvoiceAndAssignItSpecificInvoiceNumber": "400", + "CreateInvoiceWithoutSendingIt": "400", + "GetInvoiceDetails": "200", + "GetInvoiceSettings": "200", + "UpdateInvoiceSettings": "200", + "AuthenticationWithNewAccount": "201", + "AuthenticationWithNORedirect": "201", + "EnrollWithCustomerIdAsPaymentInformation": "201", + "EnrollWithPendingAuthentication": "201", + "EnrollWithTransientToken": "400", + "EnrollWithTravelInformation": "201", + "PendingAuthenticationWithUnknownPath": "201", + "SetupCompletionWithCardNumber": "201", + "SetupCompletionWithFlexTransientToken": "400", + "SetupCompletionWithFluidDataValueAndPaymentSolution": "400", + "SetupCompletionWithSecureStorageToken": "400", + "SetupCompletionWithTMSToken": "201", + "SetupCompletionWithTokenizedCard": "201", + "ValidateAuthenticationResults": "201", + "AuthorizationUsingSwipedTrackData": "201", + "CaptureOfAuthorizationThatUsedSwipedTrackData": "400", + "SimpleAuthorizationInternet": "201", + "CapturePayment": "201", + "ServiceFeesWithCreditCardTransaction": "201", + "CapturePaymentServiceFee": "201", + "RestaurantAuthorization": "201", + "RestaurantCaptureWithGratuity": "400", + "Credit": "201", + "CreditUsingBluefinPCIP2PEForCardPresentEnabledAcquirer": "502", + "CreditUsingBluefinPCIP2PEWithVisaPlatformConnect": "502", + "CreditWithCustomerPaymentInstrumentAndShippingAddressTokenId": "201", + "CreditWithCustomerTokenId": "201", + "CreditWithInstrumentIdentifierTokenId": "201", + "ElectronicCheckStandAloneCredits": "201", + "ServiceFeesCredit": "201", + "AmericanExpressDirectEMVWithContactRead": "201", + "AuthorizationCaptureForTimeoutVoidFlow": "201", + "AuthorizationForIncrementalAuthorizationFlow": "201", + "AuthorizationForTimeoutReversalFlow": "201", + "AuthorizationSkipDecisionManagerForSingleTransaction": "201", + "AuthorizationUsingBluefinPCIP2PEForCardPresentEnabledAcquirer": "502", + "AuthorizationUsingBluefinPCIP2PEWithVisaPlatformConnect": "502", + "AuthorizationWithCaptureSale": "201", + "AuthorizationWithCustomerPaymentInstrumentAndShippingAddressTokenId": "201", + "AuthorizationWithCustomerTokenCreation": "201", + "AuthorizationWithCustomerTokenDefaultPaymentInstrumentAndShippingAddressCreation": "201", + "AuthorizationWithCustomerTokenId": "201", + "AuthorizationWithDecisionManager": "201", + "AuthorizationWithDecisionManagerBuyerInformation": "201", + "AuthorizationWithDecisionManagerCustomSetup": "201", + "AuthorizationWithDecisionManagerDeviceInformation": "201", + "AuthorizationWithDecisionManagerMerchantDefinedInformation": "201", + "AuthorizationWithDecisionManagerShippingInformation": "201", + "AuthorizationWithDecisionManagerTravelInformation": "201", + "AuthorizationWithDMAcceptPAEnroll": "201", + "AuthorizationWithDMRejectPAEnroll": "201", + "AuthorizationWithDMReviewPAEnroll": "201", + "AuthorizationWithInstrumentIdentifierTokenCreation": "201", + "AuthorizationWithInstrumentIdentifierTokenId": "201", + "AuthorizationWithLegacyToken": "201", + "AuthorizationWithPAEnrollAuthenticationNeeded": "201", + "AuthorizationWithPayerAuthValidation": "201", + "AuthorizationWithTMSTokenBypassingNetworkToken": "201", + "DigitalPaymentGooglePay": "201", + "DigitalPaymentsApplePay": "201", + "ElectronicCheckDebits": "201", + "ElectronicCheckDebitsWithLegacyToken": "201", + "IncrementalAuthorization": "400", + "LevelIIData": "201", + "LevelIIIData": "201", + "PartialAuthorization": "201", + "PaymentNetworkTokenization": "201", + "PaymentWithFlexToken": "400", + "PaymentWithFlexTokenCreatePermanentTMSToken": "400", + "SaleUsingEMVTechnologyWithContactless": "201", + "SaleUsingEMVTechnologyWithContactlessReadForCardPresentEnabledAcquirer": "201", + "SaleUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect": "201", + "SaleUsingEMVTechnologyWithContactReadOneForCardPresentEnabledAcquirer": "201", + "SaleUsingEMVTechnologyWithContactReadTwoForCardPresentEnabledAcquirer": "201", + "SaleUsingEMVTechnologyWithContactReadWithVisaPlatformConnect": "201", + "SaleUsingKeyedDataForCardPresentEnabledAcquirer": "201", + "SaleUsingKeyedDataWithBalanceInquiry": "201", + "SaleUsingKeyedDataWithVisaPlatformConnect": "201", + "SaleUsingSwipedTrackDataForCardPresentEnabledAcquirer": "201", + "SaleUsingSwipedTrackDataWithVisaPlatformConnect": "201", + "Swiped": "201", + "ZeroDollarAuthorization": "201", + "ElectronicCheckFollowonRefund": "201", + "RefundCapture": "201", + "RefundPayment": "201", + "ProcessAuthorizationReversal": "201", + "ServiceFeesAuthorizationReversal": "201", + "TimeoutReversal": "201", + "TimeoutVoid": "201", + "VoidCapture": "201", + "VoidCredit": "201", + "VoidPayment": "201", + "VoidRefund": "201", + "PayoutCardNotToken": "400", + "PayoutToken": "400", + "GetChargebackDetails": "404", + "GetChargebackSummaries": "404", + "GetConversionDetailTransactions": "400", + "InterchangeClearingLevelDataForAccountOrMerchant": "404", + "GetNetfundingInformationForAccountOrMerchant": "400", + "GetNotificationOfChanges": "400", + "GetPaymentBatchSummaryData": "400", + "GetPurchaseAndRefundDetails": "400", + "GetReportDefinition": "200", + "GetReportingResourceInformation": "200", + "DownloadReport": "404", + "CreateAdhocReport": "400", + "GetReportBasedOnReportId": "404", + "RetrieveAvailableReports": "200", + "CreateClassicStandardReportSubscription": "400", + "CreateReportSubscription": "400", + "DeleteSubscriptionOfReportNameByOrganization": "404", + "GetAllSubscriptions": "200", + "GetSubscriptionForReportName": "404", + "GetRetrievalDetails": "404", + "GetRetrievalSummaries": "404", + "AddDataToList": "201", + "AddDuplicateInformation": "201", + "BasicDMTransaction": "201", + "DMWithBuyerInformation": "201", + "DMWithDecisionProfileRejectResponse": "201", + "DMWithDeviceInformation": "201", + "DMWithMerchantDefinedInformation": "201", + "DMWithScoreExceedsThresholdResponse": "201", + "DMWithShippingInformation": "201", + "DMWithTravelInformation": "201", + "MarkAsSuspect": "201", + "RemoveFromHistory": "201", + "AddressMatchNotFound": "201", + "ApartmentNumberMissingOrNotFound": "201", + "CanadianBillingDetails": "201", + "ComplianceStatusCompleted": "201", + "CustomerMatchDeniedPartiesList": "201", + "ExportComplianceInformationProvided": "201", + "MultipleLineItems": "201", + "MultipleSanctionLists": "201", + "NoCompanyName": "201", + "ShippingDetailsNotUSOrCanada": "201", + "VerboseRequestWithAllFields": "201", + "DownloadFileWithFileIdentifier": "404", + "GetListOfFiles": "400", + "CreateCustomer": "201", + "DeleteCustomer": "204", + "RetrieveCustomer": "200", + "UpdateCustomer": "200", + "UpdateCustomersDefaultPaymentInstrument": "200", + "UpdateCustomersDefaultShippingAddress": "200", + "CreateCustomerDefaultPaymentInstrumentCard": "201", + "CreateCustomerNonDefaultPaymentInstrumentCard": "201", + "CreateCustomerPaymentInstrumentBankAccount": "201", + "CreateCustomerPaymentInstrumentPinlessDebit": "201", + "DeleteCustomerPaymentInstrument": "204", + "ListPaymentInstrumentsForCustomer": "200", + "RetrieveCustomerPaymentInstrument": "200", + "CreateCustomerDefaultShippingAddress": "201", + "CreateCustomerNonDefaultShippingAddress": "201", + "DeleteCustomerShippingAddress": "204", + "ListShippingAddressesForCustomer": "200", + "RetrieveCustomerShippingAddress": "200", + "CreateInstrumentIdentifierBankAccount": "200", + "CreateInstrumentIdentifierCard": "200", + "CreateInstrumentIdentifierCardEnrollForNetworkToken": "200", + "DeleteInstrumentIdentifier": "409", + "EnrollInstrumentIdentifierForNetworkTokenization": "202", + "ListPaymentInstrumentsForInstrumentIdentifier": "200", + "RetrieveInstrumentIdentifier": "200", + "UpdateInstrumentIdentifierPreviousTransactionId": "200", + "CreatePaymentInstrumentBankAccount": "201", + "CreatePaymentInstrumentCard": "201", + "CreatePaymentInstrumentPinlessDebit": "201", + "DeletePaymentInstrument": "204", + "RetrievePaymentInstrument": "200", + "UpdatePaymentInstrument": "200", + "GetIndividualBatchFile": "404", + "GetListOfBatchFiles": "404", + "GetTransactionDetailsForGivenBatchId": "404", + "RetrieveTransaction": "200", + "CreateSearchRequest": "201", + "GetSearchResults": "200", + "GetUserInformationDeprecated": "405", + "BasicTaxCalculationRequest": "201", + "CommittedTaxCallRequest": "201", + "CommittedTaxRefundCallRequest": "201", + "TaxRefundRequest": "201", + "VoidCommittedTaxCall": "201" +} \ No newline at end of file diff --git a/Validation/ExpectedResults/java_expected_results.json b/Validation/ExpectedResults/java_expected_results.json new file mode 100644 index 0000000..ea15002 --- /dev/null +++ b/Validation/ExpectedResults/java_expected_results.json @@ -0,0 +1,210 @@ +{ + "GetNetfundingInformationForAccountOrMerchant": "200", + "GetIndividualBatchFile": "404", + "GetListOfBatchFiles": "404", + "GetTransactionDetailsForGivenBatchId": "404", + "GenerateKey": "200", + "GenerateKeyLegacyTokenFormat": "200", + "FlexTokenizeCard": "200", + "GetPurchaseAndRefundDetails": "400", + "GetReportBasedOnReportId": "404", + "CreateAdhocReport": "400", + "RetrieveAvailableReports": "200", + "GetPaymentBatchSummaryData": "400", + "DeleteGenerateHeaders": "200", + "DeleteMethod": "200", + "PostObjectMethod": "201", + "PostGenerateHeaders": "200", + "StandAloneMetaKey": "400", + "GetObjectMethod": "404", + "GetGenerateHeaders": "200", + "reportDownload": "200", + "GetMethod": "404", + "PutMethod": "404", + "PutGenerateHeaders": "200", + "PostMethod": "201", + "StandaloneJwt": "200", + "SimpleAuthorizationInternet": "201", + "RetrieveTransaction": "200", + "DMWithScoreExceedsThresholdResponse": "201", + "DMWithMerchantDefinedInformation": "201", + "AddDuplicateInformation": "201", + "DMWithTravelInformation": "201", + "DMWithDeviceInformation": "201", + "DMWithDecisionProfileRejectResponse": "201", + "BasicDMTransaction": "201", + "MarkAsSuspect": "201", + "DMWithBuyerInformation": "201", + "RemoveFromHistory": "201", + "AddDataToList": "201", + "DMWithShippingInformation": "201", + "GetRetrievalSummaries": "404", + "CreateDraftInvoice": "201", + "GetInvoiceDetails": "200", + "CreateInvoiceWithoutSendingIt": "400", + "CreateInvoiceAndAssignItSpecificInvoiceNumber": "400", + "CreateAndSendInvoiceImmediately": "201", + "UpdateInvoiceSettings": "200", + "GetInvoiceSettings": "200", + "PayoutCardNotToken": "400", + "PayoutToken": "400", + "EnrollWithCustomerIdAsPaymentInformation": "201", + "SetupCompletionWithSecureStorageToken": "400", + "EnrollWithTransientToken": "400", + "SetupCompletionWithTokenizedCard": "201", + "EnrollWithTravelInformation": "201", + "ValidateAuthenticationResults": "201", + "AuthenticationWithNORedirect": "201", + "SetupCompletionWithFluidDataValueAndPaymentSolution": "400", + "AuthenticationWithNewAccount": "201", + "SetupCompletionWithFlexTransientToken": "400", + "PendingAuthenticationWithUnknownPath": "201", + "SetupCompletionWithCardNumber": "201", + "EnrollWithPendingAuthentication": "201", + "SetupCompletionWithTMSToken": "201", + "GetChargebackSummaries": "404", + "AmericanExpressDirectEMVWithContactRead": "201", + "AuthorizationWithCaptureSale": "201", + "AuthorizationWithDecisionManagerDeviceInformation": "201", + "AuthorizationWithInstrumentIdentifierTokenId": "201", + "ElectronicCheckDebitsWithLegacyToken": "201", + "RestaurantAuthorization": "201", + "SaleUsingKeyedDataWithBalanceInquiry": "201", + "AuthorizationForIncrementalAuthorizationFlow": "201", + "AuthorizationWithCustomerTokenCreation": "201", + "AuthorizationWithDecisionManagerShippingInformation": "201", + "AuthorizationWithPAEnrollAuthenticationNeeded": "201", + "LevelIIData": "201", + "SaleUsingEMVTechnologyWithContactlessReadForCardPresentEnabledAcquirer": "201", + "SaleUsingSwipedTrackDataForCardPresentEnabledAcquirer": "201", + "AuthorizationForTimeoutReversalFlow": "201", + "AuthorizationWithCustomerTokenDefaultPaymentInstrumentAndShippingAddressCreation": "201", + "AuthorizationWithDecisionManagerTravelInformation": "201", + "AuthorizationWithPayerAuthValidation": "201", + "LevelIIIData": "201", + "SaleUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect": "201", + "SaleUsingSwipedTrackDataWithVisaPlatformConnect": "201", + "AuthorizationUsingSwipedTrackData": "201", + "AuthorizationWithDecisionManagerCustomSetup": "201", + "AuthorizationWithInstrumentIdentifierTokenCreation": "201", + "ElectronicCheckDebits": "201", + "PaymentWithFlexTokenCreatePermanentTMSToken": "400", + "SaleUsingKeyedDataForCardPresentEnabledAcquirer": "201", + "ZeroDollarAuthorization": "201", + "AuthorizationUsingBluefinPCIP2PEWithVisaPlatformConnect": "502", + "AuthorizationWithDecisionManagerBuyerInformation": "201", + "AuthorizationWithDMReviewPAEnroll": "201", + "DigitalPaymentsApplePay": "201", + "PaymentWithFlexToken": "400", + "SaleUsingEMVTechnologyWithContactReadWithVisaPlatformConnect": "201", + "Swiped": "201", + "AuthorizationSkipDecisionManagerForSingleTransaction": "201", + "AuthorizationWithCustomerTokenId": "201", + "AuthorizationWithDMAcceptPAEnroll": "201", + "AuthorizationWithTMSTokenBypassingNetworkToken": "201", + "PartialAuthorization": "201", + "SaleUsingEMVTechnologyWithContactReadOneForCardPresentEnabledAcquirer": "201", + "ServiceFeesWithCreditCardTransaction": "201", + "AuthorizationUsingBluefinPCIP2PEForCardPresentEnabledAcquirer": "502", + "AuthorizationWithDecisionManager": "201", + "AuthorizationWithDMRejectPAEnroll": "201", + "DigitalPaymentGooglePay": "201", + "PaymentNetworkTokenization": "201", + "SaleUsingEMVTechnologyWithContactReadTwoForCardPresentEnabledAcquirer": "201", + "AuthorizationCaptureForTimeoutVoidFlow": "201", + "AuthorizationWithCustomerPaymentInstrumentAndShippingAddressTokenId": "201", + "AuthorizationWithDecisionManagerMerchantDefinedInformation": "201", + "AuthorizationWithLegacyToken": "201", + "IncrementalAuthorization": "201", + "SaleUsingEMVTechnologyWithContactless": "201", + "SaleUsingKeyedDataWithVisaPlatformConnect": "201", + "UpdateCustomersDefaultShippingAddress": "200", + "CreateCustomer": "201", + "UpdateCustomersDefaultPaymentInstrument": "200", + "UpdateCustomer": "200", + "DeleteCustomer": "204", + "RetrieveCustomer": "200", + "GetChargebackDetails": "404", + "ProcessAuthorizationReversal": "201", + "ServiceFeesAuthorizationReversal": "201", + "TimeoutReversal": "201", + "InterchangeClearingLevelDataForAccountOrMerchant": "404", + "GetRetrievalDetails": "404", + "GetNotificationOfChanges": "400", + "CreateCustomerNonDefaultShippingAddress": "201", + "CreateCustomerDefaultShippingAddress": "201", + "ListShippingAddressesForCustomer": "200", + "RetrieveCustomerShippingAddress": "200", + "DeleteCustomerShippingAddress": "204", + "GetConversionDetailTransactions": "400", + "GetReportingResourceInformation": "200", + "GetReportDefinition": "200", + "GetUserInformationDeprecated": "405", + "Credit": "201", + "CreditUsingBluefinPCIP2PEWithVisaPlatformConnect": "502", + "CreditWithCustomerPaymentInstrumentAndShippingAddressTokenId": "201", + "ServiceFeesCredit": "201", + "ElectronicCheckStandAloneCredits": "201", + "CreditWithCustomerTokenId": "201", + "CreditWithInstrumentIdentifierTokenId": "201", + "CreditUsingBluefinPCIP2PEForCardPresentEnabledAcquirer": "502", + "ComplianceStatusCompleted": "201", + "CanadianBillingDetails": "201", + "VerboseRequestWithAllFields": "201", + "ExportComplianceInformationProvided": "201", + "ApartmentNumberMissingOrNotFound": "201", + "ShippingDetailsNotUSOrCanada": "201", + "AddressMatchNotFound": "201", + "NoCompanyName": "201", + "MultipleLineItems": "201", + "MultipleSanctionLists": "201", + "CustomerMatchDeniedPartiesList": "201", + "CreateCustomerDefaultPaymentInstrumentCard": "201", + "CreateCustomerPaymentInstrumentBankAccount": "201", + "RetrieveCustomerPaymentInstrument": "200", + "ListPaymentInstrumentsForCustomer": "200", + "CreateCustomerPaymentInstrumentPinlessDebit": "201", + "CreateCustomerNonDefaultPaymentInstrumentCard": "201", + "DeleteCustomerPaymentInstrument": "204", + "RetrievePaymentInstrument": "200", + "CreatePaymentInstrumentCard": "201", + "DeletePaymentInstrument": "204", + "CreatePaymentInstrumentPinlessDebit": "201", + "CreatePaymentInstrumentBankAccount": "201", + "UpdatePaymentInstrument": "200", + "CreateClassicStandardReportSubscription": "400", + "GetSubscriptionForReportName": "404", + "GetAllSubscriptions": "200", + "CreateReportSubscription": "400", + "DeleteSubscriptionOfReportNameByOrganization": "404", + "CreateSearchRequest": "201", + "GetSearchResults": "200", + "DownloadFileWithFileIdentifier": "404", + "GetListOfFiles": "400", + "CommittedTaxCallRequest": "201", + "VoidCommittedTaxCall": "201", + "CommittedTaxRefundCallRequest": "201", + "TaxRefundRequest": "201", + "BasicTaxCalculationRequest": "201", + "ElectronicCheckFollowonRefund": "201", + "CapturePayment": "201", + "RefundCapture": "201", + "RefundPayment": "201", + "DownloadReport": "200", + "RestaurantCaptureWithGratuity": "400", + "CapturePaymentServiceFee": "201", + "CaptureOfAuthorizationThatUsedSwipedTrackData": "400", + "VoidCredit": "201", + "VoidPayment": "201", + "VoidCapture": "201", + "TimeoutVoid": "201", + "VoidRefund": "201", + "EnrollInstrumentIdentifierForNetworkTokenization": "202", + "CreateInstrumentIdentifierCard": "200", + "DeleteInstrumentIdentifier": "409", + "RetrieveInstrumentIdentifier": "200", + "CreateInstrumentIdentifierCardEnrollForNetworkToken": "200", + "UpdateInstrumentIdentifierPreviousTransactionId": "200", + "CreateInstrumentIdentifierBankAccount": "200", + "ListPaymentInstrumentsForInstrumentIdentifier": "200" +} \ No newline at end of file diff --git a/Validation/ExpectedResults/json_expected_results.json b/Validation/ExpectedResults/json_expected_results.json new file mode 100644 index 0000000..90b3f9d --- /dev/null +++ b/Validation/ExpectedResults/json_expected_results.json @@ -0,0 +1,528 @@ +{ + "/pts/v2/payments": { + "post": { + "Simple Authorization(Internet)": 201, + "Authorization with Capture(Sale)": 201, + "Payment with Flex Token": 400, + "Payment with Flex Token(Create Permanent TMS token)": 400, + "Authorization with Customer Token Creation": 201, + "Authorization with Customer Token Id": 400, + "Authorization with Customer Token, Default Payment Instrument and Shipping Address Creation": 400, + "Authorization with TMS Token bypassing Network Token": 201, + "Authorization with Customer, Payment Instrument and Shipping Address Token Id": 201, + "Authorization with Instrument Identifier Token Creation": 201, + "Authorization with Decision Manager": 201, + "Authorization - Skip DecisionManager for single transaction": 201, + "Authorization with Decision Manager (Device Information)": 201, + "Authorization with Decision Manager (Merchant Defined Information)": 201, + "Authorization with Decision Manager (Travel Information)": 201, + "Authorization with Decision Manager (Buyer Information)": 201, + "Authorization with Decision Manager (Shipping Information)": 201, + "Authorization with Decision Manager (custom setup)": 201, + "Authorization with PA Enroll (Authentication Needed)": 201, + "Authorization with Payer Auth Validation": 201, + "Authorization with DM(Accept) + PA Enroll": 201, + "Authorization with DM(Review) + PA Enroll": 201, + "Authorization with DM(Reject) + PA Enroll": 201, + "Payment Network Tokenization": 201, + "Digital Payment - GooglePay": 201, + "Digital Payments - ApplePay": 201, + "Zero Dollar Authorization": 201, + "Level II Data": 201, + "Level III Data": 201, + "Partial Authorization": 201, + "Electronic Check Debits": 201, + "Electronic Check Debits with Legacy Token": 400, + "Service Fees with Credit Card transaction": 201, + "Authorization Using Swiped Track Data": 201, + "Sale Using Swiped Track Data with Visa Platform Connect": 201, + "Sale Using Keyed Data with Visa Platform Connect": 201, + "Sale Using Keyed Data with Balance Inquiry": 201, + "Sale Using EMV Technology with Contact Read with Visa Platform Connect": 201, + "Sale Using EMV Technology with Contactless Read with Visa Platform Connect": 201, + "Authorization Using Bluefin PCI P2PE with Visa Platform Connect": 502, + "Restaurant Authorization": 201, + "Sale Using EMV Technology with a Contactless": 201, + "Sale Using EMV Technology with Contact Read (One) for Card Present Enabled Acquirer": 201, + "Swiped": 201, + "Sale Using Swiped Track Data for Card Present Enabled Acquirer": 201, + "Sale Using Keyed Data for Card Present Enabled Acquirer": 201, + "American Express Direct - EMV with Contact Read": 201, + "Sale Using EMV Technology with Contact Read (Two) for Card Present Enabled Acquirer": 201, + "Sale Using EMV Technology with Contactless Read for Card Present Enabled Acquirer": 201, + "Authorization Using Bluefin PCI P2PE for Card Present Enabled Acquirer": 502, + "Authorization with Instrument Identifier Token Id": 201, + "Authorization with Legacy Token": 400 + } + }, + "/pts/v2/payments/{id}": { + "patch": { + "Incremental Authorization": 400 + } + }, + "/pts/v2/payments/{id}/reversals": { + "post": { + "Process an Authorization Reversal": 201, + "Service Fees Authorization Reversal": 400 + } + }, + "/pts/v2/reversals/": { + "post": { + "Timeout Reversal": 400 + } + }, + "/pts/v2/payments/{id}/captures": { + "post": { + "Capture a Payment": 201, + "Capture a Payment - Service Fee": 400, + "Capture of Authorization that used Swiped track data": 401, + "Restaurant Capture with Gratuity": 401 + } + }, + "/pts/v2/payments/{id}/refunds": { + "post": { + "Refund a Payment": 400, + "Electronic check follow-on Refund": 400 + } + }, + "/pts/v2/captures/{id}/refunds": { + "post": { + "Refund a Capture": 201 + } + }, + "/pts/v2/credits": { + "post": { + "Credit": 201, + "Electronic Check Stand-Alone Credits": 201, + "Service Fees Credit": 201, + "Credit with Customer Token Id": 400, + "Credit with Customer, Payment Instrument and Shipping Address Token Id": 400, + "Credit with Instrument Identifier Token Id": 400, + "Credit Using Bluefin PCI P2PE with Visa Platform Connect": 502, + "Credit Using Bluefin PCI P2PE for Card Present Enabled Acquirer": 502 + } + }, + "/pts/v2/payments/{id}/voids": { + "post": { + "Void a Payment": 201 + } + }, + "/pts/v2/captures/{id}/voids": { + "post": { + "Void a Capture": 201 + } + }, + "/pts/v2/refunds/{id}/voids": { + "post": { + "Void a Refund": 201 + } + }, + "/pts/v2/credits/{id}/voids": { + "post": { + "Void a Credit": 201 + } + }, + "/pts/v2/voids/": { + "post": { + "Timeout void": 400 + } + }, + "/pts/v1/transaction-batches": { + "get": { + "Get a List of Batch Files": 404 + } + }, + "/pts/v1/transaction-batches/{id}": { + "get": { + "Get Individual Batch File": 401 + } + }, + "/pts/v1/transaction-batch-details/{id}": { + "get": { + "Get Transaction Details for a given Batch Id": 401 + } + }, + "/tms/v2/customers": { + "post": { + "Create Customer": 201 + } + }, + "/tms/v2/customers/{customerTokenId}": { + "get": { + "Retrieve a Customer": 200 + }, + "patch": { + "Update Customer": 200, + "Update Customers default Payment Instrument": 401, + "Update Customers default Shipping Address": 401 + } + }, + "/tms/v2/customers/{customerTokenId}/shipping-addresses": { + "post": { + "Create Customer Default Shipping Address": 201, + "Create Customer Non-Default Shipping Address": 201 + }, + "get": { + "List Shipping Addresses for a Customer": 200 + } + }, + "/tms/v2/customers/{customerTokenId}/shipping-addresses/{shippingAddressTokenId}": { + "get": { + "Retrieve a Customer Shipping Address": 200 + }, + "patch": { + "Update Customer Default Shipping Address": 200 + } + }, + "/tms/v2/customers/{customerTokenId}/payment-instruments": { + "post": { + "Create Customer Default Payment Instrument (Card)": 401, + "Create Customer Non-Default Payment Instrument (Card)": 401, + "Create Customer Payment Instrument (Bank Account)": 401, + "Create Customer Payment Instrument (Pinless Debit)": 401 + }, + "get": { + "List Payment Instruments for a Customer": 401 + } + }, + "/tms/v2/customers/{customerTokenId}/payment-instruments/{paymentInstrumentTokenId}": { + "get": { + "Retrieve a Customer Payment Instrument": 401 + }, + "patch": {} + }, + "/tms/v1/paymentinstruments": { + "post": { + "Create Payment Instrument (Card)": 400, + "Create Payment Instrument (Bank Account)": 400, + "Create Payment Instrument (Pinless Debit)": 400 + } + }, + "/tms/v1/paymentinstruments/{paymentInstrumentTokenId}": { + "get": { + "Retrieve a Payment Instrument": 401 + }, + "patch": { + "Update Payment Instrument": 401 + } + }, + "/tms/v1/instrumentidentifiers": { + "post": { + "Create Instrument Identifier (Card)": 200, + "Create Instrument Identifier (Bank Account)": 200, + "Create Instrument Identifier (Card & Enroll for Network Token)": 200 + } + }, + "/tms/v1/instrumentidentifiers/{instrumentIdentifierTokenId}": { + "get": { + "Retrieve an Instrument Identifier": 200 + }, + "patch": { + "Update Instrument Identifier previousTransactionId": 401 + } + }, + "/tms/v1/instrumentidentifiers/{instrumentIdentifierTokenId}/paymentinstruments": { + "get": { + "List Payment Instruments for an Instrument Identifier": 200 + } + }, + "/tms/v1/instrumentidentifiers/{instrumentIdentifierTokenId}/enrollment": { + "post": { + "Enroll Instrument Identifier for Network Tokenization": 202 + } + }, + "/flex/v1/keys": { + "post": { + "Generate Key": 200 + } + }, + "/flex/v1/tokens": { + "post": { + "Flex Tokenize Card": 400 + } + }, + "/risk/v1/decisions": { + "post": { + "Basic DM Transaction": 201, + "DM With Device Information": 201, + "DM With Merchant Defined Information": 201, + "DM With Travel Information": 201, + "DM With Buyer Information": 201, + "DM With Shipping Information": 201, + "DM With Score_Exceeds_Threshold Response": 201, + "DM With Decision_Profile_Reject Response": 201 + } + }, + "/risk/v1/authentication-setups": { + "post": { + "Setup Completion with Card Number": 201, + "Setup Completion with Fluid Data Value and Payment Solution": 400, + "Setup Completion with Tokenized Card": 201, + "Setup Completion with TMS Token": 400, + "Setup Completion with Visa Checkout": 400, + "Setup Completion with Flex Transient Token": 400, + "Setup Completion with Secure Storage Token": 400 + } + }, + "/risk/v1/authentications": { + "post": { + "Enroll with Pending Authentication": 201, + "Enroll with Travel Information": 201, + "Authentication with NO Redirect": 201, + "Authentication with New Account": 201, + "Pending Authentication with Unknown path": 201, + "Enroll with customerId as payment information": 400, + "Enroll with transient token": 400 + } + }, + "/risk/v1/authentication-results": { + "post": { + "Validate authentication results": 201 + } + }, + "/risk/v1/lists/{type}/entries": { + "post": { + "Add Data to a List": 401, + "Add Duplicate Information": 401 + } + }, + "/risk/v1/decisions/{id}/marking": { + "post": { + "Mark as Suspect": 201, + "Remove from History": 201 + } + }, + "/risk/v1/address-verifications": { + "post": { + "Verbose Request with all fields": 201, + "Shipping Details not US or Canada": 201, + "Canadian Billing Details": 201, + "Multiple Line Items": 201, + "Apartment Number Missing or Not Found": 201, + "Address Match Not Found": 201 + } + }, + "/risk/v1/export-compliance-inquiries": { + "post": { + "Customer Match Denied Parties List": 201, + "Export Compliance Information Provided": 201, + "Compliance Status Completed": 201, + "Multiple Sanction Lists": 201, + "No Company Name": 201 + } + }, + "/pts/v2/payouts": { + "post": { + "Payout (Card not Token)": 400, + "Payout (Token)": 400 + } + }, + "/tss/v2/transactions/{id}": { + "get": { + "Retrieve a Transaction": 200 + } + }, + "/tss/v2/searches": { + "post": { + "Create a search request": 201 + } + }, + "/tss/v2/searches/{searchId}": { + "get": { + "Get Search Results": 200 + } + }, + "/reporting/v3/report-downloads": { + "get": { + "Download a Report": 404 + } + }, + "/reporting/v3/reports": { + "get": { + "Retrieve Available Reports": 400 + }, + "post": { + "Create Adhoc Report": 400 + } + }, + "/reporting/v3/reports/{reportId}": { + "get": { + "Get Report Based on Report Id": 401 + } + }, + "/reporting/v3/report-definitions/{reportDefinitionName}": { + "get": { + "Get Report Definition": 401 + } + }, + "/reporting/v3/report-definitions": { + "get": { + "Get Reporting Resource Information": 200 + } + }, + "/reporting/v3/report-subscriptions": { + "get": { + "Get All Subscriptions": 200 + }, + "put": { + "Create Report Subscription": 400 + } + }, + "/reporting/v3/report-subscriptions/{reportName}": { + "get": { + "Get Subscription for Report Name": 200 + } + }, + "/reporting/v3/predefined-report-subscriptions": { + "put": { + "Create Classic/Standard Report Subscription": 400 + } + }, + "/reporting/v3/notification-of-changes": { + "get": { + "Get Notification of Changes": 400 + } + }, + "/reporting/v3/purchase-refund-details": { + "get": { + "Get Purchase and Refund Details": 400 + } + }, + "/reporting/v3/payment-batch-summaries": { + "get": { + "Get Payment Batch Summary Data": 400 + } + }, + "/reporting/v3/conversion-details": { + "get": { + "Get Conversion Detail Transactions": 400 + } + }, + "/reporting/v3/net-fundings": { + "get": { + "Get Netfunding Information for an Account or a Merchant": 400 + } + }, + "/reporting/v3/dtds/{reportDefinitionNameVersion}": { + "get": { + "Download DTD for Report": 404 + } + }, + "/reporting/v3/xsds/{reportDefinitionNameVersion}": { + "get": { + "Download XSD for Report": 404 + } + }, + "/reporting/v3/chargeback-summaries": { + "get": { + "Get Chargeback Summaries": 400 + } + }, + "/reporting/v3/chargeback-details": { + "get": { + "Get Chargeback Details": 400 + } + }, + "/reporting/v3/retrieval-summaries": { + "get": { + "Get Retrieval Summaries": 400 + } + }, + "/reporting/v3/retrieval-details": { + "get": { + "Get Retrieval Details": 400 + } + }, + "/reporting/v3/interchange-clearing-level-details": { + "get": { + "Interchange Clearing Level data for an account or a merchant": 400 + } + }, + "/sfs/v1/file-details": { + "get": { + "Get List of Files": 400 + } + }, + "/sfs/v1/files/{fileId}": { + "get": { + "Download a File with File Identifier": 401 + } + }, + "/invoicing/v2/invoices": { + "post": { + "Create a draft invoice": 201, + "Create and send the invoice immediately": 201, + "Create an invoice and assign it a specific invoice number": 400, + "Create an invoice without sending it": 400 + }, + "get": { + "Get a List of Invoices": 200 + } + }, + "/invoicing/v2/invoices/{id}": { + "get": { + "Get Invoice Details": 200 + }, + "put": {} + }, + "/invoicing/v2/invoices/{id}/delivery": { + "post": {} + }, + "/invoicing/v2/invoices/{id}/cancelation": { + "post": {} + }, + "/invoicing/v2/invoiceSettings": { + "put": { + "UpdateInvoiceSettings": 200 + }, + "get": { + "Get Invoice Settings": 200 + } + }, + "/ums/v1/users": { + "get": { + "Get User Information - Deprecated": 405 + } + }, + "/ums/v1/users/search": { + "post": {} + }, + "/vas/v2/tax": { + "post": { + "Basic Tax Calculation Request": 201, + "Tax Refund Request": 201, + "Committed Tax Call Request": 201, + "Committed Tax Refund Call Request": 201 + } + }, + "/vas/v2/tax/{id}": { + "patch": { + "Void a Committed Tax Call": 401 + } + }, + "/kms/v2/keys-sym": { + "post": {} + }, + "/kms/v2/keys-sym/{keyId}": { + "get": { + "Retrieves shared secret key details": 401 + } + }, + "/kms/v2/keys-sym/deletes": { + "post": {} + }, + "/kms/v2/keys-asym": { + "post": {} + }, + "/kms/v2/keys-asym/{keyId}": { + "get": { + "Retrieves PKCS#12 key details": 401 + } + }, + "/kms/v2/keys-asym/deletes": { + "post": {} + }, + "/kms/v2/keys-sym/verifi": { + "post": {} + } +} \ No newline at end of file diff --git a/Validation/ExpectedResults/node_expected_results.json b/Validation/ExpectedResults/node_expected_results.json new file mode 100644 index 0000000..d5502d7 --- /dev/null +++ b/Validation/ExpectedResults/node_expected_results.json @@ -0,0 +1,199 @@ +{ + "StandAloneHttpSignature": "400", + "StandAloneJWT": "400", + "generate-key-legacy-token-format": "200", + "flex-tokenize-card": "200", + "generate-key": "200", + "create-and-send-invoice-immediately": "201", + "create-draft-invoice": "201", + "create-invoice-and-assign-it-specific-invoice-number": "400", + "create-invoice-without-sending-it": "400", + "get-invoice-details": "200", + "get-invoice-settings": "200", + "updateinvoicesettings": "200", + "authentication-with-new-account": "201", + "authentication-with-no-redirect": "201", + "enroll-with-customerid-as-payment-information": "201", + "enroll-with-pending-authentication": "201", + "enroll-with-transient-token": "400", + "enroll-with-travel-information": "201", + "pending-authentication-with-unknown-path": "201", + "setup-completion-with-card-number": "201", + "setup-completion-with-flex-transient-token": "400", + "setup-completion-with-fluid-data-value-and-payment-solution": "400", + "setup-completion-with-secure-storage-token": "400", + "setup-completion-with-tms-token": "201", + "setup-completion-with-tokenized-card": "201", + "validate-authentication-results": "201", + "authorization-using-swiped-track-data": "201", + "capture-of-authorization-that-used-swiped-track-data": "400", + "service-fees-with-credit-card-transaction": "201", + "capture-payment-service-fee": "201", + "simple-authorizationinternet": "201", + "capture-payment": "201", + "restaurant-authorization": "201", + "restaurant-capture-with-gratuity": "400", + "credit-using-bluefin-pci-p2pe-for-card-present-enabled-acquirer": "502", + "credit-using-bluefin-pci-p2pe-with-visa-platform-connect": "502", + "credit-with-customer-payment-instrument-and-shipping-address-token-id": "201", + "credit-with-customer-token-id": "201", + "credit-with-instrument-identifier-token-id": "201", + "credit": "201", + "electronic-check-standalone-credits": "201", + "service-fees-credit": "201", + "american-express-direct-emv-with-contact-read": "201", + "authorization-capture-for-timeout-void-flow": "201", + "authorization-for-incremental-authorization-flow": "201", + "authorization-for-timeout-reversal-flow": "201", + "authorization-skip-decisionmanager-for-single-transaction": "201", + "authorization-using-bluefin-pci-p2pe-for-card-present-enabled-acquirer": "502", + "authorization-using-bluefin-pci-p2pe-with-visa-platform-connect": "502", + "authorization-with-capturesale": "201", + "authorization-with-customer-payment-instrument-and-shipping-address-token-id": "201", + "authorization-with-customer-token-creation": "201", + "authorization-with-customer-token-default-payment-instrument-and-shipping-address-creation": "201", + "authorization-with-customer-token-id": "201", + "authorization-with-decision-manager-buyer-information": "201", + "authorization-with-decision-manager-custom-setup": "201", + "authorization-with-decision-manager-device-information": "201", + "authorization-with-decision-manager-merchant-defined-information": "201", + "authorization-with-decision-manager-shipping-information": "201", + "authorization-with-decision-manager-travel-information": "201", + "authorization-with-decision-manager": "201", + "authorization-with-dmaccept-pa-enroll": "201", + "authorization-with-dmreject-pa-enroll": "201", + "authorization-with-dmreview-pa-enroll": "201", + "authorization-with-instrument-identifier-token-creation": "201", + "authorization-with-instrument-identifier-token-id": "201", + "authorization-with-legacy-token": "201", + "authorization-with-pa-enroll-authentication-needed": "201", + "authorization-with-payer-auth-validation": "201", + "authorization-with-tms-token-bypassing-network-token": "201", + "digital-payment-googlepay": "201", + "digital-payments-applepay": "201", + "electronic-check-debits-with-legacy-token": "201", + "electronic-check-debits": "201", + "incremental-authorization": "400", + "level-ii-data": "201", + "level-iii-data": "201", + "partial-authorization": "201", + "payment-network-tokenization": "201", + "payment-with-flex-token-create-permanent-tms-token": "400", + "payment-with-flex-token": "400", + "sale-using-emv-technology-with-contact-read-one-for-card-present-enabled-acquirer": "201", + "sale-using-emv-technology-with-contact-read-two-for-card-present-enabled-acquirer": "201", + "sale-using-emv-technology-with-contact-read-with-visa-platform-connect": "201", + "sale-using-emv-technology-with-contactless-read-for-card-present-enabled-acquirer": "201", + "sale-using-emv-technology-with-contactless-read-with-visa-platform-connect": "201", + "sale-using-emv-technology-with-contactless": "201", + "sale-using-keyed-data-for-card-present-enabled-acquirer": "201", + "sale-using-keyed-data-with-balance-inquiry": "201", + "sale-using-keyed-data-with-visa-platform-connect": "201", + "sale-using-swiped-track-data-for-card-present-enabled-acquirer": "201", + "sale-using-swiped-track-data-with-visa-platform-connect": "201", + "swiped": "201", + "zero-dollar-authorization": "201", + "electronic-check-follow-on-refund": "201", + "refund-capture": "201", + "refund-payment": "201", + "process-authorization-reversal": "201", + "service-fees-authorization-reversal": "201", + "timeout-reversal": "201", + "timeout-void": "201", + "void-capture": "201", + "void-credit": "201", + "void-payment": "201", + "void-refund": "201", + "payout-card-not-token": "400", + "payout-token": "400", + "get-chargeback-details": "404", + "get-chargeback-summaries": "404", + "get-conversion-detail-transactions": "400", + "interchange-clearing-level-data-for-account-or-merchant": "404", + "get-netfunding-information-for-account-or-merchant": "400", + "get-notification-of-changes": "400", + "get-payment-batch-summary-data": "400", + "get-purchase-and-refund-details": "400", + "get-report-definition": "200", + "get-reporting-resource-information": "200", + "download-report": "200", + "create-adhoc-report": "400", + "get-report-based-on-report-id": "404", + "retrieve-available-reports": "200", + "create-classicstandard-report-subscription": "400", + "create-report-subscription": "400", + "delete-subscription-of-report-name-by-organization": "404", + "get-all-subscriptions": "200", + "get-subscription-for-report-name": "404", + "get-retrieval-details": "404", + "get-retrieval-summaries": "404", + "add-data-to-list": "201", + "add-duplicate-information": "201", + "basic-dm-transaction": "201", + "dm-with-buyer-information": "201", + "dm-with-decisionprofilereject-response": "201", + "dm-with-device-information": "201", + "dm-with-merchant-defined-information": "201", + "dm-with-scoreexceedsthreshold-response": "201", + "dm-with-shipping-information": "201", + "dm-with-travel-information": "201", + "mark-as-suspect": "201", + "remove-from-history": "201", + "address-match-not-found": "201", + "apartment-number-missing-or-not-found": "201", + "canadian-billing-details": "201", + "compliance-status-completed": "201", + "customer-match-denied-parties-list": "201", + "export-compliance-information-provided": "201", + "multiple-line-items": "201", + "multiple-sanction-lists": "201", + "no-company-name": "201", + "shipping-details-not-us-or-canada": "201", + "verbose-request-with-all-fields": "201", + "download-file-with-file-identifier": "200", + "get-list-of-files": "400", + "create-customer": "201", + "delete-customer": "204", + "retrieve-customer": "200", + "update-customer": "200", + "update-customers-default-payment-instrument": "200", + "update-customers-default-shipping-address": "200", + "create-customer-default-payment-instrument-card": "201", + "create-customer-non-default-payment-instrument-card": "201", + "create-customer-payment-instrument-bank-account": "201", + "create-customer-payment-instrument-pinless-debit": "201", + "delete-customer-payment-instrument": "204", + "list-payment-instruments-for-customer": "200", + "retrieve-customer-payment-instrument": "200", + "create-customer-default-shipping-address": "201", + "create-customer-non-default-shipping-address": "201", + "delete-customer-shipping-address": "204", + "list-shipping-addresses-for-customer": "200", + "retrieve-customer-shipping-address": "200", + "create-instrument-identifier-bank-account": "200", + "create-instrument-identifier-card-enroll-for-network-token": "200", + "create-instrument-identifier-card": "200", + "delete-instrument-identifier": "409", + "enroll-instrument-identifier-for-network-tokenization": "202", + "list-payment-instruments-for-instrument-identifier": "200", + "retrieve-instrument-identifier": "200", + "update-instrument-identifier-previoustransactionid": "200", + "create-payment-instrument-bank-account": "201", + "create-payment-instrument-card": "201", + "create-payment-instrument-pinless-debit": "201", + "delete-payment-instrument": "204", + "retrieve-payment-instrument": "200", + "update-payment-instrument": "200", + "get-individual-batch-file": "404", + "get-list-of-batch-files": "404", + "get-transaction-details-for-given-batch-id": "200", + "retrieve-transaction": "200", + "create-search-request": "201", + "get-search-results": "200", + "get-user-information-deprecated": "405", + "basic-tax-calculation-request": "201", + "committed-tax-call-request": "201", + "committed-tax-refund-call-request": "201", + "tax-refund-request": "201", + "void-committed-tax-call": "201" +} \ No newline at end of file diff --git a/Validation/ExpectedResults/php_expected_results.json b/Validation/ExpectedResults/php_expected_results.json new file mode 100644 index 0000000..73b5b39 --- /dev/null +++ b/Validation/ExpectedResults/php_expected_results.json @@ -0,0 +1,185 @@ +{ + "deleteMethod": "200", + "getGenerateHeaders": "200", + "getMethod": "404", + "postGenerateHeaders": "200", + "postMethod": "201", + "postMethodJsonModel": "201", + "putGenerateHeaders": "200", + "putMethod": "201", + "StandAloneHttpSignature": "200", + "StandAloneJWT": "200", + "GenerateKeyLegacyTokenFormat": "200", + "GenerateKey": "200", + "CreateAndSendInvoiceImmediately": "201", + "CreateDraftInvoice": "200", + "CreateInvoiceAndAssignItSpecificInvoiceNumber": "400", + "CreateInvoiceWithoutSendingIt": "400", + "GetInvoiceSettings": "200", + "UpdateInvoiceSettings": "200", + "AuthenticationWithNewAccount": "201", + "AuthenticationWithNORedirect": "201", + "EnrollWithCustomerIdAsPaymentInformation": "201", + "EnrollWithPendingAuthentication": "201", + "EnrollWithTransientToken": "400", + "EnrollWithTravelInformation": "201", + "PendingAuthenticationWithUnknownPath": "201", + "SetupCompletionWithCardNumber": "201", + "SetupCompletionWithFlexTransientToken": "400", + "SetupCompletionWithFluidDataValueAndPaymentSolution": "400", + "SetupCompletionWithSecureStorageToken": "400", + "SetupCompletionWithTMSToken": "201", + "SetupCompletionWithTokenizedCard": "201", + "ValidateAuthenticationResults": "201", + "CaptureOfAuthorizationThatUsedSwipedTrackData": "400", + "SimpleAuthorizationInternet": "200", + "ServiceFeesWithCreditCardTransaction": "201", + "RestaurantCaptureWithGratuity": "400", + "Credit": "201", + "CreditUsingBluefinPCIP2PEForCardPresentEnabledAcquirer": "502", + "CreditUsingBluefinPCIP2PEWithVisaPlatformConnect": "502", + "CreditWithCustomerPaymentInstrumentAndShippingAddressTokenId": "201", + "CreditWithCustomerTokenId": "201", + "CreditWithInstrumentIdentifierTokenId": "201", + "ElectronicCheckStandAloneCredits": "201", + "ServiceFeesCredit": "201", + "AmericanExpressDirectEMVWithContactRead": "201", + "AuthorizationCaptureForTimeoutVoidFlow": "201", + "AuthorizationForIncrementalAuthorizationFlow": "400", + "AuthorizationForTimeoutReversalFlow": "201", + "AuthorizationSkipDecisionManagerForSingleTransaction": "201", + "AuthorizationUsingBluefinPCIP2PEForCardPresentEnabledAcquirer": "502", + "AuthorizationUsingBluefinPCIP2PEWithVisaPlatformConnect": "502", + "AuthorizationUsingSwipedTrackData": "201", + "AuthorizationWithCaptureSale": "201", + "AuthorizationWithCustomerPaymentInstrumentAndShippingAddressTokenId": "201", + "AuthorizationWithCustomerTokenCreation": "201", + "AuthorizationWithCustomerTokenDefaultPaymentInstrumentAndShippingAddressCreation": "201", + "AuthorizationWithCustomerTokenId": "201", + "AuthorizationWithDecisionManager": "201", + "AuthorizationWithDecisionManagerBuyerInformation": "201", + "AuthorizationWithDecisionManagerCustomSetup": "201", + "AuthorizationWithDecisionManagerDeviceInformation": "201", + "AuthorizationWithDecisionManagerMerchantDefinedInformation": "201", + "AuthorizationWithDecisionManagerShippingInformation": "201", + "AuthorizationWithDecisionManagerTravelInformation": "201", + "AuthorizationWithDMAcceptPAEnroll": "201", + "AuthorizationWithDMRejectPAEnroll": "201", + "AuthorizationWithDMReviewPAEnroll": "201", + "AuthorizationWithInstrumentIdentifierTokenCreation": "201", + "AuthorizationWithInstrumentIdentifierTokenId": "201", + "AuthorizationWithLegacyToken": "201", + "AuthorizationWithPAEnrollAuthenticationNeeded": "201", + "AuthorizationWithPayerAuthValidation": "201", + "AuthorizationWithTMSTokenBypassingNetworkToken": "201", + "DigitalPaymentGooglePay": "201", + "DigitalPaymentsApplePay": "201", + "ElectronicCheckDebits": "201", + "ElectronicCheckDebitsWithLegacyToken": "201", + "LevelIIData": "201", + "LevelIIIData": "201", + "PartialAuthorization": "201", + "PaymentNetworkTokenization": "201", + "PaymentWithFlexToken": "400", + "PaymentWithFlexTokenCreatePermanentTMSToken": "400", + "RestaurantAuthorization": "201", + "SaleUsingEMVTechnologyWithContactless": "201", + "SaleUsingEMVTechnologyWithContactlessReadForCardPresentEnabledAcquirer": "201", + "SaleUsingEMVTechnologyWithContactlessReadWithVisaPlatformConnect": "201", + "SaleUsingEMVTechnologyWithContactReadOneForCardPresentEnabledAcquirer": "201", + "SaleUsingEMVTechnologyWithContactReadTwoForCardPresentEnabledAcquirer": "201", + "SaleUsingEMVTechnologyWithContactReadWithVisaPlatformConnect": "201", + "SaleUsingKeyedDataForCardPresentEnabledAcquirer": "201", + "SaleUsingKeyedDataWithBalanceInquiry": "201", + "SaleUsingKeyedDataWithVisaPlatformConnect": "201", + "SaleUsingSwipedTrackDataForCardPresentEnabledAcquirer": "201", + "SaleUsingSwipedTrackDataWithVisaPlatformConnect": "201", + "Swiped": "201", + "ZeroDollarAuthorization": "201", + "TimeoutReversal": "201", + "TimeoutVoid": "201", + "PayoutCardNotToken": "400", + "PayoutToken": "400", + "GetChargebackDetails": "404", + "GetChargebackSummaries": "404", + "GetConversionDetailTransactions": "400", + "InterchangeClearingLevelDataForAccountOrMerchant": "404", + "GetNetfundingInformationForAccountOrMerchant": "400", + "GetNotificationOfChanges": "400", + "GetPaymentBatchSummaryData": "400", + "GetPurchaseAndRefundDetails": "404", + "GetReportDefinition": "200", + "GetReportingResourceInformation": "200", + "DownloadReport": "404", + "CreateAdhocReport": "400", + "GetReportBasedOnReportId": "404", + "RetrieveAvailableReports": "200", + "CreateClassicStandardReportSubscription": "400", + "CreateReportSubscription": "400", + "DeleteSubscriptionOfReportNameByOrganization": "404", + "GetAllSubscriptions": "200", + "GetSubscriptionForReportName": "404", + "GetRetrievalDetails": "404", + "GetRetrievalSummaries": "404", + "AddDataToList": "201", + "AddDuplicateInformation": "201", + "BasicDMTransaction": "201", + "DMWithBuyerInformation": "201", + "DMWithDecisionProfileRejectResponse": "201", + "DMWithDeviceInformation": "201", + "DMWithMerchantDefinedInformation": "201", + "DMWithScoreExceedsThresholdResponse": "201", + "DMWithShippingInformation": "201", + "DMWithTravelInformation": "201", + "MarkAsSuspect": "201", + "RemoveFromHistory": "201", + "AddressMatchNotFound": "201", + "ApartmentNumberMissingOrNotFound": "201", + "CanadianBillingDetails": "201", + "ComplianceStatusCompleted": "201", + "CustomerMatchDeniedPartiesList": "201", + "ExportComplianceInformationProvided": "201", + "MultipleLineItems": "201", + "MultipleSanctionLists": "201", + "NoCompanyName": "201", + "ShippingDetailsNotUSOrCanada": "201", + "VerboseRequestWithAllFields": "201", + "DownloadFileWithFileIdentifier": "404", + "GetListOfFiles": "400", + "CreateCustomer": "204", + "RetrieveCustomer": "200", + "UpdateCustomer": "200", + "UpdateCustomersDefaultPaymentInstrument": "200", + "UpdateCustomersDefaultShippingAddress": "200", + "CreateCustomerDefaultPaymentInstrumentCard": "201", + "CreateCustomerNonDefaultPaymentInstrumentCard": "204", + "CreateCustomerPaymentInstrumentBankAccount": "201", + "CreateCustomerPaymentInstrumentPinlessDebit": "201", + "ListPaymentInstrumentsForCustomer": "200", + "RetrieveCustomerPaymentInstrument": "200", + "CreateCustomerDefaultShippingAddress": "201", + "CreateCustomerNonDefaultShippingAddress": "204", + "ListShippingAddressesForCustomer": "200", + "RetrieveCustomerShippingAddress": "200", + "CreateInstrumentIdentifierBankAccount": "200", + "CreateInstrumentIdentifierCard": "409", + "CreateInstrumentIdentifierCardEnrollForNetworkToken": "200", + "EnrollInstrumentIdentifierForNetworkTokenization": "202", + "ListPaymentInstrumentsForInstrumentIdentifier": "200", + "RetrieveInstrumentIdentifier": "200", + "UpdateInstrumentIdentifierPreviousTransactionId": "200", + "CreatePaymentInstrumentBankAccount": "201", + "CreatePaymentInstrumentCard": "204", + "CreatePaymentInstrumentPinlessDebit": "201", + "RetrievePaymentInstrument": "200", + "UpdatePaymentInstrument": "200", + "GetIndividualBatchFile": "404", + "GetListOfBatchFiles": "404", + "GetTransactionDetailsForGivenBatchId": "404", + "CreateSearchRequest": "200", + "GetUserInformationDeprecated": "405", + "BasicTaxCalculationRequest": "201", + "CommittedTaxCallRequest": "201", + "CommittedTaxRefundCallRequest": "201", + "TaxRefundRequest": "201" +} \ No newline at end of file diff --git a/Validation/ExpectedResults/python_expected_results.json b/Validation/ExpectedResults/python_expected_results.json new file mode 100644 index 0000000..a25d156 --- /dev/null +++ b/Validation/ExpectedResults/python_expected_results.json @@ -0,0 +1,211 @@ +{ + "DeleteMethod": "200", + "Delete_Generate_Headers": "200", + "GetMethod": "200", + "GetObjectMethod": "400", + "Get_Generate_Headers": "200", + "PostMethod": "200", + "PostObjectMethod": "200", + "Post_Generate_Headers": "200", + "PutMethod": "200", + "Put_Generate_Headers": "200", + "StandAloneHttpSignature": "200", + "StandAloneJWT": "200", + "StandAloneMetaKey": "400", + "StandAloneOAuth": "400", + "flex-tokenize-card": "200", + "generate-key-legacy-token-format": "200", + "generate-key": "200", + "create-and-send-invoice-immediately": "201", + "create-draft-invoice": "201", + "create-invoice-and-assign-it-specific-invoice-number": "400", + "create-invoice-without-sending-it": "400", + "get-invoice-details": "200", + "get-invoice-settings": "200", + "updateinvoicesettings": "200", + "authentication-with-new-account": "201", + "authentication-with-no-redirect": "201", + "enroll-with-customerid-as-payment-information": "201", + "enroll-with-pending-authentication": "201", + "enroll-with-transient-token": "400", + "enroll-with-travel-information": "201", + "pending-authentication-with-unknown-path": "201", + "setup-completion-with-card-number": "201", + "setup-completion-with-flex-transient-token": "400", + "setup-completion-with-fluid-data-value-and-payment-solution": "400", + "setup-completion-with-secure-storage-token": "400", + "setup-completion-with-tms-token": "201", + "setup-completion-with-tokenized-card": "201", + "validate-authentication-results": "201", + "capture-of-authorization-that-used-swiped-track-data": "400", + "capture-payment-service-fee": "201", + "capture-payment": "201", + "restaurant-capture-with-gratuity": "400", + "credit-using-bluefin-pci-p2pe-for-card-present-enabled-acquirer": "502", + "credit-using-bluefin-pci-p2pe-with-visa-platform-connect": "502", + "credit-with-customer-payment-instrument-and-shipping-address-token-id": "201", + "credit-with-customer-token-id": "201", + "credit-with-instrument-identifier-token-id": "201", + "credit": "201", + "electronic-check-standalone-credits": "201", + "service-fees-credit": "201", + "american-express-direct-emv-with-contact-read": "201", + "authorization-capture-for-timeout-void-flow": "201", + "authorization-for-incremental-authorization-flow": "201", + "authorization-for-timeout-reversal-flow": "201", + "authorization-skip-decisionmanager-for-single-transaction": "201", + "authorization-using-bluefin-pci-p2pe-for-card-present-enabled-acquirer": "502", + "authorization-using-bluefin-pci-p2pe-with-visa-platform-connect": "502", + "authorization-using-swiped-track-data": "201", + "authorization-with-capturesale": "201", + "authorization-with-customer-payment-instrument-and-shipping-address-token-id": "201", + "authorization-with-customer-token-creation": "201", + "authorization-with-customer-token-default-payment-instrument-and-shipping-address-creation": "201", + "authorization-with-customer-token-id": "201", + "authorization-with-decision-manager-buyer-information": "201", + "authorization-with-decision-manager-custom-setup": "201", + "authorization-with-decision-manager-device-information": "201", + "authorization-with-decision-manager-merchant-defined-information": "201", + "authorization-with-decision-manager-shipping-information": "201", + "authorization-with-decision-manager-travel-information": "201", + "authorization-with-decision-manager": "201", + "authorization-with-dmaccept-pa-enroll": "201", + "authorization-with-dmreject-pa-enroll": "201", + "authorization-with-dmreview-pa-enroll": "201", + "authorization-with-instrument-identifier-token-creation": "201", + "authorization-with-instrument-identifier-token-id": "201", + "authorization-with-legacy-token": "201", + "authorization-with-pa-enroll-authentication-needed": "201", + "authorization-with-payer-auth-validation": "201", + "authorization-with-tms-token-bypassing-network-token": "201", + "digital-payment-googlepay": "201", + "digital-payments-applepay": "201", + "electronic-check-debits-with-legacy-token": "201", + "electronic-check-debits": "201", + "incremental-authorization": "400", + "level-ii-data": "201", + "level-iii-data": "201", + "partial-authorization": "201", + "payment-network-tokenization": "201", + "payment-with-flex-token": "400", + "payment-with-flex-tokencreate-permanent-tms-token": "400", + "restaurant-authorization": "201", + "sale-using-emv-technology-with-contact-read-one-for-card-present-enabled-acquirer": "201", + "sale-using-emv-technology-with-contact-read-two-for-card-present-enabled-acquirer": "201", + "sale-using-emv-technology-with-contact-read-with-visa-platform-connect": "201", + "sale-using-emv-technology-with-contactless-read-for-card-present-enabled-acquirer": "201", + "sale-using-emv-technology-with-contactless-read-with-visa-platform-connect": "201", + "sale-using-emv-technology-with-contactless": "201", + "sale-using-keyed-data-for-card-present-enabled-acquirer": "201", + "sale-using-keyed-data-with-balance-inquiry": "201", + "sale-using-keyed-data-with-visa-platform-connect": "201", + "sale-using-swiped-track-data-for-card-present-enabled-acquirer": "201", + "sale-using-swiped-track-data-with-visa-platform-connect": "201", + "service-fees-with-credit-card-transaction": "201", + "simple-authorizationinternet": "201", + "swiped": "201", + "zero-dollar-authorization": "201", + "electronic-check-followon-refund": "201", + "refund-capture": "201", + "refund-payment": "201", + "process-authorization-reversal": "201", + "service-fees-authorization-reversal": "201", + "timeout-reversal": "201", + "timeout-void": "201", + "void-capture": "201", + "void-credit": "201", + "void-payment": "201", + "void-refund": "201", + "payout-card-not-token": "400", + "payout-token": "400", + "get-chargeback-details": "404", + "get-chargeback-summaries": "404", + "get-conversion-detail-transactions": "400", + "interchange-clearing-level-data-for-account-or-merchant": "404", + "get-netfunding-information-for-account-or-merchant": "400", + "get-notification-of-changes": "400", + "get-payment-batch-summary-data": "400", + "get-purchase-and-refund-details": "404", + "get-report-definition": "200", + "get-reporting-resource-information": "200", + "download-report": "404", + "create-adhoc-report": "400", + "get-report-based-on-report-id": "404", + "retrieve-available-reports": "200", + "create-classicstandard-report-subscription": "400", + "create-report-subscription": "400", + "delete-subscription-of-report-name-by-organization": "404", + "get-all-subscriptions": "200", + "get-subscription-for-report-name": "404", + "get-retrieval-details": "404", + "get-retrieval-summaries": "404", + "add-data-to-list": "201", + "add-duplicate-information": "201", + "basic-dm-transaction": "201", + "dm-with-buyer-information": "201", + "dm-with-decisionprofilereject-response": "201", + "dm-with-device-information": "201", + "dm-with-merchant-defined-information": "201", + "dm-with-scoreexceedsthreshold-response": "201", + "dm-with-shipping-information": "201", + "dm-with-travel-information": "201", + "mark-as-suspect": "201", + "remove-from-history": "201", + "address-match-not-found": "201", + "apartment-number-missing-or-not-found": "201", + "canadian-billing-details": "201", + "compliance-status-completed": "201", + "customer-match-denied-parties-list": "201", + "export-compliance-information-provided": "201", + "multiple-line-items": "201", + "multiple-sanction-lists": "201", + "no-company-name": "201", + "shipping-details-not-us-or-canada": "201", + "verbose-request-with-all-fields": "201", + "download-file-with-file-identifier": "404", + "get-list-of-files": "400", + "create-customer": "201", + "delete-customer": "204", + "retrieve-customer": "200", + "update-customer": "200", + "update-customers-default-payment-instrument": "200", + "update-customers-default-shipping-address": "200", + "create-customer-default-payment-instrument-card": "201", + "create-customer-nondefault-payment-instrument-card": "201", + "create-customer-payment-instrument-bank-account": "201", + "create-customer-payment-instrument-pinless-debit": "201", + "delete-customer-payment-instrument": "204", + "list-payment-instruments-for-customer": "200", + "retrieve-customer-payment-instrument": "200", + "create-customer-default-shipping-address": "201", + "create-customer-nondefault-shipping-address": "201", + "delete-customer-shipping-address": "204", + "list-shipping-addresses-for-customer": "200", + "retrieve-customer-shipping-address": "200", + "create-instrument-identifier-bank-account": "200", + "create-instrument-identifier-card-enroll-for-network-token": "200", + "create-instrument-identifier-card": "200", + "delete-instrument-identifier": "409", + "enroll-instrument-identifier-for-network-tokenization": "202", + "list-payment-instruments-for-instrument-identifier": "200", + "retrieve-instrument-identifier": "200", + "update-instrument-identifier-previoustransactionid": "200", + "create-payment-instrument-bank-account": "201", + "create-payment-instrument-card": "201", + "create-payment-instrument-pinless-debit": "201", + "delete-payment-instrument": "204", + "retrieve-payment-instrument": "200", + "update-payment-instrument": "200", + "get-individual-batch-file": "404", + "get-list-of-batch-files": "404", + "get-transaction-details-for-given-batch-id": "404", + "retrieve-transaction": "200", + "create-search-request": "201", + "get-search-results": "200", + "get-user-information-deprecated": "405", + "basic-tax-calculation-request": "201", + "committed-tax-call-request": "201", + "committed-tax-refund-call-request": "201", + "tax-refund-request": "201", + "void-committed-tax-call": "201" +} \ No newline at end of file diff --git a/Validation/ExpectedResults/ruby_expected_results.json b/Validation/ExpectedResults/ruby_expected_results.json new file mode 100644 index 0000000..fdd7efb --- /dev/null +++ b/Validation/ExpectedResults/ruby_expected_results.json @@ -0,0 +1,211 @@ +{ + "DeleteGenerateHeaders": "200", + "DeleteMethod": "200", + "GetGenerateHeaders": "200", + "GetMethod": "404", + "GetObjectMethod": "404", + "PostGenerateHeaders": "200", + "PostMethod": "201", + "PostObjectMethod": "201", + "PutGenerateHeaders": "200", + "PutMethod": "201", + "StandAloneHttpSignature": "200", + "StandAloneJWT": "200", + "StandAloneMetaKey": "400", + "StandAloneOAuth": "400", + "flex-tokenize-card": "200", + "generate-key-legacy-token-format": "200", + "generate-key": "200", + "create-and-send-invoice-immediately": "201", + "create-draft-invoice": "201", + "create-invoice-and-assign-it-specific-invoice-number": "400", + "create-invoice-without-sending-it": "400", + "get-invoice-details": "200", + "get-invoice-settings": "200", + "updateinvoicesettings": "200", + "authentication-with-new-account": "201", + "authentication-with-no-redirect": "201", + "enroll-with-customerid-as-payment-information": "201", + "enroll-with-pending-authentication": "201", + "enroll-with-transient-token": "400", + "enroll-with-travel-information": "201", + "pending-authentication-with-unknown-path": "201", + "setup-completion-with-card-number": "201", + "setup-completion-with-flex-transient-token": "400", + "setup-completion-with-fluid-data-value-and-payment-solution": "400", + "setup-completion-with-secure-storage-token": "400", + "setup-completion-with-tms-token": "201", + "setup-completion-with-tokenized-card": "201", + "validate-authentication-results": "201", + "capture-of-authorization-that-used-swiped-track-data": "400", + "capture-payment-service-fee": "201", + "capture-payment": "201", + "restaurant-capture-with-gratuity": "400", + "credit-using-bluefin-pci-p2pe-for-card-present-enabled-acquirer": "502", + "credit-using-bluefin-pci-p2pe-with-visa-platform-connect": "502", + "credit-with-customer-payment-instrument-and-shipping-address-token-id": "201", + "credit-with-customer-token-id": "201", + "credit-with-instrument-identifier-token-id": "201", + "credit": "201", + "electronic-check-standalone-credits": "201", + "service-fees-credit": "201", + "american-express-direct-emv-with-contact-read": "201", + "authorization-capture-for-timeout-void-flow": "201", + "authorization-for-incremental-authorization-flow": "201", + "authorization-for-timeout-reversal-flow": "201", + "authorization-skip-decisionmanager-for-single-transaction": "201", + "authorization-using-bluefin-pci-p2pe-for-card-present-enabled-acquirer": "502", + "authorization-using-bluefin-pci-p2pe-with-visa-platform-connect": "502", + "authorization-using-swiped-track-data": "201", + "authorization-with-capturesale": "201", + "authorization-with-customer-payment-instrument-and-shipping-address-token-id": "201", + "authorization-with-customer-token-creation": "201", + "authorization-with-customer-token-default-payment-instrument-and-shipping-address-creation": "201", + "authorization-with-customer-token-id": "201", + "authorization-with-decision-manager-buyer-information": "201", + "authorization-with-decision-manager-custom-setup": "201", + "authorization-with-decision-manager-device-information": "201", + "authorization-with-decision-manager-merchant-defined-information": "201", + "authorization-with-decision-manager-shipping-information": "201", + "authorization-with-decision-manager-travel-information": "201", + "authorization-with-decision-manager": "201", + "authorization-with-dmaccept-pa-enroll": "201", + "authorization-with-dmreject-pa-enroll": "201", + "authorization-with-dmreview-pa-enroll": "201", + "authorization-with-instrument-identifier-token-creation": "201", + "authorization-with-instrument-identifier-token-id": "201", + "authorization-with-legacy-token": "201", + "authorization-with-pa-enroll-authentication-needed": "201", + "authorization-with-payer-auth-validation": "201", + "authorization-with-tms-token-bypassing-network-token": "201", + "digital-payment-googlepay": "201", + "digital-payments-applepay": "201", + "electronic-check-debits-with-legacy-token": "201", + "electronic-check-debits": "201", + "incremental-authorization": "400", + "level-ii-data": "201", + "level-iii-data": "201", + "partial-authorization": "201", + "payment-network-tokenization": "201", + "payment-with-flex-token-create-permanent-tms-token": "400", + "payment-with-flex-token": "400", + "restaurant-authorization": "201", + "sale-using-emv-technology-with-contact-read-one-for-card-present-enabled-acquirer": "201", + "sale-using-emv-technology-with-contact-read-two-for-card-present-enabled-acquirer": "201", + "sale-using-emv-technology-with-contact-read-with-visa-platform-connect": "201", + "sale-using-emv-technology-with-contactless-read-for-card-present-enabled-acquirer": "201", + "sale-using-emv-technology-with-contactless-read-with-visa-platform-connect": "201", + "sale-using-emv-technology-with-contactless": "201", + "sale-using-keyed-data-for-card-present-enabled-acquirer": "201", + "sale-using-keyed-data-with-balance-inquiry": "201", + "sale-using-keyed-data-with-visa-platform-connect": "201", + "sale-using-swiped-track-data-for-card-present-enabled-acquirer": "201", + "sale-using-swiped-track-data-with-visa-platform-connect": "201", + "service-fees-with-credit-card-transaction": "201", + "simple-authorizationinternet": "201", + "swiped": "201", + "zero-dollar-authorization": "201", + "electronic-check-follow-on-refund": "201", + "refund-capture": "201", + "refund-payment": "201", + "process-authorization-reversal": "201", + "service-fees-authorization-reversal": "201", + "timeout-reversal": "201", + "timeout-void": "201", + "void-capture": "201", + "void-credit": "201", + "void-payment": "201", + "void-refund": "201", + "payout-card-not-token": "400", + "payout-token": "400", + "get-chargeback-details": "404", + "get-chargeback-summaries": "404", + "get-conversion-detail-transactions": "400", + "interchange-clearing-level-data-for-account-or-merchant": "404", + "get-netfunding-information-for-account-or-merchant": "400", + "get-notification-of-changes": "400", + "get-payment-batch-summary-data": "400", + "get-purchase-and-refund-details": "404", + "get-report-definition": "200", + "get-reporting-resource-information": "200", + "download-report": "404", + "create-adhoc-report": "400", + "get-report-based-on-report-id": "404", + "retrieve-available-reports": "200", + "create-classicstandard-report-subscription": "400", + "create-report-subscription": "400", + "delete-subscription-of-report-name-by-organization": "404", + "get-all-subscriptions": "200", + "get-subscription-for-report-name": "404", + "get-retrieval-details": "404", + "get-retrieval-summaries": "404", + "add-data-to-list": "201", + "add-duplicate-information": "201", + "basic-dm-transaction": "201", + "dm-with-buyer-information": "201", + "dm-with-decisionprofilereject-response": "201", + "dm-with-device-information": "201", + "dm-with-merchant-defined-information": "201", + "dm-with-scoreexceedsthreshold-response": "201", + "dm-with-shipping-information": "201", + "dm-with-travel-information": "201", + "mark-as-suspect": "201", + "remove-from-history": "201", + "address-match-not-found": "201", + "apartment-number-missing-or-not-found": "201", + "canadian-billing-details": "201", + "compliance-status-completed": "201", + "customer-match-denied-parties-list": "201", + "export-compliance-information-provided": "201", + "multiple-line-items": "201", + "multiple-sanction-lists": "201", + "no-company-name": "201", + "shipping-details-not-us-or-canada": "201", + "verbose-request-with-all-fields": "201", + "download-file-with-file-identifier": "404", + "get-list-of-files": "400", + "create-customer": "201", + "delete-customer": "204", + "retrieve-customer": "200", + "update-customer": "200", + "update-customers-default-payment-instrument": "200", + "update-customers-default-shipping-address": "200", + "create-customer-default-payment-instrument-card": "201", + "create-customer-non-default-payment-instrument-card": "201", + "create-customer-payment-instrument-bank-account": "201", + "create-customer-payment-instrument-pinless-debit": "201", + "delete-customer-payment-instrument": "204", + "list-payment-instruments-for-customer": "200", + "retrieve-customer-payment-instrument": "200", + "create-customer-default-shipping-address": "201", + "create-customer-non-default-shipping-address": "201", + "delete-customer-shipping-address": "204", + "list-shipping-addresses-for-customer": "200", + "retrieve-customer-shipping-address": "200", + "create-instrument-identifier-bank-account": "200", + "create-instrument-identifier-card-enroll-for-network-token": "200", + "create-instrument-identifier-card": "200", + "delete-instrument-identifier": "409", + "enroll-instrument-identifier-for-network-tokenization": "202", + "list-payment-instruments-for-instrument-identifier": "200", + "retrieve-instrument-identifier": "200", + "update-instrument-identifier-previoustransactionid": "200", + "create-payment-instrument-bank-account": "201", + "create-payment-instrument-card": "201", + "create-payment-instrument-pinless-debit": "201", + "delete-payment-instrument": "204", + "retrieve-payment-instrument": "200", + "update-payment-instrument": "200", + "get-individual-batch-file": "404", + "get-list-of-batch-files": "404", + "get-transaction-details-for-given-batch-id": "404", + "retrieve-transaction": "200", + "create-search-request": "201", + "get-search-results": "200", + "get-user-information-deprecated": "405", + "basic-tax-calculation-request": "201", + "committed-tax-call-request": "201", + "committed-tax-refund-call-request": "201", + "tax-refund-request": "201", + "void-committed-tax-call": "201" +} \ No newline at end of file diff --git a/Validation/json_to_prettified_html.py b/Validation/json_to_prettified_html.py new file mode 100644 index 0000000..6be05d2 --- /dev/null +++ b/Validation/json_to_prettified_html.py @@ -0,0 +1,171 @@ + +""" +IMPORTS +""" + +import argparse +import os +import re +import copy +import json +import re +from json2html import * +from xhtml2pdf import pisa +from bs4 import BeautifulSoup as bs, Tag + +""" +ARGUMENT PARSER +""" + +def parse_arguments(): + parser = argparse.ArgumentParser(description="Converts JSON result data to HTML") + parser.add_argument("--input", "-i", help="JSON file containing result data to be rendered") + parser.add_argument("--output", "-o", help="HTML file generated from the JSON data") + + args = parser.parse_args() + input_file = args.input + output_file = args.output + return input_file, output_file + +""" +LOAD JSON FILE +""" + +def load_json_file(file): + with open(file, "r") as file_handle: + file_contents = json.load(file_handle) + return file_contents + +""" +CONVERT JSON TO HTML +""" + +def convert_json_to_html(data, file): + with open(file, "w") as file_handle: + file_handle.write(json2html.convert(json=data)) + +""" +PRETTIFY HTML +""" + +def prettify_html(file): + with open(file, "r") as file_handle: + soup = bs(file_handle, "html.parser") + + # Processing table + table_tag = soup.table + table_tag.name = "table" + table_tag["style"] = """ + width: 95%; + border-collapse:collapse; + margin-left:auto; + margin-right:auto; + font-family: Helvetica, sans-serif; + font-size: 10px; + vertical-align: bottom; + """ + + # Processing second column + second_col_tags = soup.find_all("td") + for second_col_single_tag in second_col_tags: + more_style = "" + if "FAILURE" in second_col_single_tag.contents[0]: + more_style = """ + color: #FFFFFF; + background-color: #E34234 + """ + elif "SUCCESS" in second_col_single_tag.contents[0]: + more_style = """ + color: #000000; + background-color: #50C878 + """ + elif "SAMPLE CODE" in second_col_single_tag.contents[0]: + more_style = """ + color: #E34234; + background-color: #FFE135 + """ + second_col_single_tag.name = "td" + second_col_single_tag["style"] = "text-align: center; padding-top: 2px; padding-bottom: 0px; vertical-align: middle;" + more_style + + # Processing first column + first_col_tags = soup.find_all("th") + first_col_style = """ + text-align: left; + padding-top: 2px; + padding-bottom: 0px; + vertical-align: middle; + padding-left: 10px; + """ + for first_col_single_tag in first_col_tags: + first_col_single_tag.name = "td" + first_col_single_tag["style"] = first_col_style + + # Create header rows + first_column_style = """ + text-align: center; + padding-top: 2px; + padding-bottom: 0px; + padding-left: 10px; + color: #FFFFFF; + background-color: #333399; + font-size: 12px; + width: 70%; + """ + first_column_header = soup.new_tag("th", style=first_column_style) + first_column_header.insert(3, "Sample Code Tested") + + second_column_style = """ + text-align: center; + padding-top: 2px; + padding-bottom: 0px; + color: #FFFFFF; + background-color: #333399; + font-size: 12px; + width: 30%; + """ + second_column_header = soup.new_tag("th", style=second_column_style) + second_column_header.insert(3, "Validation Result") + + # Insert header rows into table + table_tag.insert(0, second_column_header) + table_tag.insert(0, first_column_header) + + with open(file, "wb") as file_handle: + file_handle.write(soup.prettify("utf-8")) + +""" +CONVERT HTML TO PDF +""" + +def convert_html_to_pdf(file): + with open(file, "r") as src: + source_html = src.read() + + output_file = file.split(".")[0] + ".pdf" + + try: + with open(output_file, "w+b") as result_file: + pisa_status = pisa.CreatePDF(source_html, dest=result_file) + + if pisa_status.err != 0: + raise Exception('Error during PDF file creation:\n' + pisa_status.err) + except Exception as e: + raise e + +""" +MAIN FUNCTION +""" + +def main(): + input_file, output_file = parse_arguments() + json_data = load_json_file(input_file) + convert_json_to_html(json_data, output_file) + prettify_html(output_file) + + try: + convert_html_to_pdf(output_file) + except Exception as e: + print(e) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/Validation/response_code_validator.py b/Validation/response_code_validator.py new file mode 100644 index 0000000..098a7b7 --- /dev/null +++ b/Validation/response_code_validator.py @@ -0,0 +1,96 @@ + +""" +IMPORTS +""" + +import argparse +import re +import json + +""" +ARGUMENT PARSER +""" + +def parse_arguments(): + parser = argparse.ArgumentParser(description="Validates Response Codes for Requests") + parser.add_argument("--expected", "-e", help="Source file containing the expected response codes for the requests") + parser.add_argument("--actual", "-a", help="Log file for the current testing run") + parser.add_argument("--output", "-o", help="Output JSON file for the result of validation") + + args = parser.parse_args() + expected = args.expected + actual = args.actual + output = args.output + return expected, actual, output + +""" +ADD TO JSON OBJECT +""" + +def add_to_json_object(json_obj, key, value): + json_obj[key] = value + return json_obj + +""" +DUMP JSON TO FILE +""" + +def dump_json_to_file(json_obj, filepath): + with open(filepath, "w") as file: + json.dump(json_obj, file, ensure_ascii=False, indent=4) + +""" +LOAD EXPECTED JSON FILE +""" + +def load_file(file): + file_content = json.load(open(file, "r")) + if "/pts/v2/payments" in file_content: + flat_json_object = {} + for path in file_content: + path_content = file_content[path] + for verb in path_content: + samples_content = path_content[verb] + for sample_name, response_code in samples_content.items(): + flat_json_object = add_to_json_object(flat_json_object, sample_name, response_code) + return flat_json_object + else: + return file_content + +""" +COMPARE RESULTS +""" + +def compare_results(expected, actual): + code_map = {} + for sample, response in actual.items(): + if sample in expected: + if expected[sample] == response: + validation = "SUCCESS" + else: + validation = "FAILURE [ Expected : " + str(expected[sample]) + " | Actual : " + str(response) + " ]" + + code_map = add_to_json_object(code_map, sample, validation) + expected.pop(sample) + else: + code_map = add_to_json_object(code_map, sample, "UNEXPECTED SAMPLE CODE FOUND") + + for remaining_sample, remaining_response in expected.items(): + code_map = add_to_json_object(code_map, remaining_sample, "SAMPLE CODE NOT EXECUTED | Expected : " + str(remaining_response)) + + return code_map + +""" +MAIN FUNCTION +""" + +def main(): + expected_json_file, actuals_json_file, destination_file = parse_arguments() + expected_results = load_file(expected_json_file) + actual_results = load_file(actuals_json_file) + + validation_results = compare_results(expected_results, actual_results) + dump_json_to_file(validation_results, destination_file) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/Validation/sample_code_log_processor.py b/Validation/sample_code_log_processor.py new file mode 100644 index 0000000..7e4a62c --- /dev/null +++ b/Validation/sample_code_log_processor.py @@ -0,0 +1,67 @@ + +""" +IMPORTS +""" + +import argparse +import re +import json + +""" +ARGUMENT PARSER +""" + +def parse_arguments(): + parser = argparse.ArgumentParser(description="Processes the log file from Sample Code Testing") + parser.add_argument("--log", "-l", help="Log file for the current testing run of Sample Codes") + parser.add_argument("--output", "-o", help="JSON file to store the actual results from the current testing run") + + args = parser.parse_args() + log_path = args.log + output_file = args.output + return log_path, output_file + +""" +LOG FILE PROCESSOR +""" + +def process_log_file(filepath): + with open(filepath, "r", encoding = "utf-8") as file: + contents = file.read() + matches = re.findall(r"(\[Sample Code Testing\]) (\[([A-Za-z0-9\-_]+)\]) ([0-9]{3})", contents) + + return matches + +""" +ADD TO JSON OBJECT +""" + +def add_to_json_object(json_obj, key, value): + json_obj[key] = value + return json_obj + +""" +DUMP JSON TO FILE +""" + +def dump_json_to_file(filepath, src): + with open(filepath, "w") as file: + json.dump(src, file, ensure_ascii=False, indent=4) + +""" +MAIN FUNCTION +""" + +def main(): + current_log_file, output_json_file = parse_arguments() + log_statements = process_log_file(current_log_file) + + code_map = {} + for statement in log_statements: + if statement[2] not in ("Configuration"): + code_map = add_to_json_object(code_map, statement[2], statement[3]) + + dump_json_to_file(output_json_file, code_map) + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/cybersource-rest-samples-csharp.csproj b/cybersource-rest-samples-csharp.csproj new file mode 100644 index 0000000..cc9d54b --- /dev/null +++ b/cybersource-rest-samples-csharp.csproj @@ -0,0 +1,455 @@ + + + + + Debug + AnyCPU + {97FF11A4-924D-4C87-A028-2AAF64655954} + Exe + Properties + Cybersource_rest_samples_dotnet + SampleCode + v4.6.1 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\net461 + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\net461 + TRACE + prompt + 4 + + + + False + Source\lib\net461\ApiSdk.dll + + + packages\CyberSource.Authentication.0.0.0.20\lib\AuthenticationSdk.dll + + + packages\CyberSource.Rest.Client.0.0.1.46\lib\cybersource-rest-client-dotnet.dll + + + packages\jose-jwt.4.1.0\lib\net461\jose-jwt.dll + + + packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + + + packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + packages\NLog.5.0.0\lib\net46\NLog.dll + True + + + packages\RestSharp.108.0.3\lib\netstandard2.0\RestSharp.dll + + + + packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + + + + + packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + + packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll + + + + + packages\System.Text.Encodings.Web.5.0.1\lib\net461\System.Text.Encodings.Web.dll + + + packages\System.Text.Json.5.0.1\lib\net461\System.Text.Json.dll + + + packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + + packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Always + + + Designer + + + Designer + Always + + + Designer + + + + + + + + + + + + + + + + + + + + + + + DEL /S /Q ..\..\..\obj\* + + + DEL /S /Q ..\..\..\obj\* + + \ No newline at end of file diff --git a/cybersource-rest-samples-csharp.sln b/cybersource-rest-samples-csharp.sln index 8130cfb..2acf725 100644 --- a/cybersource-rest-samples-csharp.sln +++ b/cybersource-rest-samples-csharp.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28307.645 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33205.214 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleCode", "src\SampleCode.csproj", "{4CF837FF-237D-4B5B-B922-71CCC654D718}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cybersource-rest-samples-csharp", "cybersource-rest-samples-csharp.csproj", "{97FF11A4-924D-4C87-A028-2AAF64655954}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -11,15 +11,15 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {4CF837FF-237D-4B5B-B922-71CCC654D718}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4CF837FF-237D-4B5B-B922-71CCC654D718}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4CF837FF-237D-4B5B-B922-71CCC654D718}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4CF837FF-237D-4B5B-B922-71CCC654D718}.Release|Any CPU.Build.0 = Release|Any CPU + {97FF11A4-924D-4C87-A028-2AAF64655954}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {97FF11A4-924D-4C87-A028-2AAF64655954}.Debug|Any CPU.Build.0 = Debug|Any CPU + {97FF11A4-924D-4C87-A028-2AAF64655954}.Release|Any CPU.ActiveCfg = Release|Any CPU + {97FF11A4-924D-4C87-A028-2AAF64655954}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {95563D15-3D02-4AC0-9DFD-FE5A429F71AD} + SolutionGuid = {FB9CA784-6AD6-40A2-97AE-8F3EB809EBD3} EndGlobalSection EndGlobal diff --git a/cybersource-rest-samples-netcore.csproj b/cybersource-rest-samples-netcore.csproj new file mode 100644 index 0000000..c7b5caf --- /dev/null +++ b/cybersource-rest-samples-netcore.csproj @@ -0,0 +1,67 @@ + + + + Exe + netcoreapp3.1 + SampleCodeNetCore + SampleCodeNetCore + + + + bin\Debug + full + true + + + + bin\Release + pdbonly + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Source\lib\netstandard\ApiSdk.dll + true + + + + + + Always + + + + + diff --git a/cybersource-rest-samples-netcore.sln b/cybersource-rest-samples-netcore.sln new file mode 100644 index 0000000..a2b220c --- /dev/null +++ b/cybersource-rest-samples-netcore.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30517.126 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "cybersource-rest-samples-netcore", "cybersource-rest-samples-netcore.csproj", "{EB3608A8-87BA-48C2-B5FA-99B0C400C3AC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EB3608A8-87BA-48C2-B5FA-99B0C400C3AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB3608A8-87BA-48C2-B5FA-99B0C400C3AC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB3608A8-87BA-48C2-B5FA-99B0C400C3AC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB3608A8-87BA-48C2-B5FA-99B0C400C3AC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BC37D5E2-EA43-4842-ADDE-04C956DC6FFC} + EndGlobalSection +EndGlobal diff --git a/packages.config b/packages.config new file mode 100644 index 0000000..25fd4bd --- /dev/null +++ b/packages.config @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/App.config b/src/App.config deleted file mode 100644 index 89f0254..0000000 --- a/src/App.config +++ /dev/null @@ -1,107 +0,0 @@ - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Configuration.cs b/src/Configuration.cs deleted file mode 100644 index 03f3d01..0000000 --- a/src/Configuration.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; - -namespace Cybersource_rest_samples_dotnet -{ - public class Configuration - { - // initialize dictionary object - private readonly Dictionary _configurationDictionary = new Dictionary(); - - public Dictionary GetConfiguration() - { - _configurationDictionary.Add("authenticationType", "HTTP_SIGNATURE"); - _configurationDictionary.Add("merchantID", "testrest"); - _configurationDictionary.Add("merchantsecretKey", "yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE="); - _configurationDictionary.Add("merchantKeyId", "08c94330-f618-42a3-b09d-e1e43be5efda"); - _configurationDictionary.Add("keysDirectory", "Resource"); - _configurationDictionary.Add("keyFilename", "testrest"); - _configurationDictionary.Add("runEnvironment", "cybersource.environment.sandbox"); - _configurationDictionary.Add("keyAlias", "testrest"); - _configurationDictionary.Add("keyPass", "testrest"); - _configurationDictionary.Add("enableLog", "FALSE"); - _configurationDictionary.Add("logDirectory", string.Empty); - _configurationDictionary.Add("logFileName", string.Empty); - _configurationDictionary.Add("logFileMaxSize", "5242880"); - _configurationDictionary.Add("timeout", "300000"); - _configurationDictionary.Add("proxyAddress", string.Empty); - _configurationDictionary.Add("proxyPort", string.Empty); - - return _configurationDictionary; - } - } -} diff --git a/src/CybsPayments.ruleset b/src/CybsPayments.ruleset deleted file mode 100644 index de6824e..0000000 --- a/src/CybsPayments.ruleset +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/SampleCode.csproj b/src/SampleCode.csproj deleted file mode 100644 index 6aded5e..0000000 --- a/src/SampleCode.csproj +++ /dev/null @@ -1,206 +0,0 @@ - - - - - Debug - AnyCPU - {4CF837FF-237D-4B5B-B922-71CCC654D718} - Exe - Properties - Cybersource_rest_samples_dotnet - SampleCode - v4.6.1 - 512 - true - - - AnyCPU - true - full - false - .\ - DEBUG;TRACE - prompt - 4 - CybsPayments.ruleset - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - CybsPayments.ruleset - - - - False - lib\ApiSdk.dll - - - ..\packages\CyberSource.Authentication.0.0.0.5\lib\AuthenticationSdk.dll - - - ..\packages\CyberSource.Rest.Client.0.0.1.1\lib\cybersource-rest-client-dotnet.dll - - - ..\packages\jose-jwt.2.4.0\lib\net461\jose-jwt.dll - - - ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll - True - - - ..\packages\NLog.4.5.10\lib\net45\NLog.dll - True - - - ..\packages\RestSharp.106.5.4\lib\net452\RestSharp.dll - True - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Designer - - - - - Designer - - - Designer - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Samples/DecisionManager/CoreServices/CreateDecisionManagerCase.cs b/src/Samples/DecisionManager/CoreServices/CreateDecisionManagerCase.cs deleted file mode 100644 index 185e560..0000000 --- a/src/Samples/DecisionManager/CoreServices/CreateDecisionManagerCase.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.DecisionManager.CoreServices -{ - public class CreateDecisionManagerCase - { - public static RiskV1DecisionsPost201Response Run() - { - var requestObj = new CreateDecisionManagerCaseRequest(); - - var clientReferenceInformation = new Riskv1decisionsClientReferenceInformation(); - - clientReferenceInformation.Code = "54323007"; - requestObj.ClientReferenceInformation = clientReferenceInformation; - - var paymentInformation = new Riskv1decisionsPaymentInformation(); - - var card = new Riskv1decisionsPaymentInformationCard(); - - card.Number = "4444444444444448"; - card.ExpirationMonth = "12"; - card.ExpirationYear = "2020"; - paymentInformation.Card = card; - - requestObj.PaymentInformation = paymentInformation; - - var orderInformation = new Riskv1decisionsOrderInformation(); - - var amountDetails = new Riskv1decisionsOrderInformationAmountDetails("USD"); - - amountDetails.Currency = "USD"; - amountDetails.TotalAmount = "144.14"; - orderInformation.AmountDetails = amountDetails; - - var billTo = new Riskv1decisionsOrderInformationBillTo(); - - billTo.Address1 = "96, powers street"; - billTo.AdministrativeArea = "NH"; - billTo.Country = "US"; - billTo.Locality = "Clearwater milford"; - billTo.FirstName = "James"; - billTo.LastName = "Smith"; - billTo.PhoneNumber = "7606160717"; - billTo.Email = "test@visa.com"; - billTo.PostalCode = "03055"; - orderInformation.BillTo = billTo; - - requestObj.OrderInformation = orderInformation; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new DecisionManagerApi(clientConfig); - - var result = apiInstance.CreateDecisionManagerCase(requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API : " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/DecisionManager/CoreServices/DecisionProfileReject.cs b/src/Samples/DecisionManager/CoreServices/DecisionProfileReject.cs deleted file mode 100644 index d341729..0000000 --- a/src/Samples/DecisionManager/CoreServices/DecisionProfileReject.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.DecisionManager.CoreServices -{ - public class DecisionProfileReject - { - public static RiskV1DecisionsPost201Response Run() - { - var requestObj = new CreateDecisionManagerCaseRequest(); - - var clientReferenceInformation = new Riskv1decisionsClientReferenceInformation(); - - clientReferenceInformation.Code = "54323007"; - requestObj.ClientReferenceInformation = clientReferenceInformation; - - var paymentInformation = new Riskv1decisionsPaymentInformation(); - - var card = new Riskv1decisionsPaymentInformationCard(); - - card.Number = "4444444444444448"; - card.ExpirationMonth = "12"; - card.ExpirationYear = "2020"; - paymentInformation.Card = card; - - requestObj.PaymentInformation = paymentInformation; - - var orderInformation = new Riskv1decisionsOrderInformation(); - - var amountDetails = new Riskv1decisionsOrderInformationAmountDetails("USD"); - - amountDetails.Currency = "USD"; - amountDetails.TotalAmount = "144.14"; - orderInformation.AmountDetails = amountDetails; - - var billTo = new Riskv1decisionsOrderInformationBillTo(); - - billTo.Address1 = "96, powers street"; - billTo.AdministrativeArea = "NH"; - billTo.Country = "US"; - billTo.Locality = "Clearwater milford"; - billTo.FirstName = "James"; - billTo.LastName = "Smith"; - billTo.PhoneNumber = "7606160717"; - billTo.Email = "test@visa.com"; - billTo.PostalCode = "03055"; - orderInformation.BillTo = billTo; - - requestObj.OrderInformation = orderInformation; - - var riskInformation = new Riskv1decisionsRiskInformation(); - - var profile = new Riskv1decisionsRiskInformationProfile(); - - profile.Name = "profile2"; - riskInformation.Profile = profile; - - requestObj.RiskInformation = riskInformation; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new DecisionManagerApi(clientConfig); - - var result = apiInstance.CreateDecisionManagerCase(requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API : " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/DecisionManager/CoreServices/DmWithBuyerInformation.cs b/src/Samples/DecisionManager/CoreServices/DmWithBuyerInformation.cs deleted file mode 100644 index e2646e4..0000000 --- a/src/Samples/DecisionManager/CoreServices/DmWithBuyerInformation.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.DecisionManager.CoreServices -{ - public class DmWithBuyerInformation - { - public static RiskV1DecisionsPost201Response Run() - { - var requestObj = new CreateDecisionManagerCaseRequest(); - - var clientReferenceInformation = new Riskv1decisionsClientReferenceInformation(); - - clientReferenceInformation.Code = "54323007"; - requestObj.ClientReferenceInformation = clientReferenceInformation; - - var paymentInformation = new Riskv1decisionsPaymentInformation(); - - var card = new Riskv1decisionsPaymentInformationCard(); - - card.Number = "4444444444444448"; - card.ExpirationMonth = "12"; - card.ExpirationYear = "2020"; - paymentInformation.Card = card; - - requestObj.PaymentInformation = paymentInformation; - - var orderInformation = new Riskv1decisionsOrderInformation(); - - var amountDetails = new Riskv1decisionsOrderInformationAmountDetails("USD"); - - amountDetails.Currency = "USD"; - amountDetails.TotalAmount = "144.14"; - orderInformation.AmountDetails = amountDetails; - - var billTo = new Riskv1decisionsOrderInformationBillTo(); - - billTo.Address1 = "96, powers street"; - billTo.AdministrativeArea = "NH"; - billTo.Country = "US"; - billTo.Locality = "Clearwater milford"; - billTo.FirstName = "James"; - billTo.LastName = "Smith"; - billTo.PhoneNumber = "7606160717"; - billTo.Email = "test@visa.com"; - billTo.PostalCode = "03055"; - orderInformation.BillTo = billTo; - - requestObj.OrderInformation = orderInformation; - - var buyerInformation = new Riskv1decisionsBuyerInformation(); - - buyerInformation.HashedPassword = ""; - buyerInformation.DateOfBirth = "1998-05-05"; - var personalIdentification = new List(); - - var personalIdentification0 = new Ptsv2paymentsBuyerInformationPersonalIdentification(); - personalIdentification0.Type = "CPF"; - personalIdentification0.Id = "1a23apwe98"; - personalIdentification.Add(personalIdentification0); - - requestObj.BuyerInformation = buyerInformation; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new DecisionManagerApi(clientConfig); - - var result = apiInstance.CreateDecisionManagerCase(requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API : " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/DecisionManager/CoreServices/DmWithDeviceInformation.cs b/src/Samples/DecisionManager/CoreServices/DmWithDeviceInformation.cs deleted file mode 100644 index a433764..0000000 --- a/src/Samples/DecisionManager/CoreServices/DmWithDeviceInformation.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.DecisionManager.CoreServices -{ - public class DmWithDeviceInformation - { - public static RiskV1DecisionsPost201Response Run() - { - var requestObj = new CreateDecisionManagerCaseRequest(); - - var clientReferenceInformation = new Riskv1decisionsClientReferenceInformation(); - - clientReferenceInformation.Code = "54323007"; - requestObj.ClientReferenceInformation = clientReferenceInformation; - - var paymentInformation = new Riskv1decisionsPaymentInformation(); - - var card = new Riskv1decisionsPaymentInformationCard(); - - card.Number = "4444444444444448"; - card.ExpirationMonth = "12"; - card.ExpirationYear = "2020"; - paymentInformation.Card = card; - - requestObj.PaymentInformation = paymentInformation; - - var orderInformation = new Riskv1decisionsOrderInformation(); - - var amountDetails = new Riskv1decisionsOrderInformationAmountDetails("USD"); - - amountDetails.Currency = "USD"; - amountDetails.TotalAmount = "144.14"; - orderInformation.AmountDetails = amountDetails; - - var billTo = new Riskv1decisionsOrderInformationBillTo(); - - billTo.Address1 = "96, powers street"; - billTo.AdministrativeArea = "NH"; - billTo.Country = "US"; - billTo.Locality = "Clearwater milford"; - billTo.FirstName = "James"; - billTo.LastName = "Smith"; - billTo.PhoneNumber = "7606160717"; - billTo.Email = "test@visa.com"; - billTo.PostalCode = "03055"; - orderInformation.BillTo = billTo; - - requestObj.OrderInformation = orderInformation; - - var deviceInformation = new Riskv1decisionsDeviceInformation(); - - deviceInformation.CookiesAccepted = "yes"; - deviceInformation.IpAddress = "64.124.61.215"; - deviceInformation.HostName = "host.com"; - deviceInformation.HttpBrowserEmail = "xyz@gmail.com"; - deviceInformation.UserAgent = "Chrome"; - requestObj.DeviceInformation = deviceInformation; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new DecisionManagerApi(clientConfig); - - var result = apiInstance.CreateDecisionManagerCase(requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API : " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/DecisionManager/CoreServices/DmWithMerchantDefinedInformation.cs b/src/Samples/DecisionManager/CoreServices/DmWithMerchantDefinedInformation.cs deleted file mode 100644 index ad6e935..0000000 --- a/src/Samples/DecisionManager/CoreServices/DmWithMerchantDefinedInformation.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.DecisionManager.CoreServices -{ - public class DmWithMerchantDefinedInformation - { - public static RiskV1DecisionsPost201Response Run() - { - var requestObj = new CreateDecisionManagerCaseRequest(); - - var clientReferenceInformation = new Riskv1decisionsClientReferenceInformation(); - - clientReferenceInformation.Code = "54323007"; - requestObj.ClientReferenceInformation = clientReferenceInformation; - - var paymentInformation = new Riskv1decisionsPaymentInformation(); - - var card = new Riskv1decisionsPaymentInformationCard(); - - card.Number = "4444444444444448"; - card.ExpirationMonth = "12"; - card.ExpirationYear = "2020"; - paymentInformation.Card = card; - - requestObj.PaymentInformation = paymentInformation; - - var orderInformation = new Riskv1decisionsOrderInformation(); - - var amountDetails = new Riskv1decisionsOrderInformationAmountDetails("USD"); - - amountDetails.Currency = "USD"; - amountDetails.TotalAmount = "144.14"; - orderInformation.AmountDetails = amountDetails; - - var billTo = new Riskv1decisionsOrderInformationBillTo(); - - billTo.Address1 = "96, powers street"; - billTo.AdministrativeArea = "NH"; - billTo.Country = "US"; - billTo.Locality = "Clearwater milford"; - billTo.FirstName = "James"; - billTo.LastName = "Smith"; - billTo.PhoneNumber = "7606160717"; - billTo.Email = "test@visa.com"; - billTo.PostalCode = "03055"; - orderInformation.BillTo = billTo; - - requestObj.OrderInformation = orderInformation; - - var merchantDefinedInformation = new List(); - - var merchantDefinedInformation0 = new Riskv1decisionsMerchantDefinedInformation(); - merchantDefinedInformation0.Key = "1"; - merchantDefinedInformation0.Value = "Test"; - merchantDefinedInformation.Add(merchantDefinedInformation0); - - var merchantDefinedInformation1 = new Riskv1decisionsMerchantDefinedInformation(); - merchantDefinedInformation1.Key = "2"; - merchantDefinedInformation1.Value = "Test2"; - merchantDefinedInformation.Add(merchantDefinedInformation1); - - requestObj.MerchantDefinedInformation = merchantDefinedInformation; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new DecisionManagerApi(clientConfig); - - var result = apiInstance.CreateDecisionManagerCase(requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API : " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/DecisionManager/CoreServices/DmWithShippingInformation.cs b/src/Samples/DecisionManager/CoreServices/DmWithShippingInformation.cs deleted file mode 100644 index a867ee4..0000000 --- a/src/Samples/DecisionManager/CoreServices/DmWithShippingInformation.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.DecisionManager.CoreServices -{ - public class DmWithShippingInformation - { - public static RiskV1DecisionsPost201Response Run() - { - var requestObj = new CreateDecisionManagerCaseRequest(); - - var clientReferenceInformation = new Riskv1decisionsClientReferenceInformation(); - - clientReferenceInformation.Code = "54323007"; - requestObj.ClientReferenceInformation = clientReferenceInformation; - - var paymentInformation = new Riskv1decisionsPaymentInformation(); - - var card = new Riskv1decisionsPaymentInformationCard(); - - card.Number = "4444444444444448"; - card.ExpirationMonth = "12"; - card.ExpirationYear = "2020"; - paymentInformation.Card = card; - - requestObj.PaymentInformation = paymentInformation; - - var orderInformation = new Riskv1decisionsOrderInformation(); - - var amountDetails = new Riskv1decisionsOrderInformationAmountDetails("USD"); - - amountDetails.Currency = "USD"; - amountDetails.TotalAmount = "144.14"; - orderInformation.AmountDetails = amountDetails; - - var shipTo = new Riskv1decisionsOrderInformationShipTo(); - - shipTo.Address1 = "96, powers street"; - shipTo.Address2 = ""; - shipTo.AdministrativeArea = "KA"; - shipTo.Country = "INDIA"; - shipTo.Locality = "Clearwater milford"; - shipTo.FirstName = "James"; - shipTo.LastName = "Smith"; - shipTo.PhoneNumber = "7606160717"; - shipTo.PostalCode = "560056"; - orderInformation.ShipTo = shipTo; - - var billTo = new Riskv1decisionsOrderInformationBillTo(); - - billTo.Address1 = "96, powers street"; - billTo.AdministrativeArea = "NH"; - billTo.Country = "US"; - billTo.Locality = "Clearwater milford"; - billTo.FirstName = "James"; - billTo.LastName = "Smith"; - billTo.PhoneNumber = "7606160717"; - billTo.Email = "test@visa.com"; - billTo.PostalCode = "03055"; - orderInformation.BillTo = billTo; - - requestObj.OrderInformation = orderInformation; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new DecisionManagerApi(clientConfig); - - var result = apiInstance.CreateDecisionManagerCase(requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API : " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/DecisionManager/CoreServices/DmWithTravelInformation.cs b/src/Samples/DecisionManager/CoreServices/DmWithTravelInformation.cs deleted file mode 100644 index e99020c..0000000 --- a/src/Samples/DecisionManager/CoreServices/DmWithTravelInformation.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.DecisionManager.CoreServices -{ - public class DmWithTravelInformation - { - public static RiskV1DecisionsPost201Response Run() - { - var requestObj = new CreateDecisionManagerCaseRequest(); - - var clientReferenceInformation = new Riskv1decisionsClientReferenceInformation(); - - clientReferenceInformation.Code = "54323007"; - requestObj.ClientReferenceInformation = clientReferenceInformation; - - var paymentInformation = new Riskv1decisionsPaymentInformation(); - - var card = new Riskv1decisionsPaymentInformationCard(); - - card.Number = "4444444444444448"; - card.ExpirationMonth = "12"; - card.ExpirationYear = "2020"; - paymentInformation.Card = card; - - requestObj.PaymentInformation = paymentInformation; - - var orderInformation = new Riskv1decisionsOrderInformation(); - - var amountDetails = new Riskv1decisionsOrderInformationAmountDetails("USD"); - - amountDetails.Currency = "USD"; - amountDetails.TotalAmount = "144.14"; - orderInformation.AmountDetails = amountDetails; - - var billTo = new Riskv1decisionsOrderInformationBillTo(); - - billTo.Address1 = "96, powers street"; - billTo.AdministrativeArea = "NH"; - billTo.Country = "US"; - billTo.Locality = "Clearwater milford"; - billTo.FirstName = "James"; - billTo.LastName = "Smith"; - billTo.PhoneNumber = "7606160717"; - billTo.Email = "test@visa.com"; - billTo.PostalCode = "03055"; - orderInformation.BillTo = billTo; - - requestObj.OrderInformation = orderInformation; - - var travelInformation = new Riskv1decisionsTravelInformation(); - - travelInformation.CompleteRoute = "SFO-JFK:JFK-BLR"; - travelInformation.DepartureTime = "2011-03-20 11:30pm GMT"; - travelInformation.JourneyType = "One way"; - var legs = new List(); - - var legs0 = new Riskv1decisionsTravelInformationLegs(); - legs0.Origination = "SFO"; - legs0.Destination = "JFK"; - legs.Add(legs0); - - var legs1 = new Riskv1decisionsTravelInformationLegs(); - legs1.Origination = "JFK"; - legs1.Destination = "BLR"; - legs.Add(legs1); - - travelInformation.Legs = legs; - - requestObj.TravelInformation = travelInformation; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new DecisionManagerApi(clientConfig); - - var result = apiInstance.CreateDecisionManagerCase(requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API : " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/DecisionManager/CoreServices/ScoreExceedsThreshold.cs b/src/Samples/DecisionManager/CoreServices/ScoreExceedsThreshold.cs deleted file mode 100644 index 4d41c6d..0000000 --- a/src/Samples/DecisionManager/CoreServices/ScoreExceedsThreshold.cs +++ /dev/null @@ -1,86 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.DecisionManager.CoreServices -{ - public class ScoreExceedsThreshold - { - public static RiskV1DecisionsPost201Response Run() - { - var requestObj = new CreateDecisionManagerCaseRequest(); - - var clientReferenceInformation = new Riskv1decisionsClientReferenceInformation(); - - clientReferenceInformation.Code = "54323007"; - requestObj.ClientReferenceInformation = clientReferenceInformation; - - var paymentInformation = new Riskv1decisionsPaymentInformation(); - - var card = new Riskv1decisionsPaymentInformationCard(); - - card.Number = "4444444444444448"; - card.ExpirationMonth = "12"; - card.ExpirationYear = "2020"; - paymentInformation.Card = card; - - requestObj.PaymentInformation = paymentInformation; - - var orderInformation = new Riskv1decisionsOrderInformation(); - - var amountDetails = new Riskv1decisionsOrderInformationAmountDetails("USD"); - - amountDetails.Currency = "USD"; - amountDetails.TotalAmount = "144.14"; - orderInformation.AmountDetails = amountDetails; - - var shipTo = new Riskv1decisionsOrderInformationShipTo(); - - shipTo.Address1 = "96, powers street"; - shipTo.Address2 = ""; - shipTo.AdministrativeArea = "KA"; - shipTo.Country = "INDIA"; - shipTo.Locality = "Clearwater milford"; - shipTo.FirstName = "James"; - shipTo.LastName = "Smith"; - shipTo.PhoneNumber = "7606160717"; - shipTo.PostalCode = "560056"; - orderInformation.ShipTo = shipTo; - - var billTo = new Riskv1decisionsOrderInformationBillTo(); - - billTo.Address1 = "96, powers street"; - billTo.AdministrativeArea = "NH"; - billTo.Country = "US"; - billTo.Locality = "Clearwater milford"; - billTo.FirstName = "James"; - billTo.LastName = "Smith"; - billTo.PhoneNumber = "7606160717"; - billTo.Email = "test@visa.com"; - billTo.PostalCode = "03055"; - orderInformation.BillTo = billTo; - - requestObj.OrderInformation = orderInformation; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new DecisionManagerApi(clientConfig); - - var result = apiInstance.CreateDecisionManagerCase(requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API : " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/Flex/CoreServices/GenerateKey.cs b/src/Samples/Flex/CoreServices/GenerateKey.cs deleted file mode 100644 index fbf19af..0000000 --- a/src/Samples/Flex/CoreServices/GenerateKey.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Flex.CoreServices -{ - public class GenerateKey - { - public static FlexV1KeysPost200Response Run() - { - var requestObj = new GeneratePublicKeyRequest("None"); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new KeyGenerationApi(clientConfig); - - var result = apiInstance.GeneratePublicKey(requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/Payments/CoreServices/CapturePayment.cs b/src/Samples/Payments/CoreServices/CapturePayment.cs deleted file mode 100644 index 529105f..0000000 --- a/src/Samples/Payments/CoreServices/CapturePayment.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.CoreServices -{ - public class CapturePayment - { - public static PtsV2PaymentsCapturesPost201Response Run() - { - var processPaymentId = ProcessPayment.Run().Id; - - var requestObj = new CapturePaymentRequest(); - - var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation - { - Code = "test_capture" - }; - - requestObj.ClientReferenceInformation = clientReferenceInformationObj; - - var orderInformationObj = new Ptsv2paymentsidcapturesOrderInformation(); - - var billToObj = new Ptsv2paymentsidcapturesOrderInformationBillTo - { - Country = "US", - FirstName = "John", - LastName = "Doe", - Address1 = "1 Market St", - PostalCode = "94105", - Locality = "San Francisco", - AdministrativeArea = "CA", - Email = "test@cybs.com" - }; - - orderInformationObj.BillTo = billToObj; - - var amountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails - { - TotalAmount = "102.21", - Currency = "USD" - }; - - orderInformationObj.AmountDetails = amountDetailsObj; - - requestObj.OrderInformation = orderInformationObj; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new CaptureApi(clientConfig); - - var result = apiInstance.CapturePayment(requestObj, processPaymentId); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/Payments/CoreServices/ProcessAuthorizationReversal.cs b/src/Samples/Payments/CoreServices/ProcessAuthorizationReversal.cs deleted file mode 100644 index 7ee8449..0000000 --- a/src/Samples/Payments/CoreServices/ProcessAuthorizationReversal.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.CoreServices -{ - public class ProcessAuthorizationReversal - { - public static PtsV2PaymentsReversalsPost201Response Run() - { - var processPaymentId = ProcessPayment.Run().Id; - - var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_reversal"); - var amount = new Ptsv2paymentsidreversalsOrderInformationLineItems(null, "102.21"); - var amountDetailsObj = new List { amount }; - var orderInformationObj = new Ptsv2paymentsidreversalsOrderInformation(null, amountDetailsObj); - var requestBody = new AuthReversalRequest(clientReferenceInformationObj, null, null, orderInformationObj); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new ReversalApi(clientConfig); - - var result = apiInstance.AuthReversal(processPaymentId, requestBody); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/Payments/CoreServices/ProcessCredit.cs b/src/Samples/Payments/CoreServices/ProcessCredit.cs deleted file mode 100644 index a054e9f..0000000 --- a/src/Samples/Payments/CoreServices/ProcessCredit.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.CoreServices -{ - public class ProcessCredit - { - public static PtsV2CreditsPost201Response Run() - { - var requestObj = new CreateCreditRequest(); - - var v2PaymentsClientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation - { - Code = "test_credits" - }; - - requestObj.ClientReferenceInformation = v2PaymentsClientReferenceInformationObj; - - var v2PaymentsOrderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(); - - var v2PaymentsOrderInformationBillToObj = new Ptsv2paymentsidcapturesOrderInformationBillTo - { - Country = "US", - FirstName = "John", - LastName = "Doe", - PhoneNumber = "4158880000", - Address1 = "1 Market St", - PostalCode = "94105", - Locality = "san francisco", - AdministrativeArea = "CA", - Email = "test@cybs.com" - }; - - v2PaymentsOrderInformationObj.BillTo = v2PaymentsOrderInformationBillToObj; - - var v2PaymentsOrderInformationAmountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails - { - TotalAmount = "200", - Currency = "usd" - }; - - v2PaymentsOrderInformationObj.AmountDetails = v2PaymentsOrderInformationAmountDetailsObj; - - requestObj.OrderInformation = v2PaymentsOrderInformationObj; - - var v2PaymentsPaymentInformationObj = new Ptsv2paymentsidrefundsPaymentInformation(); - - var v2PaymentsPaymentInformationCardObj = new Ptsv2paymentsidrefundsPaymentInformationCard - { - ExpirationYear = "2031", - Number = "4111111111111111", - ExpirationMonth = "03", - Type = "001" - }; - - v2PaymentsPaymentInformationObj.Card = v2PaymentsPaymentInformationCardObj; - - requestObj.PaymentInformation = v2PaymentsPaymentInformationObj; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new CreditApi(clientConfig); - - var result = apiInstance.CreateCredit(requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/Payments/CoreServices/ProcessPayment.cs b/src/Samples/Payments/CoreServices/ProcessPayment.cs deleted file mode 100644 index 49ebb09..0000000 --- a/src/Samples/Payments/CoreServices/ProcessPayment.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.CoreServices -{ - public class ProcessPayment - { - public static bool CaptureTrueForProcessPayment { get; set; } = false; - - public static PtsV2PaymentsPost201Response Run() - { - var processingInformationObj = new Ptsv2paymentsProcessingInformation() { CommerceIndicator = "internet" }; - - var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation { Code = "test_payment" }; - - var pointOfSaleInformationObj = new Ptsv2paymentsPointOfSaleInformation - { - CatLevel = 6, - TerminalCapability = 4 - }; - - var orderInformationObj = new Ptsv2paymentsOrderInformation(); - - var billToObj = new Ptsv2paymentsOrderInformationBillTo - { - Country = "US", - FirstName = "John", - LastName = "Doe", - Address1 = "1 Market St", - PostalCode = "94105", - Locality = "San Francisco", - AdministrativeArea = "CA", - Email = "test@cybs.com" - }; - - orderInformationObj.BillTo = billToObj; - - var amountDetailsObj = new Ptsv2paymentsOrderInformationAmountDetails - { - TotalAmount = "102.21", - Currency = "USD" - }; - - orderInformationObj.AmountDetails = amountDetailsObj; - - var paymentInformationObj = new Ptsv2paymentsPaymentInformation(); - - var cardObj = new Ptsv2paymentsPaymentInformationCard - { - ExpirationYear = "2031", - Number = "4111111111111111", - SecurityCode = "123", - ExpirationMonth = "12" - }; - - paymentInformationObj.Card = cardObj; - - var requestObj = new CreatePaymentRequest - { - ProcessingInformation = processingInformationObj, - PaymentInformation = paymentInformationObj, - ClientReferenceInformation = clientReferenceInformationObj, - PointOfSaleInformation = pointOfSaleInformationObj, - OrderInformation = orderInformationObj - }; - - if (CaptureTrueForProcessPayment) - { - requestObj.ProcessingInformation.Capture = true; - } - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new PaymentsApi(clientConfig); - - var result = apiInstance.CreatePayment(requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/Payments/CoreServices/RefundCapture.cs b/src/Samples/Payments/CoreServices/RefundCapture.cs deleted file mode 100644 index 5fdb171..0000000 --- a/src/Samples/Payments/CoreServices/RefundCapture.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.CoreServices -{ - public class RefundCapture - { - public static void Run() - { - var capturePaymentId = CapturePayment.Run().Id; - - var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation("test_refund_capture"); - var amountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails("102.21", "USD"); - var orderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(amountDetailsObj); - var requestBody = new RefundCaptureRequest(clientReferenceInformationObj,null, null, orderInformationObj); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new RefundApi(clientConfig); - - var result = apiInstance.RefundCapture(requestBody, capturePaymentId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Payments/CoreServices/RefundPayment.cs b/src/Samples/Payments/CoreServices/RefundPayment.cs deleted file mode 100644 index 6031c80..0000000 --- a/src/Samples/Payments/CoreServices/RefundPayment.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.CoreServices -{ - public class RefundPayment - { - public static PtsV2PaymentsRefundPost201Response Run() - { - ProcessPayment.CaptureTrueForProcessPayment = true; - var processPaymentId = ProcessPayment.Run().Id; - - var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation("test_refund_payment"); - var amountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails("10", "USD"); - var orderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(amountDetailsObj); - var requestBody = new RefundPaymentRequest(clientReferenceInformationObj, null, null, orderInformationObj); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new RefundApi(clientConfig); - - var result = apiInstance.RefundPayment(requestBody, processPaymentId); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} \ No newline at end of file diff --git a/src/Samples/Payments/CoreServices/VoidCapture.cs b/src/Samples/Payments/CoreServices/VoidCapture.cs deleted file mode 100644 index 93250e7..0000000 --- a/src/Samples/Payments/CoreServices/VoidCapture.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.CoreServices -{ - public class VoidCapture - { - public static void Run() - { - var capturePaymentId = CapturePayment.Run().Id; - var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_capture_void"); - var requestBody = new VoidCaptureRequest(clientReferenceInformationObj); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new VoidApi(clientConfig); - - var result = apiInstance.VoidCapture(requestBody, capturePaymentId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Payments/CoreServices/VoidCredit.cs b/src/Samples/Payments/CoreServices/VoidCredit.cs deleted file mode 100644 index a12def3..0000000 --- a/src/Samples/Payments/CoreServices/VoidCredit.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.CoreServices -{ - public class VoidCredit - { - public static void Run() - { - var processCreditId = ProcessCredit.Run().Id; - - var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_credit_void"); - var requestBody = new VoidCreditRequest(clientReferenceInformationObj); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new VoidApi(clientConfig); - - var result = apiInstance.VoidCredit(requestBody, processCreditId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Payments/CoreServices/VoidPayment.cs b/src/Samples/Payments/CoreServices/VoidPayment.cs deleted file mode 100644 index 542ebac..0000000 --- a/src/Samples/Payments/CoreServices/VoidPayment.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.CoreServices -{ - public class VoidPayment - { - public static void Run() - { - ProcessPayment.CaptureTrueForProcessPayment = true; - var processPaymentId = ProcessPayment.Run().Id; - var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_payment_void"); - var requestObj = new VoidPaymentRequest(clientReferenceInformationObj); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new VoidApi(clientConfig); - - var result = apiInstance.VoidPayment(requestObj, processPaymentId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Payments/CoreServices/VoidRefund.cs b/src/Samples/Payments/CoreServices/VoidRefund.cs deleted file mode 100644 index b24c772..0000000 --- a/src/Samples/Payments/CoreServices/VoidRefund.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.CoreServices -{ - public class VoidRefund - { - public static void Run() - { - var refundPaymentId = RefundPayment.Run().Id; - - var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_refund_void"); - var requestBody = new VoidRefundRequest(clientReferenceInformationObj); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new VoidApi(clientConfig); - - var result = apiInstance.VoidRefund(requestBody, refundPaymentId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Payments/ElectronicCheck/ProcessEcheckCredit.cs b/src/Samples/Payments/ElectronicCheck/ProcessEcheckCredit.cs deleted file mode 100644 index bffd794..0000000 --- a/src/Samples/Payments/ElectronicCheck/ProcessEcheckCredit.cs +++ /dev/null @@ -1,86 +0,0 @@ -using CyberSource.Api; -using CyberSource.Model; -using System; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ElectronicCheck -{ - /** - * This is the sample code to do Credit transaction to bank account - */ - class ProcessEcheckCredit - { - public static PtsV2CreditsPost201Response Run() - { - var requestObj = new CreateCreditRequest(); - - var v2PaymentsClientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation - { - Code = "test_credits" - }; - - requestObj.ClientReferenceInformation = v2PaymentsClientReferenceInformationObj; - - var v2PaymentsOrderInformationBillToObj = new Ptsv2paymentsidcapturesOrderInformationBillTo - { - Country = "US", - FirstName = "John", - LastName = "Doe", - PhoneNumber = "4158880000", - Address1 = "1 Market St", - PostalCode = "94105", - Locality = "san francisco", - AdministrativeArea = "CA", - Email = "test@cybs.com" - }; - - var v2PaymentsOrderInformationAmountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails - { - TotalAmount = "200", - Currency = "usd" - }; - - var v2PaymentsOrderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(); - v2PaymentsOrderInformationObj.BillTo = v2PaymentsOrderInformationBillToObj; - v2PaymentsOrderInformationObj.AmountDetails = v2PaymentsOrderInformationAmountDetailsObj; - - requestObj.OrderInformation = v2PaymentsOrderInformationObj; - - var bankAccountObj = new Ptsv2paymentsPaymentInformationBankAccount - { - Number = "4100", - Type = "C", - CheckNumber = "123456" - }; - - var bankObj = new Ptsv2paymentsPaymentInformationBank - { - Account = bankAccountObj - }; - - bankObj.RoutingNumber = "071923284"; - - var paymentInformationObj = new Ptsv2paymentsidrefundsPaymentInformation(); - paymentInformationObj.Bank = bankObj; - - requestObj.PaymentInformation = paymentInformationObj; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new CreditApi(clientConfig); - - var result = apiInstance.CreateCredit(requestObj); - - Console.WriteLine(result); - - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/Payments/ElectronicCheck/ProcessEcheckPayment.cs b/src/Samples/Payments/ElectronicCheck/ProcessEcheckPayment.cs deleted file mode 100644 index b0cc018..0000000 --- a/src/Samples/Payments/ElectronicCheck/ProcessEcheckPayment.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ElectronicCheck -{ - public class ProcessEcheckPayment - { - public static bool CaptureTrueForProcessPayment { get; set; } = false; - - public static PtsV2PaymentsPost201Response Run() - { - var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation { Code = "test_payment" }; - - var processingInformationObj = new Ptsv2paymentsProcessingInformation() { CommerceIndicator = "internet" }; - - var billToObj = new Ptsv2paymentsOrderInformationBillTo - { - Country = "US", - FirstName = "John", - LastName = "Doe", - Address1 = "1 Market St", - PostalCode = "94105", - Locality = "San Francisco", - AdministrativeArea = "CA", - Email = "test@cybs.com" - }; - - var amountDetailsObj = new Ptsv2paymentsOrderInformationAmountDetails - { - TotalAmount = "102.21", - Currency = "USD" - }; - - var orderInformationObj = new Ptsv2paymentsOrderInformation(); - orderInformationObj.BillTo = billToObj; - orderInformationObj.AmountDetails = amountDetailsObj; - - var bankAccountObj = new Ptsv2paymentsPaymentInformationBankAccount - { - Number = "4100", - Type = "C", - CheckNumber = "123456" - }; - - var bankObj = new Ptsv2paymentsPaymentInformationBank - { - Account = bankAccountObj - }; - bankObj.RoutingNumber= "071923284"; - - var paymentInformationObj = new Ptsv2paymentsPaymentInformation(); - paymentInformationObj.Bank = bankObj; - - var requestObj = new CreatePaymentRequest - { - ProcessingInformation = processingInformationObj, - PaymentInformation = paymentInformationObj, - ClientReferenceInformation = clientReferenceInformationObj, - OrderInformation = orderInformationObj - }; - - if (CaptureTrueForProcessPayment) - { - requestObj.ProcessingInformation.Capture = true; - } - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new PaymentsApi(clientConfig); - - var result = apiInstance.CreatePayment(requestObj); - - Console.WriteLine(result); - - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/Payments/ElectronicCheck/RefundEcheckPayment.cs b/src/Samples/Payments/ElectronicCheck/RefundEcheckPayment.cs deleted file mode 100644 index fb1231b..0000000 --- a/src/Samples/Payments/ElectronicCheck/RefundEcheckPayment.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; -using Cybersource_rest_samples_dotnet.Samples.Payments.CoreServices; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ElectronicCheck -{ - public class RefundEcheckPayment - { - public static PtsV2PaymentsRefundPost201Response Run() - { - var capturePaymentId = CapturePayment.Run().Id; - - var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation("test_refund_capture"); - - var amountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails("102.21", "USD"); - - var billToObj = new Ptsv2paymentsidcapturesOrderInformationBillTo - { - Country = "US", - FirstName = "John", - LastName = "Doe", - Address1 = "1 Market St", - PostalCode = "94105", - Locality = "San Francisco", - AdministrativeArea = "CA", - Email = "test@cybs.com" - }; - var orderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(amountDetailsObj, billToObj); - - var bankAccountObj = new Ptsv2paymentsPaymentInformationBankAccount - { - Number = "4100", - Type = "C", - CheckNumber = "123456" - }; - - var bankObj = new Ptsv2paymentsPaymentInformationBank - { - Account = bankAccountObj - }; - bankObj.RoutingNumber = "071923284"; - - var paymentInformationObj = new Ptsv2paymentsidrefundsPaymentInformation(); - paymentInformationObj.Bank = bankObj; - - var requestBody = new RefundCaptureRequest(clientReferenceInformationObj, null, paymentInformationObj, orderInformationObj); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new RefundApi(clientConfig); - - var result = apiInstance.RefundCapture(requestBody, capturePaymentId); - - Console.WriteLine(result.Id); - - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} \ No newline at end of file diff --git a/src/Samples/Payments/ElectronicCheck/VoidECheckPaymentRefund.cs b/src/Samples/Payments/ElectronicCheck/VoidECheckPaymentRefund.cs deleted file mode 100644 index a7d79eb..0000000 --- a/src/Samples/Payments/ElectronicCheck/VoidECheckPaymentRefund.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ElectronicCheck -{ - public class VoidECheckPaymentRefund - { - public static void Run() - { - var refundPaymentId = RefundEcheckPayment.Run().Id; - - var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_refund_void"); - var requestBody = new VoidRefundRequest(clientReferenceInformationObj); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new VoidApi(clientConfig); - var result = apiInstance.VoidRefund(requestBody, refundPaymentId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Payments/ElectronicCheck/VoidEcheckCredit.cs b/src/Samples/Payments/ElectronicCheck/VoidEcheckCredit.cs deleted file mode 100644 index dc5b387..0000000 --- a/src/Samples/Payments/ElectronicCheck/VoidEcheckCredit.cs +++ /dev/null @@ -1,32 +0,0 @@ - -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ElectronicCheck -{ - public class VoidEcheckCredit - { - public static void Run() - { - var processCreditId = ProcessEcheckCredit.Run().Id; - - var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_credit_void"); - var requestBody = new VoidCreditRequest(clientReferenceInformationObj); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new VoidApi(clientConfig); - - var result = apiInstance.VoidCredit(requestBody, processCreditId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Payments/ServiceFees/CapturePaymentWithServiceFee.cs b/src/Samples/Payments/ServiceFees/CapturePaymentWithServiceFee.cs deleted file mode 100644 index b73c452..0000000 --- a/src/Samples/Payments/ServiceFees/CapturePaymentWithServiceFee.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; -using Cybersource_rest_samples_dotnet.Samples.Payments.CoreServices; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ServiceFees -{ - public class CapturePaymentWithServiceFee - { - public static PtsV2PaymentsRefundPost201Response Run() - { - ProcessPayment.CaptureTrueForProcessPayment = true; - - var processPaymentId = ProcessPayment.Run().Id; - - var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation("test_refund_payment"); - - var amountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails - { - TotalAmount = "2325.00", - Currency = "USD", - ServiceFeeAmount = "30.00" - }; - - var billToObj = new Ptsv2paymentsidcapturesOrderInformationBillTo - { - Country = "US", - FirstName = "John", - LastName = "Doe", - Address1 = "1 Market St", - PostalCode = "94105", - Locality = "San Francisco", - AdministrativeArea = "CA", - Email = "test@cybs.com" - }; - - var orderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(amountDetailsObj, billToObj); - - var bankAccountObj = new Ptsv2paymentsPaymentInformationBankAccount - { - Number = "4100", - Type = "C", - CheckNumber = "123456" - }; - - var bankObj = new Ptsv2paymentsPaymentInformationBank - { - Account = bankAccountObj - }; - bankObj.RoutingNumber = "071923284"; - - var paymentInformationObj = new Ptsv2paymentsidrefundsPaymentInformation(); - paymentInformationObj.Bank = bankObj; - - var requestBody = new RefundPaymentRequest - { - PaymentInformation = paymentInformationObj, - ClientReferenceInformation = clientReferenceInformationObj, - OrderInformation = orderInformationObj - }; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new RefundApi(clientConfig); - - var result = apiInstance.RefundPayment(requestBody, processPaymentId); - - Console.WriteLine(result); - - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } - } \ No newline at end of file diff --git a/src/Samples/Payments/ServiceFees/CreditWithServiceFee.cs b/src/Samples/Payments/ServiceFees/CreditWithServiceFee.cs deleted file mode 100644 index 687978a..0000000 --- a/src/Samples/Payments/ServiceFees/CreditWithServiceFee.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Model; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ServiceFees -{ - public class CreditWithServiceFee - { - public static PtsV2CreditsPost201Response Run() - { - var requestObj = new CreateCreditRequest(); - - var v2PaymentsClientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation - { - Code = "12345678" - }; - - requestObj.ClientReferenceInformation = v2PaymentsClientReferenceInformationObj; - - var v2PaymentsOrderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(); - var v2paymentsOrderInformationBillToCompany = "Visa"; - var v2PaymentsOrderInformationBillToObj = new Ptsv2paymentsidcapturesOrderInformationBillTo - { - Country = "US", - FirstName = "John", - LastName = "Doe", - PhoneNumber = "4158880000", - Address1 = "1 Market St", - PostalCode = "94105", - Locality = "san francisco", - AdministrativeArea = "CA", - Email = "test@cybs.com" - }; - v2PaymentsOrderInformationBillToObj.Company = v2paymentsOrderInformationBillToCompany; - v2PaymentsOrderInformationObj.BillTo = v2PaymentsOrderInformationBillToObj; - - var v2PaymentsOrderInformationAmountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails - { - TotalAmount = "2325.00", - Currency = "usd", - ServiceFeeAmount = "30.00" - }; - - v2PaymentsOrderInformationObj.AmountDetails = v2PaymentsOrderInformationAmountDetailsObj; - - requestObj.OrderInformation = v2PaymentsOrderInformationObj; - - var v2PaymentsPaymentInformationObj = new Ptsv2paymentsidrefundsPaymentInformation(); - - var v2PaymentsPaymentInformationCardObj = new Ptsv2paymentsidrefundsPaymentInformationCard - { - ExpirationYear = "2031", - Number = "4111111111111111", - ExpirationMonth = "03" - }; - - v2PaymentsPaymentInformationObj.Card = v2PaymentsPaymentInformationCardObj; - - requestObj.PaymentInformation = v2PaymentsPaymentInformationObj; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new CreditApi(clientConfig); - - var result = apiInstance.CreateCredit(requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/Payments/ServiceFees/ECheckStandaloneCreditWithServiceFee.cs b/src/Samples/Payments/ServiceFees/ECheckStandaloneCreditWithServiceFee.cs deleted file mode 100644 index 8f67e1f..0000000 --- a/src/Samples/Payments/ServiceFees/ECheckStandaloneCreditWithServiceFee.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ServiceFees -{ - public class ECheckStandaloneCreditWithServiceFee - { - public static PtsV2CreditsPost201Response Run() - { - var requestObj = new CreateCreditRequest(); - - var v2PaymentsClientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation - { - Code = "TC46125-1" - }; - requestObj.ClientReferenceInformation = v2PaymentsClientReferenceInformationObj; - var processingInformation = new Ptsv2creditsProcessingInformation - { - CommerceIndicator = "internet" - }; - requestObj.ProcessingInformation = processingInformation; - - var v2PaymentsOrderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(); - var v2paymentsOrderInformationBillToCompany = "Visa"; - var v2PaymentsOrderInformationBillToObj = new Ptsv2paymentsidcapturesOrderInformationBillTo - { - Country = "US", - FirstName = "John", - LastName = "Doe", - PhoneNumber = "4158880000", - Address1 = "1 Market St", - PostalCode = "94105", - Locality = "san francisco", - AdministrativeArea = "CA", - Email = "test@cybs.com" - }; - v2PaymentsOrderInformationBillToObj.Company = v2paymentsOrderInformationBillToCompany; - v2PaymentsOrderInformationObj.BillTo = v2PaymentsOrderInformationBillToObj; - - var v2PaymentsOrderInformationAmountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails - { - TotalAmount = "2325.00", - Currency = "usd", - ServiceFeeAmount = "30.00" - }; - - v2PaymentsOrderInformationObj.AmountDetails = v2PaymentsOrderInformationAmountDetailsObj; - - requestObj.OrderInformation = v2PaymentsOrderInformationObj; - - var v2PaymentsPaymentInformationObj = new Ptsv2paymentsidrefundsPaymentInformation(); - var v2paymentsPaymentInformationBankAccountObj = new Ptsv2paymentsPaymentInformationBankAccount - { - Number = "4100", - Type = "C", - CheckNumber = "123456" - }; - var v2paymentsPaymentInformationBankObj = new Ptsv2paymentsPaymentInformationBank - { - RoutingNumber = "071923284" - }; - v2paymentsPaymentInformationBankObj.Account = v2paymentsPaymentInformationBankAccountObj; - v2PaymentsPaymentInformationObj.Bank = v2paymentsPaymentInformationBankObj; - requestObj.PaymentInformation = v2PaymentsPaymentInformationObj; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new CreditApi(clientConfig); - - var result = apiInstance.CreateCredit(requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/Payments/ServiceFees/ProcessAuthorizationReversalWithServiceFee.cs b/src/Samples/Payments/ServiceFees/ProcessAuthorizationReversalWithServiceFee.cs deleted file mode 100644 index a18d255..0000000 --- a/src/Samples/Payments/ServiceFees/ProcessAuthorizationReversalWithServiceFee.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Model; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ServiceFees -{ - public class ProcessAuthorizationReversalWithServiceFee - { - public static PtsV2PaymentsReversalsPost201Response Run() - { - var processPaymentId = ProcessPaymentWithServiceFee.Run().Id; - var requestBody = new AuthReversalRequest(); - var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("TC50171_3"); - requestBody.ClientReferenceInformation = clientReferenceInformationObj; - var v2paymentsidreversalsReversalInformationObj = new Ptsv2paymentsidreversalsReversalInformation - { - Reason = "34" - }; - var v2paymentsidreversalsReversalInformationAmountDetailsobj = new Ptsv2paymentsidreversalsReversalInformationAmountDetails - { - TotalAmount = "2325.00" - }; - v2paymentsidreversalsReversalInformationObj.AmountDetails = v2paymentsidreversalsReversalInformationAmountDetailsobj; - requestBody.ReversalInformation = v2paymentsidreversalsReversalInformationObj; - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new ReversalApi(clientConfig); - - var result = apiInstance.AuthReversal(processPaymentId, requestBody); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/Payments/ServiceFees/ProcessEcheckCreditWithServiceFee.cs b/src/Samples/Payments/ServiceFees/ProcessEcheckCreditWithServiceFee.cs deleted file mode 100644 index c1e15f9..0000000 --- a/src/Samples/Payments/ServiceFees/ProcessEcheckCreditWithServiceFee.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ServiceFees -{ - public class ProcessEcheckCreditWithServiceFee - { - public static void Run() - { - var echeckPaymentWithServiceFeecapturePaymentId = ProcessEcheckPaymentWithServiceFee.Run().Id; - - var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation("test_refund_capture"); - - var amountDetailsObj = new Ptsv2paymentsidcapturesOrderInformationAmountDetails("102.21", "USD"); - - var billToObj = new Ptsv2paymentsidcapturesOrderInformationBillTo - { - Country = "US", - FirstName = "John", - LastName = "Doe", - Address1 = "1 Market St", - PostalCode = "94105", - Locality = "San Francisco", - AdministrativeArea = "CA", - Email = "test@cybs.com" - }; - - var orderInformationObj = new Ptsv2paymentsidrefundsOrderInformation(amountDetailsObj, billToObj); - - var bankAccountObj = new Ptsv2paymentsPaymentInformationBankAccount - { - Number = "4100", - Type = "C", - CheckNumber = "123456" - }; - - var bankObj = new Ptsv2paymentsPaymentInformationBank - { - Account = bankAccountObj - }; - bankObj.RoutingNumber = "071923284"; - - var paymentInformationObj = new Ptsv2paymentsidrefundsPaymentInformation(); - paymentInformationObj.Bank = bankObj; - - var requestBody = new RefundCaptureRequest(clientReferenceInformationObj, null, paymentInformationObj, orderInformationObj); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new RefundApi(clientConfig); - - var result = apiInstance.RefundCapture(requestBody, echeckPaymentWithServiceFeecapturePaymentId); - - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} \ No newline at end of file diff --git a/src/Samples/Payments/ServiceFees/ProcessEcheckPaymentWithServiceFee.cs b/src/Samples/Payments/ServiceFees/ProcessEcheckPaymentWithServiceFee.cs deleted file mode 100644 index 8f8e7f4..0000000 --- a/src/Samples/Payments/ServiceFees/ProcessEcheckPaymentWithServiceFee.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ServiceFees -{ - public class ProcessEcheckPaymentWithServiceFee - { - public static bool CaptureTrueForProcessPayment { get; set; } = false; - - public static PtsV2PaymentsPost201Response Run() - { - var processingInformationObj = new Ptsv2paymentsProcessingInformation() { CommerceIndicator = "internet" }; - - var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation { Code = "test_payment" }; - - var orderInformationObj = new Ptsv2paymentsOrderInformation(); - - var billToObj = new Ptsv2paymentsOrderInformationBillTo - { - Country = "US", - FirstName = "John", - LastName = "Doe", - Address1 = "1 Market St", - PostalCode = "94105", - Locality = "San Francisco", - AdministrativeArea = "CA", - Email = "test@cybs.com" - }; - - orderInformationObj.BillTo = billToObj; - - var amountDetailsObj = new Ptsv2paymentsOrderInformationAmountDetails - { - TotalAmount = "2325.00", - ServiceFeeAmount = "30.00", - Currency = "USD", - }; - - orderInformationObj.AmountDetails = amountDetailsObj; - - var bankAccountObj = new Ptsv2paymentsPaymentInformationBankAccount - { - Number = "4100", - Type = "C", - }; - - var bankObj = new Ptsv2paymentsPaymentInformationBank - { - Account = bankAccountObj, - RoutingNumber = "071923284", - }; - - var paymentInformationObj = new Ptsv2paymentsPaymentInformation(); - paymentInformationObj.Bank = bankObj; - - var requestObj = new CreatePaymentRequest - { - ProcessingInformation = processingInformationObj, - PaymentInformation = paymentInformationObj, - ClientReferenceInformation = clientReferenceInformationObj, - OrderInformation = orderInformationObj - }; - - if (CaptureTrueForProcessPayment) - { - requestObj.ProcessingInformation.Capture = true; - } - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new PaymentsApi(clientConfig); - - var result = apiInstance.CreatePayment(requestObj); - - Console.WriteLine(result); - - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/Payments/ServiceFees/ProcessPaymentWithServiceFee.cs b/src/Samples/Payments/ServiceFees/ProcessPaymentWithServiceFee.cs deleted file mode 100644 index 47c1d6a..0000000 --- a/src/Samples/Payments/ServiceFees/ProcessPaymentWithServiceFee.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ServiceFees -{ - public class ProcessPaymentWithServiceFee - { - public static bool CaptureTrueForProcessPayment { get; set; } = false; - - public static PtsV2PaymentsPost201Response Run() - { - var processingInformationObj = new Ptsv2paymentsProcessingInformation() { CommerceIndicator = "internet" }; - - var clientReferenceInformationObj = new Ptsv2paymentsClientReferenceInformation { Code = "test_payment" }; - - var billToObj = new Ptsv2paymentsOrderInformationBillTo - { - Country = "US", - FirstName = "John", - LastName = "Doe", - Address1 = "1 Market St", - PostalCode = "94105", - Locality = "San Francisco", - AdministrativeArea = "CA", - Email = "test@cybs.com" - }; - - var amountDetailsObj = new Ptsv2paymentsOrderInformationAmountDetails - { - TotalAmount = "2325.00", - Currency = "USD", - ServiceFeeAmount = "30.00" - }; - - var orderInformationObj = new Ptsv2paymentsOrderInformation(); - orderInformationObj.BillTo = billToObj; - orderInformationObj.AmountDetails = amountDetailsObj; - - var cardObj = new Ptsv2paymentsPaymentInformationCard - { - ExpirationYear = "2031", - Number = "4111111111111111", - ExpirationMonth = "12" - }; - - var paymentInformationObj = new Ptsv2paymentsPaymentInformation(); - paymentInformationObj.Card = cardObj; - - var serviceFeeDescriptorObj = new Ptsv2paymentsMerchantInformationServiceFeeDescriptor - { - Name = "CyberSource Service Fee", - Contact = "800-999-9999", - State = "CA", - - }; - - var merchantInformationObj = new Ptsv2paymentsMerchantInformation(); - merchantInformationObj.ServiceFeeDescriptor = serviceFeeDescriptorObj; - - var requestObj = new CreatePaymentRequest - { - ProcessingInformation = processingInformationObj, - PaymentInformation = paymentInformationObj, - ClientReferenceInformation = clientReferenceInformationObj, - OrderInformation = orderInformationObj, - MerchantInformation = merchantInformationObj - }; - - if (CaptureTrueForProcessPayment) - { - requestObj.ProcessingInformation.Capture = true; - } - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new PaymentsApi(clientConfig); - - var result = apiInstance.CreatePayment(requestObj); - - Console.WriteLine(result); - - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/Payments/ServiceFees/VoidCreditWithServiceFee.cs b/src/Samples/Payments/ServiceFees/VoidCreditWithServiceFee.cs deleted file mode 100644 index 11dc9b6..0000000 --- a/src/Samples/Payments/ServiceFees/VoidCreditWithServiceFee.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ServiceFees -{ - public class VoidCreditWithServiceFee - { - public static void Run() - { - var creditWithServiceFeeId = CreditWithServiceFee.Run().Id; - - var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_credit_void"); - var requestBody = new VoidCreditRequest(clientReferenceInformationObj); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new VoidApi(clientConfig); - - var result = apiInstance.VoidCredit(requestBody, creditWithServiceFeeId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Payments/ServiceFees/VoidStandaloneEcheckCreditWithServiceFee.cs b/src/Samples/Payments/ServiceFees/VoidStandaloneEcheckCreditWithServiceFee.cs deleted file mode 100644 index 978932d..0000000 --- a/src/Samples/Payments/ServiceFees/VoidStandaloneEcheckCreditWithServiceFee.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payments.ServiceFees -{ - public class VoidStandaloneEcheckCreditWithServiceFee - { - public static void Run() - { - var eCheckStandaloneCreditWithServiceFeeId = ECheckStandaloneCreditWithServiceFee.Run().Id; - - var clientReferenceInformationObj = new Ptsv2paymentsidreversalsClientReferenceInformation("test_credit_void"); - var requestBody = new VoidCreditRequest(clientReferenceInformationObj); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new VoidApi(clientConfig); - - var result = apiInstance.VoidCredit(requestBody, eCheckStandaloneCreditWithServiceFeeId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Payouts/CoreServices/ProcessPayout.cs b/src/Samples/Payouts/CoreServices/ProcessPayout.cs deleted file mode 100644 index 8d5dbea..0000000 --- a/src/Samples/Payouts/CoreServices/ProcessPayout.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Payouts.CoreServices -{ - public class ProcessPayout - { - public static void Run() - { - var requestObj = new OctCreatePaymentRequest(); - - var clientReferenceInformationObj = new Ptsv2payoutsClientReferenceInformation - { - Code = "33557799" - }; - - requestObj.ClientReferenceInformation = clientReferenceInformationObj; - - var senderInformationObj = new Ptsv2payoutsSenderInformation - { - ReferenceNumber = "1234567890", - Address1 = "900 Metro Center Blvd.900", - CountryCode = "US", - Locality = "San Francisco", - Name = "Thomas Jefferson", - AdministrativeArea = "CA" - }; - - var accountObj = new Ptsv2payoutsSenderInformationAccount - { - Number = "1234567890123456789012345678901234", - FundsSource = "01" - }; - - senderInformationObj.Account = accountObj; - - requestObj.SenderInformation = senderInformationObj; - - var processingInformationObj = new Ptsv2payoutsProcessingInformation - { - CommerceIndicator = "internet", - BusinessApplicationId = "FD", - NetworkRoutingOrder = "ECG" - }; - - requestObj.ProcessingInformation = processingInformationObj; - - var orderInformationObj = new Ptsv2payoutsOrderInformation(); - - var amountDetailsObj = new Ptsv2payoutsOrderInformationAmountDetails - { - TotalAmount = "100.00", - Currency = "USD" - }; - - orderInformationObj.AmountDetails = amountDetailsObj; - - requestObj.OrderInformation = orderInformationObj; - - var merchantInformationObj = new Ptsv2payoutsMerchantInformation - { - CategoryCode = 123 - }; - - var merchantDescriptorObj = new Ptsv2payoutsMerchantInformationMerchantDescriptor - { - Country = "US", - PostalCode = "94440", - Locality = "FC", - Name = "Thomas", - AdministrativeArea = "CA" - }; - - merchantInformationObj.MerchantDescriptor = merchantDescriptorObj; - - requestObj.MerchantInformation = merchantInformationObj; - - var paymentInformationObj = new Ptsv2payoutsPaymentInformation(); - - var cardObj = new Ptsv2payoutsPaymentInformationCard - { - ExpirationYear = "2025", - Number = "4111111111111111", - ExpirationMonth = "12", - Type = "001", - SourceAccountType = "CH" - }; - - paymentInformationObj.Card = cardObj; - - requestObj.PaymentInformation = paymentInformationObj; - - var recipientInformationObj = new Ptsv2payoutsRecipientInformation - { - FirstName = "John", - LastName = "Doe", - Address1 = "Paseo Padre Boulevard", - Locality = "San Francisco", - AdministrativeArea = "CA", - PostalCode = "94400", - PhoneNumber = "6504320556", - DateOfBirth = "19801009", - Country = "US" - }; - - requestObj.RecipientInformation = recipientInformationObj; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new PayoutsApi(clientConfig); - - var result = apiInstance.OctCreatePaymentWithHttpInfo(requestObj); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Reporting/CoreServices/CreateAdhocReport.cs b/src/Samples/Reporting/CoreServices/CreateAdhocReport.cs deleted file mode 100644 index d6e5570..0000000 --- a/src/Samples/Reporting/CoreServices/CreateAdhocReport.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class CreateAdhocReport - { - public static void Run() - { - try - { - var requestObj = new CreateAdhocReportRequest - { - ReportDefinitionName = "TransactionRequestClass", - ReportFields = new List() - { - "Request.RequestID", - "Request.TransactionDate", - "Request.MerchantID" - }, - ReportMimeType = "application/xml", - ReportName = Utilities.RandomString(17), - Timezone = "GMT", - ReportStartTime = DateTime.ParseExact("2018-09-01T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture), - ReportEndTime = DateTime.ParseExact("2018-09-02T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture) - }; - - var reportPreferencesObj = new Reportingv3reportsReportPreferences() - { - SignedAmounts = true, - FieldNameConvention = "SOAPI" - }; - - requestObj.ReportPreferences = reportPreferencesObj; - - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new ReportsApi(clientConfig); - - apiInstance.CreateReport(requestObj); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Reporting/CoreServices/CreateReportSubscriptionForReportNameByOrganization.cs b/src/Samples/Reporting/CoreServices/CreateReportSubscriptionForReportNameByOrganization.cs deleted file mode 100644 index 6429546..0000000 --- a/src/Samples/Reporting/CoreServices/CreateReportSubscriptionForReportNameByOrganization.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class CreateReportSubscriptionForReportNameByOrganization - { - public static void Run() - { - const string reportName = "testrest_subcription_v1"; - - var request = new CreateReportSubscriptionRequest( - ReportDefinitionName: "TransactionRequestClass", - ReportMimeType: "application/xml", - ReportFields: new List() {"Request.RequestID", "Request.TransactionDate", "Request.MerchantID"}, - ReportName: reportName, - ReportFrequency: "WEEKLY", - Timezone: "GMT", - StartTime: "0115", - StartDay: 1); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new ReportSubscriptionsApi(clientConfig); - - apiInstance.CreateSubscription(request); - - DeleteSubscriptionOfReportNameByOrganization.ReportNameToDelete = reportName; - DeleteSubscriptionOfReportNameByOrganization.Run(); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Reporting/CoreServices/DeleteSubscriptionOfReportNameByOrganization.cs b/src/Samples/Reporting/CoreServices/DeleteSubscriptionOfReportNameByOrganization.cs deleted file mode 100644 index ebf4b17..0000000 --- a/src/Samples/Reporting/CoreServices/DeleteSubscriptionOfReportNameByOrganization.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class DeleteSubscriptionOfReportNameByOrganization - { - public static string ReportNameToDelete { get; set; } - - public static void Run() - { - if (string.IsNullOrEmpty(ReportNameToDelete)) - { - ReportNameToDelete = "testrest_subcription_v1"; - } - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new ReportSubscriptionsApi(clientConfig); - - apiInstance.DeleteSubscription(ReportNameToDelete); - ReportNameToDelete = null; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} \ No newline at end of file diff --git a/src/Samples/Reporting/CoreServices/DownloadReport.cs b/src/Samples/Reporting/CoreServices/DownloadReport.cs deleted file mode 100644 index d2ac934..0000000 --- a/src/Samples/Reporting/CoreServices/DownloadReport.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Globalization; -using System.IO; -using System.Xml; -using System.Xml.Serialization; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class DownloadReport - { - public static void Run() - { - // File will be created with the Data received in the Response Body - - // Provide the File Name - const string fileName = "DownloadReport.csv"; - - // Provide the path where the file needs to be downloaded - // This can be either a relative path or an absolute path - const string downloadFilePath = @".\Resource\" + fileName; - - const string organizationId = "testrest"; - const string reportName = "testrest_subcription_v2989"; - var reportDate = DateTime.ParseExact("2019-09-05", "yyyy-MM-dd", CultureInfo.InvariantCulture); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new ReportDownloadsApi(clientConfig); - - var content = apiInstance.DownloadReportWithHttpInfo(reportDate, reportName, organizationId); - - File.WriteAllText(downloadFilePath, CreateXml(content.Data)); - - Console.WriteLine("\nFile downloaded at the below location:"); - Console.WriteLine($"{Path.GetFullPath(downloadFilePath)}\n"); - } - catch (FileNotFoundException) - { - Console.WriteLine("File Not Found: Kindly verify the path"); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - - private static string CreateXml(object obj) - { - var xmlDoc = new XmlDocument(); // Represents an XML document - var xmlSerializer = new XmlSerializer(obj.GetType()); // Initializes a new instance of the XmlDocument class. - - // Creates a stream whose backing store is memory. - using (var xmlStream = new MemoryStream()) - { - xmlSerializer.Serialize(xmlStream, obj); - xmlStream.Position = 0; - - // Loads the XML document from the specified string. - xmlDoc.Load(xmlStream); - return xmlDoc.InnerText; - } - } - } -} diff --git a/src/Samples/Reporting/CoreServices/GetAllSubscriptions.cs b/src/Samples/Reporting/CoreServices/GetAllSubscriptions.cs deleted file mode 100644 index 655160d..0000000 --- a/src/Samples/Reporting/CoreServices/GetAllSubscriptions.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class GetAllSubscriptions - { - public static void Run() - { - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new ReportSubscriptionsApi(clientConfig); - - var result = apiInstance.GetAllSubscriptions(); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Reporting/CoreServices/GetConversionDetailTransactions.cs b/src/Samples/Reporting/CoreServices/GetConversionDetailTransactions.cs deleted file mode 100644 index 60894a7..0000000 --- a/src/Samples/Reporting/CoreServices/GetConversionDetailTransactions.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using CyberSource.Api; -using System.Globalization; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class GetConversionDetailTransactions - { - public static void Run() - { - DateTime startTime = DateTime.ParseExact("2019-03-21T00:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); - DateTime endTime = DateTime.ParseExact("2019-03-21T23:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new ConversionDetailsApi(clientConfig); - string organizationId = null; // "testrest"; - - var result = apiInstance.GetConversionDetail(startTime, endTime, organizationId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Reporting/CoreServices/GetNetfundingInformationForAccountOrMerchant.cs b/src/Samples/Reporting/CoreServices/GetNetfundingInformationForAccountOrMerchant.cs deleted file mode 100644 index 40368c4..0000000 --- a/src/Samples/Reporting/CoreServices/GetNetfundingInformationForAccountOrMerchant.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Globalization; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class GetNetfundingInformationForAccountOrMerchant - { - public static void Run() - { - try - { - var startTime = DateTime.ParseExact("2019-03-21T00:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); - var endTime = DateTime.ParseExact("2019-03-21T23:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); - var groupName = "testName"; - var organizationId = "testrest"; - - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new NetFundingsApi(clientConfig); - - var result = apiInstance.GetNetFundingDetails(startTime, endTime, organizationId, groupName); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Reporting/CoreServices/GetNotificationOfChanges.cs b/src/Samples/Reporting/CoreServices/GetNotificationOfChanges.cs deleted file mode 100644 index 1b4b1bd..0000000 --- a/src/Samples/Reporting/CoreServices/GetNotificationOfChanges.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class GetNotificationOfChanges - { - public static void Run() - { - var startTime = DateTime.Parse("2019-03-01T12:00:00-05:00"); - var endTime = DateTime.Parse("2019-03-30T12:00:00-05:00"); - - //var startTime = DateTime.Parse("2018-09-01T12:00:00.000Z"); - //var endTime = DateTime.Parse("2018-09-30T12:00:00.000Z"); - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new NotificationOfChangesApi(clientConfig); - - var result = apiInstance.GetNotificationOfChangeReport(startTime, endTime); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Reporting/CoreServices/GetPaymentBatchSummaryData.cs b/src/Samples/Reporting/CoreServices/GetPaymentBatchSummaryData.cs deleted file mode 100644 index d55105c..0000000 --- a/src/Samples/Reporting/CoreServices/GetPaymentBatchSummaryData.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Code Generated: getPaymentBatchSummary[Get payment batch summary data] - -using System; -using System.Collections.Generic; -using System.Globalization; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class GetPaymentBatchSummaryData - { - public static void Run() - { - var startTime = DateTime.ParseExact("2019-05-01T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); - var endTime = DateTime.ParseExact("2019-08-30T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); - string organizationId = "testrest"; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - - var apiInstance = new PaymentBatchSummariesApi(clientConfig); - var result = apiInstance.GetPaymentBatchSummary(startTime, endTime, organizationId); - Console.WriteLine(result); - - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API : " + e.Message); - } - } - } -} \ No newline at end of file diff --git a/src/Samples/Reporting/CoreServices/GetPurchaseAndRefundDetails.cs b/src/Samples/Reporting/CoreServices/GetPurchaseAndRefundDetails.cs deleted file mode 100644 index b206615..0000000 --- a/src/Samples/Reporting/CoreServices/GetPurchaseAndRefundDetails.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class GetPurchaseAndRefundDetails - { - public static void Run() - { - const string organizationId = "testrest"; - var startTime = DateTime.Parse("2018-05-01T12:00:00-05:00"); - var endTime = DateTime.Parse("2018-05-30T12:00:00-05:00"); - const string paymentSubtype = "VI"; - const string viewBy = "requestDate"; - const string groupName = "groupName"; - const int offset = 20; - const int limit = 2000; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new PurchaseAndRefundDetailsApi(clientConfig); - - var result = apiInstance.GetPurchaseAndRefundDetails(startTime, endTime, organizationId, paymentSubtype, - viewBy, groupName, offset, limit); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Reporting/CoreServices/GetReportBasedOnReportid.cs b/src/Samples/Reporting/CoreServices/GetReportBasedOnReportid.cs deleted file mode 100644 index bb2e508..0000000 --- a/src/Samples/Reporting/CoreServices/GetReportBasedOnReportid.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class GetReportBasedOnReportid - { - public static void Run() - { - const string reportId = "79642c43-2368-0cd5-e053-a2588e0a7b3c"; - const string organizationId = "testrest"; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new ReportsApi(clientConfig); - - var result = apiInstance.GetReportByReportId(reportId, organizationId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Reporting/CoreServices/GetReportDefinition.cs b/src/Samples/Reporting/CoreServices/GetReportDefinition.cs deleted file mode 100644 index e32ab14..0000000 --- a/src/Samples/Reporting/CoreServices/GetReportDefinition.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class GetReportDefinition - { - public static void Run() - { - const string reportDefinitionName = "SubscriptionDetailClass"; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new ReportDefinitionsApi(clientConfig); - - var result = apiInstance.GetResourceInfoByReportDefinition(reportDefinitionName); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Reporting/CoreServices/GetReportingResourceInformation.cs b/src/Samples/Reporting/CoreServices/GetReportingResourceInformation.cs deleted file mode 100644 index 6d14aa8..0000000 --- a/src/Samples/Reporting/CoreServices/GetReportingResourceInformation.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class GetReportingResourceInformation - { - public static void Run() - { - const string organizationId = "testrest"; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new ReportDefinitionsApi(clientConfig); - - var result = apiInstance.GetResourceV2Info(organizationId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Reporting/CoreServices/GetSubscriptionForReportName.cs b/src/Samples/Reporting/CoreServices/GetSubscriptionForReportName.cs deleted file mode 100644 index 027ba59..0000000 --- a/src/Samples/Reporting/CoreServices/GetSubscriptionForReportName.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class GetSubscriptionForReportName - { - public static void Run() - { - var reportName = "testrest_subcription_v1"; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new ReportSubscriptionsApi(clientConfig); - - var result = apiInstance.GetSubscription(reportName); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/Reporting/CoreServices/RetrieveAvailableReports.cs b/src/Samples/Reporting/CoreServices/RetrieveAvailableReports.cs deleted file mode 100644 index 7cdf80c..0000000 --- a/src/Samples/Reporting/CoreServices/RetrieveAvailableReports.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Globalization; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.Reporting.CoreServices -{ - public class RetrieveAvailableReports - { - public static void Run() - { - try - { - var startTime = DateTime.ParseExact("2018-10-01T00:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); - var endTime = DateTime.ParseExact("2018-10-30T23:59:59Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); - var timeQueryType = "executedTime"; - var organizationId = "testrest"; - - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new ReportsApi(clientConfig); - - var result = apiInstance.SearchReports(startTime, endTime, timeQueryType, organizationId); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/SecureFileShare/CoreServices/DownloadFileWithFileIdentifier.cs b/src/Samples/SecureFileShare/CoreServices/DownloadFileWithFileIdentifier.cs deleted file mode 100644 index f06c364..0000000 --- a/src/Samples/SecureFileShare/CoreServices/DownloadFileWithFileIdentifier.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.IO; -using System.Xml; -using System.Xml.Serialization; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.SecureFileShare.CoreServices -{ - public class DownloadFileWithFileIdentifier - { - public static void Run() - { - try - { - // File will be created with the Data received in the Response Body - - // Provide the File Name - const string fileName = "DownloadFileWithFileIdentifier.csv"; - - // Provide the path where the file needs to be downloaded - // This can be either a relative path or an absolute path - const string downloadFilePath = @".\Resource\" + fileName; - - var fileId = "dGVzdHJlc3Rfc3ViY3JpcHRpb25fdjI5ODktOTMwYWU5MmItOTcxMy00N2U4LWUwNTMtYTI1ODhlMGFjZDNjLnhtbC0yMDE5LTA5LTMw"; - var organizationId = "testrest"; - - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new SecureFileShareApi(clientConfig); - - var content = apiInstance.GetFileWithHttpInfo(fileId, organizationId); - - File.WriteAllText(downloadFilePath, CreateXml(content.Data)); - - Console.WriteLine("\nFile downloaded at the below location:"); - Console.WriteLine($"{Path.GetFullPath(downloadFilePath)}\n"); - } - catch (FileNotFoundException) - { - Console.WriteLine("File Not Found: Kindly verify the path"); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - - private static string CreateXml(object obj) - { - var xmlDoc = new XmlDocument(); // Represents an XML document - var xmlSerializer = new XmlSerializer(obj.GetType()); // Initializes a new instance of the XmlDocument class. - - // Creates a stream whose backing store is memory. - using (var xmlStream = new MemoryStream()) - { - xmlSerializer.Serialize(xmlStream, obj); - xmlStream.Position = 0; - - // Loads the XML document from the specified string. - xmlDoc.Load(xmlStream); - return xmlDoc.InnerText; - } - } - } -} diff --git a/src/Samples/SecureFileShare/CoreServices/GetListOfFiles.cs b/src/Samples/SecureFileShare/CoreServices/GetListOfFiles.cs deleted file mode 100644 index 260acca..0000000 --- a/src/Samples/SecureFileShare/CoreServices/GetListOfFiles.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Globalization; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.SecureFileShare.CoreServices -{ - public class GetListOfFiles - { - public static void Run() - { - try - { - var startDate = DateTime.ParseExact("2018-10-20", "yyyy-MM-dd", CultureInfo.InvariantCulture); - var endDate = DateTime.ParseExact("2018-10-30", "yyyy-MM-dd", CultureInfo.InvariantCulture); - var organizationId = "testrest"; - - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new SecureFileShareApi(clientConfig); - var result = apiInstance.GetFileDetail(startDate, endDate, organizationId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/TMS/CoreServices/CreateInstrumentIdentifier.cs b/src/Samples/TMS/CoreServices/CreateInstrumentIdentifier.cs deleted file mode 100644 index 58191b3..0000000 --- a/src/Samples/TMS/CoreServices/CreateInstrumentIdentifier.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices -{ - public class CreateInstrumentIdentifier - { - public static TmsV1InstrumentIdentifiersPost200Response Run() - { - var requestObj = new CreateInstrumentIdentifierRequest(); - - var cardObj = new Tmsv1instrumentidentifiersCard - { - Number = "1234567123487456" - }; - - requestObj.Card = cardObj; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new InstrumentIdentifierApi(clientConfig); - - var result = apiInstance.CreateInstrumentIdentifier("93B32398-AD51-4CC2-A682-EA3E93614EB1", requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/TMS/CoreServices/CreatePaymentInstrument.cs b/src/Samples/TMS/CoreServices/CreatePaymentInstrument.cs deleted file mode 100644 index 9248f83..0000000 --- a/src/Samples/TMS/CoreServices/CreatePaymentInstrument.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices -{ - public class CreatePaymentInstrument - { - public static TmsV1InstrumentIdentifiersPaymentInstrumentsGet200ResponseEmbeddedPaymentInstruments Run() - { - var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; - var requestObj = new CreatePaymentInstrumentRequest(); - - var cardObj = new TmsV1InstrumentIdentifiersPaymentInstrumentsGet200ResponseEmbeddedCard - ( - ExpirationMonth: "09", - ExpirationYear: "2022", - Type: "visa" - ); - - requestObj.Card = cardObj; - - var billToObj = new TmsV1InstrumentIdentifiersPaymentInstrumentsGet200ResponseEmbeddedBillTo - { - FirstName = "John", - LastName = "Smith", - Company = "CyberSource", - Address1 = "12 Main Street", - Address2 = "20 My Street", - Locality = "San Francisco", - AdministrativeArea = "CA", - PostalCode = "90200", - Country = "US", - Email = "john.smith@example.com", - PhoneNumber = "555123456" - }; - - requestObj.BillTo = billToObj; - - var instrumentIdentifierObj = new Tmsv1paymentinstrumentsInstrumentIdentifier(); - - var cardObj2 = new TmsV1InstrumentIdentifiersPost200ResponseCard - { - Number = "4111111111111111" - }; - - instrumentIdentifierObj.Card = cardObj2; - - requestObj.InstrumentIdentifier = instrumentIdentifierObj; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new PaymentInstrumentApi(clientConfig); - - var result = apiInstance.CreatePaymentInstrument(profileId, requestObj); - Console.WriteLine(result); - return result; - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - return null; - } - } - } -} diff --git a/src/Samples/TMS/CoreServices/DeleteInstrumentIdentifier.cs b/src/Samples/TMS/CoreServices/DeleteInstrumentIdentifier.cs deleted file mode 100644 index f46cabb..0000000 --- a/src/Samples/TMS/CoreServices/DeleteInstrumentIdentifier.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices -{ - public class DeleteInstrumentIdentifier - { - public static void Run() - { - var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; - var tokenId = CreateInstrumentIdentifier.Run().Id; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new InstrumentIdentifierApi(clientConfig); - - apiInstance.DeleteInstrumentIdentifier(profileId, tokenId); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/TMS/CoreServices/DeletePaymentInstrument.cs b/src/Samples/TMS/CoreServices/DeletePaymentInstrument.cs deleted file mode 100644 index 6f12746..0000000 --- a/src/Samples/TMS/CoreServices/DeletePaymentInstrument.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices -{ - public class DeletePaymentInstrument - { - public static void Run() - { - var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; - var tokenId = CreatePaymentInstrument.Run().Id; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new PaymentInstrumentApi(clientConfig); - - apiInstance.DeletePaymentInstrument(profileId, tokenId); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/TMS/CoreServices/RetrieveAllPaymentInstruments.cs b/src/Samples/TMS/CoreServices/RetrieveAllPaymentInstruments.cs deleted file mode 100644 index 216d4ab..0000000 --- a/src/Samples/TMS/CoreServices/RetrieveAllPaymentInstruments.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices -{ - public class RetrieveAllPaymentInstruments - { - public static void Run() - { - var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; - var tokenId = "7010000000016241111"; // CreateInstrumentIdentifier.Run().Id; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new InstrumentIdentifierApi(clientConfig); - - var result = apiInstance.GetAllPaymentInstruments(profileId, tokenId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/TMS/CoreServices/RetrieveInstrumentIdentifier.cs b/src/Samples/TMS/CoreServices/RetrieveInstrumentIdentifier.cs deleted file mode 100644 index beb4a44..0000000 --- a/src/Samples/TMS/CoreServices/RetrieveInstrumentIdentifier.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices -{ - public class RetrieveInstrumentIdentifier - { - public static void Run() - { - var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; - var tokenId = CreateInstrumentIdentifier.Run().Id; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new InstrumentIdentifierApi(clientConfig); - - var result = apiInstance.GetInstrumentIdentifier(profileId, tokenId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/TMS/CoreServices/RetrievePaymentInstrument.cs b/src/Samples/TMS/CoreServices/RetrievePaymentInstrument.cs deleted file mode 100644 index ab3e925..0000000 --- a/src/Samples/TMS/CoreServices/RetrievePaymentInstrument.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices -{ - public class RetrievePaymentInstrument - { - public static void Run() - { - var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; - var tokenId = CreatePaymentInstrument.Run().Id; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new PaymentInstrumentApi(clientConfig); - - var result = apiInstance.GetPaymentInstrument(profileId, tokenId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/TMS/CoreServices/UpdateInstrumentIdentifier.cs b/src/Samples/TMS/CoreServices/UpdateInstrumentIdentifier.cs deleted file mode 100644 index 362954a..0000000 --- a/src/Samples/TMS/CoreServices/UpdateInstrumentIdentifier.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices -{ - public class UpdateInstrumentIdentifier - { - public static void Run() - { - var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; - var tokenId = CreateInstrumentIdentifier.Run().Id; - - var requestObj = new UpdateInstrumentIdentifierRequest(); - - var processingInformationObj = new TmsV1InstrumentIdentifiersPost200ResponseProcessingInformation(); - - var authorizationOptionsObj = new TmsV1InstrumentIdentifiersPost200ResponseProcessingInformationAuthorizationOptions(); - - var initiatorObj = new TmsV1InstrumentIdentifiersPost200ResponseProcessingInformationAuthorizationOptionsInitiator(); - - var merchantInitiatedTransactionObj = - new TmsV1InstrumentIdentifiersPost200ResponseProcessingInformationAuthorizationOptionsInitiatorMerchantInitiatedTransaction - { - PreviousTransactionId = "123456789012345" - }; - - initiatorObj.MerchantInitiatedTransaction = merchantInitiatedTransactionObj; - - authorizationOptionsObj.Initiator = initiatorObj; - - processingInformationObj.AuthorizationOptions = authorizationOptionsObj; - - requestObj.ProcessingInformation = processingInformationObj; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new InstrumentIdentifierApi(clientConfig); - - var result = apiInstance.UpdateInstrumentIdentifier(profileId, tokenId, requestObj); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/TMS/CoreServices/UpdatePaymentInstrument.cs b/src/Samples/TMS/CoreServices/UpdatePaymentInstrument.cs deleted file mode 100644 index d844cf4..0000000 --- a/src/Samples/TMS/CoreServices/UpdatePaymentInstrument.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.TMS.CoreServices -{ - public class UpdatePaymentInstrument - { - public static void Run() - { - var profileId = "93B32398-AD51-4CC2-A682-EA3E93614EB1"; - var tokenId = CreatePaymentInstrument.Run().Id; - - var requestObj = new UpdatePaymentInstrumentRequest(); - - var cardObj = new TmsV1InstrumentIdentifiersPaymentInstrumentsGet200ResponseEmbeddedCard - ( - ExpirationMonth: "09", - ExpirationYear: "2022", - Type: "visa" - ); - - requestObj.Card = cardObj; - - var billToObj = new TmsV1InstrumentIdentifiersPaymentInstrumentsGet200ResponseEmbeddedBillTo - { - FirstName = "John", - LastName = "Smith", - Company = "CyberSource", - Address1 = "12 Main Street", - Address2 = "20 My Street", - Locality = "San Francisco", - AdministrativeArea = "CA", - PostalCode = "90200", - Country = "US", - Email = "john.smith@example.com", - PhoneNumber = "555123456" - }; - - requestObj.BillTo = billToObj; - - var instrumentIdentifierObj = new Tmsv1paymentinstrumentsInstrumentIdentifier(); - - var cardObj2 = new TmsV1InstrumentIdentifiersPost200ResponseCard - { - Number = "4111111111111111" - }; - - instrumentIdentifierObj.Card = cardObj2; - - requestObj.InstrumentIdentifier = instrumentIdentifierObj; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new PaymentInstrumentApi(clientConfig); - - var result = apiInstance.UpdatePaymentInstrument(profileId, tokenId, requestObj); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/TransactionBatches/CoreServices/GetIndividualBatchFile.cs b/src/Samples/TransactionBatches/CoreServices/GetIndividualBatchFile.cs deleted file mode 100644 index adb975d..0000000 --- a/src/Samples/TransactionBatches/CoreServices/GetIndividualBatchFile.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.TransactionBatches.CoreServices -{ - public class GetIndividualBatchFile - { - public static void Run() - { - try - { - var id = "12345"; - - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new TransactionBatchesApi(clientConfig); - - var result = apiInstance.GetTransactionBatchId(id); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} \ No newline at end of file diff --git a/src/Samples/TransactionBatches/CoreServices/GetListOfBatchFiles.cs b/src/Samples/TransactionBatches/CoreServices/GetListOfBatchFiles.cs deleted file mode 100644 index ec1e98e..0000000 --- a/src/Samples/TransactionBatches/CoreServices/GetListOfBatchFiles.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Globalization; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.TransactionBatches.CoreServices -{ - public class GetListOfBatchFiles - { - public static void Run() - { - try - { - var startTime = DateTime.ParseExact("2019-08-11T22:47:57Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); - var endTime = DateTime.ParseExact("2019-08-29T22:47:57Z", "yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture); - - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new TransactionBatchesApi(clientConfig); - - var result = apiInstance.GetTransactionBatches(startTime, endTime); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} \ No newline at end of file diff --git a/src/Samples/TransactionDetails/CoreServices/RetrieveTransaction.cs b/src/Samples/TransactionDetails/CoreServices/RetrieveTransaction.cs deleted file mode 100644 index 3341cfe..0000000 --- a/src/Samples/TransactionDetails/CoreServices/RetrieveTransaction.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.TransactionDetails.CoreServices -{ - public class RetrieveTransaction - { - public static void Run() - { - const string id = "5698452335976950303001"; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new TransactionDetailsApi(clientConfig); - - var result = apiInstance.GetTransaction(id); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/TransactionSearch/CoreServices/CreateSearchRequest.cs b/src/Samples/TransactionSearch/CoreServices/CreateSearchRequest.cs deleted file mode 100644 index 3bd18fd..0000000 --- a/src/Samples/TransactionSearch/CoreServices/CreateSearchRequest.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using CyberSource.Api; -using CyberSource.Model; - -namespace Cybersource_rest_samples_dotnet.Samples.TransactionSearch.CoreServices -{ - public class CreateSearchRequest - { - public static void Run() - { - try - { - var requestObj = new CyberSource.Model.CreateSearchRequest() - { - Save = false, - Name = "TSS search", - Timezone = "America/Chicago", - Query = "clientReferenceInformation.code:TC50171_3 AND submitTimeUtc:[NOW/DAY-7DAYS TO NOW/DAY+1DAY}", - Offset = 0, - Limit = 10, - Sort = "id:asc, submitTimeUtc:asc" - }; - - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new SearchTransactionsApi(clientConfig); - - var result = apiInstance.CreateSearch(requestObj); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/Samples/TransactionSearch/CoreServices/GetSearchResults.cs b/src/Samples/TransactionSearch/CoreServices/GetSearchResults.cs deleted file mode 100644 index 555ab3c..0000000 --- a/src/Samples/TransactionSearch/CoreServices/GetSearchResults.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.TransactionSearch.CoreServices -{ - public class GetSearchResults - { - public static void Run() - { - var id = "cd46194f-b41f-4084-990a-7ea1f28aa831"; - - try - { - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new SearchTransactionsApi(clientConfig); - - var result = apiInstance.GetSearch(id); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} \ No newline at end of file diff --git a/src/Samples/UserManagement/CoreServices/GetUserInformation.cs b/src/Samples/UserManagement/CoreServices/GetUserInformation.cs deleted file mode 100644 index f702e9c..0000000 --- a/src/Samples/UserManagement/CoreServices/GetUserInformation.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using CyberSource.Api; - -namespace Cybersource_rest_samples_dotnet.Samples.UserManagement.CoreServices -{ - public class GetUserInformation - { - public static void Run() - { - try - { - var organizationId = "testrest"; - var permissionId = "CustomerProfileViewPermission"; - var roleId = "admin"; - var username = "testrest"; - - var configDictionary = new Configuration().GetConfiguration(); - var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); - var apiInstance = new UserManagementApi(clientConfig); - - var result = apiInstance.GetUsers(organizationId); - Console.WriteLine(result); - } - catch (Exception e) - { - Console.WriteLine("Exception on calling the API: " + e.Message); - } - } - } -} diff --git a/src/lib/ApiSdk.dll b/src/lib/ApiSdk.dll deleted file mode 100644 index 6a2a1fa..0000000 Binary files a/src/lib/ApiSdk.dll and /dev/null differ diff --git a/src/packages.config b/src/packages.config deleted file mode 100644 index 91d6fae..0000000 --- a/src/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - -