public function CcaValidation::validateJwt in Commerce Authorize.Net 8
Validates the JWT.
1 string reference to 'CcaValidation::validateJwt'
File
- src/
Controller/ CcaValidation.php, line 49
Class
- CcaValidation
- Verifies JWT in the CCA process.
Namespace
Drupal\commerce_authnet\ControllerCode
public function validateJwt() {
$response_jwt = $this->requestStack
->getCurrentRequest()->request
->get('responseJwt');
/** @var \Lcobucci\JWT\Token $token */
$token = (new Parser())
->parse($response_jwt);
$signer = new Sha256();
$gateway_id = $this->requestStack
->getCurrentRequest()->request
->get('gatewayId');
/** @var \Drupal\commerce_payment\Entity\PaymentGateway $gateway */
$gateway = PaymentGateway::load($gateway_id);
$api_key = $gateway
->getPlugin()
->getCcaApiKey();
$claims = $token
->getClaims();
$response = [
'verified' => $token
->verify($signer, $api_key),
'payload' => $claims,
];
return new JsonResponse($response);
}