Skip to content

Commit

Permalink
Release 6.1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrowanwallee committed Mar 5, 2025
1 parent 82b2dd4 commit 7df4e68
Show file tree
Hide file tree
Showing 13 changed files with 217 additions and 157 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 6.1.12
- Compatibility with 6.6.10.x
- Prevent duplicate transactions being created when the first times out
- Fix for error when changing space credentials
- Payment status now shows refunded/partially refunded
- Order delivery status now shows 'open' instead of 'hold'

# 6.1.11
- Implement payment page integration.
- Fixed bug with duplicate payment methods appearing
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG_de-DE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 6.1.12
- Kompatibilität mit 6.6.10.x
- Verhindern Sie, dass beim ersten Timeout doppelte Transaktionen erstellt werden
- Fehler beim Ändern der Space-Anmeldeinformationen behoben
- Der Zahlungsstatus zeigt jetzt „erstattet/teilweise erstattet“ an
- Der Lieferstatus der Bestellung wird jetzt „Offen“ statt „Halten“ angezeigt.

# 6.1.11
- Integration der Zahlungsseite implementieren.
- Fehler mit doppelten angezeigten Zahlungsmethoden behoben
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ tail -f var/log/wallee_payment*.log

## Documentation

[Documentation](https://plugin-documentation.wallee.com/wallee-payment/shopware-6/6.1.11/docs/en/documentation.html)
[Documentation](https://plugin-documentation.wallee.com/wallee-payment/shopware-6/6.1.12/docs/en/documentation.html)

## License

Expand Down
124 changes: 62 additions & 62 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
{
"authors": [
{
"homepage": "https://www.wallee.com",
"name": "wallee"
}
],
"autoload": {
"psr-4": {
"WalleePayment\\": "src/"
}
},
"description": "Wallee integration for Shopware 6",
"extra": {
"copyright": "(c) by wallee",
"description": {
"de-DE": "Wallee integration f\u00fcr Shopware 6",
"en-GB": "Wallee integration for Shopware 6",
"fr-FR": "Int\u00e9gration de Wallee pour Shopware 6",
"it-IT": "Integrazione Wallee per Shopware"
},
"label": {
"de-DE": "Wallee Produkte f\u00fcr Shopware 6",
"en-GB": "Wallee Products for Shopware 6",
"fr-FR": "Wallee Produits for Shopware 6",
"it-IT": "Wallee Prodotti per Shopware 6"
},
"manufacturerLink": {
"de-DE": "https://www.wallee.com",
"en-GB": "https://www.wallee.com",
"fr-FR": "https://www.wallee.com",
"it-IT": "https://www.wallee.com"
},
"supportLink": {
"de-DE": "https://app-wallee.com/space/select?target=/support",
"en-GB": "https://app-wallee.com/space/select?target=/support",
"fr-FR": "https://app-wallee.com/space/select?target=/support",
"it-IT": "https://app-wallee.com/space/select?target=/support"
},
"shopware-plugin-class": "WalleePayment\\WalleePayment"
},
"homepage": "https://www.wallee.com/",
"keywords": [
"wallee",
"payment",
"php",
"shopware"
],
"license": "Apache-2.0",
"name": "wallee/shopware-6",
"require": {
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"php": ">=8.2",
"shopware/core": "6.6.*",
"shopware/administration": "~6.6.0",
"shopware/storefront": "6.6.*",
"wallee/sdk": "4.6.0"
},
"type": "shopware-platform-plugin",
"version": "6.1.11"
}
"authors": [
{
"homepage": "https://www.wallee.com",
"name": "wallee"
}
],
"autoload": {
"psr-4": {
"WalleePayment\\": "src/"
}
},
"description": "Wallee integration for Shopware 6",
"extra": {
"copyright": "(c) by wallee",
"description": {
"de-DE": "Wallee integration für Shopware 6",
"en-GB": "Wallee integration for Shopware 6",
"fr-FR": "Intégration de Wallee pour Shopware 6",
"it-IT": "Integrazione Wallee per Shopware"
},
"label": {
"de-DE": "Wallee Produkte für Shopware 6",
"en-GB": "Wallee Products for Shopware 6",
"fr-FR": "Wallee Produits for Shopware 6",
"it-IT": "Wallee Prodotti per Shopware 6"
},
"manufacturerLink": {
"de-DE": "https://www.wallee.com",
"en-GB": "https://www.wallee.com",
"fr-FR": "https://www.wallee.com",
"it-IT": "https://www.wallee.com"
},
"supportLink": {
"de-DE": "https://app-wallee.com/space/select?target=/support",
"en-GB": "https://app-wallee.com/space/select?target=/support",
"fr-FR": "https://app-wallee.com/space/select?target=/support",
"it-IT": "https://app-wallee.com/space/select?target=/support"
},
"shopware-plugin-class": "WalleePayment\\WalleePayment"
},
"homepage": "https://www.wallee.com/",
"keywords": [
"wallee",
"payment",
"php",
"shopware"
],
"license": "Apache-2.0",
"name": "wallee/shopware-6",
"require": {
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"php": ">=8.2",
"shopware/core": "~6.6.0",
"shopware/administration": "~6.6.0",
"shopware/storefront":"~6.6.0",
"wallee/sdk": "^4.0.0"
},
"type": "shopware-platform-plugin",
"version": "6.1.12"
}
2 changes: 1 addition & 1 deletion docs/en/documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2>Documentation</h2> </div>
</a>
</li>
<li>
<a href="https://github.com/wallee-payment/shopware-6/releases/tag/6.1.11/">
<a href="https://github.com/wallee-payment/shopware-6/releases/tag/6.1.12/">
Source
</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ public function synchronize(Context $context): array
{
// Configuration
$settings = $this->settingsService->getSettings($this->getSalesChannelId());
$this->setSpaceId($settings->getSpaceId())
->setApiClient($settings->getApiClient());
$this->setSpaceId($settings->getSpaceId())->setApiClient($settings->getApiClient());

$this->disablePaymentMethodConfigurations($context);
$this->enablePaymentMethodConfigurations($context);
Expand Down Expand Up @@ -254,9 +253,14 @@ private function disablePaymentMethodConfigurations(Context $context): void
$paymentMethodData = [];
$salesChannelPaymentMethodData = [];

$criteria = (new Criteria())->addFilter(new EqualsFilter('spaceId', $this->getSpaceId()));
$criteria = (new Criteria())->addFilter(new EqualsFilter('state', 'ACTIVE'));

$paymentMethodConfigurationEntities = $this->walleePaymentMethodConfigurationRepository
/**
* @var $walleePMConfigurationRepository
*/
$walleePMConfigurationRepository = $this->container->get(PaymentMethodConfigurationEntityDefinition::ENTITY_NAME . '.repository');

$paymentMethodConfigurationEntities = $walleePMConfigurationRepository
->search($criteria, $context)
->getEntities();

Expand All @@ -275,16 +279,11 @@ private function disablePaymentMethodConfigurations(Context $context): void
'id' => $paymentMethodConfigurationEntity->getId(),
'active' => false,
];

$salesChannelPaymentMethodData[] = [
'paymentMethodId' => $paymentMethodConfigurationEntity->getId(),
];
}

