Exception while creating Card Token with cardId #271
Replies: 2 comments 2 replies
-
Hello @suryapts007 ! Thank you for informing us about this problem, we will analyze it and get back to you as soon as possible. |
Beta Was this translation helpful? Give feedback.
-
@suryapts007 I tried to reproduce your problem by creating a new project, downloading the SDK in version 2.1.17 and creating a card token, and everything worked fine. I suggest you try recompiling the SDK or the project and see if it works. If you have any further questions, please let me know! |
Beta Was this translation helpful? Give feedback.
-
Hi guys,
I am a software engineer from UnDosTres (Mexico).
Recently I was trying to integrate mercadopago-java SDK (v 2.1.7) with our system.
I was able to associate the card successfully with a customer and get a cardId in response.
But when I was trying to create a token with the received cardId, I was getting an exception from the SDK.
After digging into the SDK code I found that the problem is in line no 94 of the below screenshot.
CardToken cardToken = Serializer.deserializeFromJson(CardToken.class, response.getContent());
After digging a little more I found out that I am successfully receiving a
201
response code with JSON string having the tokenId in line no. 87. You can see it in the below screenshot.But when we are trying to deserialize the JSON to a CardToken object, it throws an exception with the message
class com.mercadopago.resources.CardToken cannot be cast to class com.mercadopago.net.MPResource (com.mercadopago.resources.CardToken and com.mercadopago.net.MPResource are in unnamed module of loader 'app')
The problem is that
Serializer.deserializeFromJson
function expects a class that is a subtype of theMPResource
class, but the classCardToken
does not extendMPResource
.Well actually,
CardToken
does extendMPResource
class, but just in the source code, not in the JAR file (which is kind of weird). Below is the screenshot of the same.Can you guys please help us with this issue?
Beta Was this translation helpful? Give feedback.
All reactions