C# {#rn-announce}
=================

Prerequisites
-------------

You must create a P12 certificate. See the *[Getting Started with REST Developer Guide](https://developer.cybersource.com/docs/cybs/en-us/platform/developer/all/rest/rest-getting-started/restgs-jwt-message-intro/restgs-security-p12-intro.md "")*.  
With this change to use a P12 certificate in your C# SOAP toolkit configuration, your application must meet these new requirements:
* .NET Framework 4.7.2 and later Redistributable Package
* [NuGet Command-Line Interface](https://learn.microsoft.com/en-us/nuget/reference/nuget-exe-cli-reference?tabs=windows "")
* Portable.BouncyCastle
  {#rn-announce_ul_nqh_t5v_ldc}

PHP Prerequisites
-----------------

You must create a P12 certificate. See the *[REST Getting Started Developer Guide](https://developer.cybersource.com/docs/cybs/en-us/platform/developer/all/rest/rest-getting-started/restgs-jwt-message-intro/restgs-security-p12-intro.md "")*.  
With this change to use a P12 certificate in your PHP SOAP toolkit configuration, the new requirements for your application will be:
* PHP 5.6x and higher
* PHP SOAP extension
* PHP OpenSSL extension
  {#rn-announce_ul_gpv_mcz_mdc}

Migration Steps
---------------

Follow these steps to upgrade your C# code:

1. Add the following service URL as a service reference to your project:

   ```
   https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_N.NNN.wsdl
   ```

   where *N.NNN* is the latest server API version.  
   This will generate a Connected Services section in your project. It will also generate an *app.config* file for your project.

2. Add the following sections to the top of your *app.config* file:

   ```
   &lt;configuration&gt;
      &lt;configSections&gt;
         &lt;section name="toolkitProperties" type="System.Configuration.NameValueSectionHandler"/&gt;
      &lt;/configSections&gt;

      &lt;toolkitProperties&gt;
         &lt;add key="MERCHANT_ID" value="&lt;your_merchant_id&gt;"/&gt;
         &lt;add key="KEY_ALIAS" value="&lt;your_certificate_key_alias&gt;"/&gt;
         &lt;add key="KEY_FILE" value="&lt;your_certificate_file&gt;"/&gt;
         &lt;add key="KEY_PASS" value="&lt;your_certificate_password&gt;"/&gt;
         &lt;add key="KEY_DIRECTORY" value="&lt;path/to/certificate/file&gt;"/&gt;
      &lt;/toolkitProperties&gt;
   &lt;/configuration&gt;
   ```

   > The ` &lt;configSections&gt; ` tag must be the first section inside ` &lt;configurations&gt; `.

   3. In the generated *app.config* file, leave the `&lt;binding&gt;` section as it is.  
      The `&lt;binding&gt;` section must look like this:

   ```
   &lt;bindings&gt;
      &lt;basicHttpBinding&gt;
            &lt;binding name="ITransactionProcessor"&gt;
            &lt;security mode="Transport"/&gt;
            &lt;/binding&gt;
      &lt;/basicHttpBinding&gt;
   &lt;/bindings&gt;
   ```
3. Add this dependency to the *packages.config* file:

   ```
   &lt;packages&gt;
      &lt;package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net472" /&gt;
   &lt;/packages&gt;
   ```
4. Install the dependency:

   ```
   nuget install packages.config -OutputDirectory packages
   ```
5. Add this package reference to your *.csproj* file:

   ```
   &lt;Reference Include="BouncyCastle.Crypto, Version=1.9.0.0, Culture=neutral, PublicKeyToken=0e99375e54769942, processorArchitecture=MSIL"&gt;
      &lt;HintPath&gt;packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll&lt;/HintPath&gt;
   &lt;/Reference&gt;
   ```

   The steps for adding a new dependency can also be done through Visual Studio Package Manager.

6. Add your P12 certificate to the `KEY_DIRECTORY`.  
   This `KEY_DIRECTORY` location must be accessible to your code. Ensure that your code has permission to read this location.

7. Copy these files to your project directory and import them to your project:

   * [CertificateCacheUtility.cs](https://github.com/CyberSource/cybersource-soap-toolkit/blob/master/CSharpSoapToolkit/CSharpSoapToolkit%5CCertificateCacheUtility.cs "")
   * [InspectorBehavior.cs](https://github.com/CyberSource/cybersource-soap-toolkit/blob/master/CSharpSoapToolkit/CSharpSoapToolkit%5CInspectorBehavior.cs "")
   * [PropertiesUtility.cs](https://github.com/CyberSource/cybersource-soap-toolkit/blob/master/CSharpSoapToolkit/CSharpSoapToolkit%5CPropertiesUtility.cs "")
   * [SecurityUtility.cs](https://github.com/CyberSource/cybersource-soap-toolkit/blob/master/CSharpSoapToolkit/CSharpSoapToolkit%5CSecurityUtility.cs "")
   * [SoapEnvelopeUtility.cs](https://github.com/CyberSource/cybersource-soap-toolkit/blob/master/CSharpSoapToolkit/CSharpSoapToolkit%5CSoapEnvelopeUtility.cs "")
     {#rn-announce_ul_ypc_v5v_ldc}
8. Find these lines in your existing code:

   ```
   TransactionProcessorClient proc = new TransactionProcessorClient();

   proc.ChannelFactory.Credentials.UserName.UserName =  request.merchantID;
   proc.ChannelFactory.Credentials.UserName.Password =  TRANSACTION_KEY;

   ReplyMessage reply = proc.runTransaction(request);
   ```

   Replace them with these lines:

   ```
   TransactionProcessorClient proc = new TransactionProcessorClient();

   proc.Endpoint.EndpointBehaviors.Add(new InspectorBehavior());

   ReplyMessage reply = proc.runTransaction(request);
   ```
9. Find your installation of .NET Framework.  
   This is often located at one of these locations:

   * *C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319* (32-bit)
   * *C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319* (64-bit)
     {#rn-announce_ul_gtq_zdp_zdc}
10. Use *msBuild.exe* to compile your project.

    ```
    &lt;path_to_framework&gt;\msBuild.exe &lt;name_of_project&gt;.csproj
    ```
11. Run the project executable:

    ```
    bin\&lt;configuration&gt;\&lt;project_name&gt;.exe
    ```
12. (Optional) You can confirm that your configuration is updated successfully by checking that your request was authenticated using a Bearer token. To confirm, add this command after line 59 in the *CSharpSoapToolkit\\InspectorBehavior.cs* file:

    ```
    Console.WriteLine(request.ToString()); 
    ```

{#rn-announce_ol_xpc_v5v_ldc}
