500 Internal Error Market Payment

-1

Hello, I am trying to make a basic payment for MercadoPago and return the "500 Internal Error". Here I leave the code that I am using. Thanks.

var mp = new MercadoPago();
String data = "{" +
     "\"transaction_amount\": 10," +
     "\"token\": \"c2caced385925193f59423f0d630efef14:12 02/10/2017\"," +
     "\"description\": \"Title of what you are paying for\"," +
     "\"installments\": 1," +
      "\"payment_method_id\": \"visa\"," +
      "\"payer\": {" +
      "\"email\": \"[email protected]\"" +
   "}" +
 "}";
mp.post("/v1/payments", data);
    
asked by AndreaFonr 05.10.2017 в 17:30
source

1 answer

0

The problem is that this "Json" does not have the format as such, to solve it:

Install the Newtonsoft package from Nuget, import the following class: using Newtonsoft.Json.Linq;

And the code would look like this:

var mp = new MercadoPago();
String data = "{" +
    "\"transaction_amount\": 10," +
    "\"token\": \"c2caced385925193f59423f0d630efef14:12 02/10/2017\"," +
    "\"description\": \"Title of what you are paying for\"," +
    "\"installments\": 1," +
     "\"payment_method_id\": \"visa\"," +
     "\"payer\": {" +
     "\"email\": \"[email protected]\"" +
  "}" +
"}";

JObject jsonData= JObject.Parse(data);
mp.post("/v1/payments", jsonData);

The content of the jsonData:

{
  "transaction_amount": 10,
  "token": "c2caced385925193f59423f0d630efef14:12 02/10/2017",
  "description": "Title of what you are paying for",
  "installments": 1,
  "payment_method_id": "visa",
  "payer": {
    "email": "[email protected]"
  }
}
    
answered by 05.10.2017 в 18:14