diff --git a/README.md b/README.md index 6a5a9ab..14a587e 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ tail -f var/log/wallee_payment*.log ## Documentation -[Documentation](https://plugin-documentation.wallee.com/wallee-payment/shopware-6/4.0.11/docs/en/documentation.html) +[Documentation](https://plugin-documentation.wallee.com/wallee-payment/shopware-6/4.0.12/docs/en/documentation.html) ## License diff --git a/composer.json b/composer.json index c27c6bc..ef96b22 100644 --- a/composer.json +++ b/composer.json @@ -54,5 +54,5 @@ "wallee/sdk": "3.0.1" }, "type": "shopware-platform-plugin", - "version": "4.0.11" + "version": "4.0.12" } \ No newline at end of file diff --git a/docs/en/documentation.html b/docs/en/documentation.html index d1ead79..2653266 100644 --- a/docs/en/documentation.html +++ b/docs/en/documentation.html @@ -22,7 +22,7 @@

Documentation

  • - + Source
  • diff --git a/src/Core/Settings/Struct/Settings.php b/src/Core/Settings/Struct/Settings.php index f6ba404..6ef7092 100644 --- a/src/Core/Settings/Struct/Settings.php +++ b/src/Core/Settings/Struct/Settings.php @@ -4,6 +4,7 @@ use Shopware\Core\Framework\Struct\Struct; use Wallee\Sdk\ApiClient; +use WalleePayment\Core\Util\Analytics\Analytics; /** * Class Settings @@ -185,6 +186,7 @@ public function getApiClient(): ApiClient $this->apiClient = new ApiClient($this->getUserId(), $this->getApplicationKey()); $apiClientBasePath = getenv('WALLEE_API_BASE_PATH') ? getenv('WALLEE_API_BASE_PATH') : $this->apiClient->getBasePath(); $this->apiClient->setBasePath($apiClientBasePath); + Analytics::addHeaders($this->apiClient); } return $this->apiClient; } @@ -220,4 +222,4 @@ public function setApplicationKey(string $applicationKey): void { $this->applicationKey = $applicationKey; } -} \ No newline at end of file +} diff --git a/src/Core/Util/Analytics/Analytics.php b/src/Core/Util/Analytics/Analytics.php new file mode 100644 index 0000000..a692e17 --- /dev/null +++ b/src/Core/Util/Analytics/Analytics.php @@ -0,0 +1,43 @@ + 'shopware', + self::SHOP_SYSTEM_VERSION => '6', + self::SHOP_SYSTEM_AND_VERSION => 'shopware-6', + ]; + } + + /** + * @param \Wallee\Sdk\ApiClient $apiClient + */ + public static function addHeaders(ApiClient &$apiClient) + { + $data = self::getDefaultData(); + foreach ($data as $key => $value) { + $apiClient->addDefaultHeader($key, $value); + } + } +} + + diff --git a/src/Core/Util/Payload/TransactionPayload.php b/src/Core/Util/Payload/TransactionPayload.php index bf9a321..3ed718f 100644 --- a/src/Core/Util/Payload/TransactionPayload.php +++ b/src/Core/Util/Payload/TransactionPayload.php @@ -118,10 +118,16 @@ public function get(): TransactionCreate $billingAddress = $this->getAddressPayload($customer, $customer->getActiveBillingAddress()); $shippingAddress = $this->getAddressPayload($customer, $customer->getActiveShippingAddress()); + + $customerId = null; + if($customer->getGuest() === false){ + $customerId = $customer->getCustomerNumber(); + } + $transactionData = [ 'currency' => $this->salesChannelContext->getCurrency()->getIsoCode(), 'customer_email_address' => $billingAddress->getEmailAddress(), - 'customer_id' => $customer->getCustomerNumber() ?? null, + 'customer_id' => $customerId, 'language' => $this->localeCodeProvider->getLocaleCodeFromContext($this->salesChannelContext->getContext()) ?? null, 'merchant_reference' => $this->fixLength($this->transaction->getOrder()->getOrderNumber(), 100), 'meta_data' => [ @@ -553,4 +559,4 @@ protected function getFailUrl(string $orderId): string UrlGeneratorInterface::ABSOLUTE_URL ); } -} \ No newline at end of file +}