Skip to content
Snippets Groups Projects

Add Drupal Commerce Information to API Calls.

All threads resolved!
Files
2
+ 19
1
@@ -7,6 +7,7 @@ use Drupal\commerce_signifyd\Entity\SignifydTeamInterface;
use Drupal\commerce_signifyd\Exception\InvalidRequestException;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\Logger\LoggerChannelTrait;
use GuzzleHttp\Client;
@@ -38,6 +39,13 @@ class SignifydClient implements SignifydClientInterface {
*/
protected $settings;
/**
* Module extension list.
*
* @var \Drupal\Core\Extension\ModuleExtensionList
*/
protected $moduleExtensionList;
/**
* Client constructor.
*
@@ -45,11 +53,14 @@ class SignifydClient implements SignifydClientInterface {
* The client.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param $module_extension_list
* The module extension list.
*/
public function __construct(Client $client, ConfigFactoryInterface $config_factory) {
public function __construct(Client $client, ConfigFactoryInterface $config_factory, ModuleExtensionList $module_extension_list) {
$this->client = $client;
$this->configFactory = $config_factory;
$this->settings = $config_factory->get('commerce_signifyd.settings');
$this->moduleExtensionList = $module_extension_list;
}
/**
@@ -120,6 +131,13 @@ class SignifydClient implements SignifydClientInterface {
];
if (!empty($payload)) {
$commerce_core = $this->moduleExtensionList->getExtensionInfo('commerce');
$payload['platformAndClient'] = [
'storePlatform' => 'Drupal_Commerce',
'storePlatformVersion' => $commerce_core['version'] ?? 'dev',
'signifydClientApp' => '',
];
$values['json'] = $payload;
}
Loading