Stripe and google endpoints

0

I have a webhook in Stripe that connects to an endpoint sending a Json in the body, however I'm not sure how to get that json using the google endpoints, since I understand that only manages pojos, I'm trying with the following:

import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.stripe.model.Event;
import com.yogome.heroesofknowledge.rest.pojos.GenericResponse;
import com.yogome.heroesofknowledge.rest.pojos.Response;
import java.util.logging.Level;
import java.util.logging.Logger;


@Api(name = "eventos")
public class EventosEndpoint {

@ApiMethod(name = "guardar", httpMethod = "POST")
public Response guardar(Event event) {

    Logger logger = Logger.getLogger(this.getClass().getName());

    logger.log(Level.INFO, event.getType());

    return new GenericResponse(event.getType());
    }

}

But he does send me the following error:

  
    

com.google.api.server.spi.SystemService invokeServiceMethod: exception occurred while calling backend method (SystemService.java:378)     com.google.api.server.spi.response.BadRequestException: com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.stripe.model.StripeObject, problem: abstract types need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information

  

so I need a way to be able to either get the raw json or cast the event object.

    
asked by gibran alexis moreno zuñiga 03.01.2018 в 01:21
source

1 answer

0

So that the endpoint can parse the json that sends stripe, the object should comply with 2 condtions:

  • Having an empty constructor
  • That all the fields that you want to parse have a public getter or that they are public.
  • Most likely, this Stripe object does not meet the conditions. My recommendation would be to make an own object that intercepts the call and build the Stripe object by hand.

        
    answered by 23.07.2018 в 20:50