try {
$this->walleePaymentMethodConfigurationRepository->update($data, $context);
$this->paymentMethodRepository->update($paymentMethodData, $context);
$this->salesChannelPaymentRepository->delete($salesChannelPaymentMethodData, $context);
} catch (\Exception $exception) {
$this->logger->critical($exception->getMessage());
}
Expand Down Expand Up @@ -369,7 +368,13 @@ private function enablePaymentMethodConfigurations(Context $context): void
];

$this->upsertPaymentMethod($id, $paymentMethodConfiguration, $context);
$this->walleePaymentMethodConfigurationRepository->upsert([$data], $context);

try {
$this->container->get(PaymentMethodConfigurationEntityDefinition::ENTITY_NAME . '.repository')->upsert([$data], $context);
} catch (\Exception $e) {
$this->logger->error($e->getMessage(), [$e->getTraceAsString()]);
}

}
}

Expand Down Expand Up @@ -500,7 +505,12 @@ protected function upsertPaymentMethod(

$data = array_filter($data);

$this->paymentMethodRepository->upsert([$data], $context);
try {
$this->paymentMethodRepository->upsert([$data], $context);
} catch (\Exception $e) {
$this->logger->error($e->getMessage(), [$e->getTraceAsString()]);
}

}

/**
Expand Down
13 changes: 6 additions & 7 deletions src/Core/Api/Transaction/Service/TransactionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,12 @@ public function create(
$settings = $this->settingsService->getSettings($salesChannelId);
$apiClient = $settings->getApiClient();

$failedStates = [
TransactionState::DECLINE,
TransactionState::FAILED,
TransactionState::VOIDED,
];
$pendingTransaction = $this->read($_SESSION['transactionId'], $salesChannelId);
if (in_array($pendingTransaction->getState(), $failedStates)) {
$transactionId = $_SESSION['transactionId'] ?? null;
if ($transactionId !== null) {
$pendingTransaction = $this->read($_SESSION['transactionId'], $salesChannelId);
}

if ($transactionId === null || $pendingTransaction === null || $pendingTransaction->getState() !== TransactionState::PENDING) {
unset($_SESSION['transactionId']);
$pendingTransactionId = $this->createPendingTransaction($salesChannelContext);
$pendingTransaction = $this->read($pendingTransactionId, $salesChannelId);
Expand Down
43 changes: 32 additions & 11 deletions src/Core/Api/WebHooks/Controller/WebHookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,25 +638,46 @@ private function updatePriceIfAdditionalItemsExist(TransactionInvoice $transacti
private function unholdDelivery(string $orderId, Context $context): void
{
try {
/**
* @var OrderDeliveryStateHandler $orderDeliveryStateHandler
*/
$order = $this->getOrderEntity($orderId, $context);
/**
* @var OrderDeliveryEntity $orderDelivery
*/
$criteria = new Criteria([$orderId]);
$criteria->addAssociation('deliveries.stateMachineState');
$order = $this->container->get('order.repository')
->search($criteria, $context)
->first();

