MercadoPago does not find payments in sandbox mode

1

I am having problems in the market integration payment in sandbox with java, when I make a payment (with the test cards) it is supposedly successful but when I want to access the payment information with the collection_id that returns it tells me that he can not find it. Can you tell me if I'm doing something wrong or is there any data inconsistency in the paid market sandbox? in the documentation it says that it is in maintenance and that it may not work as expected. I leave the code:

public String createPayPreference(String title, String description, int quantity, double unitPrice) {
        MP mp = new MP(applicationProperties.getProperty("viajes.mercado.pago.client.id"), applicationProperties.getProperty("viajes.mercado.pago.client.secret"));

        String initPoint = "";


        String preferenceData =
                "{'items':"+
                        "[{"+
                            "'title':'" + title + "',"+
                            "'description':'" + description + "',"+
                            "'quantity':" + quantity +","+
                            "'currency_id':'ARS',"+ 
                            "'unit_price':"+ unitPrice +
                        "}]," +
                "'payment_methods': {" +
                    "'excluded_payment_types': [" +
                        "{" +
                            "'id': 'ticket' " +
                        "}," +
                        "{" +
                            "'id': 'atm' " +
                        "}" +
                    "]" +
                "}," +
                "'operation_type': 'regular_payment'" +
                "}";

        mp.sandboxMode(Boolean.valueOf(applicationProperties.getProperty("viajes.mercado.pago.sandbox.mode")));
        try {

            JSONObject preference = mp.createPreference(preferenceData);
            initPoint = preference.getJSONObject("response").getString(applicationProperties.getProperty("viajes.mercado.pago.init.point"));

        } catch(JSONException e) {
            logger.error("Error al generar la preferencia de pago de mercado pago: " + e.getMessage());
        } catch(Exception e) {
            logger.error("Error al generar la preferencia de pago de mercado pago: " + e.getMessage());
        }

        return initPoint;
    }


public void refund(Reservation reservation) {
            MP mp = new MP(applicationProperties.getProperty("viajes.mercado.pago.client.id"), applicationProperties.getProperty("viajes.mercado.pago.client.secret"));
            mp.sandboxMode(Boolean.valueOf(applicationProperties.getProperty("viajes.mercado.pago.sandbox.mode")));
            try {
                JSONObject response = mp.refundPayment(reservation.getPayment().getCollectionId());
                String status = response.getJSONObject("response").getString("status");
                String message = response.getJSONObject("response").getString("message");
                if(Integer.valueOf(status) == 200) {
                    logger.info("Se genero una devolución de pago total para la reserva: " + reservation.getId());
                } else {
                    throw new Exception("No se pudo generar la devolución del pago total para la reserva: " + reservation.getId() + " Código de error: " + status + " " + message);
                }
            } catch(JSONException e) {
                logger.error("Error al generar la devolucion de pago total de mercado pago: Reserva:" + reservation.getId() + " Error: " + e.getMessage());
            } catch(Exception e) {
                logger.error("Error al generar la devolucion de pago total de mercado pago: Reserva:" + reservation.getId() + " Error: " + e.getMessage());
            }


    }

The sandbox mode property is true for the development environment, and the init_point is sandbox_init_point. Greetings and thanks

    
asked by Nico Lucini 10.03.2017 в 18:12
source

0 answers