function commerce_authnet_post_update_verify_client_key in Commerce Authorize.Net 8
Verify that AcceptJS and eCheck payment gateways have the client_key configured.
File
- ./
commerce_authnet.post_update.php, line 123 - Post update functions for commerce_authnet.
Code
function commerce_authnet_post_update_verify_client_key() {
$entity_type_manager = \Drupal::entityTypeManager();
$payment_gateway_storage = $entity_type_manager
->getStorage('commerce_payment_gateway');
/** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface[] $gateways */
$gateways = array_filter($payment_gateway_storage
->loadMultiple(), function (PaymentGatewayInterface $gateway) {
return in_array($gateway
->getPluginId(), [
'authorizenet_acceptjs',
'authorizenet_echeck',
]);
});
$gateways_with_warnings = [];
foreach ($gateways as $gateway) {
$configuration = $gateway
->getPluginConfiguration();
if (empty($configuration['client_key'])) {
$gateways_with_warnings[] = $gateway
->label();
}
}
if (!empty($gateways_with_warnings)) {
return t('Please provide a client key for %labels. It is required to continue accepting payments.', [
'%labels' => implode(', ', $gateways_with_warnings),
]);
}
return t('All Authorize.net payment gateways which require a client key have it configured.');
}