Source:
<code>public void shouldCreateCorrectChallengeToken() { var gatewayAccount = new GatewayAccount(1L, WORLDPAY.getName(), validCredentials); String worldpayChallengeAcsUrl = "<LINK_0>"; String worldpayChallengePayload = "a-payload"; String worldpayChallengeTransactionId = "a-transaction-id"; Auth3dsDetailsEntity auth3dsDetailsEntity = anAuth3dsDetailsEntity() .withWorldpayChallengeAcsUrl(worldpayChallengeAcsUrl) .withWorldpayChallengePayload(worldpayChallengePayload) .withWorldpayChallengeTransactionId(worldpayChallengeTransactionId) .build(); String token = worldpay3dsFlexJwtService.generateChallengeToken(gatewayAccount, auth3dsDetailsEntity); Jws<Claims> jws = Jwts.parser() .setSigningKey(new SecretKeySpec(validCredentials.get("jwt_mac_id").getBytes(), "HmacSHA256")) .parseClaimsJws(token); assertThat(jws.getHeader().getAlgorithm(), is("HS256")); assertThat((Map<String, Object>)jws.getHeader(), hasEntry("typ", "JWT")); assertThat(jws.getBody(), hasKey("jti")); assertThat(jws.getBody(), hasKey("iat")); <START> assertThat(jws.getBody(), hasEntry("iss", validCredentials.get("issuer"))); <END> assertThat(jws.getBody(), hasEntry("OrgUnitId", validCredentials.get("organisational_unit_id"))); assertThat(jws.getBody(), hasEntry("ObjectifyPayload", true)); assertThat(jws.getBody(), hasEntry(is("Payload"), instanceOf(Map.class))); Map<String, Object> payload = (Map<String, Object>) jws.getBody().get("Payload"); assertThat(payload, hasEntry("ACSUrl", worldpayChallengeAcsUrl)); assertThat(payload, hasEntry("Payload", worldpayChallengePayload)); assertThat(payload, hasEntry("TransactionId", worldpayChallengeTransactionId)); }</code><technical_language>Do need a "ReturnUrl" too</technical_language>

Target:
public void shouldCreateCorrectChallengeToken() { GatewayAccountEntity gatewayAccountEntity = aGatewayAccountEntity() .withGatewayName(WORLDPAY.getName()) .withCredentials(VALID_CREDENTIALS) .build(); ChargeEntity chargeEntity = createValidChargeEntityForChallengeToken(gatewayAccountEntity); String token = worldpay3dsFlexJwtService.generateChallengeToken(chargeEntity); Jws<Claims> jws = Jwts.parser() .setSigningKey(new SecretKeySpec(VALID_CREDENTIALS.get("jwt_mac_id").getBytes(), "HmacSHA256")) .parseClaimsJws(token); assertThat(jws.getHeader().getAlgorithm(), is("HS256")); assertThat((Map<String, Object>)jws.getHeader(), hasEntry("typ", "JWT")); assertThat(jws.getBody(), hasKey("jti")); assertThat(jws.getBody(), hasKey("iat")); assertThat(jws.getBody(), hasEntry("iss", VALID_CREDENTIALS.get("issuer"))); assertThat(jws.getBody(), hasEntry("OrgUnitId", VALID_CREDENTIALS.get("organisational_unit_id"))); assertThat(jws.getBody(), hasEntry("ReturnUrl", format("%s/card_details/%s/3ds_required_in", FRONTEND_URL, CHARGE_EXTERNAL_ID))); assertThat(jws.getBody(), hasEntry("ObjectifyPayload", true)); assertThat(jws.getBody(), hasEntry(is("Payload"), instanceOf(Map.class))); Map<String, Object> payload = (Map<String, Object>) jws.getBody().get("Payload"); assertThat(payload, hasEntry("ACSUrl", WORLDPAY_CHALLENGE_ACS_URL)); assertThat(payload, hasEntry("Payload", WORLDPAY_CHALLENGE_PAYLOAD)); assertThat(payload, hasEntry("TransactionId", WORLDPAY_CHALLENGE_TRANSACTION_ID)); }