open-pay / openpay-java Goto Github PK
View Code? Open in Web Editor NEWOpenpay Java bindings
License: Apache License 2.0
Openpay Java bindings
License: Apache License 2.0
Using Charging a credit card:
Returns as follows
category=request, description=Attribute device_session_id is required, httpCode=400, errorCode=1001, requestId=c2dfb4ed-c4f4-46b6-8ed4-3d0c06bd9794, riskData=null
Wrapped by: com.google.gson.JsonIOException: Failed making field 'java.lang.Throwable#detailMessage' accessible; either change its visibility or write a custom TypeAdapter for its declaring type
at com.google.gson.internal.reflect.ReflectionHelper.makeAccessible(ReflectionHelper.java:22)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:158)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:101)
at com.google.gson.Gson.getAdapter(Gson.java:501)
at com.google.gson.Gson.fromJson(Gson.java:990)
at com.google.gson.Gson.fromJson(Gson.java:956)
at com.google.gson.Gson.fromJson(Gson.java:905)
at com.google.gson.Gson.fromJson(Gson.java:876)
at mx.openpay.client.core.impl.DefaultSerializer.deserialize(DefaultSerializer.java:58)
at mx.openpay.client.core.JsonServiceClient.checkForErrors(JsonServiceClient.java:191)
at mx.openpay.client.core.JsonServiceClient.postString(JsonServiceClient.java:173)
at mx.openpay.client.core.JsonServiceClient.postObjectAsJson(JsonServiceClient.java:167)
at mx.openpay.client.core.JsonServiceClient.post(JsonServiceClient.java:147)
at mx.openpay.client.core.operations.ChargeOperations.createCharge(ChargeOperations.java:92)
at
Disculpen pedir ayuda por aquí, pero es que la persona que me esta atendiendo mediante soporte es nefasta, le proporciono código pero insiste en pedir capturas de pantalla, por lo que asumo que programador no es.
Ahora si, después del desahogo, estoy batallando para hacer el cargo. Genero el deviceSessionId con la libreria anti fraudes de javascript, posteriormente genero un tokenId igual con javascript enviandole la información de la tarjeta. Estos dos datos los envio al servidor donde usando la api de java intento realizar el cargo, lo estoy haciendo de ésta manera:
//la url esta hacia el sandbox, los otros dos datos igual son los de pruebas
OpenpayAPI api = new OpenpayAPI(openpayApiUrl, openpayPrivateId, openpayMerchantId);
Customer customer = new Customer();
customer.setName(params.getNombre());
customer.setLastName(StringUtils.EMPTY);
customer.setPhoneNumber(StringUtils.EMPTY);
customer.setEmail(params.getCorreo());
CreateCardChargeParams chargeParams = new CreateCardChargeParams()
.cardId(params.getToken())
.deviceSessionId(params.getDevice())
.amount(precio.getTotal())
.currency(Currency.MXN)
.description("Compra realizada")
.customer(customer);
Charge charge;
try {
charge = api.charges().createCharge(chargeParams);
} catch(ServiceUnavailableException | OpenpayServiceException ex) {
throw new RuntimeException(ex);
}
pero siempre me genera la siguiente excepción:
Caused by: mx.openpay.client.exceptions.OpenpayServiceException: [405] Internal server error
at mx.openpay.client.core.JsonServiceClient.checkForErrors(JsonServiceClient.java:198)
at mx.openpay.client.core.JsonServiceClient.postString(JsonServiceClient.java:173)
at mx.openpay.client.core.JsonServiceClient.postObjectAsJson(JsonServiceClient.java:167)
at mx.openpay.client.core.JsonServiceClient.post(JsonServiceClient.java:147)
at mx.openpay.client.core.operations.ChargeOperations.createCharge(ChargeOperations.java:92)
Algo que se me este escapando? Aclaro que actualmente tenemos este cargo funcionando en un sistema con PHP sin problemas, estamos enviando la misma información que se envia aqui en java, solo que aqui siempre nos genera este error, les copio el logging que genera el http client de apache cuando realiza la llamada al api:
>> POST /v1/msjiloon6ehagjedgslk/charges HTTP/1.1
>> User-Agent: openpay-java/1.7.0
>> Accept: application/json
>> Content-Type: application/json
>> Authorization: Basic c2tfODlhZDc4ODBhZjM2NGUyMW.....
>> Content-Length: 283
>> Host: sandbox-dashboard.openpay.mx
>> Connection: Keep-Alive
>> Accept-Encoding: gzip,deflate
>> "POST /v1/msjiloon6ehagjedgslk/charges HTTP/1.1[\r][\n]"
>> "User-Agent: openpay-java/1.7.0[\r][\n]"
>> "Accept: application/json[\r][\n]"
>> "Content-Type: application/json[\r][\n]"
>> "Authorization: Basic c2tfODlhZDc4ODBhZjM2NGUyMW.....[\r][\n]"
>> "Content-Length: 283[\r][\n]"
>> "Host: sandbox-dashboard.openpay.mx[\r][\n]"
>> "Connection: Keep-Alive[\r][\n]"
>> "Accept-Encoding: gzip,deflate[\r][\n]"
>> "[\r][\n]"
>> "{"device_session_id":"zI7hRumS3hHNrMlKWAz06PH0vjFk3rRg","amount":1450.000000000,"method":"card","description":"Compra realizada","currency":"MXN","source_id":"k15esro8sdjliin3y3sa","customer":{"name":"JOSE PEREZ","email":"[email protected]","last_name":"","phone_number":""}}"
<< "HTTP/1.1 405 [\r][\n]"
<< "Date: Thu, 20 Jul 2023 18:19:46 GMT[\r][\n]"
<< "Content-Length: 0[\r][\n]"
<< "Connection: keep-alive[\r][\n]"
<< "Set-Cookie: AWSALB=SxYHhArTEbY8cAnuqHMHp3uqG27Rc71+IyNPlGOQ6Gnw3UfffiSwBi02my1Tz+NH+TkNqbB+QQgGvZGkzwqeNpbH+9woN0A6f5pYQu/Wu0wehSOFQNOg3gbeWNk7; Expires=Thu, 27 Jul 2023 18:19:46 GMT; Path=/[\r][\n]"
<< "Set-Cookie: AWSALBCORS=SxYHhArTEbY8cAnuqHMHp3uqG27Rc71+IyNPlGOQ6Gnw3UfffiSwBi02my1Tz+NH+TkNqbB+QQgGvZGkzwqeNpbH+9woN0A6f5pYQu/Wu0wehSOFQNOg3gbeWNk7; Expires=Thu, 27 Jul 2023 18:19:46 GMT; Path=/; SameSite=None; Secure[\r][\n]"
<< "Cache-Control: no-cache, no-store, max-age=0, must-revalidate[\r][\n]"
<< "Pragma: no-cache[\r][\n]"
<< "Expires: 0[\r][\n]"
<< "Strict-Transport-Security: max-age=31536000 ; includeSubDomains[\r][\n]"
<< "X-XSS-Protection: 1; mode=block[\r][\n]"
<< "X-Frame-Options: DENY[\r][\n]"
<< "X-Content-Type-Options: nosniff[\r][\n]"
<< "Set-Cookie: JSESSIONID=92B41E191B7EA65CA0895002F8AA6AF9; Path=/; Secure; HttpOnly[\r][\n]"
<< "Allow: GET[\r][\n]"
<< "[\r][\n]"
<< HTTP/1.1 405
<< Date: Thu, 20 Jul 2023 18:19:46 GMT
<< Content-Length: 0
<< Connection: keep-alive
<< Set-Cookie: AWSALB=SxYHhArTEbY8cAnuqHMHp3uqG27Rc71+IyNPlGOQ6Gnw3UfffiSwBi02my1Tz+NH+TkNqbB+QQgGvZGkzwqeNpbH+9woN0A6f5pYQu/Wu0wehSOFQNOg3gbeWNk7; Expires=Thu, 27 Jul 2023 18:19:46 GMT; Path=/
<< Set-Cookie: AWSALBCORS=SxYHhArTEbY8cAnuqHMHp3uqG27Rc71+IyNPlGOQ6Gnw3UfffiSwBi02my1Tz+NH+TkNqbB+QQgGvZGkzwqeNpbH+9woN0A6f5pYQu/Wu0wehSOFQNOg3gbeWNk7; Expires=Thu, 27 Jul 2023 18:19:46 GMT; Path=/; SameSite=None; Secure
<< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
<< Pragma: no-cache
<< Expires: 0
<< Strict-Transport-Security: max-age=31536000 ; includeSubDomains
<< X-XSS-Protection: 1; mode=block
<< X-Frame-Options: DENY
<< X-Content-Type-Options: nosniff
<< Set-Cookie: JSESSIONID=92B41E191B7EA65CA0895002F8AA6AF9; Path=/; Secure; HttpOnly
<< Allow: GET
2023-07-20 13:19:46,836 ERROR [qtp1999415998-82] mx.openpay.client.core.JsonServiceClient: Not a Json response. Code: 405, body:
2023-07-20 13:19:53,179 DEBUG [qtp1999415998-82] o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver: Using @ExceptionHandler server.controllers.support.ApiErrorsAdvice#exception(Exception, HttpServletResponse)
2023-07-20 13:19:53,179 ERROR [qtp1999415998-82] a.server.controllers.support.ApiErrorsAdvice: ### exception
java.lang.RuntimeException: OpenpayServiceException(category=null, description=null, httpCode=405, errorCode=1000, requestId=null, riskData=null)
Gracias por su apoyo.
Hola, buenos días.
En mi trabajo estoy intentando implementar OpenPay desde API.
Ya tengo las credenciales y pude hacer un token de una tarjeta pegandole al siguiente endpoint : POST https://sandbox-api.openpay.mx/v1/{MERCHANT_ID}/tokens
Pero al querer hacer un cargo (hacer un pago), me pide el campo "device_session_id", el cual no tengo ese valor ya que hago el desarrollo por backend, no tengo forma de usar la libreria de javaScript para generarlo.
Hay otra forma de hacerlo ya sea desde otro endpoint pasandole datos del dispositivo?
Saludos y muchas gracias.
I tried to payout to a bank acount, but the following exception responsed.
the request path: /mtp3g23ni5awolchjb14/customers/ataqrxxmvs7tiwyxthzh/payouts
the request body: {
"amount": 10,
"method": "bank_account",
"destination_id": "bpzgzat97bbjaaqq7ydf",
"description": "Customer payout"
}
the respone: {
"http_code": 412,
"error_code": 3006,
"category": "request",
"description": "Merchant does not allow payouts to third parties",
"request_id": "96e89336-4722-4ec2-876e-ec40b7b07f43"
}
What should I do to payout to the bank account successfully
Hola, realizando pruebas con el api de java me regresa un error de que no se esta enviando el source_id, lo que veo es que estan haciendo obligatorio el uso de tokenización cuando yo estoy enviando el objeto completo CARD, podrían confirmarme eso de favor?
Request:
{
"amount": 100.00,
"device_session_id": "vBtcKJT00uwbxhpZ50a9iVja9kffYVMs",
"method": "card",
"description": "Cargo inicial a mi merchant",
"order_id": "7670592",
"card": {
"holder_name": "rafael",
"expiration_month": "12",
"expiration_year": "20",
"card_number": "411111XXXXXX1111",
"cvv2": "XXX",
"points_card": false
}
}
Response:
{
"http_code": 400,
"error_code": 1001,
"category": "request",
"description": "Attribute source_id is required",
"request_id": "44714731-ea4c-49ad-807d-ad6d539c7432"
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.