universal/core/cards&&Unable to parse or decrypt

Solved! Go to solution
wypintec
Regular Visitor

universal/core/cards&&Unable to parse or decrypt

EndPonit

https://sandbox.api.visa.com/universal/core/cards?apikey=PNQCIP6QZPELAVRMDDFQ21pcqPS2qd-3opkzAtbh9EWSSGo5U

Response Header:

Status Code: 400 Bad Request
Server : nginx
Date : Wed, 02 Jun 2021 08:03:32 GMT
Content-Type : application/json;charset=UTF-8
Content-Length : 180
Connection : keep-alive
X-SERVED-BY : l55c016
X-CORRELATION-ID : 1622621012_721_300520491_l55c016_VDP_WS
X-APP-STATUS : 400
X-Frame-Options : SAMEORIGIN
X-XSS-Protection : 1; mode=block
X-Content-Type-Options : nosniff
Strict-Transport-Security : max-age=2592000;includeSubdomains
Cache-Control : no-cache, no-store, must-revalidate
Pragma : no-cache
Expires : -1
X-Cnection : close

Response:

{"errorResponse": {
"reason": "invalidParameterEncCard",
"details": [{
"location": "encCard",
"message": "Unable to parse or decrypt"
}],
"message": "Invalid input parameter(s)",
"status": 400
}}

encrypted method:

public static String getEncryptedPayload(String mleServerPublicCertificatePath, String requestPayload, String apiKey) throws CertificateException, JOSEException, IOException {
JWEHeader.Builder headerBuilder = new JWEHeader.Builder(JWEAlgorithm.RSA_OAEP_256, EncryptionMethod.A256GCM);
headerBuilder.keyID(apiKey);
JWEObject jweObject = new JWEObject(headerBuilder.build(), new Payload(requestPayload));
jweObject.encrypt(new RSAEncrypter(getRSAPublicKey(mleServerPublicCertificatePath)));
return "{\"encCard\":\"" + jweObject.serialize() + "\"}";
}

public static String getEncryptedPayload(String requestPayload, StringapiKey, String sharedSecret) throws CertificateException, JOSEException, IOException, NoSuchAlgorithmException {
JWEHeader.Builder headerBuilder = new JWEHeader.Builder(JWEAlgorithm.A256GCMKW, EncryptionMethod.A256GCM);
headerBuilder.keyID(apiKey);
JWEObject jweObject = new JWEObject(headerBuilder.build(), new Payload(requestPayload));
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
jweObject.encrypt(new AESEncrypter(messageDigest.digest(sharedSecret.getBytes(StandardCharsets.UTF_8))));
return "{\"encCard\":\"" + jweObject.serialize() + "\"}";
}

encrypted data:

{"encCard":"eyJraWQiOiIxODQ1ZWZlNC1lMGZmLTRhNzgtOGZmOC0yYWU0M2I2MzM5Y2QiLCJlbmMiOiJBMjU2R0NNIiwidGFnIjoiWGswajRkVXVxRmtLeUVWSEF0UnBWUSIsImFsZyI6IkEyNTZHQ01LVyIsIml2IjoiN0t4UlBHY1AwTDZJWGowSCJ9.VB-GGpOllYVAdEzmQjpPNvNaOTDF3vR3HslKlWX8y1o.kQEN_SJOLcqok_rt.rjXwgTppwDVtf4iBtPcbJ54lTY0ippr5UH_rTsaEcHhsvtxeb8z_9CaNHd4NQyvsTMJk-HERvFs-QSHH-J40cnkbkekRoebXUIt0xm9e5WXVbKQzqmFdw8AEZu3o1dRANfRCM30dVFmtH4-Xa6jgOnXaYamzcXA1FQKX_9m-Ip2hM7cPwcOqNtFLx1ND0XyeJt10HsetFgY2wIXfedLblX7n3M02kJLXp5oq-o1K8TbbW2sApoosgQ2sTAnt9FYX3p5_8iN3Gtyk-3fV5cDrbjC5-yO5kOOQpt0RPskjNQP-3QAoAGGFPxQwELzZjYy1sq_aQLkRmKYZEz3DZIbrZUiDblXxiDfd858Ve21FidSkefrFkrX7OgcJ9ZpiOytADJ6cc_Mn25tvGCimFpE-C3sJwS4_VJeiGKiIXjn2lqzy90YWL29Vaxjcau8FIHlmyfYTRbJPwK6OiDbjI4Mh8jMFKoK8C6gSf-zjF_G3zGgcpWLtJdwKlmHNtKSZv_XBfuc8qXmprrAQXkDA-ZWP2vPlTYhWnwPVUq7_vVcjZQ.vNlzPf-M5jbsuUJdlf1p4w"}

 

I have used JWe RSA and JWe AES to encrypt the payload, but the result is the same. Can you help me solve the problem

 

1 REPLY 1
SLi
Visa Developer Support Specialist
Visa Developer Support Specialist

Re: universal/core/cards&&Unable to parse or decrypt

Hi @wypintec,

 

Visa In-App Provisioning APIs require Field Level Encryption. Please email developer@visa.com to obtain the encryption key and test data for sandbox testing.


Best,
Stacey

Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.