Exemplo n.º 1
0
        public static string SingleUseCardToken(string PublicKey, string Status)
        {
            JObject payload = JObject.Parse(CardDummyWithSpecificStatus(Status));

            MPRESTClient  client            = new MPRESTClient();
            String        path              = "https://api.mercadopago.com/v1/card_tokens?public_key=" + PublicKey;
            MPAPIResponse responseCardToken = client.ExecuteRequestCore(HttpMethod.POST, path, PayloadType.JSON, payload, null, 0, 1);

            JObject       jsonResponse = JObject.Parse(responseCardToken.StringResponse.ToString());
            List <JToken> tokens       = MPCoreUtils.FindTokens(jsonResponse, "id");

            return(tokens.First().ToString());
        }
Exemplo n.º 2
0
        public string GenerateSingleUseCardToken()
        {
            JObject       payload           = JObject.Parse("{ \"card_number\": \"4544610257481730\", \"security_code\": \"122\", \"expiration_month\": \"7\", \"expiration_year\": \"2030\", \"cardholder\": { \"name\": \"Test test\", \"identification\": { \"type\": \"DNI\", \"number\": \"12345678\" } } }");
            MPRESTClient  client            = new MPRESTClient();
            MPAPIResponse responseCardToken = client.ExecuteRequestCore(
                HttpMethod.POST,
                "https://api.mercadopago.com/v1/card_tokens?public_key=" + Environment.GetEnvironmentVariable("PUBLIC_KEY"),
                PayloadType.JSON,
                payload,
                null,
                0,
                1);

            JObject       jsonResponse = JObject.Parse(responseCardToken.StringResponse.ToString());
            List <JToken> tokens       = MPCoreUtils.FindTokens(jsonResponse, "id");

            return(tokens.First().ToString());
        }