if (!$order) {
$this->logger->info('Order not found: ' . $orderId);
return;
}

/** @var OrderDeliveryEntity|null $orderDelivery */
$orderDelivery = $order->getDeliveries()?->last();

if (null === $orderDelivery) {
$this->logger->info('No deliveries found for order: ' . $orderId);
return;
}
if ($orderDelivery->getStateMachineState()?->getTechnicalName() !== OrderDeliveryStateHandler::STATE_HOLD){

$orderDeliveryState = $orderDelivery->getStateMachineState();
if (!$orderDeliveryState) {
$this->logger->info('Order delivery state is null for order: ' . $orderId);
return;
}

$technicalName = $orderDeliveryState->getTechnicalName();
$this->logger->info('Order delivery state: ' . $technicalName);

if ($technicalName !== OrderDeliveryStateHandler::STATE_HOLD) {
$this->logger->info('Order delivery is not on hold, skipping unhold process.');
return;
}

/** @var OrderDeliveryStateHandler $orderDeliveryStateHandler */
$orderDeliveryStateHandler = $this->container->get(OrderDeliveryStateHandler::class);
$orderDeliveryStateHandler->unhold($orderDelivery->getId(), $context);

$this->logger->info('Successfully unheld order delivery for order: ' . $orderId);
} catch (\Exception $exception) {
$this->logger->info($exception->getMessage(), $exception->getTrace());
$this->logger->error('Error unholding order delivery: ' . $exception->getMessage(), $exception->getTrace());
}
}

Expand Down Expand Up @@ -689,7 +710,7 @@ private function unholdAndCancelDelivery(string $orderId, Context $context): voi
* @var OrderDeliveryEntity $orderDelivery
*/
$orderDelivery = $order->getDeliveries()?->last();

if (null === $orderDelivery) {
return;
}
Expand Down
36 changes: 8 additions & 28 deletions src/Core/Api/WebHooks/Strategy/WebHookRefundStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,41 +125,21 @@ public function updateRefund(WebHookRequest $request, Context $context): Respons
$orderId = $this->getOrderIdByTransaction($refund);

if(!empty($orderId)) {

$this->executeLocked($orderId, $context, function () use ($orderId, $refund, $context, $request) {
if ($request->getListenerEntityTechnicalName() == WebHookRequest::REFUND && $request->getState() == RefundState::SUCCESSFUL) {
$this->refundService->upsert($refund, $context);
$orderTransactionId = $refund->getTransaction()->getMetaData()[TransactionPayload::WALLEE_METADATA_ORDER_TRANSACTION_ID];
$orderTransaction = $this->getOrderTransaction($orderId, $context);

$this->refundService->upsert($refund, $context);

$orderTransactionId = $refund->getTransaction()->getMetaData()[TransactionPayload::WALLEE_METADATA_ORDER_TRANSACTION_ID];
$orderTransaction = $this->getOrderTransaction($orderId, $context);
if (
in_array(
$orderTransaction->getStateMachineState()?->getTechnicalName(),
[
OrderTransactionStates::STATE_PAID,
OrderTransactionStates::STATE_PARTIALLY_PAID,
]
) &&
($request->getState() == RefundState::SUCCESSFUL)
) {
if ($refund->getAmount() == $orderTransaction->getAmount()->getTotalPrice()) {
$this->orderTransactionStateHandler->refund($orderTransactionId, $context);
} else {
if ($refund->getAmount() < $orderTransaction->getAmount()->getTotalPrice()) {
$this->orderTransactionStateHandler->refundPartially($orderTransactionId, $context);
}
}
} elseif ($orderTransaction->getStateMachineState()?->getTechnicalName() ===
OrderTransactionStates::STATE_PARTIALLY_REFUNDED &&
($request->getState() == RefundState::SUCCESSFUL)
) {
$transactionByOrderTransactionId = $this->transactionService->getByOrderTransactionId($orderTransactionId, $context);
$totalRefundedAmount = $this->getTotalRefundedAmount($transactionByOrderTransactionId->getTransactionId(), $context);
if (floatval($orderTransaction->getAmount()->getTotalPrice()) - $totalRefundedAmount <= 0) {
$leftToRefund = floatval($orderTransaction->getAmount()->getTotalPrice()) - $totalRefundedAmount;
if ($leftToRefund > 0) {
$this->orderTransactionStateHandler->refundPartially($orderTransactionId, $context);
} elseif ($leftToRefund === floatval(0)) { // This trick is used, because it's float type and 0 is int
$this->orderTransactionStateHandler->refund($orderTransactionId, $context);
}
}

});
}

Expand Down
Loading

0 comments on commit 7df4e68

Please sign in to comment.