Enable SO Authentication Using P12 Certificates with .Ne
You can upgrade to P12 Authentication in your SOAP toolkit by doing the following:
- Update the files in your project directory.
- Add your certificate information to a toolkit.properties file in your project directory.
- Update your pom.xml file.
IMPORTANT
A java tookit is available on GitHub: JavaSoapToolkitCybersource SOAP Toolkit
Prerequisites
You will need an SO P12 Certificate. For Information on creating a P12 certificate, See the .
Your application must meet these requirements:
- .NET Framework 4.7.2 and later Redistributable Package
- Portable.BouncyCastle
C# Migration Steps
Follow these steps to upgrade your C# code:
- Add the following service URL as a service reference to your project:
wherehttps://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_N.NNN.wsdlN.NNNis the latest server API version.This will generate a Connected Services section in your project. It will also generate anapp.configfile for your project. - Add the following sections to the top of yourapp.configfile:<configuration> <configSections> <section name="toolkitProperties" type="System.Configuration.NameValueSectionHandler"/> </configSections> <toolkitProperties> <add key="MERCHANT_ID" value="<your_merchant_id>"/> <add key="KEY_ALIAS" value="<your_certificate_key_alias>"/> <add key="KEY_FILE" value="<your_certificate_file>"/> <add key="KEY_PASS" value="<your_certificate_password>"/> <add key="KEY_DIRECTORY" value="<path/to/certificate/file>"/> </toolkitProperties> </configuration>IMPORTANTThe<configSections>tag must be the first section inside<configurations>.
- In the generatedapp.configfile, leave the<binding>section as it is.The<binding>section must look like this:<bindings> <basicHttpBinding> <binding name="ITransactionProcessor"> <security mode="Transport"/> </binding> </basicHttpBinding> </bindings>
- Add this dependency to thepackages.configfile:<packages> <package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net472" /> </packages>
- Install the dependency:nuget install packages.config -OutputDirectory packages
- Add this package reference to your.csprojfile:
The steps for adding a new dependency can also be done through Visual Studio Package Manager.<Reference Include="BouncyCastle.Crypto, Version=1.9.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL"> <HintPath>packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll</HintPath> </Reference> - Add your P12 certificate to theKEY_DIRECTORY.ThisKEY_DIRECTORYlocation must be accessible by your code. Ensure that your code has permissions to read this location.
- Copy these files to your project directory and import them to your project:
- Find these lines in your existing code:
and replace them with these lines:TransactionProcessorClient proc = new TransactionProcessorClient(); proc.ChannelFactory.Credentials.UserName.UserName = request.merchantID; proc.ChannelFactory.Credentials.UserName.Password = TRANSACTION_KEY; ReplyMessage reply = proc.runTransaction(request);TransactionProcessorClient proc = new TransactionProcessorClient(); proc.Endpoint.EndpointBehaviors.Add(new InspectorBehavior()); ReplyMessage reply = proc.runTransaction(request); - Find your installation of .NET Framework.This is often located atC:\Windows\Microsoft.NET\Framework\v4.0.30319(32-bit) orC:\Windows\Microsoft.NET\Framework64\v4.0.30319(64-bit).
- UsemsBuild.exeto compile your project.<path_to_framework>\msBuild.exe <name_of_project>.csproj
- Run the project executable:bin\<configuration>\<project_name>.exe
You can confirm that your configuration is updated successfully by sending a test
request. A successful configuration is indicated when the request log shows that the
request was authenticated using a Bearer token.