Release 7.1.6

This commit is contained in:
andrewrowanwallee
2025-11-24 11:56:40 +01:00
parent 55bdb5c640
commit 089555e77f
12 changed files with 94 additions and 36 deletions
+6
View File
@@ -1,3 +1,9 @@
# 7.1.6
- Improved rounding handling to force 2 decimal places
- Removed references to unused classes
- Fixed some type errors
- Further improved 0 amount transaction; state transitions
# 7.1.5
- Improved analytics
- Improved error handling for refunding amount 0 and too many items
+6
View File
@@ -1,3 +1,9 @@
# 7.1.6
- Verbesserte Rundungsbehandlung für zwei Dezimalstellen
- Entfernte Verweise auf ungenutzte Klassen
- Behebung einiger Typfehler
- Weitere Verbesserung von Transaktionen mit dem Betrag 0 und Zustandsübergängen
# 7.1.5
- Verbesserte Analysefunktionen
- Verbesserte Fehlerbehandlung bei Rückerstattungen von 0 Beträgen und zu vielen Artikeln
+4 -4
View File
@@ -13,10 +13,10 @@ Please note that this plugin is for versions 6.5, 6.6 or 6.7. For the 6.4 plugin
## Documentation
- For English documentation click [here](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.1.5/docs/en/documentation.html)
- Für die deutsche Dokumentation klicken Sie [hier](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.1.5/docs/de/documentation.html)
- Pour la documentation Française, cliquez [ici](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.1.5/docs/fr/documentation.html)
- Per la documentazione in tedesco, clicca [qui](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.1.5/docs/it/documentation.html)
- For English documentation click [here](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.1.6/docs/en/documentation.html)
- Für die deutsche Dokumentation klicken Sie [hier](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.1.6/docs/de/documentation.html)
- Pour la documentation Française, cliquez [ici](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.1.6/docs/fr/documentation.html)
- Per la documentazione in tedesco, clicca [qui](https://docs.plugin-documentation.vr-payment.de/vr-payment/shopware-6/7.1.6/docs/it/documentation.html)
## Installation
+1 -1
View File
@@ -59,5 +59,5 @@
"vrpayment/sdk": "^4.0.0"
},
"type": "shopware-platform-plugin",
"version": "7.1.5"
"version": "7.1.6"
}
+1 -1
View File
@@ -23,7 +23,7 @@
</a>
</li>
<li>
<a href="https://github.com/vr-payment/shopware-6/releases/tag/7.1.5/">
<a href="https://github.com/vr-payment/shopware-6/releases/tag/7.1.6/">
Source
</a>
</li>
+1 -1
View File
@@ -23,7 +23,7 @@
</a>
</li>
<li>
<a href="https://github.com/vr-payment/shopware-6/releases/tag/7.1.5/">
<a href="https://github.com/vr-payment/shopware-6/releases/tag/7.1.6/">
Source
</a>
</li>
+1 -1
View File
@@ -23,7 +23,7 @@
</a>
</li>
<li>
<a href="https://github.com/vr-payment/shopware-6/releases/tag/7.1.5/">
<a href="https://github.com/vr-payment/shopware-6/releases/tag/7.1.6/">
Source
</a>
</li>
+1 -1
View File
@@ -23,7 +23,7 @@
</a>
</li>
<li>
<a href="https://github.com/vr-payment/shopware-6/releases/tag/7.1.5/">
<a href="https://github.com/vr-payment/shopware-6/releases/tag/7.1.6/">
Source
</a>
</li>
@@ -387,7 +387,7 @@ class TransactionService
*
* @return \Shopware\Core\Checkout\Order\OrderEntity
*/
protected function getOrderEntity(string $orderId, Context $context): OrderEntity
public function getOrderEntity(string $orderId, Context $context): OrderEntity
{
try {
$criteria = (new Criteria([$orderId]))->addAssociations(['deliveries']);
@@ -721,18 +721,20 @@ class TransactionService
{
$lineItem = new LineItemCreate();
$roundedPrice = $this->round($productData->getPrice()->getUnitPrice());
if ($productData instanceof LineItem) {
$lineItem->setName($productData->getLabel());
$lineItem->setUniqueId($productData->getId());
$lineItem->setSku($productData->getReferencedId() ?? $productData->getId());
$lineItem->setQuantity($productData->getQuantity());
$lineItem->setAmountIncludingTax($productData->getPrice()->getUnitPrice());
$lineItem->setAmountIncludingTax($roundedPrice);
} elseif ($productData instanceof OrderLineItemEntity) {
$lineItem->setName($productData->getLabel());
$lineItem->setUniqueId($productData->getId());
$lineItem->setSku($productData->getProductId() ?? $productData->getIdentifier() ?? $productData->getId());
$lineItem->setQuantity($productData->getQuantity());
$lineItem->setAmountIncludingTax($productData->getUnitPrice());
$lineItem->setAmountIncludingTax($roundedPrice);
} else {
throw new \InvalidArgumentException('Unsupported line item type: ' . get_class($productData));
}
@@ -806,4 +808,14 @@ class TransactionService
}
return false;
}
/**
* @param $amount
* @param int $precision
*
* @return float
*/
private function round($value, $precision = 2): float {
return \round($value, $precision);
}
}
@@ -125,7 +125,9 @@ class VRPaymentPaymentHandler extends AbstractPaymentHandler
$orderTransactionId = $transaction->getOrderTransactionId();
$orderTransaction = $this->orderTransactionRepository->search(
(new Criteria([$orderTransactionId]))
->addAssociation('order'), $context
->addAssociation('order')
->addAssociation('stateMachineState'),
$context
)->getEntities()->first();
$contextSource = $context->getSource();
@@ -133,20 +135,9 @@ class VRPaymentPaymentHandler extends AbstractPaymentHandler
$salesChannelContextId = $contextSource->getSalesChannelId();
}
$orderCustomer = $orderTransaction->getOrder()?->getOrderCustomer();
if ($orderCustomer) {
$customerId = $orderCustomer->getCustomerId();
} else {
$customerId = null;
}
$contextToken = $this->getContextToken($request);
$parameters = new SalesChannelContextServiceParameters($salesChannelContextId, $contextToken, originalContext: $context);
$parameters = new SalesChannelContextServiceParameters(
$salesChannelContextId,
$request->getSession()->get("sw-context-token", Random::getAlphanumericString(32)),
originalContext: $context,
customerId: $customerId
);
$salesChannelContext = $this->salesChannelContextService->get($parameters);
$redirectUrl = $transaction->getReturnUrl();
@@ -162,7 +153,10 @@ class VRPaymentPaymentHandler extends AbstractPaymentHandler
$request->getSession()->remove('transactionId');
$errorMessage = 'An error occurred during the communication with external payment gateway : ' . $e->getMessage();
$this->logger->critical($errorMessage);
throw PaymentException::customerCanceled($orderTransactionId, $errorMessage);
if ($orderTransaction->getState()?->getTechnicalName() === OrderTransactionStates::STATE_CANCELLED) {
throw PaymentException::asyncFinalizeInterrupted($orderTransaction->getOrder()->getId(), $errorMessage);
}
throw PaymentException::customerCanceled($transaction->getOrderTransactionId(), $errorMessage);
}
}
@@ -186,7 +180,9 @@ class VRPaymentPaymentHandler extends AbstractPaymentHandler
$orderTransactionId = $transaction->getOrderTransactionId();
$orderTransaction = $this->orderTransactionRepository->search(
(new Criteria([$orderTransactionId]))
->addAssociation('order'), $context
->addAssociation('order')
->addAssociation('stateMachineState'),
$context
)->getEntities()->first();
if ($orderTransaction->getOrder()->getAmountTotal() > 0) {
@@ -215,7 +211,11 @@ class VRPaymentPaymentHandler extends AbstractPaymentHandler
$token = $request->getSession()->get('sw-context-token');
if ($token) {
$salesChannelId = $transactionEntity->getSalesChannelId();
$orderEntity = $this->pluginTransactionService->getOrderEntity(
$orderTransaction->getOrder()->getId(),
$context
);
$salesChannelId = $orderEntity->getSalesChannelId();
$parameters = new SalesChannelContextServiceParameters($salesChannelId, $token, originalContext: $context);
$salesChannelContext = $this->salesChannelContextService->get($parameters);
@@ -432,7 +432,9 @@ class VRPaymentPaymentHandler extends AbstractPaymentHandler
{
$lineItemCreate = new \VRPayment\Sdk\Model\LineItemCreate();
$lineItemCreate->setAmountIncludingTax($lineItem->getAmountIncludingTax());
$roundedPrice = $this->round($lineItem->getAmountIncludingTax());
$lineItemCreate->setAmountIncludingTax($roundedPrice);
$attributes = $lineItem->getAttributes();
$attributesCreate = [];
@@ -469,4 +471,28 @@ class VRPaymentPaymentHandler extends AbstractPaymentHandler
return $lineItemCreate;
}
/**
* @param $amount
* @param int $precision
*
* @return float
*/
private function round($value, $precision = 2): float {
return \round($value, $precision);
}
private function getContextToken(Request $request): string
{
$headerContextToken = $request->headers->get('sw-context-token');
if ($headerContextToken) {
return $headerContextToken;
}
$sessionContextToken = $request->getSession()->get("sw-context-token");
if (!$sessionContextToken) {
return $sessionContextToken;
}
return Random::getAlphanumericString(32);
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ class Analytics {
self::SHOP_SYSTEM => 'shopware',
self::SHOP_SYSTEM_VERSION => '6',
self::SHOP_SYSTEM_AND_VERSION => 'shopware-6',
self::PLUGIN_SYSTEM_VERSION => '7.1.5',
self::PLUGIN_SYSTEM_VERSION => '7.1.6',
];
}
+13 -5
View File
@@ -397,7 +397,9 @@ class TransactionPayload extends AbstractPayload
$discountTitle = sprintf('DISCOUNT: %s', $discountName);
}
$lineItem->setAmountIncludingTax($amount)
$roundedAmount = self::round($amount);
$lineItem->setAmountIncludingTax($roundedAmount)
->setName($discountTitle)
->setQuantity(1)
->setShippingRequired(false)
@@ -520,12 +522,14 @@ class TransactionPayload extends AbstractPayload
$amount = self::round($amount + $shopLineItem->getPrice()->getCalculatedTaxes()->getAmount());
}
$roundedAmount = self::round($amount);
$lineItem = (new LineItemCreate())
->setName($this->fixLength($shopLineItem->getLabel(), 150))
->setUniqueId($uniqueId)
->setSku($sku)
->setQuantity($shopLineItem->getQuantity() ?? 1)
->setAmountIncludingTax($amount);
->setAmountIncludingTax($roundedAmount);
if (!empty($shopLineItem->getType()) && $shopLineItem->getType() == CustomProductsLineItemTypes::LINE_ITEM_TYPE_CUSTOMIZED_PRODUCTS) {
@@ -644,9 +648,10 @@ class TransactionPayload extends AbstractPayload
$amount = self::round($amount + $this->order->getShippingCosts()->getCalculatedTaxes()->getAmount());
}
$roundedAmount = self::round($amount);
$lineItem = (new LineItemCreate())
->setAmountIncludingTax($amount)
->setAmountIncludingTax($roundedAmount)
->setName($this->fixLength($shippingName . ' ' . $this->translator->trans('vrpayment.payload.shipping.lineItem'), 150))
->setQuantity($this->order->getShippingCosts()->getQuantity() ?? 1)
->setSku($this->fixLength($shippingName . '-Shipping', 200))
@@ -694,9 +699,11 @@ class TransactionPayload extends AbstractPayload
->setRate($taxRate)
->setTitle('Tax rate: '.$taxRate);
$roundedAmount = self::round($amount);
$name = $taxRate . '%-' . $shippingName;
$lineItem = (new LineItemCreate())
->setAmountIncludingTax($amount)
->setAmountIncludingTax($roundedAmount)
->setName($this->fixLength($name . ' ' . $this->translator->trans('vrpayment.payload.shipping.lineItem'), 150))
->setQuantity($this->order->getShippingCosts()->getQuantity() ?? 1)
->setSku($this->fixLength($name . '-Shipping', 200))
@@ -768,7 +775,8 @@ class TransactionPayload extends AbstractPayload
->setSku('Adjustment-Line-Item')
->setQuantity(1);
/** @noinspection PhpParamsInspection */
$lineItem->setAmountIncludingTax($adjustmentPrice)
$roundedAdjustmentPrice = self::round($adjustmentPrice);
$lineItem->setAmountIncludingTax($roundedAdjustmentPrice)
->setType(($adjustmentPrice > 0) ? LineItemType::FEE : LineItemType::DISCOUNT);
if (!$lineItem->valid()) {