class CcaValidation in Commerce Authorize.Net 8
Verifies JWT in the CCA process.
Hierarchy
- class \Drupal\commerce_authnet\Controller\CcaValidation implements ContainerInjectionInterface
Expanded class hierarchy of CcaValidation
See also
https://developer.cardinalcommerce.com/cardinal-cruise-activation.shtml#...
File
- src/
Controller/ CcaValidation.php, line 18
Namespace
Drupal\commerce_authnet\ControllerView source
class CcaValidation implements ContainerInjectionInterface {
/**
* The request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
private $requestStack;
/**
* Constructs a new CcaValidation object.
*
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
*/
public function __construct(RequestStack $request_stack) {
$this->requestStack = $request_stack;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('request_stack'));
}
/**
* Validates the JWT.
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CcaValidation:: |
private | property | The request stack. | |
CcaValidation:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
CcaValidation:: |
public | function | Validates the JWT. | |
CcaValidation:: |
public | function | Constructs a new CcaValidation object. |