"Value cannot be null. Parameter name: s" 2Checkout payment API

Pratik picture Pratik · Oct 5, 2017 · Viewed 7.6k times · Source

i have integrate 2Checkout Payment API using following code but got error when Authorize Customer.

follow : https://www.2checkout.com/documentation/libraries-net-tutorial

Code :

 public ActionResult Process()
 {
       TwoCheckoutConfig.SellerID = "801785575";
       TwoCheckoutConfig.PrivateKey = "SA7947DS-CWE1-1233-4EE-33331DA607B6";
       TwoCheckoutConfig.Sandbox = true;

       try
       {
          var Billing = new AuthBillingAddress();
          Billing.addrLine1 = "123 test st";
          Billing.city = "Columbus";
          Billing.zipCode = "43123";
          Billing.state = "OH";
          Billing.country = "USA";
          Billing.name = "Testing Tester";
          Billing.email = "[email protected]";

          var Customer = new ChargeAuthorizeServiceOptions();
          Customer.total = (decimal)1.00;
          Customer.currency = "USD";
          Customer.merchantOrderId = "123";
          Customer.billingAddr = Billing;
          Customer.token = Request["token"];

          var Charge = new ChargeService();

          var result = Charge.Authorize(Customer);
          Console.Write(result);
       }
       catch (TwoCheckoutException e)
       {
          Console.Write(e);
       }

       return View();
}  

Got Error "Value cannot be null. Parameter name: s" Please help me..

thanks,

Answer

Tetsuya Yamamoto picture Tetsuya Yamamoto · Oct 5, 2017

From the stack trace I got when the error reproduced, the exception seems originated from System.IO.StringReader(String s) constructor since certain action passed the constructor argument as null string value, indicating you're using a version of TwoCheckOut DLL assembly which may having bug with StringReader that expects non-null value (it belongs to the TwoCheckOut assembly).

Try updating TwoCheckOut assembly by issuing Package Manager command:

Update-Package TwoCheckout

If the update process is unsuccessful or the exception still appears after updating, remove the corresponding package with this command:

Uninstall-Package TwoCheckout

Then download latest TwoCheckOut DLL assembly from this source and add it in References section of your project.

Similar issues:

Value cannot be null. Parameter name: s, 2Chekout sandbox error

TwoCheckout System.ArgumentNullException : Value cannot be null Parameter name: s