Skip to content

Commit

Permalink
Release 1.0.33
Browse files Browse the repository at this point in the history
  • Loading branch information
edgaraswallee committed Oct 14, 2024
1 parent 497fa75 commit 34e5c0d
Show file tree
Hide file tree
Showing 9 changed files with 363 additions and 324 deletions.
43 changes: 31 additions & 12 deletions Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,24 +145,43 @@ private function listenFrontendHooks(Dispatcher $dispatcher, FrontendHandler $ha
$paymentMethods = $handler->getPaymentMethodsForForm($smarty);
$smarty->assign('Zahlungsarten', $paymentMethods);
});

$dispatcher->listen('shop.hook.' . \HOOK_BESTELLUNGEN_XML_BEARBEITESET, function ($args) use ($handler) {
$order = $args['oBestellung'] ?? [];
if ((int)$order->cStatus === \BESTELLUNG_STATUS_BEZAHLT) {
$order = new Bestellung($args['oBestellung']->kBestellung);

$paymentMethodEntity = new Zahlungsart((int)$order->kZahlungsart);
$moduleId = $paymentMethodEntity->cModulId ?? '';
$paymentMethod = new Method($moduleId);
$paymentMethod->setOrderStatusToPaid($order);
$order = $args['oBestellung'] ?? null;
if ($order === null) {
return;
}

$orderStatus = $order->cStatus ?? null;
if ($orderStatus === null) {
return;
}

if ((int)$orderStatus === \BESTELLUNG_STATUS_BEZAHLT) {
$orderId = $args['oBestellung']->kBestellung ?? null;
if ($orderId === null) {
return;
}

Shop::Container()
->getDB()->update(
$order = new Bestellung($orderId);
if (empty($order->kZahlungsart)) {
return;
}
$paymentMethodEntity = new Zahlungsart($order->kZahlungsart);

if ($order->cStatus != \BESTELLUNG_STATUS_VERSANDT && $paymentMethodEntity->cAnbieter === 'Wallee') {
$moduleId = $paymentMethodEntity->cModulId ?? '';
$paymentMethod = new Method($moduleId);
$paymentMethod->setOrderStatusToPaid($order);

Shop::Container()
->getDB()->update(
'tbestellung',
['kBestellung',],
[$args['oBestellung']->kBestellung],
[$orderId],
(object)['cAbgeholt' => 'Y']
);
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ account dashboard.

## Documentation

[Documentation](https://plugin-documentation.wallee.com/wallee-payment/jtl-5/1.0.32/docs/en/documentation.html)
[Documentation](https://plugin-documentation.wallee.com/wallee-payment/jtl-5/1.0.33/docs/en/documentation.html)

## License

Expand Down
4 changes: 4 additions & 0 deletions Services/WalleeTransactionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,10 @@ private function createLineItemProductItem(CartItem $productData, $isDiscount =
$slug = trim($slug, '-');

$uniqueName = $productData->cArtNr ?: $slug;
$uniqueProperty = $productData->cUnique ?? null;
if ($uniqueProperty !== null) {
$uniqueName .= '_' . $productData->cUnique;
}
$attributes = $productData->WarenkorbPosEigenschaftArr ?? [];
if ($isDiscount || $productData->nPosTyp === \C_WARENKORBPOS_TYP_GUTSCHEIN) {
$uniqueName = $uniqueName . '_' . rand(1, 99999);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,23 @@ public function updateOrderStatus(string $entityId): void
$transaction = $transactionInvoice->getCompletion()
->getLineItemVersion()
->getTransaction();

$transactionId = $transaction->getId();

$orderNr = $transaction->getMetaData()['order_nr'];
$orderData = $this->transactionService->getOrderIfExists($orderNr);
$orderId = (int)$orderData->kBestellung;
$transactionId = $transaction->getId();

// Fallback for older plugin versions
if ($orderNr === null) {
$localTransaction = $this->transactionService->getLocalWalleeTransactionById((string)$transactionId);
$orderId = (int)$localTransaction->order_id;
} else {
$orderData = $this->transactionService->getOrderIfExists($orderNr);
if ($orderData === null) {
Shop::Container()->getLogService()->error('Order was not found by nr: ' . $orderNr);
return;
}
$orderId = (int)$orderData->kBestellung;
}

switch ($transactionInvoice->getState()) {
case TransactionInvoiceState::DERECOGNIZED:
Expand Down
14 changes: 12 additions & 2 deletions Webhooks/Strategies/WalleeNameOrderUpdateTransactionStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,18 @@ public function updateOrderStatus(string $entityId): void
$transactionId = $transaction->getId();

$orderNr = $transaction->getMetaData()['order_nr'];
$orderData = $this->transactionService->getOrderIfExists($orderNr);
$orderId = (int)$orderData->kBestellung;
if ($orderNr === null) {
$localTransaction = $this->transactionService->getLocalWalleeTransactionById((string)$transactionId);
$orderId = (int)$localTransaction->order_id;
} else {
$orderData = $this->transactionService->getOrderIfExists($orderNr);
if ($orderData === null) {
Shop::Container()->getLogService()->error('Order was not found by nr: ' . $orderNr);
return;
}
$orderId = (int)$orderData->kBestellung;
}

$transactionState = $transaction->getState();

switch ($transactionState) {
Expand Down
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/jtl-5/releases/tag/1.0.32/">
<a href="https://github.com/wallee-payment/jtl-5/releases/tag/1.0.33/">
Source
</a>
</li>
Expand Down
Loading

0 comments on commit 34e5c0d

Please sign in to comment.